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 expectedScope = expectedScope.replace(/#.*$/, ''); | |
20 expectedURL = expectedURL.replace(/#.*$/, ''); | |
kinuko
2014/05/21 03:37:15
It might be good to include this in normalizeURL h
jsbell
2014/05/22 16:49:05
Done.
| |
21 | |
19 service_worker_unregister_and_register(t, url, scope, onRegister); | 22 service_worker_unregister_and_register(t, url, scope, onRegister); |
20 | 23 |
21 function onRegister(worker) { | 24 function onRegister(worker) { |
22 assert_equals(worker.scope, expectedScope, 'Returned ServiceWorker o bject should have scope'); | 25 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'); | 26 assert_equals(worker.url, expectedURL, 'Returned ServiceWorker objec t should have url'); |
24 service_worker_unregister_and_done(t, scope); | 27 service_worker_unregister_and_done(t, scope); |
25 } | 28 } |
26 }); | 29 }); |
27 } | 30 } |
28 | 31 |
29 scope_test('default', 'resources/worker-no-op.js'); | 32 scope_test('default', 'resources/worker-no-op.js'); |
30 scope_test('wildcard', 'resources/worker-no-op.js', '*'); | 33 scope_test('wildcard', 'resources/worker-no-op.js', '*'); |
34 scope_test('script with fragment', 'resources/worker-no-op.js#ref', 'http://127. 0.0.1:8000/*'); | |
35 scope_test('scope with fragment', 'resources/worker-no-op.js', 'http://127.0.0.1 :8000/*#ref'); | |
36 scope_test('scope with query', 'resources/worker-no-op.js', '/a?b=c'); | |
31 scope_test('relative path', 'resources/worker-no-op.js', '/a/b/c/'); | 37 scope_test('relative path', 'resources/worker-no-op.js', '/a/b/c/'); |
32 scope_test('relative path with wildcard', 'resources/empty-worker.js', '/a/b/c/* '); | 38 scope_test('relative path with wildcard', 'resources/empty-worker.js', '/a/b/c/* '); |
33 scope_test('absolute url', 'resources/empty-worker.js', 'http://127.0.0.1:8000/' ); | 39 scope_test('absolute url', 'resources/empty-worker.js', 'http://127.0.0.1:8000/' ); |
34 scope_test('absolute url with wildcard', 'resources/empty-worker.js', 'http://12 7.0.0.1:8000/*'); | 40 scope_test('absolute url with wildcard', 'resources/empty-worker.js', 'http://12 7.0.0.1:8000/*'); |
35 | 41 |
36 </script> | 42 </script> |
OLD | NEW |