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

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

Issue 1192013003: [Extension ServiceWorkers] Allow service worker registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Took out extra reload 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
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
index 1c4a1b6becd18c0051bc29e77ca6f1537c01bbbe..3dfa3732267ffc3140fcd1dc0f4514f7a15c53bc 100644
--- a/chrome/browser/extensions/service_worker_apitest.cc
+++ b/chrome/browser/extensions/service_worker_apitest.cc
@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/test/browser_test_utils.h"
#include "extensions/test/extension_test_message_listener.h"
namespace extensions {
@@ -22,14 +24,7 @@ class ServiceWorkerTest : public ExtensionApiTest {
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());
+ ASSERT_TRUE(RunExtensionTest("service_worker/register")) << message_;
}
// This feature is restricted to trunk, so on dev it should have existing
@@ -47,4 +42,26 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, CannotRegisterServiceWorkersOnDev) {
listener.message());
}
+IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, ServiceWorkerFetchEvent) {
+ RunExtensionTest("service_worker/fetch");
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ content::WaitForLoadStop(contents);
+
+ std::string output;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ contents, "window.domAutomationController.send(document.body.innerText);",
+ &output));
+ ASSERT_EQ("No Fetch Event yet.", output);
Devlin 2015/07/21 22:42:27 These ASSERT_EQ should probably be EXPECT_EQ.
annekao 2015/07/21 22:55:45 Done.
+
+ // Page must reload in order for the service worker to take control.
+ contents->GetController().Reload(true);
+ content::WaitForLoadStop(contents);
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ contents, "window.domAutomationController.send(document.body.innerText);",
+ &output));
+ ASSERT_EQ("Caught a fetch!", output);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698