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

Side by Side Diff: chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/page.js

Issue 2943583002: [extension SW] Support lazy events from extension service workers. (Closed)
Patch Set: address comments Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var readyPromise = new Promise(function(resolve, reject) {
6 navigator.serviceWorker.register('sw.js').then(function() {
7 return navigator.serviceWorker.ready;
8 }).then(function(registration) {
9 resolve('ready');
10 }).catch(function(err) {
11 reject(err);
12 });
13 });
14
15 window.runServiceWorker = function() {
16 readyPromise.then(function(message) {
17 window.domAutomationController.send(message);
18 }).catch(function(err) {
19 window.domAutomationController.send('FAILURE');
20 });
21 };
22
23 window.createTabThenUpdate = function() {
24 navigator.serviceWorker.onmessage = function(e) {
25 if (e.data == 'chrome.tabs.onUpdated callback') {
Devlin 2017/06/20 20:31:19 nit: maybe just send e.data in call cases? If it'
lazyboy 2017/06/22 02:46:56 I was more interested in hinting about e.data's va
26 window.domAutomationController.send(e.data);
27 } else {
28 window.domAutomationController.send('FAILURE');
29 }
30 };
31 var url = chrome.extension.getURL('on_updated.html');
32 chrome.tabs.create({url: url});
33 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698