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

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: Added comments to test 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/common/chrome_content_client.h » ('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
index 1c4a1b6becd18c0051bc29e77ca6f1537c01bbbe..3dd54521a95d4a5eb90781c951e71333d5a3b97a 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
@@ -40,11 +35,33 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, CannotRegisterServiceWorkersOnDev) {
ExtensionTestMessageListener listener(false);
ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_;
ASSERT_TRUE(listener.WaitUntilSatisfied());
- ASSERT_EQ(
+ EXPECT_EQ(
"SecurityError: Failed to register a ServiceWorker: The URL "
"protocol of the current origin ('chrome-extension://" +
GetSingleLoadedExtension()->id() + "') is not supported.",
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));
+ EXPECT_EQ("No Fetch Event yet.", output);
+
+ // 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));
+ EXPECT_EQ("Caught a fetch!", output);
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | chrome/common/chrome_content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698