| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- FIXME: Move this test out of chromium/ when PHP is no longer needed | 2 <!-- FIXME: Move this test out of chromium/ when PHP is no longer needed |
| 3 to set the Service-Worker-Allowed header (crbug.com/347864). | 3 to set the Service-Worker-Allowed header (crbug.com/347864). |
| 4 --> | 4 --> |
| 5 <title>Service Worker: Service-Worker-Allowed header</title> | 5 <title>Service Worker: Service-Worker-Allowed header</title> |
| 6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharness-helpers.js"></script> | |
| 8 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../../resources/get-host-info.js"></script> | 8 <script src="../../resources/get-host-info.js"></script> |
| 10 <script src="../resources/test-helpers.js"></script> | 9 <script src="../resources/test-helpers.js"></script> |
| 11 <script> | 10 <script> |
| 12 | 11 |
| 13 var host_info = get_host_info(); | 12 var host_info = get_host_info(); |
| 14 | 13 |
| 15 promise_test(function(t) { | 14 promise_test(function(t) { |
| 16 var script = 'resources/service-worker-allowed-worker.php' + | 15 var script = 'resources/service-worker-allowed-worker.php' + |
| 17 '?ServiceWorkerAllowed=/allowed-path'; | 16 '?ServiceWorkerAllowed=/allowed-path'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 44 'Registering within Service-Worker-Allowed path with parent ' + | 43 'Registering within Service-Worker-Allowed path with parent ' + |
| 45 'reference should pass'); | 44 'reference should pass'); |
| 46 service_worker_unregister_and_done(t, scope); | 45 service_worker_unregister_and_done(t, scope); |
| 47 }) | 46 }) |
| 48 }, 'Registering within Service-Worker-Allowed path with parent reference'); | 47 }, 'Registering within Service-Worker-Allowed path with parent reference'); |
| 49 | 48 |
| 50 promise_test(function(t) { | 49 promise_test(function(t) { |
| 51 var script = 'resources/service-worker-allowed-worker.php' + | 50 var script = 'resources/service-worker-allowed-worker.php' + |
| 52 '?ServiceWorkerAllowed=/allowed-path'; | 51 '?ServiceWorkerAllowed=/allowed-path'; |
| 53 var scope = '/disallowed-path'; | 52 var scope = '/disallowed-path'; |
| 54 return assert_promise_rejects( | 53 return promise_rejects(t, |
| 54 'SecurityError', |
| 55 navigator.serviceWorker.register(script, {scope: scope}), | 55 navigator.serviceWorker.register(script, {scope: scope}), |
| 56 'SecurityError', | |
| 57 'Registering outside Service-Worker-Allowed path should fail'); | 56 'Registering outside Service-Worker-Allowed path should fail'); |
| 58 }, 'Registering outside Service-Worker-Allowed path'); | 57 }, 'Registering outside Service-Worker-Allowed path'); |
| 59 | 58 |
| 60 promise_test(function(t) { | 59 promise_test(function(t) { |
| 61 var script = 'resources/service-worker-allowed-worker.php' + | 60 var script = 'resources/service-worker-allowed-worker.php' + |
| 62 '?ServiceWorkerAllowed=../allowed-path-with-parent'; | 61 '?ServiceWorkerAllowed=../allowed-path-with-parent'; |
| 63 var scope = '/allowed-path-with-parent'; | 62 var scope = '/allowed-path-with-parent'; |
| 64 return assert_promise_rejects( | 63 return promise_rejects(t, |
| 64 'SecurityError', |
| 65 navigator.serviceWorker.register(script, {scope: scope}), | 65 navigator.serviceWorker.register(script, {scope: scope}), |
| 66 'SecurityError', | |
| 67 'Registering outside Service-Worker-Allowed path with parent ' + | 66 'Registering outside Service-Worker-Allowed path with parent ' + |
| 68 'reference should fail'); | 67 'reference should fail'); |
| 69 }, 'Registering outside Service-Worker-Allowed path with parent reference'); | 68 }, 'Registering outside Service-Worker-Allowed path with parent reference'); |
| 70 | 69 |
| 71 promise_test(function(t) { | 70 promise_test(function(t) { |
| 72 var script = host_info.HTTPS_REMOTE_ORIGIN + | 71 var script = host_info.HTTPS_REMOTE_ORIGIN + |
| 73 '/serviceworker/chromium/resources/' + | 72 '/serviceworker/chromium/resources/' + |
| 74 'service-worker-allowed-worker.php' + | 73 'service-worker-allowed-worker.php' + |
| 75 '?ServiceWorkerAllowed=' + | 74 '?ServiceWorkerAllowed=' + |
| 76 host_info.HTTP_REMOTE_ORIGIN + '/cross-origin/'; | 75 host_info.HTTP_REMOTE_ORIGIN + '/cross-origin/'; |
| 77 var scope = '/cross-origin/'; | 76 var scope = '/cross-origin/'; |
| 78 return assert_promise_rejects( | 77 return promise_rejects(t, |
| 78 'SecurityError', |
| 79 navigator.serviceWorker.register(script, {scope: scope}), | 79 navigator.serviceWorker.register(script, {scope: scope}), |
| 80 'SecurityError', | |
| 81 'Registering cross-origin Service-Worker-Allowed should fail'); | 80 'Registering cross-origin Service-Worker-Allowed should fail'); |
| 82 }, 'Registering cross-origin Service-Worker-Allowed'); | 81 }, 'Registering cross-origin Service-Worker-Allowed'); |
| 83 | 82 |
| 84 </script> | 83 </script> |
| OLD | NEW |