| 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() {
|
|
|