Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: LayoutTests/http/tests/serviceworker/serviceworkerglobalscope-scope.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: update comments in service-worker-gc.html Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>ServiceWorkerGlobalScope: scope property</title> 2 <title>ServiceWorkerGlobalScope: scope property</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script> 6 <script>
7 function scope_test(name, scope) {
8 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.
7 9
8 function scope_test(name, scope) {
9 var t = async_test('Verify the scope property: ' + name); 10 var t = async_test('Verify the scope property: ' + name);
11 t.step(function() {
12 var expectedScope, options;
falken 2014/08/14 14:23:15 indent
nhiroki 2014/08/14 16:37:54 Done.
13 if (scope) {
14 expectedScope = new URL(scope, document.location).toString();
15 } else {
16 expectedScope = new URL('/', document.location).toString();
17 }
10 18
11 t.step(function() { 19 service_worker_unregister_and_register(
12 var expectedScope, options; 20 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope)
13 if (scope) { 21 .then(function(r) {
14 expectedScope = new URL(scope, document.location).toString(); 22 registration = r;
15 } else { 23 assert_equals(registration.waiting, null,
16 expectedScope = new URL('/', document.location).toString(); 24 'registration.waiting should be null');
17 } 25 assert_equals(registration.active, null,
26 'registration.active should be null');
27 assert_equals(registration.installing, null,
28 'registration.installing should be null');
29 return wait_for_update(t, registration);
30 })
31 .then(function(worker) {
32 assert_equals(registration.waiting, null,
33 'registration.waiting should be null');
34 assert_equals(registration.active, null,
35 'registration.active should be null');
36 assert_equals(registration.installing, worker,
37 'registration.installing should not be null');
18 38
19 service_worker_unregister_and_register( 39 var messageChannel = new MessageChannel();
20 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope 40 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.
21 ).then( 41 var message = e.data;
22 t.step_func(function(worker) { 42 assert_equals(message.initialScope, expectedScope,
23 var messageChannel = new MessageChannel(); 43 'Worker should see the scope on eval.');
24 messageChannel.port1.onmessage = t.step_func(function(e) { 44 assert_equals(message.currentScope, expectedScope,
25 message = e.data; 45 'Worker scope should not change.');
26 assert_equals(message.initialScope, expectedScope, 'Worker s hould see the scope on eval.'); 46 service_worker_unregister_and_done(t, scope);
27 assert_equals(message.currentScope, expectedScope, 'Worker s cope should not change.'); 47 });
28 service_worker_unregister_and_done(t, scope); 48 worker.postMessage('', [messageChannel.port2]);
29 }); 49 })
30 worker.postMessage('', [messageChannel.port2]); 50 .catch(unreached_rejection(t));
31 })
32 );
33 }); 51 });
34 } 52 }
35 53
36 scope_test('default'); 54 scope_test('default');
37 scope_test('relative path', '/a/b/c/'); 55 scope_test('relative path', '/a/b/c/');
38 scope_test('absolute url', 'http://127.0.0.1:8000/'); 56 scope_test('absolute url', 'http://127.0.0.1:8000/');
39 57
40 </script> 58 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698