OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>ServiceWorker object: scriptURL property</title> | 2 <title>ServiceWorker object: scriptURL 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.sub.js"></script> |
6 <script> | 6 <script> |
7 | 7 |
8 function url_test(name, url) { | 8 function url_test(name, url) { |
9 var scope = 'resources/scope/' + name; | 9 var scope = 'resources/scope/' + name; |
10 async_test(function(t) { | 10 async_test(function(t) { |
11 var expectedURL = normalizeURL(url); | 11 var expectedURL = (new URL(url, window.location)).toString(); |
12 service_worker_unregister_and_register(t, url, scope) | 12 service_worker_unregister_and_register(t, url, scope) |
13 .then(function(registration) { | 13 .then(function(registration) { |
14 var worker = registration.installing; | 14 var worker = registration.installing; |
15 assert_equals(worker.scriptURL, expectedURL, | 15 assert_equals(worker.scriptURL, expectedURL, |
16 'Returned ServiceWorker object should have scriptURL'); | 16 'Returned ServiceWorker object should have scriptURL'); |
17 service_worker_unregister_and_done(t, scope); | 17 service_worker_unregister_and_done(t, scope); |
18 }) | 18 }) |
19 .catch(unreached_rejection(t)); | 19 .catch(unreached_rejection(t)); |
20 }, 'Verify the scriptURL property: ' + name); | 20 }, 'Verify the scriptURL property: ' + name); |
21 } | 21 } |
22 | 22 |
23 url_test('relative', 'resources/empty-worker.js'); | 23 url_test('relative', 'resources/empty-worker.js'); |
24 url_test('with-fragment', 'resources/empty-worker.js#ref'); | 24 url_test('absolute', (new URL('./resources/empty-worker.js', window.location)).h
ref); |
25 url_test('absolute', window.location.origin + | |
26 '/serviceworker/resources/empty-worker.js'); | |
27 | 25 |
28 </script> | 26 </script> |
OLD | NEW |