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

Unified Diff: third_party/WebKit/Source/core/workers/MainThreadWorkletTest.cpp

Issue 2558643005: Worker: Enable UseCounter for MainThreadWorkletGlobalScope (Closed)
Patch Set: fix KURL Created 4 years 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/workers/MainThreadWorkletGlobalScope.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/workers/MainThreadWorkletTest.cpp
diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorkletTest.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorkletTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c5629a5bd8768838431a3add6b566754652fff5c
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorkletTest.cpp
@@ -0,0 +1,54 @@
+// 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/frame/UseCounter.h"
+#include "core/testing/DummyPageHolder.h"
+#include "core/workers/MainThreadWorkletGlobalScope.h"
+#include "platform/weborigin/SecurityOrigin.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class MainThreadWorkletTest : public ::testing::Test {
+ public:
+ void SetUp() override {
+ KURL url(ParsedURLString, "https://example.com/");
+ m_page = DummyPageHolder::create();
+ m_securityOrigin = SecurityOrigin::create(url);
+ m_globalScope = new MainThreadWorkletGlobalScope(
+ &m_page->frame(), url, "fake user agent", m_securityOrigin.get(),
+ toIsolate(m_page->frame().document()));
+ }
+
+ void TearDown() override { m_globalScope->terminateWorkletGlobalScope(); }
+
+ protected:
+ RefPtr<SecurityOrigin> m_securityOrigin;
+ std::unique_ptr<DummyPageHolder> m_page;
+ Persistent<MainThreadWorkletGlobalScope> m_globalScope;
+};
+
+TEST_F(MainThreadWorkletTest, UseCounter) {
+ Document& document = *m_page->frame().document();
+
+ // This feature is randomly selected.
+ const UseCounter::Feature feature1 = UseCounter::Feature::RequestFileSystem;
+
+ // API use on the MainThreadWorkletGlobalScope should be recorded in
+ // UseCounter on the Document.
+ EXPECT_FALSE(UseCounter::isCounted(document, feature1));
+ UseCounter::count(m_globalScope, feature1);
+ EXPECT_TRUE(UseCounter::isCounted(document, feature1));
+
+ // This feature is randomly selected from Deprecation::deprecationMessage().
+ const UseCounter::Feature feature2 = UseCounter::Feature::PrefixedStorageInfo;
+
+ // Deprecated API use on the MainThreadWorkletGlobalScope should be recorded
+ // in UseCounter on the Document.
+ EXPECT_FALSE(UseCounter::isCounted(document, feature2));
+ Deprecation::countDeprecation(m_globalScope, feature2);
+ EXPECT_TRUE(UseCounter::isCounted(document, feature2));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698