| 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 "bindings/core/v8/ScriptPromiseResolver.h" | 5 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptFunction.h" | 7 #include "bindings/core/v8/ScriptFunction.h" |
| 8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
| 9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include <memory> |
| 14 #include <v8.h> | 15 #include <v8.h> |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { } | 21 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { } |
| 21 | 22 |
| 22 class Function : public ScriptFunction { | 23 class Function : public ScriptFunction { |
| 23 public: | 24 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 { | 56 { |
| 56 ScriptState::Scope scope(getScriptState()); | 57 ScriptState::Scope scope(getScriptState()); |
| 57 // FIXME: We put this statement here to clear an exception from the | 58 // FIXME: We put this statement here to clear an exception from the |
| 58 // isolate. | 59 // isolate. |
| 59 createClosure(callback, v8::Undefined(isolate()), isolate()); | 60 createClosure(callback, v8::Undefined(isolate()), isolate()); |
| 60 | 61 |
| 61 // Execute all pending microtasks | 62 // Execute all pending microtasks |
| 62 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 63 v8::MicrotasksScope::PerformCheckpoint(isolate()); |
| 63 } | 64 } |
| 64 | 65 |
| 65 OwnPtr<DummyPageHolder> m_pageHolder; | 66 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 66 ScriptState* getScriptState() const { return ScriptState::forMainWorld(&m_pa
geHolder->frame()); } | 67 ScriptState* getScriptState() const { return ScriptState::forMainWorld(&m_pa
geHolder->frame()); } |
| 67 ExecutionContext* getExecutionContext() const { return &m_pageHolder->docume
nt(); } | 68 ExecutionContext* getExecutionContext() const { return &m_pageHolder->docume
nt(); } |
| 68 v8::Isolate* isolate() const { return getScriptState()->isolate(); } | 69 v8::Isolate* isolate() const { return getScriptState()->isolate(); } |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 TEST_F(ScriptPromiseResolverTest, construct) | 72 TEST_F(ScriptPromiseResolverTest, construct) |
| 72 { | 73 { |
| 73 ASSERT_FALSE(getExecutionContext()->activeDOMObjectsAreStopped()); | 74 ASSERT_FALSE(getExecutionContext()->activeDOMObjectsAreStopped()); |
| 74 ScriptState::Scope scope(getScriptState()); | 75 ScriptState::Scope scope(getScriptState()); |
| 75 ScriptPromiseResolver::create(getScriptState()); | 76 ScriptPromiseResolver::create(getScriptState()); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 resolver->reject(); | 347 resolver->reject(); |
| 347 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 348 v8::MicrotasksScope::PerformCheckpoint(isolate()); |
| 348 | 349 |
| 349 EXPECT_EQ(String(), onFulfilled); | 350 EXPECT_EQ(String(), onFulfilled); |
| 350 EXPECT_EQ("undefined", onRejected); | 351 EXPECT_EQ("undefined", onRejected); |
| 351 } | 352 } |
| 352 | 353 |
| 353 } // namespace | 354 } // namespace |
| 354 | 355 |
| 355 } // namespace blink | 356 } // namespace blink |
| OLD | NEW |