| OLD | NEW |
| 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/dom/TaskRunnerHelper.h" |
| 9 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 10 #include "core/testing/NullExecutionContext.h" | 11 #include "core/testing/NullExecutionContext.h" |
| 11 #include "core/timing/PerformanceBase.h" | 12 #include "core/timing/PerformanceBase.h" |
| 12 #include "core/timing/PerformanceLongTaskTiming.h" | 13 #include "core/timing/PerformanceLongTaskTiming.h" |
| 13 #include "core/timing/PerformanceObserver.h" | 14 #include "core/timing/PerformanceObserver.h" |
| 14 #include "core/timing/PerformanceObserverInit.h" | 15 #include "core/timing/PerformanceObserverInit.h" |
| 15 #include "platform/network/ResourceResponse.h" | 16 #include "platform/network/ResourceResponse.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 class TestPerformanceBase : public PerformanceBase { | 21 class TestPerformanceBase : public PerformanceBase { |
| 21 public: | 22 public: |
| 22 TestPerformanceBase() : PerformanceBase(0) {} | 23 explicit TestPerformanceBase(ScriptState* scriptState) |
| 24 : PerformanceBase( |
| 25 0, |
| 26 TaskRunnerHelper::get(TaskType::PerformanceTimeline, scriptState)) { |
| 27 } |
| 23 ~TestPerformanceBase() {} | 28 ~TestPerformanceBase() {} |
| 24 | 29 |
| 25 ExecutionContext* getExecutionContext() const override { return nullptr; } | 30 ExecutionContext* getExecutionContext() const override { return nullptr; } |
| 26 | 31 |
| 27 int numActiveObservers() { return m_activeObservers.size(); } | 32 int numActiveObservers() { return m_activeObservers.size(); } |
| 28 | 33 |
| 29 int numObservers() { return m_observers.size(); } | 34 int numObservers() { return m_observers.size(); } |
| 30 | 35 |
| 31 bool hasPerformanceObserverFor(PerformanceEntry::EntryType entryType) { | 36 bool hasPerformanceObserverFor(PerformanceEntry::EntryType entryType) { |
| 32 return hasObserverFor(entryType); | 37 return hasObserverFor(entryType); |
| 33 } | 38 } |
| 34 | 39 |
| 35 DEFINE_INLINE_TRACE() { PerformanceBase::trace(visitor); } | 40 DEFINE_INLINE_TRACE() { PerformanceBase::trace(visitor); } |
| 36 }; | 41 }; |
| 37 | 42 |
| 38 class PerformanceBaseTest : public ::testing::Test { | 43 class PerformanceBaseTest : public ::testing::Test { |
| 39 protected: | 44 protected: |
| 40 void initialize(ScriptState* scriptState) { | 45 void initialize(ScriptState* scriptState) { |
| 41 v8::Local<v8::Function> callback = | 46 v8::Local<v8::Function> callback = |
| 42 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); | 47 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); |
| 43 m_base = new TestPerformanceBase(); | 48 m_base = new TestPerformanceBase(scriptState); |
| 44 m_cb = PerformanceObserverCallback::create(scriptState, callback); | 49 m_cb = PerformanceObserverCallback::create(scriptState, callback); |
| 45 m_observer = PerformanceObserver::create(scriptState->getExecutionContext(), | 50 m_observer = PerformanceObserver::create(scriptState->getExecutionContext(), |
| 46 m_base, m_cb); | 51 m_base, m_cb); |
| 47 } | 52 } |
| 48 | 53 |
| 49 void SetUp() override { | 54 void SetUp() override { |
| 50 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); | 55 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 51 m_executionContext = new NullExecutionContext(); | 56 m_executionContext = new NullExecutionContext(); |
| 52 } | 57 } |
| 53 | 58 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 194 |
| 190 // When cross-origin redirect opts in. | 195 // When cross-origin redirect opts in. |
| 191 redirectChain.back().setHTTPHeaderField(HTTPNames::Timing_Allow_Origin, | 196 redirectChain.back().setHTTPHeaderField(HTTPNames::Timing_Allow_Origin, |
| 192 originDomain); | 197 originDomain); |
| 193 EXPECT_TRUE(allowsTimingRedirect(redirectChain, finalResponse, | 198 EXPECT_TRUE(allowsTimingRedirect(redirectChain, finalResponse, |
| 194 *securityOrigin.get(), | 199 *securityOrigin.get(), |
| 195 getExecutionContext())); | 200 getExecutionContext())); |
| 196 } | 201 } |
| 197 | 202 |
| 198 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |