| Index: LayoutTests/http/tests/serviceworker/current-on-load.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/activation-after-registration.html b/LayoutTests/http/tests/serviceworker/current-on-load.html
|
| similarity index 52%
|
| copy from LayoutTests/http/tests/serviceworker/activation-after-registration.html
|
| copy to LayoutTests/http/tests/serviceworker/current-on-load.html
|
| index 80d8667dd60d2f50efb0aa6285ddf9f8617fae67..5c43c4d47d9ff8db6634e418f5e483b59380dfbd 100644
|
| --- a/LayoutTests/http/tests/serviceworker/activation-after-registration.html
|
| +++ b/LayoutTests/http/tests/serviceworker/current-on-load.html
|
| @@ -1,13 +1,13 @@
|
| <!DOCTYPE html>
|
| -<title>Service Worker: Activation occurs after registration</title>
|
| +<title>Service Worker: Current on load</title>
|
| <script src="../resources/testharness.js"></script>
|
| <script src="../resources/testharnessreport.js"></script>
|
| <script src="resources/test-helpers.js"></script>
|
| <body>
|
| <script>
|
| -var t = async_test('activation occurs after registration');
|
| +var t = async_test('current is set for a controlled document');
|
| t.step(function() {
|
| - var scope = 'resources/blank.html';
|
| + var scope = 'resources/blank.html'
|
| navigator.serviceWorker.unregister(scope).then(
|
| doTest,
|
| unreached_rejection(t, 'Unregister should not fail')
|
| @@ -16,16 +16,25 @@ t.step(function() {
|
| function doTest() {
|
| navigator.serviceWorker.register(
|
| 'resources/worker-no-op.js', {scope: scope}
|
| - ).then(t.step_func(onRegister), t.step_func(function(reason) {
|
| - assert_unreached('Registration should succeed, but failed: ' + reason.name);
|
| - }));
|
| + ).then(
|
| + onRegister,
|
| + unreached_rejection(t, 'Registration should succeed, but failed')
|
| + );
|
| }
|
|
|
| function onRegister(worker) {
|
| - assert_equals(worker.state, 'parsed', 'worker should be in the "parsed" state upon registration');
|
| worker.addEventListener('statechange', t.step_func(function(event) {
|
| if (event.target.state == 'active')
|
| - t.done();
|
| + onActive();
|
| + }));
|
| + }
|
| +
|
| + function onActive() {
|
| + with_iframe(scope, t.step_func(function(frame) {
|
| + var w = frame.contentWindow;
|
| + assert_true(w.navigator.serviceWorker.current instanceof w.ServiceWorker,
|
| + 'current should be a ServiceWorker object');
|
| + t.done();
|
| }));
|
| }
|
| });
|
|
|