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

Unified Diff: chrome/test/data/extensions/api_test/service_worker/update/v2/background.js

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: test updated 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/test/data/extensions/api_test/service_worker/update/v2/background.js
diff --git a/chrome/test/data/extensions/api_test/service_worker/update/v2/background.js b/chrome/test/data/extensions/api_test/service_worker/update/v2/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..9d5d43d2633daa6f1ed70530c11a919f2d02c794
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/service_worker/update/v2/background.js
@@ -0,0 +1,29 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var serviceWorkerPromise = new Promise(function(resolve, reject) {
+ navigator.serviceWorker.register('sw.js').then(function() {
+ return navigator.serviceWorker.ready;
+ }).then(function(registration) {
+ var sw = registration.active;
+ var channel = new MessageChannel();
+ channel.port1.onmessage = function(e) {
+ resolve(e.data);
+ };
+ sw.postMessage('ping', [channel.port2]);
+ }).catch(function(err) {
+ reject(err);
+ });
+});
+
+var testPromise = new Promise(function(resolve) {
+ window.testResolver = resolve;
+});
+
+Promise.all([serviceWorkerPromise, testPromise]).then(function(messages) {
+ window.domAutomationController.send(
+ String(messages[0] == 'Pong from version 2'));
+}).catch(function(err) {
+ window.domAutomationController.send('false');
+});

Powered by Google App Engine
This is Rietveld 408576698