Skip to content

Commit

Permalink
Update service_worker_unregister_and_register()
Browse files Browse the repository at this point in the history
Allows callsites of this helper function to pass RegistrationOptions.
It will be useful for testing module service workers.

Bug: 824647
Change-Id: Idc9a5c012144da46dfc4d692ce26df9f604a6ea1
  • Loading branch information
bashi authored and chromium-wpt-export-bot committed Oct 11, 2019
1 parent 97b69c1 commit 8e6b06b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions service-workers/service-worker/resources/test-helpers.sub.js
@@ -1,10 +1,16 @@
// Adapter for testharness.js-style tests with Service Workers

function service_worker_unregister_and_register(test, url, scope) {
/**
* @param options an object that represents RegistrationOptions except for scope.
* @param options.type a WorkerType.
* @param options.updateViaCache a ServiceWorkerUpdateViaCache.
* @see https://w3c.github.io/ServiceWorker/#dictdef-registrationoptions
*/
function service_worker_unregister_and_register(test, url, scope, options = {}) {
if (!scope || scope.length == 0)
return Promise.reject(new Error('tests must define a scope'));

var options = { scope: scope };
options.scope = scope;
return service_worker_unregister(test, scope)
.then(function() {
return navigator.serviceWorker.register(url, options);
Expand Down

0 comments on commit 8e6b06b

Please sign in to comment.