| 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/dom/TaskRunnerHelper.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 options.setEntryTypes(entryTypeVec); | 132 options.setEntryTypes(entryTypeVec); |
| 133 m_observer->observe(options, exceptionState); | 133 m_observer->observe(options, exceptionState); |
| 134 | 134 |
| 135 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); | 135 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); |
| 136 // Add a long task entry | 136 // Add a long task entry |
| 137 m_base->addLongTaskTiming(1234, 5678, "same-origin", "www.foo.com/bar", "", | 137 m_base->addLongTaskTiming(1234, 5678, "same-origin", "www.foo.com/bar", "", |
| 138 ""); | 138 ""); |
| 139 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry | 139 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry |
| 140 } | 140 } |
| 141 | 141 |
| 142 TEST_F(PerformanceBaseTest, GetNavigationType) { | |
| 143 m_pageHolder->page().setVisibilityState(PageVisibilityStatePrerender, false); | |
| 144 PerformanceNavigationTiming::NavigationType returnedType = | |
| 145 PerformanceBase::getNavigationType(NavigationTypeBackForward, | |
| 146 &m_pageHolder->document()); | |
| 147 EXPECT_EQ(returnedType, | |
| 148 PerformanceNavigationTiming::NavigationType::Prerender); | |
| 149 | |
| 150 m_pageHolder->page().setVisibilityState(PageVisibilityStateHidden, false); | |
| 151 returnedType = PerformanceBase::getNavigationType(NavigationTypeBackForward, | |
| 152 &m_pageHolder->document()); | |
| 153 EXPECT_EQ(returnedType, | |
| 154 PerformanceNavigationTiming::NavigationType::BackForward); | |
| 155 | |
| 156 m_pageHolder->page().setVisibilityState(PageVisibilityStateVisible, false); | |
| 157 returnedType = PerformanceBase::getNavigationType( | |
| 158 NavigationTypeFormResubmitted, &m_pageHolder->document()); | |
| 159 EXPECT_EQ(returnedType, | |
| 160 PerformanceNavigationTiming::NavigationType::Navigate); | |
| 161 } | |
| 162 | |
| 163 TEST_F(PerformanceBaseTest, AllowsTimingRedirect) { | 142 TEST_F(PerformanceBaseTest, AllowsTimingRedirect) { |
| 164 // When there are no cross-origin redirects. | 143 // When there are no cross-origin redirects. |
| 165 AtomicString originDomain = "http://127.0.0.1:8000"; | 144 AtomicString originDomain = "http://127.0.0.1:8000"; |
| 166 Vector<ResourceResponse> redirectChain; | 145 Vector<ResourceResponse> redirectChain; |
| 167 KURL url(ParsedURLString, originDomain + "/foo.html"); | 146 KURL url(ParsedURLString, originDomain + "/foo.html"); |
| 168 ResourceResponse finalResponse; | 147 ResourceResponse finalResponse; |
| 169 ResourceResponse redirectResponse1; | 148 ResourceResponse redirectResponse1; |
| 170 redirectResponse1.setURL(url); | 149 redirectResponse1.setURL(url); |
| 171 ResourceResponse redirectResponse2; | 150 ResourceResponse redirectResponse2; |
| 172 redirectResponse2.setURL(url); | 151 redirectResponse2.setURL(url); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 193 | 172 |
| 194 // When cross-origin redirect opts in. | 173 // When cross-origin redirect opts in. |
| 195 redirectChain.back().setHTTPHeaderField(HTTPNames::Timing_Allow_Origin, | 174 redirectChain.back().setHTTPHeaderField(HTTPNames::Timing_Allow_Origin, |
| 196 originDomain); | 175 originDomain); |
| 197 EXPECT_TRUE(allowsTimingRedirect(redirectChain, finalResponse, | 176 EXPECT_TRUE(allowsTimingRedirect(redirectChain, finalResponse, |
| 198 *securityOrigin.get(), | 177 *securityOrigin.get(), |
| 199 getExecutionContext())); | 178 getExecutionContext())); |
| 200 } | 179 } |
| 201 | 180 |
| 202 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |