OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>ServiceWorker object: scope and url property</title> | 2 <title>ServiceWorker object: scope and url 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, url, scope) { | 8 function scope_test(name, url, scope) { |
9 var t = async_test('Verify the scope and url property: ' + name); | 9 var t = async_test('Verify the scope and url property: ' + name); |
10 | 10 |
11 t.step(function() { | 11 t.step(function() { |
12 var expectedScope; | 12 var expectedScope; |
13 if (scope) | 13 if (scope) |
14 expectedScope = normalizeURL(scope); | 14 expectedScope = normalizeURL(scope); |
15 else | 15 else |
16 expectedScope = normalizeURL('*'); | 16 expectedScope = normalizeURL('/*'); |
17 var expectedURL = normalizeURL(url); | 17 var expectedURL = normalizeURL(url); |
18 | 18 |
19 service_worker_unregister_and_register(t, url, scope, onRegister); | 19 service_worker_unregister_and_register(t, url, scope, onRegister); |
20 | 20 |
21 function onRegister(worker) { | 21 function onRegister(worker) { |
22 assert_equals(worker.scope, expectedScope, 'Returned ServiceWorker o
bject should have scope'); | 22 assert_equals(worker.scope, expectedScope, 'Returned ServiceWorker o
bject should have scope'); |
23 assert_equals(worker.url, expectedURL, 'Returned ServiceWorker objec
t should have url'); | 23 assert_equals(worker.url, expectedURL, 'Returned ServiceWorker objec
t should have url'); |
24 service_worker_unregister_and_done(t, scope); | 24 service_worker_unregister_and_done(t, scope); |
25 } | 25 } |
26 }); | 26 }); |
27 } | 27 } |
28 | 28 |
29 scope_test('default', 'resources/worker-no-op.js'); | 29 scope_test('default', 'resources/worker-no-op.js'); |
30 scope_test('wildcard', 'resources/worker-no-op.js', '*'); | 30 scope_test('wildcard', 'resources/worker-no-op.js', '*'); |
31 scope_test('script with fragment', 'resources/worker-no-op.js#ref', 'http://127.
0.0.1:8000/*'); | 31 scope_test('script with fragment', 'resources/worker-no-op.js#ref', 'http://127.
0.0.1:8000/*'); |
32 scope_test('scope with fragment', 'resources/worker-no-op.js', 'http://127.0.0.1
:8000/*#ref'); | 32 scope_test('scope with fragment', 'resources/worker-no-op.js', 'http://127.0.0.1
:8000/*#ref'); |
33 scope_test('scope with query', 'resources/worker-no-op.js', '/a?b=c'); | 33 scope_test('scope with query', 'resources/worker-no-op.js', '/a?b=c'); |
34 scope_test('relative path', 'resources/worker-no-op.js', '/a/b/c/'); | 34 scope_test('relative path', 'resources/worker-no-op.js', '/a/b/c/'); |
35 scope_test('relative path with wildcard', 'resources/empty-worker.js', '/a/b/c/*
'); | 35 scope_test('relative path with wildcard', 'resources/empty-worker.js', '/a/b/c/*
'); |
36 scope_test('absolute url', 'resources/empty-worker.js', 'http://127.0.0.1:8000/'
); | 36 scope_test('absolute url', 'resources/empty-worker.js', 'http://127.0.0.1:8000/'
); |
37 scope_test('absolute url with wildcard', 'resources/empty-worker.js', 'http://12
7.0.0.1:8000/*'); | 37 scope_test('absolute url with wildcard', 'resources/empty-worker.js', 'http://12
7.0.0.1:8000/*'); |
38 | 38 |
39 </script> | 39 </script> |
OLD | NEW |