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

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

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test 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
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 7dfebe5351eb8f77521f05a649c260210c231df2..56be354933bffe02d4021c9b75ea32e6948e7641 100644
--- a/content/test/data/background_sync/service_worker.js
+++ b/content/test/data/background_sync/service_worker.js
@@ -9,6 +9,7 @@
// "delay" - Delays finishing the sync event with event.waitUntil.
// Send a postMessage of "completeDelayedOneShot" to finish the
// event.
+// "unregister" - Unregisters the sync registration from within the sync event.
'use strict';
@@ -39,6 +40,21 @@ this.onmessage = function(event) {
}
this.onsync = function(event) {
+ var eventProperties = [
+ // Extract name from toString result: "[object <Class>]"
+ Object.prototype.toString.call(event).match(/\s([a-zA-Z]+)/)[1],
+ (typeof event.waitUntil)
+ ];
+
+ if (eventProperties[0] != 'SyncEvent') {
+ sendMessageToClients('sync', 'error - wrong event type');
+ return;
+ }
+
+ if (eventProperties[1] != 'function') {
+ sendMessageToClients('sync', 'error - wrong wait until type');
+ }
+
if (event.registration === undefined) {
sendMessageToClients('sync', 'error - event missing registration');
return;
@@ -60,6 +76,14 @@ this.onsync = function(event) {
return;
}
+ if (tag === 'unregister') {
+ event.waitUntil(event.registration.unregister()
+ .then(function() {
+ sendMessageToClients('sync', 'ok - unregister completed');
+ }));
+ return;
+ }
+
sendMessageToClients('sync', tag + ' fired');
};

Powered by Google App Engine
This is Rietveld 408576698