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

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

Issue 2343553005: enable / disable Long Task instrumentation based on presence of LongTask observer (Closed)
Patch Set: address review comments Created 4 years, 3 months 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
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceObserver.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/timing/Performance.h"
6
7 #include "core/testing/DummyPageHolder.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace blink {
11
12 class PerformanceTest : public ::testing::Test {
13 protected:
14 void SetUp() override
15 {
16 m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
17 m_pageHolder->document().setURL(KURL(KURL(), "https://example.com"));
18 m_performance = Performance::create(&m_pageHolder->frame());
19 }
20
21 bool hasLongTaskInspectorAgent()
22 {
23 return m_performance->m_longTaskInspectorAgent;
24 }
25
26 void addLongTaskObserver()
27 {
28 // simulate with filter options.
29 m_performance->m_observerFilterOptions |= PerformanceEntry::LongTask;
30 }
31
32 void removeLongTaskObserver()
33 {
34 // simulate with filter options.
35 m_performance->m_observerFilterOptions = PerformanceEntry::Invalid;
36 }
37
38 Persistent<Performance> m_performance;
39 std::unique_ptr<DummyPageHolder> m_pageHolder;
40 };
41
42 TEST_F(PerformanceTest, LongTaskObserverInstrumentation)
43 {
44 m_performance->updateLongTaskInstrumentation();
45 EXPECT_FALSE(hasLongTaskInspectorAgent());
46
47 // Adding LongTask observer (with filer option) enables instrumentation.
48 addLongTaskObserver();
49 m_performance->updateLongTaskInstrumentation();
50 EXPECT_TRUE(hasLongTaskInspectorAgent());
51
52 // While LongTask observer is present, updateLongTaskInstrumentation has no effect.
53 m_performance->updateLongTaskInstrumentation();
54 EXPECT_TRUE(hasLongTaskInspectorAgent());
55
56 // Removing LongTask observer disables instrumentation.
57 removeLongTaskObserver();
58 m_performance->updateLongTaskInstrumentation();
59 EXPECT_FALSE(hasLongTaskInspectorAgent());
60 }
61
62 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceObserver.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698