Update web-platform-tests to revision 3840f46213d9a991acc9288e3863530f7502c05e

This commit is contained in:
WPT Sync Bot 2019-06-06 12:17:06 +00:00
parent 347d8bdf72
commit 141ba90a6d
58 changed files with 1507 additions and 883 deletions

View file

@ -88,4 +88,21 @@ async_test(function(t) {
.catch(unreached_rejection(t));
}, 'Register then Unregister then getRegistration');
promise_test(async function(t) {
const scope = 'resources/scope/getregistration/register-unregister';
const registration = await service_worker_unregister_and_register(
t, 'resources/empty-worker.js', scope
);
const frame = await with_iframe(scope);
t.add_cleanup(() => frame.remove());
const frameNav = frame.contentWindow.navigator;
await registration.unregister();
const value = await frameNav.serviceWorker.getRegistration(scope);
assert_equals(value, undefined, 'getRegistration should resolve with undefined');
}, 'Register then Unregister then getRegistration in controlled iframe');
</script>

View file

@ -5,180 +5,131 @@
<script>
var worker_url = 'resources/empty-worker.js';
async_test(function(t) {
var scope = 'resources/scope/unregister-then-register-new-script-that-exists';
var new_worker_url = worker_url + '?new';
var iframe;
var registration;
var new_registration;
promise_test(async function(t) {
const scope = 'resources/scope/unregister-then-register-new-script-that-exists';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(frame) {
iframe = frame;
return registration.unregister();
})
.then(function() {
return navigator.serviceWorker.register(new_worker_url,
{ scope: scope });
})
.then(function(r) {
new_registration = r;
assert_equals(registration.installing.scriptURL,
normalizeURL(new_worker_url),
'before activated registration.installing');
assert_equals(registration.waiting, null,
'before activated registration.waiting');
assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
'before activated registration.active');
assert_equals(new_registration.installing.scriptURL,
normalizeURL(new_worker_url),
'before activated new_registration.installing');
assert_equals(new_registration.waiting, null,
'before activated new_registration.waiting');
assert_equals(new_registration.active.scriptURL,
normalizeURL(worker_url),
'before activated new_registration.active');
iframe.remove();
return wait_for_state(t, registration.installing, 'activated');
})
.then(function() {
assert_equals(new_registration.installing, null,
'after activated new_registration.installing');
assert_equals(new_registration.waiting, null,
'after activated new_registration.waiting');
assert_equals(new_registration.active.scriptURL,
normalizeURL(new_worker_url),
'after activated new_registration.active');
return with_iframe(scope);
})
.then(function(frame) {
assert_equals(
frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(new_worker_url),
'the new worker should control a new document');
frame.remove();
return registration.unregister();
})
.then(function() {
t.done();
})
.catch(unreached_rejection(t));
const newWorkerURL = worker_url + '?new';
await wait_for_state(t, registration.installing, 'activated');
const iframe = await with_iframe(scope);
t.add_cleanup(() => iframe.remove());
await registration.unregister();
const newRegistration = await navigator.serviceWorker.register(newWorkerURL, { scope });
t.add_cleanup(() => newRegistration.unregister());
assert_equals(
registration.installing.scriptURL,
normalizeURL(newWorkerURL),
'before activated registration.installing'
);
assert_equals(
registration.waiting,
null,
'before activated registration.waiting'
);
assert_equals(
registration.active.scriptURL,
normalizeURL(worker_url),
'before activated registration.active'
);
assert_equals(
newRegistration.installing.scriptURL,
normalizeURL(newWorkerURL),
'before activated newRegistration.installing'
);
assert_equals(
newRegistration.waiting,
null,
'before activated newRegistration.waiting'
);
assert_equals(
newRegistration.active.scriptURL,
normalizeURL(worker_url),
'before activated newRegistration.active'
);
iframe.remove();
await wait_for_state(t, registration.installing, 'activated');
assert_equals(
newRegistration.installing,
null,
'after activated newRegistration.installing'
);
assert_equals(
newRegistration.waiting,
null,
'after activated newRegistration.waiting'
);
assert_equals(
newRegistration.active.scriptURL,
normalizeURL(newWorkerURL),
'after activated newRegistration.active'
);
const newIframe = await with_iframe(scope);
t.add_cleanup(() => newIframe.remove());
assert_equals(
newIframe.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(newWorkerURL),
'the new worker should control a new document'
);
}, 'Registering a new script URL while an unregistered registration is in use');
async_test(function(t) {
var scope = 'resources/scope/unregister-then-register-new-script-that-404s';
var iframe;
var registration;
promise_test(async function(t) {
const scope = 'resources/scope/unregister-then-register-new-script-that-404s';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(frame) {
iframe = frame;
return registration.unregister();
})
.then(function() {
// Step 5.1 of Register clears the uninstall flag before fetching
// the script:
//
// https://w3c.github.io/ServiceWorker/#register-algorithm
var promise = navigator.serviceWorker.register('this-will-404',
{ scope: scope });
return promise;
})
.then(
function() {
assert_unreached('register should reject the promise');
},
function() {
assert_equals(registration.installing, null,
'registration.installing');
assert_equals(registration.waiting, null,
'registration.waiting');
assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
'registration.active');
iframe.remove();
return with_iframe(scope);
})
.then(function(frame) {
assert_equals(
frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(worker_url),
'the original worker should control a new document');
frame.remove();
return registration.unregister();
})
.then(function() {
t.done();
})
.catch(unreached_rejection(t));
}, 'Registering a new script URL that 404s does resurrect an ' +
'unregistered registration');
await wait_for_state(t, registration.installing, 'activated');
async_test(function(t) {
var scope = 'resources/scope/unregister-then-register-reject-install-worker';
var iframe;
var registration;
const iframe = await with_iframe(scope);
t.add_cleanup(() => iframe.remove());
service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(frame) {
iframe = frame;
return registration.unregister();
})
.then(function() {
// Step 5.1 of Register clears the uninstall flag before firing
// the install event:
//
// https://w3c.github.io/ServiceWorker/#register-algorithm
var promise = navigator.serviceWorker.register(
'resources/reject-install-worker.js', { scope: scope });
return promise;
})
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'redundant');
})
.then(function() {
assert_equals(registration.installing, null,
'registration.installing');
assert_equals(registration.waiting, null,
'registration.waiting');
assert_equals(registration.active.scriptURL, normalizeURL(worker_url),
'registration.active');
iframe.remove();
return with_iframe(scope);
})
.then(function(frame) {
assert_equals(
frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
normalizeURL(worker_url),
'the original worker should control a new document');
frame.remove();
return registration.unregister();
})
.then(function() {
t.done();
})
.catch(unreached_rejection(t));
}, 'Registering a new script URL that fails to install does resurrect ' +
'an unregistered registration');
await registration.unregister();
await promise_rejects(
t, new TypeError(),
navigator.serviceWorker.register('this-will-404', { scope })
);
assert_equals(registration.installing, null, 'registration.installing');
assert_equals(registration.waiting, null, 'registration.waiting');
assert_equals(registration.active.scriptURL, normalizeURL(worker_url), 'registration.active');
const newIframe = await with_iframe(scope);
t.add_cleanup(() => newIframe.remove());
assert_equals(newIframe.contentWindow.navigator.serviceWorker.controller, null, 'Document should not be controlled');
}, 'Registering a new script URL that 404s does not resurrect unregistered registration');
promise_test(async function(t) {
const scope = 'resources/scope/unregister-then-register-reject-install-worker';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
const iframe = await with_iframe(scope);
t.add_cleanup(() => iframe.remove());
await registration.unregister();
const newRegistration = await navigator.serviceWorker.register(
'resources/reject-install-worker.js', { scope }
);
t.add_cleanup(() => newRegistration.unregister());
await wait_for_state(t, newRegistration.installing, 'redundant');
assert_equals(registration.installing, null, 'registration.installing');
assert_equals(registration.waiting, null, 'registration.waiting');
assert_equals(registration.active, null, 'registration.active');
assert_not_equals(registration, newRegistration, 'New registration is different');
}, 'Registering a new script URL that fails to install does not resurrect unregistered registration');
</script>

