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

Unified Diff: content/test/data/background_sync/background_sync_test_helpers.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/common/background_sync_service.mojom ('k') | content/test/data/background_sync/service_worker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/background_sync/background_sync_test_helpers.js
diff --git a/content/test/data/background_sync/background_sync_test_helpers.js b/content/test/data/background_sync/background_sync_test_helpers.js
index e48bfb85ab2cdd2b6a64babffc906d39bd34a2a5..ac175df9fd816f8033359308dec41bfc81a89aad 100644
--- a/content/test/data/background_sync/background_sync_test_helpers.js
+++ b/content/test/data/background_sync/background_sync_test_helpers.js
@@ -5,6 +5,7 @@
'use strict';
var resultQueue = new ResultQueue();
+var registrationReference = null;
// Sends data back to the test. This must be in response to an earlier
// request, but it's ok to respond asynchronously. The request blocks until
@@ -113,7 +114,7 @@ function getRegistrationsOneShot(tag) {
function completeDelayedOneShot() {
navigator.serviceWorker.ready
.then(function(swRegistration) {
- swRegistration.active.postMessage('completeDelayedOneShot');
+ swRegistration.active.postMessage({action: 'completeDelayedOneShot'});
sendResultToTest('ok - delay completing');
})
.catch(sendErrorToTest);
@@ -122,12 +123,49 @@ function completeDelayedOneShot() {
function rejectDelayedOneShot() {
navigator.serviceWorker.ready
.then(function(swRegistration) {
- swRegistration.active.postMessage('rejectDelayedOneShot');
+ swRegistration.active.postMessage({action: 'rejectDelayedOneShot'});
sendResultToTest('ok - delay rejecting');
})
.catch(sendErrorToTest);
}
+function notifyWhenDoneOneShot(tag) {
+ navigator.serviceWorker.ready
+ .then(function(swRegistration) {
+ swRegistration.active.postMessage({action: 'notifyWhenDone', tag: tag});
+ })
+ .catch(sendErrorToTest);
+}
+
+function notifyWhenDoneImmediateOneShot(tag) {
+ if (registrationReference == null) {
+ sendResultToTest('error - must call storeRegistration first');
+ return;
+ }
+
+ registrationReference.done
+ .then(function(success) {
+ sendResultToTest('ok - ' + registrationReference.tag +
+ ' result: ' + success)
+ }, function(err) {
+ sendResultToTest('error - ' + registrationReference.tag + ' failed');
+ })
+ .catch(sendErrorToTest)
+}
+
+
+function storeRegistration(tag) {
+ navigator.serviceWorker.ready
+ .then(function(swRegistration) {
+ return swRegistration.sync.getRegistration(tag);
+ })
+ .then(function(syncRegistration) {
+ registrationReference = syncRegistration;
+ sendResultToTest('ok - ' + tag + ' stored');
+ })
+ .catch(sendErrorToTest);
+}
+
// Queue storing asynchronous results received from the Service Worker. Results
// are sent to the test when requested.
function ResultQueue() {
« no previous file with comments | « content/common/background_sync_service.mojom ('k') | content/test/data/background_sync/service_worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698