[Background Sync] Allow sync manager access from uncontrolled clients

This patch cleans up the method which was deprecated in part 1, and
whose implementations were removed in part 2.

This is part 4 of a four-part blink-chromium-blink dance.
Part 1: https://codereview.chromium.org/1309393003
Part 2: https://codereview.chromium.org/1324903002
Part 3: https://codereview.chromium.org/1316743002
Part 4: https://codereview.chromium.org/1314453003 (this patch)

BUG=518884

Review URL: https://codereview.chromium.org/1314453003

git-svn-id: svn://svn.chromium.org/blink/trunk@201606 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cb0f1054
...@@ -51,10 +51,37 @@ promise_test(function(t) { ...@@ -51,10 +51,37 @@ promise_test(function(t) {
}, 'Background Sync API should allow one-shot syncs to be registered from ' + }, 'Background Sync API should allow one-shot syncs to be registered from ' +
'the Document scope'); 'the Document scope');
// The test which verified that uncontrolled window clients could not register promise_test(function(t) {
// sync events is out-of-date, and so has been removed. Uncontrolled window var url = 'resources/empty_worker.js';
// clients should be allowed to register sync events, as long as they have a var scope = 'resources/scope/background_sync/oneshot-uncontrolled.html';
// registered service worker. var sync_manager;
// TODO(iclelland): Add a test which verifies the correct behaviour, as per var sync_registration;
// crbug/518884
// One-shot syncs can also be registered from uncontrolled documents. This
// test creates a frame, after the service worker is active, in order to use
// its service worker registration.
return service_worker_unregister_and_register(t, url, scope)
.then(function(sw_registration) {
sync_manager = sw_registration.sync;
return wait_for_state(t, sw_registration.installing, 'activated');
})
.then(function() { return clear_registered_syncs(sync_manager); })
.then(function() { return sync_manager.getRegistrations(); })
.then(function(registrations) {
assert_equals(registrations.length, 0, 'One-shot syncs should be ' +
'cleared at the start of the test.');
return sync_manager.register({tag: 'abcde'});
})
.then(function(registration) {
sync_registration = registration;
assert_class_string(sync_registration, 'SyncRegistration', 'One-' +
'shot sync registrations should have the correct ' +
'class name.');
assert_equals('abcde', registration.tag, 'Sync registration tag ' +
'returned should match the tag registered.');
return service_worker_unregister(t, scope);
})
.then(function() { return service_worker_unregister(t, scope); })
}, 'Background Sync API should allow one-shot syncs to be registered ' +
'with window clients not currently controlled by service worker');
</script> </script>
...@@ -29,14 +29,7 @@ public: ...@@ -29,14 +29,7 @@ public:
// Takes ownership of the WebSyncRegistrationCallbacks. // Takes ownership of the WebSyncRegistrationCallbacks.
// Does not take ownership of the WebServiceWorkerRegistration. // Does not take ownership of the WebServiceWorkerRegistration.
// TODO(iclelland): Remove the body of this method once it is implemented in all subclasses. virtual void registerBackgroundSync(const WebSyncRegistration*, WebServiceWorkerRegistration*, bool, WebSyncRegistrationCallbacks*) = 0;
virtual void registerBackgroundSync(const WebSyncRegistration* options, WebServiceWorkerRegistration* serviceWorkerRegistration, bool requestedFromServiceWorker, WebSyncRegistrationCallbacks* callbacks)
{
registerBackgroundSync(options, serviceWorkerRegistration, callbacks);
}
// TODO(iclelland): Remove this deprecated method once the browser implements the 4-argument version.
virtual void registerBackgroundSync(const WebSyncRegistration*, WebServiceWorkerRegistration*, WebSyncRegistrationCallbacks*) { }
// Takes ownership of the WebSyncUnregistrationCallbacks. // Takes ownership of the WebSyncUnregistrationCallbacks.
// Does not take ownership of the WebServiceWorkerRegistration. // Does not take ownership of the WebServiceWorkerRegistration.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment