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

Unified Diff: chrome/browser/extensions/service_worker_apitest.cc

Issue 1211243010: [Service Worker Registration] Registered extension scheme to allow service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added license Created 5 years, 5 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 | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/service_worker_apitest.cc
diff --git a/chrome/browser/extensions/service_worker_apitest.cc b/chrome/browser/extensions/service_worker_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c4a1b6becd18c0051bc29e77ca6f1537c01bbbe
--- /dev/null
+++ b/chrome/browser/extensions/service_worker_apitest.cc
@@ -0,0 +1,50 @@
+// Copyright 2015 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 "chrome/browser/extensions/extension_apitest.h"
+#include "extensions/test/extension_test_message_listener.h"
+
+namespace extensions {
+
+class ServiceWorkerTest : public ExtensionApiTest {
+ public:
+ // Set the channel to "trunk" since service workers are restricted to trunk.
+ ServiceWorkerTest()
+ : current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {}
+
+ ~ServiceWorkerTest() override {}
+
+ private:
+ ScopedCurrentChannel current_channel_;
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerTest);
+};
+
+IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterServiceWorkersOnTrunk) {
+ ExtensionTestMessageListener listener(false);
+ // This should fail because there are changes to be made to
+ // successfully register a service worker.
+ ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_;
+ ASSERT_TRUE(listener.WaitUntilSatisfied());
+ ASSERT_EQ(
+ "SecurityError: Failed to register a ServiceWorker: No URL is "
+ "associated with the caller's document.",
+ listener.message());
+}
+
+// This feature is restricted to trunk, so on dev it should have existing
+// behavior - which is for it to fail.
+IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, CannotRegisterServiceWorkersOnDev) {
+ ScopedCurrentChannel current_channel_override(
+ chrome::VersionInfo::CHANNEL_DEV);
+ ExtensionTestMessageListener listener(false);
+ ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_;
+ ASSERT_TRUE(listener.WaitUntilSatisfied());
+ ASSERT_EQ(
+ "SecurityError: Failed to register a ServiceWorker: The URL "
+ "protocol of the current origin ('chrome-extension://" +
+ GetSingleLoadedExtension()->id() + "') is not supported.",
+ listener.message());
+}
+
+} // namespace extensions
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698