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

Side by Side Diff: chrome/test/data/extensions/api_test/service_worker/sync/sw.js

Issue 1812503002: Fix race in ServiceWorkerBackgroundSyncTest.Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « chrome/test/data/extensions/api_test/service_worker/sync/page.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var port = null; 5 var port = null;
6 this.onsync = function(e) { 6 this.onsync = function(e) {
7 if (port) { 7 if (port) {
8 e.waitUntil(new Promise(function(resolve) { 8 e.waitUntil(new Promise(function(resolve) {
9 // Add a small delay to respond so we can exercise and test the 9 // Add a small delay to respond so we can exercise and test the
10 // offline->online transition. 10 // offline->online transition.
11 // NOTE: the following setTimeout() is not a requirement for this test. It 11 // NOTE: the following setTimeout() is not a requirement for this test. It
12 // is here to just demonstrate that the test passes with a bit of 12 // is here to just demonstrate that the test passes with a bit of
13 // asynchrony. 13 // asynchrony.
14 setTimeout(function() { 14 setTimeout(function() {
15 port.postMessage('SYNC: ' + e.tag); 15 port.postMessage('SYNC: ' + e.tag);
16 resolve(); 16 resolve();
17 }, 0); 17 }, 0);
18 })); 18 }));
19 } 19 }
20 }; 20 };
21 21
22 this.onmessage = function(e) { 22 this.onmessage = function(e) {
23 port = e.ports[0]; 23 port = e.ports[0];
24 port.postMessage('connected');
iclelland 2016/03/16 15:46:33 Should this check to see if e.data is "connect"? I
jkarlin 2016/03/16 16:59:37 Sure. Done.
24 }; 25 };
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/service_worker/sync/page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698