View file

@ -5,100 +5,40 @@
<script>
var worker_url = 'resources/empty-worker.js';
promise_test(function(t) {
var scope = 'resources/scope/re-register-resolves-to-new-value';
var registration;
promise_test(async function(t) {
const scope = 'resources/scope/re-register-resolves-to-new-value';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
await wait_for_state(t, r.installing, 'activated');
await registration.unregister();
const newRegistration = await navigator.serviceWorker.register(worker_url, { scope });
t.add_cleanup(() => newRegistration.unregister());
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return registration.unregister();
})
.then(function() {
return navigator.serviceWorker.register(worker_url, { scope: scope });
})
.then(function(new_registration) {
assert_not_equals(registration, new_registration,
'register should resolve to a new value');
});
assert_not_equals(
registration, newRegistration,
'register should resolve to a new value'
);
}, 'Unregister then register resolves to a new value');
promise_test(function(t) {
var scope = 'resources/scope/re-register-while-old-registration-in-use';
var registration;
promise_test(async function(t) {
const scope = 'resources/scope/re-register-while-old-registration-in-use';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
await wait_for_state(t, registration.installing, 'activated');
const frame = await with_iframe(scope);
t.add_cleanup(() => frame.remove());
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(frame) {
return registration.unregister();
})
.then(function() {
return navigator.serviceWorker.register(worker_url, { scope: scope });
})
.then(function(new_registration) {
assert_equals(registration, new_registration,
'new registration should resolve to the same registration');
});
}, 'Unregister then register resolves to the original value if the ' +
'registration is in use.');
await registration.unregister();
const newRegistration = await navigator.serviceWorker.register(worker_url, { scope });
t.add_cleanup(() => newRegistration.unregister());
promise_test(function(t) {
var scope = 'resources/scope/complete-unregistration-followed-by-' +
'reloading-controllee-iframe';
var registration;
var frame;
var service_worker;
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(f) {
frame = f;
return registration.unregister();
})
.then(function() {
return new Promise(function(resolve) {
frame.onload = resolve;
frame.contentWindow.location.reload();
});
})
.then(function() {
var c = frame.contentWindow.navigator.serviceWorker.controller;
assert_equals(c, null, 'a page after unregistration should not be ' +
'controlled by service worker');
return navigator.serviceWorker.getRegistration(scope);
})
.then(function(r) {
assert_equals(r, undefined, 'getRegistration should return ' +
'undefined after unregistration');
});
}, 'Reloading the last controlled iframe after unregistration should ensure ' +
'the deletion of the registration');
assert_not_equals(
registration, newRegistration,
'Unregister and register should always create a new registration'
);
}, 'Unregister then register does not resolve to the original value even if the registration is in use.');
promise_test(function(t) {
var scope = 'resources/scope/re-register-does-not-affect-existing-controllee';
@ -109,8 +49,8 @@ promise_test(function(t) {
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
return service_worker_unregister(t, scope);
});
registration = r;
return wait_for_state(t, r.installing, 'activated');
@ -138,39 +78,30 @@ promise_test(function(t) {
});
}, 'Unregister then register does not affect existing controllee');
promise_test(function(t) {
var scope = 'resources/scope/resurrection';
var iframe;
var registration;
promise_test(async function(t) {
const scope = 'resources/scope/resurrection';
const altWorkerURL = worker_url + '?alt';
const registration = await service_worker_unregister_and_register(t, worker_url, scope);
t.add_cleanup(() => registration.unregister());
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
t.add_cleanup(function() {
return service_worker_unregister(t, scope);
});
await wait_for_state(t, registration.installing, 'activating');
const iframe = await with_iframe(scope);
t.add_cleanup(() => iframe.remove());
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
.then(function() {
return with_iframe(scope);
})
.then(function(frame) {
iframe = frame;
return registration.unregister();
})
.then(function() {
return navigator.serviceWorker.register(worker_url, { scope: scope });
})
.then(function() {
iframe.remove();
return with_iframe(scope);
})
.then(function(frame) {
assert_not_equals(
frame.contentWindow.navigator.serviceWorker.controller, null,
'document should have a controller');
frame.remove();
});
}, 'Unregister then register resurrects the registration');
await registration.unregister();
const newRegistration = await navigator.serviceWorker.register(altWorkerURL, { scope });
t.add_cleanup(() => newRegistration.unregister());
assert_equals(newRegistration.active, null, 'Registration is new');
await wait_for_state(t, newRegistration.installing, 'activating');
const newIframe = await with_iframe(scope);
t.add_cleanup(() => newIframe.remove());
const iframeController = iframe.contentWindow.navigator.serviceWorker.controller;
const newIframeController = newIframe.contentWindow.navigator.serviceWorker.controller;
assert_not_equals(iframeController, newIframeController, 'iframes have different controllers');
}, 'Unregister then register does not resurrect the registration');
</script>