Bug 1691367 [wpt PR 27519] - Update registration-schedule-job.https.html to reflect the spec, a=testonly

Automatic update from web-platform-tests
Update registration-schedule-job.https.html to reflect the spec

Previously, the test expectation didn't comply with the spec because it
expected there's an installing worker even if register() actually didn't
install a new worker.
This CL is to update the expectation to wait for each register() call
resolved one by one. This should work because each job must not be
coalesced so the states should be updated correctly when those promises
are resolved.

Bug: 979593
Change-Id: Ib3874e7e15ebb0dfa5608cc2ff4d3484cffd72b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2679094
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: Asami Doi <asamidoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852157}

--

wpt-commits: 6cd5f63fb98c42d7c1e79a4e2db84b970e7fb86d
wpt-pr: 27519
This commit is contained in:
Makoto Shimazu 2021-02-11 16:47:02 +00:00 коммит произвёл moz-wptsync-bot
Родитель 70ac9440ac
Коммит 1dcf505b65
1 изменённых файлов: 53 добавлений и 10 удалений

Просмотреть файл

@ -31,13 +31,33 @@ promise_test(async t => {
navigator.serviceWorker.register(script1, {scope});
assert_equals(registration.updateViaCache, 'imports');
// Schedule several register jobs.
navigator.serviceWorker.register(script1, {scope});
navigator.serviceWorker.register(script2, {scope});
await navigator.serviceWorker.register(script2,
// Schedule several register jobs in the same scope.
// None of the changes should have been coalesced.
// This resolves without changing anything.
const p1 = navigator.serviceWorker.register(script1, {scope});
// This changes the script URL so going with installing a new worker without
// byte-for-byte update check.
const p2 = navigator.serviceWorker.register(script2, {scope});
// This changes the updateViaCache option but the script URL is the same. That
// results in updating the updateViaCache flag but no worker is going to be
// stored.
const p3 = navigator.serviceWorker.register(script2,
{scope, updateViaCache: 'none'});
// None of the changes should have been coalesced.
// The first call of register() doesn't change anything.
await p1;
assert_equals(registration.installing, null);
// The scriptURL must be updated when `p2` resolves. At that point, a new
// worker must be in the installing state because changing scriptURL is
// treated as the same as there's an update in the script.
await p2;
assert_equals(registration.installing.scriptURL, absolute_url(script2));
assert_equals(registration.updateViaCache, 'imports');
// The updateViaCache must be updated when `p3` resolves.
await p3;
assert_equals(registration.installing.scriptURL, absolute_url(script2));
assert_equals(registration.updateViaCache, 'none');
}, 'different scriptURL and updateViaCache');
@ -55,12 +75,35 @@ promise_test(async t => {
navigator.serviceWorker.register(script1, {scope});
assert_equals(registration.installing.type, 'classic');
// Schedule several register jobs.
navigator.serviceWorker.register(script1, {scope});
navigator.serviceWorker.register(script2, {scope});
await navigator.serviceWorker.register(script2, {scope, type: 'module'});
// Schedule several register jobs in the same scope.
// None of the changes should have been coalesced.
// This resolves without changing anything.
const p1 = navigator.serviceWorker.register(script1, {scope});
// This changes the script URL so going with installing a new worker without
// byte-for-byte update check.
const p2 = navigator.serviceWorker.register(script2, {scope});
// This changes the worker type, and that goes to the same path with updating
// the worker script or the script URL.
const p3 = navigator.serviceWorker.register(script2, {scope, type: 'module'});
// The first call of register() doesn't change anything.
await p1;
assert_equals(registration.installing, null);
// The scriptURL must be updated when `p2` resolves. At this point, a new
// worker must be in the installing state because changing scriptURL is
// treated as the same as there's an update in the script.
await p2;
assert_equals(registration.installing.scriptURL, absolute_url(script2));
assert_equals(registration.installing.type, 'classic');
// The script type must be updated when `p3` resolves. At this point, a new
// worker must be in the installing state because changing script type is also
// treated as the same as there's an update in the script.
await p3;
assert_equals(registration.installing.scriptURL, absolute_url(script2));
assert_equals(registration.installing.type, 'module');
}, 'different type');