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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceObserverTest.cpp

Issue 2458573002: bindings: Store ScriptState in generated callback functions (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/timing/PerformanceObserver.h" 5 #include "core/timing/PerformanceObserver.h"
6 6
7 #include "bindings/core/v8/PerformanceObserverCallback.h" 7 #include "bindings/core/v8/PerformanceObserverCallback.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/timing/Performance.h" 9 #include "core/timing/Performance.h"
10 #include "core/timing/PerformanceBase.h" 10 #include "core/timing/PerformanceBase.h"
(...skipping 10 matching lines...) Expand all
21 21
22 ExecutionContext* getExecutionContext() const override { return nullptr; } 22 ExecutionContext* getExecutionContext() const override { return nullptr; }
23 }; 23 };
24 24
25 class PerformanceObserverTest : public ::testing::Test { 25 class PerformanceObserverTest : public ::testing::Test {
26 protected: 26 protected:
27 void initialize(ScriptState* scriptState) { 27 void initialize(ScriptState* scriptState) {
28 v8::Local<v8::Function> callback = 28 v8::Local<v8::Function> callback =
29 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); 29 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked();
30 m_base = new MockPerformanceBase(); 30 m_base = new MockPerformanceBase();
31 m_cb = 31 m_cb = PerformanceObserverCallback::create(scriptState, callback);
32 PerformanceObserverCallback::create(scriptState->isolate(), callback);
33 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); 32 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb);
34 } 33 }
35 34
36 bool isRegistered() { return m_observer->m_isRegistered; } 35 bool isRegistered() { return m_observer->m_isRegistered; }
37 int numPerformanceEntries() { 36 int numPerformanceEntries() {
38 return m_observer->m_performanceEntries.size(); 37 return m_observer->m_performanceEntries.size();
39 } 38 }
40 void deliver() { m_observer->deliver(); } 39 void deliver() { m_observer->deliver(); }
41 40
42 Persistent<MockPerformanceBase> m_base; 41 Persistent<MockPerformanceBase> m_base;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 EXPECT_EQ(0, numPerformanceEntries()); 90 EXPECT_EQ(0, numPerformanceEntries());
92 91
93 m_observer->enqueuePerformanceEntry(*entry); 92 m_observer->enqueuePerformanceEntry(*entry);
94 EXPECT_EQ(1, numPerformanceEntries()); 93 EXPECT_EQ(1, numPerformanceEntries());
95 94
96 m_observer->disconnect(); 95 m_observer->disconnect();
97 EXPECT_FALSE(isRegistered()); 96 EXPECT_FALSE(isRegistered());
98 EXPECT_EQ(0, numPerformanceEntries()); 97 EXPECT_EQ(0, numPerformanceEntries());
99 } 98 }
100 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698