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); |