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

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

Issue 354953002: Promisify Service Worker test unregister_and_register helper function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: patch for landing Created 6 years, 6 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 | Annotate | Revision Log
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 7
8 function scope_test(name, scope) { 8 function scope_test(name, scope) {
9 var t = async_test('Verify the scope property: ' + name); 9 var t = async_test('Verify the scope property: ' + name);
10 10
11 t.step(function() { 11 t.step(function() {
12 var expectedScope, options; 12 var expectedScope, options;
13 if (scope) { 13 if (scope) {
14 expectedScope = new URL(scope, document.location).toString(); 14 expectedScope = new URL(scope, document.location).toString();
15 } else { 15 } else {
16 expectedScope = new URL('/*', document.location).toString(); 16 expectedScope = new URL('/*', document.location).toString();
17 } 17 }
18 18
19 service_worker_unregister_and_register( 19 service_worker_unregister_and_register(
20 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope, 20 t, 'resources/serviceworkerglobalscope-scope-worker.js', scope
21 function(worker) { 21 ).then(
22 t.step_func(function(worker) {
22 var messageChannel = new MessageChannel(); 23 var messageChannel = new MessageChannel();
23 messageChannel.port1.onmessage = t.step_func(function(e) { 24 messageChannel.port1.onmessage = t.step_func(function(e) {
24 message = e.data; 25 message = e.data;
25 assert_equals(message.initialScope, expectedScope, 'Worker s hould see the scope on eval.'); 26 assert_equals(message.initialScope, expectedScope, 'Worker s hould see the scope on eval.');
26 assert_equals(message.currentScope, expectedScope, 'Worker s cope should not change.'); 27 assert_equals(message.currentScope, expectedScope, 'Worker s cope should not change.');
27 service_worker_unregister_and_done(t, scope); 28 service_worker_unregister_and_done(t, scope);
28 }); 29 });
29 worker.postMessage('', [messageChannel.port2]); 30 worker.postMessage('', [messageChannel.port2]);
30 }); 31 })
32 );
31 }); 33 });
32 } 34 }
33 35
34 scope_test('default'); 36 scope_test('default');
35 scope_test('wildcard', '*'); 37 scope_test('wildcard', '*');
36 scope_test('relative path', '/a/b/c/'); 38 scope_test('relative path', '/a/b/c/');
37 scope_test('relative path with wildcard', '/a/b/c/*'); 39 scope_test('relative path with wildcard', '/a/b/c/*');
38 scope_test('absolute url', 'http://127.0.0.1:8000/'); 40 scope_test('absolute url', 'http://127.0.0.1:8000/');
39 scope_test('absolute url with wildcard', 'http://127.0.0.1:8000/*'); 41 scope_test('absolute url with wildcard', 'http://127.0.0.1:8000/*');
40 42
41 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698