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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBaseTest.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/Performance.h" 5 #include "core/timing/Performance.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/PerformanceBase.h" 9 #include "core/timing/PerformanceBase.h"
10 #include "core/timing/PerformanceLongTaskTiming.h" 10 #include "core/timing/PerformanceLongTaskTiming.h"
(...skipping 20 matching lines...) Expand all
31 31
32 DEFINE_INLINE_TRACE() { PerformanceBase::trace(visitor); } 32 DEFINE_INLINE_TRACE() { PerformanceBase::trace(visitor); }
33 }; 33 };
34 34
35 class PerformanceBaseTest : public ::testing::Test { 35 class PerformanceBaseTest : public ::testing::Test {
36 protected: 36 protected:
37 void initialize(ScriptState* scriptState) { 37 void initialize(ScriptState* scriptState) {
38 v8::Local<v8::Function> callback = 38 v8::Local<v8::Function> callback =
39 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); 39 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked();
40 m_base = new TestPerformanceBase(); 40 m_base = new TestPerformanceBase();
41 m_cb = 41 m_cb = PerformanceObserverCallback::create(scriptState, callback);
42 PerformanceObserverCallback::create(scriptState->isolate(), callback);
43 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); 42 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb);
44 } 43 }
45 44
46 int numPerformanceEntriesInObserver() { 45 int numPerformanceEntriesInObserver() {
47 return m_observer->m_performanceEntries.size(); 46 return m_observer->m_performanceEntries.size();
48 } 47 }
49 48
50 Persistent<TestPerformanceBase> m_base; 49 Persistent<TestPerformanceBase> m_base;
51 Persistent<PerformanceObserver> m_observer; 50 Persistent<PerformanceObserver> m_observer;
52 Persistent<PerformanceObserverCallback> m_cb; 51 Persistent<PerformanceObserverCallback> m_cb;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 entryTypeVec.append("longtask"); 103 entryTypeVec.append("longtask");
105 options.setEntryTypes(entryTypeVec); 104 options.setEntryTypes(entryTypeVec);
106 m_observer->observe(options, exceptionState); 105 m_observer->observe(options, exceptionState);
107 106
108 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); 107 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask));
109 // Add a long task entry 108 // Add a long task entry
110 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar", nullptr); 109 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar", nullptr);
111 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry 110 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry
112 } 111 }
113 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698