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

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: remove SW.register() from v2 extension Created 5 years 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/test/data/extensions/api_test/service_worker/update/service_worker.pem » ('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 0d7a9a9771a536f871afce382ff2eb30be9e410d..fbfc56144f5d02b1b6b9ab83fe6a6b1ecc48b547 100644
--- a/chrome/browser/extensions/service_worker_apitest.cc
+++ b/chrome/browser/extensions/service_worker_apitest.cc
@@ -24,6 +24,7 @@
#include "content/public/test/background_sync_test_util.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/extension_host.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/process_manager.h"
#include "extensions/test/background_page_watcher.h"
#include "extensions/test/extension_test_message_listener.h"
@@ -214,6 +215,44 @@ 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());
+ const char* kId = "hfaanndiiilofhfokeanhddpkfffchdi";
+
+ ExtensionTestMessageListener listener_v1("Pong from version 1", false);
+ listener_v1.set_failure_message("FAILURE_V1");
+ // Install version 1.0 of the extension.
+ ASSERT_TRUE(InstallExtension(path_v1, 1));
+ EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile())
+ ->enabled_extensions()
+ .GetByID(kId));
+ EXPECT_TRUE(listener_v1.WaitUntilSatisfied());
+
+ ExtensionTestMessageListener listener_v2("Pong from version 2", false);
+ listener_v2.set_failure_message("FAILURE_V2");
+
+ // Update to version 2.0.
+ EXPECT_TRUE(UpdateExtension(kId, path_v2, 0));
+ EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile())
+ ->enabled_extensions()
+ .GetByID(kId));
+ EXPECT_TRUE(listener_v2.WaitUntilSatisfied());
+}
+
IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, FetchArbitraryPaths) {
const Extension* extension =
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/service_worker/update/service_worker.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698