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 |