Chromium Code Reviews| 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 b4cd8b6e67c5937e6841ec8144f1a1525fc56e0c..05c73e402d6a035a8cb196b6816c79d19fcc32e9 100644 |
| --- a/content/test/data/background_sync/background_sync_test_helpers.js |
| +++ b/content/test/data/background_sync/background_sync_test_helpers.js |
| @@ -35,9 +35,9 @@ function registerServiceWorker() { |
| function registerOneShot(tag) { |
| navigator.serviceWorker.ready |
| .then(function(swRegistration) { |
| - return swRegistration.sync.register({'tag': tag}); |
| + return swRegistration.sync.register(tag); |
| }) |
| - .then(function(syncRegistration) { |
| + .then(function() { |
| sendResultToTest('ok - ' + tag + ' registered'); |
| }) |
| .catch(sendErrorToTest); |
| @@ -52,56 +52,18 @@ function registerOneShotFromServiceWorker(tag) { |
| .catch(sendErrorToTest); |
| } |
| -function unregisterOneShot(tag) { |
| - navigator.serviceWorker.ready |
| - .then(function(swRegistration) { |
| - return swRegistration.sync.getRegistration(tag); |
| - }) |
| - .then(function(syncRegistration) { |
| - if (!syncRegistration) { |
| - sendResultToTest('error - ' + tag + ' not found'); |
| - return; |
| - } |
| - return syncRegistration.unregister(); |
| - }) |
| - .then(function() { |
| - sendResultToTest('ok - ' + tag + ' unregistered'); |
| - }) |
| - .catch(sendErrorToTest); |
| -} |
| - |
| -function unregisterOneShotTwice(tag) { |
| - navigator.serviceWorker.ready |
| - .then(function(swRegistration) { |
| - return swRegistration.sync.getRegistration(tag); |
| - }) |
| - .then(function(syncRegistration) { |
| - if (!syncRegistration) { |
| - sendResultToTest('error - ' + tag + ' not found'); |
| - return; |
| - } |
| - return syncRegistration.unregister(); |
| - }) |
| - .then(function() { |
| - return syncRegistration.unregister(); |
| - }) |
| - .then(sendErrorToTest, function() { |
| - sendResultToTest('ok - ' + tag + ' failed to unregister twice'); |
| - }) |
| - .catch(sendErrorToTest); |
| -} |
| - |
| function getRegistrationOneShot(tag) { |
| navigator.serviceWorker.ready |
| .then(function(swRegistration) { |
| - return swRegistration.sync.getRegistration(tag); |
| + return swRegistration.sync.getTags(); |
| }) |
| - .then(function(syncRegistration) { |
| - if (!syncRegistration) { |
| + .then(function(tags) { |
| + if (tags.indexOf(tag) >= 0) { |
| + sendResultToTest('ok - ' + tag + ' found'); |
| + } else { |
| sendResultToTest('error - ' + tag + ' not found'); |
| return; |
| } |
| - sendResultToTest('ok - ' + tag + ' found'); |
| }) |
| .catch(sendErrorToTest); |
| } |
| @@ -119,12 +81,9 @@ function getRegistrationOneShotFromServiceWorker(tag) { |
| function getRegistrationsOneShot(tag) { |
| navigator.serviceWorker.ready |
| .then(function(swRegistration) { |
| - return swRegistration.sync.getRegistrations(); |
| + return swRegistration.sync.getTags(); |
| }) |
| - .then(function(syncRegistrations) { |
| - var tags = syncRegistrations.map(function(syncRegistration) { |
| - return syncRegistration.tag; |
| - }); |
| + .then(function(tags) { |
| sendResultToTest('ok - ' + tags.toString()); |
| }) |
| .catch(sendErrorToTest); |
| @@ -157,44 +116,6 @@ function rejectDelayedOneShot() { |
| .catch(sendErrorToTest); |
| } |
| -function notifyWhenFinishedOneShot(tag) { |
| - navigator.serviceWorker.ready |
| - .then(function(swRegistration) { |
| - swRegistration.active.postMessage( |
| - {action: 'notifyWhenFinished', tag: tag}); |
| - }) |
| - .catch(sendErrorToTest); |
| -} |
| - |
| -function notifyWhenFinishedImmediateOneShot(tag) { |
| - if (registrationReference == null) { |
| - sendResultToTest('error - must call storeRegistration first'); |
| - return; |
| - } |
| - |
| - registrationReference.finished |
| - .then(function(success) { |
| - sendResultToTest('ok - ' + registrationReference.tag + |
| - ' result: true') |
| - }, function(err) { |
| - sendResultToTest('ok - ' + registrationReference.tag + |
| - ' result: false') |
| - }) |
| - .catch(sendErrorToTest) |
| -} |
| - |
| - |
| -function storeRegistration(tag) { |
| - navigator.serviceWorker.ready |
| - .then(function(swRegistration) { |
| - return swRegistration.sync.getRegistration(tag); |
| - }) |
| - .then(function(syncRegistration) { |
| - registrationReference = syncRegistration; |
|
jkarlin
2015/11/13 01:32:18
Delete var registrationReference at the top of the
iclelland
2015/11/13 15:26:19
Good catch, thanks. Done.
|
| - sendResultToTest('ok - ' + tag + ' stored'); |
| - }) |
| - .catch(sendErrorToTest); |
| -} |
| // Queue storing asynchronous results received from the Service Worker. Results |
| // are sent to the test when requested. |