Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| diff --git a/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html b/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| index 397e2f52d0236b5d0bafa2613a98973b90b5ad03..d1ada0b0b8c404e4b544e939fa8e6cfa9bcbe2c6 100644 |
| --- a/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| +++ b/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| @@ -4,32 +4,50 @@ |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="resources/test-helpers.js"></script> |
| <script> |
| - |
| function scope_test(name, scope) { |
| - var t = async_test('Verify the scope property: ' + name); |
| + var registration; |
|
falken
2014/08/14 14:23:15
can you move this down to be the same scope as exp
nhiroki
2014/08/14 16:37:54
Done.
|
| + var t = async_test('Verify the scope property: ' + name); |
| t.step(function() { |
| - var expectedScope, options; |
| - if (scope) { |
| - expectedScope = new URL(scope, document.location).toString(); |
| - } else { |
| - expectedScope = new URL('/', document.location).toString(); |
| - } |
| + var expectedScope, options; |
|
falken
2014/08/14 14:23:15
indent
nhiroki
2014/08/14 16:37:54
Done.
|
| + if (scope) { |
| + expectedScope = new URL(scope, document.location).toString(); |
| + } else { |
| + expectedScope = new URL('/', document.location).toString(); |
| + } |
| + |
| + service_worker_unregister_and_register( |
| + t, 'resources/serviceworkerglobalscope-scope-worker.js', scope) |
| + .then(function(r) { |
| + registration = r; |
| + assert_equals(registration.waiting, null, |
| + 'registration.waiting should be null'); |
| + assert_equals(registration.active, null, |
| + 'registration.active should be null'); |
| + assert_equals(registration.installing, null, |
| + 'registration.installing should be null'); |
| + return wait_for_update(t, registration); |
| + }) |
| + .then(function(worker) { |
| + assert_equals(registration.waiting, null, |
| + 'registration.waiting should be null'); |
| + assert_equals(registration.active, null, |
| + 'registration.active should be null'); |
| + assert_equals(registration.installing, worker, |
| + 'registration.installing should not be null'); |
| - service_worker_unregister_and_register( |
| - t, 'resources/serviceworkerglobalscope-scope-worker.js', scope |
| - ).then( |
| - t.step_func(function(worker) { |
| - var messageChannel = new MessageChannel(); |
| - messageChannel.port1.onmessage = t.step_func(function(e) { |
| - message = e.data; |
| - assert_equals(message.initialScope, expectedScope, 'Worker should see the scope on eval.'); |
| - assert_equals(message.currentScope, expectedScope, 'Worker scope should not change.'); |
| - service_worker_unregister_and_done(t, scope); |
| - }); |
| - worker.postMessage('', [messageChannel.port2]); |
| - }) |
| - ); |
| + var messageChannel = new MessageChannel(); |
| + messageChannel.port1.onmessage = t.step_func(function(e) { |
|
falken
2014/08/14 14:23:15
Would it be better to promisify this?
return ne
nhiroki
2014/08/14 16:37:54
Done.
|
| + var message = e.data; |
| + assert_equals(message.initialScope, expectedScope, |
| + 'Worker should see the scope on eval.'); |
| + assert_equals(message.currentScope, expectedScope, |
| + 'Worker scope should not change.'); |
| + service_worker_unregister_and_done(t, scope); |
| + }); |
| + worker.postMessage('', [messageChannel.port2]); |
| + }) |
| + .catch(unreached_rejection(t)); |
| }); |
| } |