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

Unified Diff: content/test/data/background_sync/service_worker.js

Issue 1344843003: [BackgroundSync] Add browser side support for SyncRegistration.done (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ncn_max
Patch Set: Address comments from PS7 Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/data/background_sync/background_sync_test_helpers.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/background_sync/service_worker.js
diff --git a/content/test/data/background_sync/service_worker.js b/content/test/data/background_sync/service_worker.js
index 56be354933bffe02d4021c9b75ea32e6948e7641..68f57b55e5e45817b495c90f962a1ef605cac34d 100644
--- a/content/test/data/background_sync/service_worker.js
+++ b/content/test/data/background_sync/service_worker.js
@@ -17,7 +17,7 @@ var resolveCallback = null;
var rejectCallback = null;
this.onmessage = function(event) {
- if (event.data === 'completeDelayedOneShot') {
+ if (event.data['action'] === 'completeDelayedOneShot') {
if (resolveCallback === null) {
sendMessageToClients('sync', 'error - resolveCallback is null');
return;
@@ -28,7 +28,7 @@ this.onmessage = function(event) {
return;
}
- if (event.data === 'rejectDelayedOneShot') {
+ if (event.data['action'] === 'rejectDelayedOneShot') {
if (rejectCallback === null) {
sendMessageToClients('sync', 'error - rejectCallback is null');
return;
@@ -37,6 +37,21 @@ this.onmessage = function(event) {
rejectCallback();
sendMessageToClients('sync', 'ok - delay rejected');
}
+
+ if (event.data['action'] === 'notifyWhenDone') {
+ var tag = event.data['tag'];
+ registration.sync.getRegistration(tag)
+ .then(function (syncRegistration) {
+ sendMessageToClients('sync', 'ok - ' + tag + ' done');
+ return syncRegistration.done;
+ })
+ .then(function(success) {
+ sendMessageToClients('sync', tag + " done result: " + success);
+ }, function(error) {
+ sendMessageToClients('sync', tag + " done result: error");
+ })
+ .catch(sendSyncErrorToClients);
+ }
}
this.onsync = function(event) {
@@ -96,3 +111,7 @@ function sendMessageToClients(type, data) {
console.log(error);
});
}
+
+function sendSyncErrorToClients(error) {
+ sendMessageToClients('sync', error.name + ' - ' + error.message);
+}
« no previous file with comments | « content/test/data/background_sync/background_sync_test_helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698