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

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

Issue 468753003: SW tests update (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 467133002 and fix test 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
8 function scope_test(name, scope) { 7 function scope_test(name, scope) {
9 var t = async_test('Verify the scope property: ' + name); 8 var t = async_test('Verify the scope property: ' + name);
9 t.step(function() {
10 var expectedScope, options;
11 if (scope) {
12 expectedScope = new URL(scope, document.location).toString();
13 } else {
14 expectedScope = new URL('/', document.location).toString();
15 }
10 16
11 t.step(function() { 17 service_worker_unregister_and_register(
12 var expectedScope, options; 18 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope)
13 if (scope) { 19 .then(function(registration) {
14 expectedScope = new URL(scope, document.location).toString(); 20 assert_equals(registration.waiting, null,
15 } else { 21 'registration.waiting should be null');
16 expectedScope = new URL('/', document.location).toString(); 22 assert_equals(registration.active, null,
17 } 23 'registration.active should be null');
18 24 assert_equals(registration.installing, null,
19 service_worker_unregister_and_register( 25 'registration.installing should be null');
20 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope 26 return new Promise(function(resolve, reject) {
21 ).then( 27 registration.addEventListener('updatefound',
22 t.step_func(function(worker) { 28 t.step_func(function() {
23 var messageChannel = new MessageChannel(); 29 assert_equals(registration.waiting, null,
24 messageChannel.port1.onmessage = t.step_func(function(e) { 30 'registration.waiting should be null');
25 message = e.data; 31 assert_equals(registration.active, null,
26 assert_equals(message.initialScope, expectedScope, 'Worker s hould see the scope on eval.'); 32 'registration.active should be null');
27 assert_equals(message.currentScope, expectedScope, 'Worker s cope should not change.'); 33 assert_true(registration.installing != null,
28 service_worker_unregister_and_done(t, scope); 34 'registration.installing should not be null');
29 }); 35 resolve(registration.installing);
30 worker.postMessage('', [messageChannel.port2]); 36 }));
31 }) 37 });
32 ); 38 })
39 .then(function(worker) {
40 var messageChannel = new MessageChannel();
41 messageChannel.port1.onmessage = t.step_func(function(e) {
42 var message = e.data;
43 assert_equals(message.initialScope, expectedScope,
44 'Worker should see the scope on eval.');
45 assert_equals(message.currentScope, expectedScope,
46 'Worker scope should not change.');
47 service_worker_unregister_and_done(t, scope);
48 });
49 worker.postMessage('', [messageChannel.port2]);
50 })
51 .catch(unreached_rejection(t));
33 }); 52 });
34 } 53 }
35 54
36 scope_test('default'); 55 scope_test('default');
37 scope_test('relative path', '/a/b/c/'); 56 scope_test('relative path', '/a/b/c/');
38 scope_test('absolute url', 'http://127.0.0.1:8000/'); 57 scope_test('absolute url', 'http://127.0.0.1:8000/');
39 58
40 </script> 59 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698