OLD | NEW |
(Empty) | |
| 1 // This file is using testharness.js coding style. |
| 2 |
| 3 function get_script_href() |
| 4 { |
| 5 var filename = window.location.href.substr(window.location.href.lastIndexOf(
'/') + 1); |
| 6 return 'resources/' + filename.replace('.html', '.js'); |
| 7 } |
| 8 |
| 9 function get_current_scope() |
| 10 { |
| 11 if ('document' in self) { |
| 12 return 'Window'; |
| 13 } |
| 14 if ('DedicatedWorkerGlobalScope' in self && |
| 15 self instanceof DedicatedWorkerGlobalScope) { |
| 16 return 'DedicatedWorker'; |
| 17 } |
| 18 if ('SharedWorkerGlobalScope' in self && |
| 19 self instanceof SharedWorkerGlobalScope) { |
| 20 return 'SharedWorker'; |
| 21 } |
| 22 if ('ServiceWorkerGlobalScope' in self && |
| 23 self instanceof ServiceWorkerGlobalScope) { |
| 24 return 'ServiceWorker'; |
| 25 } |
| 26 |
| 27 throw new Error('unknown scope'); |
| 28 } |
| 29 |
| 30 function run_test() { |
| 31 var script_href = get_script_href(); |
| 32 |
| 33 // Run the tests on the Window scope. |
| 34 var script_element = document.createElement('script'); |
| 35 script_element.src = script_href; |
| 36 document.body.appendChild(script_element); |
| 37 |
| 38 // Run the tests on {Dedicated,Shared,Service}Worker. |
| 39 fetch_tests_from_worker(new Worker(script_href)); |
| 40 fetch_tests_from_worker(new SharedWorker(script_href)); |
| 41 window.service_worker_test(script_href); |
| 42 } |
OLD | NEW |