Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Any copyright is dedicated to the Public Domain. | |
| 2 // http://creativecommons.org/publicdomain/zero/1.0/ | |
|
Peter Beverloo
2014/12/01 11:30:34
Please don't add this copyright header. (Nor in th
mlamouri (slow - plz ping)
2014/12/01 12:36:00
This is unfortunate.
| |
| 3 | |
| 4 // This file is using testharness.js coding style. | |
| 5 | |
| 6 function get_script_href() | |
| 7 { | |
| 8 var filename = window.location.href.substr(window.location.href.lastIndexOf( '/') + 1); | |
| 9 return 'resources/' + filename.replace('.html', '.js'); | |
| 10 } | |
| 11 | |
| 12 function get_current_scope() | |
| 13 { | |
| 14 if ('document' in self) { | |
| 15 return 'Window'; | |
|
Peter Beverloo
2014/12/01 11:30:34
indentation
mlamouri (slow - plz ping)
2014/12/01 12:36:00
Fixed.
| |
| 16 } | |
| 17 if ('DedicatedWorkerGlobalScope' in self && | |
| 18 self instanceof DedicatedWorkerGlobalScope) { | |
| 19 return 'DedicatedWorker'; | |
|
Peter Beverloo
2014/12/01 11:30:34
indentation
mlamouri (slow - plz ping)
2014/12/01 12:36:00
Fixed.
| |
| 20 } | |
| 21 if ('SharedWorkerGlobalScope' in self && | |
| 22 self instanceof SharedWorkerGlobalScope) { | |
| 23 return 'SharedWorker'; | |
| 24 } | |
| 25 if ('ServiceWorkerGlobalScope' in self && | |
| 26 self instanceof ServiceWorkerGlobalScope) { | |
| 27 return 'ServiceWorker'; | |
| 28 } | |
| 29 | |
| 30 throw new Error('unknown scope'); | |
| 31 } | |
| 32 | |
| 33 if (get_current_scope() == 'Window') { | |
| 34 window.addEventListener('load', function() { | |
| 35 var script_href = get_script_href(); | |
| 36 | |
| 37 // Run the tests on the Window scope. | |
| 38 var script_element = document.createElement('script'); | |
| 39 script_element.src = script_href; | |
| 40 document.body.appendChild(script_element); | |
| 41 | |
| 42 // Run the tests on {Dedicated,Shared,Shared}Worker. | |
| 43 fetch_tests_from_worker(new Worker(script_href)); | |
| 44 fetch_tests_from_worker(new SharedWorker(script_href)); | |
| 45 window.service_worker_test(script_href); | |
| 46 }); | |
| 47 } | |
| OLD | NEW |