| 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/timing/PerformanceBase.h" | 9 #include "core/timing/PerformanceBase.h" |
| 10 #include "core/timing/PerformanceLongTaskTiming.h" | 10 #include "core/timing/PerformanceLongTaskTiming.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 m_base->unregisterPerformanceObserver(*m_observer.get()); | 85 m_base->unregisterPerformanceObserver(*m_observer.get()); |
| 86 EXPECT_EQ(0, m_base->numObservers()); | 86 EXPECT_EQ(0, m_base->numObservers()); |
| 87 EXPECT_EQ(0, m_base->numActiveObservers()); | 87 EXPECT_EQ(0, m_base->numActiveObservers()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(PerformanceBaseTest, AddLongTaskTiming) { | 90 TEST_F(PerformanceBaseTest, AddLongTaskTiming) { |
| 91 V8TestingScope scope; | 91 V8TestingScope scope; |
| 92 initialize(scope.getScriptState()); | 92 initialize(scope.getScriptState()); |
| 93 | 93 |
| 94 // Add a long task entry, but no observer registered. | 94 // Add a long task entry, but no observer registered. |
| 95 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar", nullptr); | 95 m_base->addLongTaskTiming(1234, 5678, "same-origin", "www.foo.com/bar", "", |
| 96 ""); |
| 96 EXPECT_FALSE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); | 97 EXPECT_FALSE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); |
| 97 EXPECT_EQ(0, numPerformanceEntriesInObserver()); // has no effect | 98 EXPECT_EQ(0, numPerformanceEntriesInObserver()); // has no effect |
| 98 | 99 |
| 99 // Make an observer for longtask | 100 // Make an observer for longtask |
| 100 NonThrowableExceptionState exceptionState; | 101 NonThrowableExceptionState exceptionState; |
| 101 PerformanceObserverInit options; | 102 PerformanceObserverInit options; |
| 102 Vector<String> entryTypeVec; | 103 Vector<String> entryTypeVec; |
| 103 entryTypeVec.append("longtask"); | 104 entryTypeVec.append("longtask"); |
| 104 options.setEntryTypes(entryTypeVec); | 105 options.setEntryTypes(entryTypeVec); |
| 105 m_observer->observe(options, exceptionState); | 106 m_observer->observe(options, exceptionState); |
| 106 | 107 |
| 107 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); | 108 EXPECT_TRUE(m_base->hasPerformanceObserverFor(PerformanceEntry::LongTask)); |
| 108 // Add a long task entry | 109 // Add a long task entry |
| 109 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar", nullptr); | 110 m_base->addLongTaskTiming(1234, 5678, "same-origin", "www.foo.com/bar", "", |
| 111 ""); |
| 110 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry | 112 EXPECT_EQ(1, numPerformanceEntriesInObserver()); // added an entry |
| 111 } | 113 } |
| 112 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |