| OLD | NEW |
| 1 importScripts('../../resources/testharness.js'); | 1 importScripts('/resources/testharness.js'); |
| 2 | 2 |
| 3 let echo_output = null; | 3 let echo_output = null; |
| 4 | 4 |
| 5 // Tests importing a script that sets |echo_output| to the query string. | 5 // Tests importing a script that sets |echo_output| to the query string. |
| 6 function test_import(str) { | 6 function test_import(str) { |
| 7 importScripts('echo.php?' + str); | 7 importScripts('import-scripts-echo.py?msg=' + str); |
| 8 assert_equals(echo_output, str); | 8 assert_equals(echo_output, str); |
| 9 } | 9 } |
| 10 | 10 |
| 11 test_import('root'); | 11 test_import('root'); |
| 12 test_import('root-and-message'); | 12 test_import('root-and-message'); |
| 13 | 13 |
| 14 self.addEventListener('install', () => { | 14 self.addEventListener('install', () => { |
| 15 test_import('install'); | 15 test_import('install'); |
| 16 test_import('install-and-message'); | 16 test_import('install-and-message'); |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 self.addEventListener('message', e => { | 19 self.addEventListener('message', e => { |
| 20 test_import('root-and-message'); | 20 var error = null; |
| 21 test_import('install-and-message'); | 21 |
| 22 // TODO(falken): This should fail. The spec disallows importing a non-cached | 22 try { |
| 23 // script like this but currently Chrome and Firefox allow it. | 23 importScripts('import-scripts-echo.py?msg=' + e.data); |
| 24 test_import('message'); | 24 } catch (e) { |
| 25 e.source.postMessage('OK'); | 25 error = e && e.name; |
| 26 } |
| 27 |
| 28 e.source.postMessage({ error: error, value: echo_output }); |
| 26 }); | 29 }); |
| OLD | NEW |