-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert of Revert of Service Worker: Add tests for same-scope new scri…
…pt registration (patchset #1 id:1 of https://codereview.chromium.org/512703002/) Reason for revert: This crash will be fixed by https://codereview.chromium.org/556003006. Original issue's description: > Revert of Service Worker: Add tests for same-scope new script registration (patchset #6 of https://codereview.chromium.org/480943002/) > > Reason for revert: > This is crashing on Mac. > > Original issue's description: > > Service Worker: Add tests for same-scope, new script registration > > > > Tests for Chromium patch: > > https://codereview.chromium.org/506043002/ > > > > BUG=398355 > > > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=180948 > > [email protected],[email protected],[email protected] > NOTREECHECKS=true > NOTRY=true > BUG=398355 > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=180956 [email protected],[email protected],[email protected],[email protected] NOTREECHECKS=true NOTRY=true BUG=398355 Review URL: https://codereview.chromium.org/547743003 git-svn-id: svn://svn.chromium.org/blink/trunk@181878 bbb929c8-8fbe-4397-9dbb-9b2b20218538
- Loading branch information
Showing
4 changed files
with
364 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
254 changes: 254 additions & 0 deletions
254
LayoutTests/http/tests/serviceworker/register-same-scope-different-script-url.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
<!DOCTYPE html> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<script src="resources/test-helpers.js"></script> | ||
<script> | ||
var script1 = normalizeURL('resources/empty-worker.js'); | ||
var script2 = normalizeURL('resources/empty-worker.js?new'); | ||
|
||
// FIXME: The spec is in flux, this test's asserts may not be as per-spec. | ||
async_test(function(t) { | ||
var scope = 'scope/register-new-script-concurrently'; | ||
var registration; | ||
var register_promise1; | ||
var register_promise2; | ||
|
||
navigator.serviceWorker.unregister(scope) | ||
.then(function() { | ||
register_promise1 = navigator.serviceWorker.register(script1, | ||
{scope: scope}); | ||
register_promise2 = navigator.serviceWorker.register(script2, | ||
{scope: scope}); | ||
return register_promise1; | ||
}) | ||
.then(function(r) { | ||
registration = r; | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing.scriptURL, script1, | ||
'on first update, first script should be installing'); | ||
assert_equals(registration.waiting, null, | ||
'on first update, waiting should be null'); | ||
assert_equals(registration.active, null, | ||
'on first update, active should be null'); | ||
return register_promise2; | ||
}) | ||
.then(function(r) { | ||
assert_equals(r, registration); | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing.scriptURL, script2, | ||
'on second update, second script should be installing'); | ||
assert_equals(registration.waiting, null, | ||
'on second update, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on second update, first script should be active'); | ||
return registration.unregister(); | ||
}) | ||
.then(function() { | ||
t.done(); | ||
}) | ||
.catch(unreached_rejection(t)); | ||
}, 'Register different scripts concurrently'); | ||
|
||
async_test(function(t) { | ||
var scope = 'scope/register-then-register-new-script'; | ||
var registration; | ||
|
||
service_worker_unregister_and_register(t, script1, scope) | ||
.then(function(r) { | ||
registration = r; | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
return wait_for_state(t, registration.installing, 'activated'); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing, null, | ||
'on activated, installing should be null'); | ||
assert_equals(registration.waiting, null, | ||
'on activated, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on activated, the first script should be active'); | ||
return navigator.serviceWorker.register(script2, {scope:scope}); | ||
}) | ||
.then(function(r) { | ||
assert_equals(r, registration, | ||
'register() should resolve to the same registration'); | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing.scriptURL, script2, | ||
'on update, the second script should be installing'); | ||
assert_equals(registration.waiting, null, | ||
'on update waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on update, the first script should be active'); | ||
return wait_for_state(t, registration.installing, 'installed'); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing, null, | ||
'on installed, installing should be null'); | ||
assert_equals(registration.waiting.scriptURL, script2, | ||
'on installed, the second script should be waiting'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on installed, the first script should be active'); | ||
return registration.unregister(); | ||
}) | ||
.then(function() { | ||
t.done(); | ||
}) | ||
.catch(unreached_rejection(t)); | ||
}, 'Register then register new script URL'); | ||
|
||
async_test(function(t) { | ||
var scope = 'scope/register-then-register-new-script-404'; | ||
var registration; | ||
|
||
service_worker_unregister_and_register(t, script1, scope) | ||
.then(function(r) { | ||
registration = r; | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
return wait_for_state(t, registration.installing, 'activated'); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing, null, | ||
'on activated, installing should be null'); | ||
assert_equals(registration.waiting, null, | ||
'on activated, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on activated, the first script should be active'); | ||
return navigator.serviceWorker.register('this-will-404.js', | ||
{scope:scope}); | ||
}) | ||
.then( | ||
function() { assert_unreached('register should reject'); }, | ||
function(error) { | ||
assert_equals(registration.installing, null, | ||
'on rejected, installing should be null'); | ||
assert_equals(registration.waiting, null, | ||
'on rejected, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on rejected, the first script should be active'); | ||
return registration.unregister(); | ||
}) | ||
.then(function() { | ||
t.done(); | ||
}) | ||
.catch(unreached_rejection(t)); | ||
}, 'Register then register new script URL that 404s'); | ||
|
||
async_test(function(t) { | ||
var scope = 'scope/register-then-register-new-script-reject-install'; | ||
var reject_script = normalizeURL('resources/reject-install-worker.js'); | ||
var registration; | ||
|
||
service_worker_unregister_and_register(t, script1, scope) | ||
.then(function(r) { | ||
registration = r; | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
return wait_for_state(t, registration.installing, 'activated'); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing, null, | ||
'on activated, installing should be null'); | ||
assert_equals(registration.waiting, null, | ||
'on activated, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on activated, the first script should be active'); | ||
return navigator.serviceWorker.register(reject_script, {scope:scope}); | ||
}) | ||
.then(function(r) { | ||
assert_equals(r, registration, | ||
'register() should resolve to the same registration'); | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing.scriptURL, reject_script, | ||
'on update, the second script should be installing'); | ||
assert_equals(registration.waiting, null, | ||
'on update, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on update, the first script should be active'); | ||
return wait_for_state(t, registration.installing, 'redundant'); | ||
}) | ||
.then(function() { | ||
assert_equals(registration.installing, null, | ||
'on redundant, installing should be null'); | ||
assert_equals(registration.waiting, null, | ||
'on redundant, waiting should be null'); | ||
assert_equals(registration.active.scriptURL, script1, | ||
'on redundant, the first script should be active'); | ||
return registration.unregister(); | ||
}) | ||
.then(function() { | ||
t.done(); | ||
}) | ||
.catch(unreached_rejection(t)); | ||
}, 'Register then register new script that does not install'); | ||
|
||
async_test(function(t) { | ||
var scope = 'scope/register-new-script-controller'; | ||
var iframe; | ||
var registration; | ||
|
||
service_worker_unregister_and_register(t, script1, scope) | ||
.then(function(r) { | ||
registration = r; | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
return wait_for_state(t, registration.installing, 'activated'); | ||
}) | ||
.then(function() { | ||
return with_iframe(scope); | ||
}) | ||
.then(function(frame) { | ||
iframe = frame; | ||
return navigator.serviceWorker.register(script2, { scope: scope }) | ||
}) | ||
.then(function() { | ||
return wait_for_update(t, registration); | ||
}) | ||
.then(function() { | ||
return wait_for_state(t, registration.installing, 'installed'); | ||
}) | ||
.then(function() { | ||
var sw_container = iframe.contentWindow.navigator.serviceWorker; | ||
assert_equals(sw_container.controller.scriptURL, script1, | ||
'the old version should control the old doc'); | ||
return with_iframe(scope); | ||
}) | ||
.then(function(frame) { | ||
var sw_container = frame.contentWindow.navigator.serviceWorker; | ||
assert_equals(sw_container.controller.scriptURL, script1, | ||
'the old version should control a new doc'); | ||
var onactivated_promise = wait_for_state(t, | ||
registration.waiting, | ||
'activated'); | ||
unload_iframe(frame); | ||
unload_iframe(iframe); | ||
return onactivated_promise; | ||
}) | ||
.then(function() { | ||
return with_iframe(scope); | ||
}) | ||
.then(function(frame) { | ||
var sw_container = frame.contentWindow.navigator.serviceWorker; | ||
assert_equals(sw_container.controller.scriptURL, script2, | ||
'the new version should control a new doc'); | ||
unload_iframe(frame); | ||
return registration.unregister(); | ||
}) | ||
.then(function() { | ||
t.done(); | ||
}) | ||
.catch(unreached_rejection(t)); | ||
}, 'Register same-scope new script url effect on controller'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.