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

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

Issue 1432823003: Add a test to cover service worker update codepath when extension is updated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use set_force_update_on_page_load() + git cl format Created 5 years, 1 month 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 29fad8fa5aa7285fc66d58454b3be8d38db67766..887ffb7f40a44fdc74fd2028f6cbf89077e30c28 100644
--- a/chrome/browser/extensions/service_worker_apitest.cc
+++ b/chrome/browser/extensions/service_worker_apitest.cc
@@ -132,6 +132,41 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterFailsOnDev) {
error);
}
+IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, UpdateRefreshesServiceWorker) {
+ base::ScopedTempDir scoped_temp_dir;
+ ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
+ base::FilePath pem_path = test_data_dir_.AppendASCII("service_worker")
+ .AppendASCII("update")
+ .AppendASCII("service_worker.pem");
+ base::FilePath path_v1 = PackExtensionWithOptions(
+ test_data_dir_.AppendASCII("service_worker")
+ .AppendASCII("update")
+ .AppendASCII("v1"),
+ scoped_temp_dir.path().AppendASCII("v1.crx"), pem_path, base::FilePath());
+ base::FilePath path_v2 = PackExtensionWithOptions(
+ test_data_dir_.AppendASCII("service_worker")
+ .AppendASCII("update")
+ .AppendASCII("v2"),
+ scoped_temp_dir.path().AppendASCII("v2.crx"), pem_path, base::FilePath());
+
+ ExtensionService* service =
Devlin 2015/11/11 17:10:29 nit: there's an extension_service() accessor on Ex
lazyboy 2015/11/11 22:32:23 Not needed anymore.
+ ExtensionSystem::Get(browser()->profile())->extension_service();
+ const char kId[] = "hfaanndiiilofhfokeanhddpkfffchdi";
+
+ // Install version 1.0 of the extension.
+ ASSERT_TRUE(InstallExtension(path_v1, 1));
+ EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
Devlin 2015/11/11 17:10:29 nit: GetExtensionById is deprecated. Prefer Extens
lazyboy 2015/11/11 22:32:23 Done.
+
+ const char* kScript = "window.testResolver();";
Devlin 2015/11/11 17:10:29 nitty nit: pick one between const char[] (line 154
lazyboy 2015/11/11 22:32:23 Done.
+ EXPECT_EQ("true", ExecuteScriptInBackgroundPage(kId, kScript));
Devlin 2015/11/11 17:10:29 This is an interesting pattern. Usually we would
lazyboy 2015/11/11 22:32:23 Changed to compare with the actual received messag
+
+ // Update to version 2.0.
+ EXPECT_TRUE(UpdateExtension(kId, path_v2, 0));
+ EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+
+ EXPECT_EQ("true", ExecuteScriptInBackgroundPage(kId, kScript));
+}
+
IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, FetchArbitraryPaths) {
const Extension* extension =
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);

Powered by Google App Engine
This is Rietveld 408576698