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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceObserver.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/timing/PerformanceTest.cpp
diff --git a/third_party/WebKit/Source/core/timing/PerformanceTest.cpp b/third_party/WebKit/Source/core/timing/PerformanceTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c09f58f53001aa36def72988788f8ee005ebda8f
--- /dev/null
+++ b/third_party/WebKit/Source/core/timing/PerformanceTest.cpp
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/timing/Performance.h"
+
+#include "core/testing/DummyPageHolder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class PerformanceTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
+ m_pageHolder->document().setURL(KURL(KURL(), "https://example.com"));
+ m_performance = Performance::create(&m_pageHolder->frame());
+ }
+
+ bool hasLongTaskInspectorAgent()
+ {
+ return m_performance->m_longTaskInspectorAgent;
+ }
+
+ void addLongTaskObserver()
+ {
+ // simulate with filter options.
+ m_performance->m_observerFilterOptions |= PerformanceEntry::LongTask;
+ }
+
+ void removeLongTaskObserver()
+ {
+ // simulate with filter options.
+ m_performance->m_observerFilterOptions = PerformanceEntry::Invalid;
+ }
+
+ Persistent<Performance> m_performance;
+ std::unique_ptr<DummyPageHolder> m_pageHolder;
+};
+
+TEST_F(PerformanceTest, LongTaskObserverInstrumentation)
+{
+ m_performance->updateLongTaskInstrumentation();
+ EXPECT_FALSE(hasLongTaskInspectorAgent());
+
+ // Adding LongTask observer (with filer option) enables instrumentation.
+ addLongTaskObserver();
+ m_performance->updateLongTaskInstrumentation();
+ EXPECT_TRUE(hasLongTaskInspectorAgent());
+
+ // While LongTask observer is present, updateLongTaskInstrumentation has no effect.
+ m_performance->updateLongTaskInstrumentation();
+ EXPECT_TRUE(hasLongTaskInspectorAgent());
+
+ // Removing LongTask observer disables instrumentation.
+ removeLongTaskObserver();
+ m_performance->updateLongTaskInstrumentation();
+ EXPECT_FALSE(hasLongTaskInspectorAgent());
+}
+
+}
« 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