Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolverTest.cpp

Issue 2144413004: Removes abuse of createClosure() from ScriptPromiseTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed a review comment. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
15 #include <v8.h> 15 #include <v8.h>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 namespace { 19 namespace {
20 20
21 void callback(const v8::FunctionCallbackInfo<v8::Value>& info) { }
22
23 class Function : public ScriptFunction { 21 class Function : public ScriptFunction {
24 public: 22 public:
25 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Stri ng* value) 23 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Stri ng* value)
26 { 24 {
27 Function* self = new Function(scriptState, value); 25 Function* self = new Function(scriptState, value);
28 return self->bindToV8Function(); 26 return self->bindToV8Function();
29 } 27 }
30 28
31 private: 29 private:
32 Function(ScriptState* scriptState, String* value) 30 Function(ScriptState* scriptState, String* value)
(...skipping 14 matching lines...) Expand all
47 45
48 class ScriptPromiseResolverTest : public ::testing::Test { 46 class ScriptPromiseResolverTest : public ::testing::Test {
49 public: 47 public:
50 ScriptPromiseResolverTest() 48 ScriptPromiseResolverTest()
51 : m_pageHolder(DummyPageHolder::create()) 49 : m_pageHolder(DummyPageHolder::create())
52 { 50 {
53 } 51 }
54 52
55 ~ScriptPromiseResolverTest() override 53 ~ScriptPromiseResolverTest() override
56 { 54 {
57 ScriptState::Scope scope(getScriptState());
58 // FIXME: We put this statement here to clear an exception from the
59 // isolate.
60 createClosure(callback, v8::Undefined(isolate()), isolate());
61
62 // Execute all pending microtasks 55 // Execute all pending microtasks
63 v8::MicrotasksScope::PerformCheckpoint(isolate()); 56 v8::MicrotasksScope::PerformCheckpoint(isolate());
64 } 57 }
65 58
66 std::unique_ptr<DummyPageHolder> m_pageHolder; 59 std::unique_ptr<DummyPageHolder> m_pageHolder;
67 ScriptState* getScriptState() const { return ScriptState::forMainWorld(&m_pa geHolder->frame()); } 60 ScriptState* getScriptState() const { return ScriptState::forMainWorld(&m_pa geHolder->frame()); }
68 ExecutionContext* getExecutionContext() const { return &m_pageHolder->docume nt(); } 61 ExecutionContext* getExecutionContext() const { return &m_pageHolder->docume nt(); }
69 v8::Isolate* isolate() const { return getScriptState()->isolate(); } 62 v8::Isolate* isolate() const { return getScriptState()->isolate(); }
70 }; 63 };
71 64
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 resolver->reject(); 340 resolver->reject();
348 v8::MicrotasksScope::PerformCheckpoint(isolate()); 341 v8::MicrotasksScope::PerformCheckpoint(isolate());
349 342
350 EXPECT_EQ(String(), onFulfilled); 343 EXPECT_EQ(String(), onFulfilled);
351 EXPECT_EQ("undefined", onRejected); 344 EXPECT_EQ("undefined", onRejected);
352 } 345 }
353 346
354 } // namespace 347 } // namespace
355 348
356 } // namespace blink 349 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptPromiseTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698