| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/ScriptPromiseResolver.h" | 6 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return self->bindToV8Function(); | 30 return self->bindToV8Function(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 Function(ScriptState* scriptState, String* value) | 34 Function(ScriptState* scriptState, String* value) |
| 35 : ScriptFunction(scriptState) | 35 : ScriptFunction(scriptState) |
| 36 , m_value(value) | 36 , m_value(value) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual ScriptValue call(ScriptValue value) override | 40 ScriptValue call(ScriptValue value) override |
| 41 { | 41 { |
| 42 ASSERT(!value.isEmpty()); | 42 ASSERT(!value.isEmpty()); |
| 43 *m_value = toCoreString(value.v8Value()->ToString(scriptState()->context
()).ToLocalChecked()); | 43 *m_value = toCoreString(value.v8Value()->ToString(scriptState()->context
()).ToLocalChecked()); |
| 44 return value; | 44 return value; |
| 45 } | 45 } |
| 46 | 46 |
| 47 String* m_value; | 47 String* m_value; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class ScriptPromiseResolverTest : public ::testing::Test { | 50 class ScriptPromiseResolverTest : public ::testing::Test { |
| 51 public: | 51 public: |
| 52 ScriptPromiseResolverTest() | 52 ScriptPromiseResolverTest() |
| 53 : m_pageHolder(DummyPageHolder::create()) | 53 : m_pageHolder(DummyPageHolder::create()) |
| 54 { | 54 { |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual ~ScriptPromiseResolverTest() | 57 ~ScriptPromiseResolverTest() override |
| 58 { | 58 { |
| 59 ScriptState::Scope scope(scriptState()); | 59 ScriptState::Scope scope(scriptState()); |
| 60 // FIXME: We put this statement here to clear an exception from the | 60 // FIXME: We put this statement here to clear an exception from the |
| 61 // isolate. | 61 // isolate. |
| 62 createClosure(callback, v8::Undefined(isolate()), isolate()); | 62 createClosure(callback, v8::Undefined(isolate()), isolate()); |
| 63 | 63 |
| 64 // Execute all pending microtasks | 64 // Execute all pending microtasks |
| 65 isolate()->RunMicrotasks(); | 65 isolate()->RunMicrotasks(); |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 resolver->reject(); | 313 resolver->reject(); |
| 314 isolate()->RunMicrotasks(); | 314 isolate()->RunMicrotasks(); |
| 315 | 315 |
| 316 EXPECT_EQ(String(), onFulfilled); | 316 EXPECT_EQ(String(), onFulfilled); |
| 317 EXPECT_EQ("undefined", onRejected); | 317 EXPECT_EQ("undefined", onRejected); |
| 318 } | 318 } |
| 319 | 319 |
| 320 } // namespace | 320 } // namespace |
| 321 | 321 |
| 322 } // namespace blink | 322 } // namespace blink |
| OLD | NEW |