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..f5e3c9f279f0ae51f97e95cff808ba95df168cbb 100644 |
| --- a/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| +++ b/LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html |
| @@ -4,37 +4,57 @@ |
| <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); |
| - |
| 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; |
| + 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( |
| - 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]); |
| - }) |
| - ); |
| + service_worker_unregister_and_register( |
| + t, 'resources/serviceworkerglobalscope-scope-worker.js', scope) |
| + .then(function(registration) { |
| + return new Promise(function(resolve, reject) { |
| + assert_equals(registration.waiting, null, |
| + 'registration.waiting shuold be null'); |
|
falken
2014/08/14 04:46:12
typo: "shuold" (and below)
horo
2014/08/14 07:11:46
Done.
|
| + assert_equals(registration.active, null, |
| + 'registration.active shuold be null'); |
| + assert_equals(registration.installing, null, |
| + 'registration.installing shuold be null'); |
| + registration.addEventListener('updatefound', t.step_func(function() { |
|
falken
2014/08/14 04:46:12
this should use wait_for_update()
horo
2014/08/14 07:11:47
We can't test (registration.waiting/active == null
falken
2014/08/14 10:16:36
You can save registration in a global:
var regist
nhiroki
2014/08/14 13:22:07
Done.
|
| + assert_equals(registration.waiting , null, |
|
falken
2014/08/14 04:46:12
nit: extra space before , (and below)
horo
2014/08/14 07:11:46
Done.
|
| + 'registration.waiting shuld be null'); |
|
falken
2014/08/14 04:46:12
typo: "shuld"
horo
2014/08/14 07:11:47
Done.
|
| + assert_equals(registration.active , null, |
| + 'registration.active should be null'); |
| + assert_true(registration.installing != null, |
| + 'registration.installing should not be null'); |
| + resolve(registration.installing); |
| + })); |
| + }); |
| + }) |
| + .then(function(worker) { |
| + var messageChannel = new MessageChannel(); |
| + messageChannel.port1.onmessage = t.step_func(function(e) { |
| + message = e.data; |
|
falken
2014/08/14 04:46:12
nit: var
horo
2014/08/14 07:11:47
Done.
|
| + 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)); |
| }); |
| } |
| scope_test('default'); |
| scope_test('relative path', '/a/b/c/'); |
| -scope_test('absolute url', 'http://127.0.0.1:8000/'); |
| + |
| +// [BUG] Same scope test doesn't work. updatefound doesn't called. |
|
falken
2014/08/14 04:46:12
nit: FIXME, not [BUG] (but please link to a bug if
horo
2014/08/14 07:11:47
removed.
|
| +// scope_test('absolute url', 'http://127.0.0.1:8000/'); |
| </script> |