| 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> | 7 <script src="../../resources/testharness-helpers.js"></script> |
| 8 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../../resources/get-host-info.js"></script> | 9 <script src="../../resources/get-host-info.js"></script> |
| 10 <script src="../resources/test-helpers.js"></script> | 10 <script src="../resources/test-helpers.js"></script> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 'Registering within Service-Worker-Allowed path with parent ' + | 44 'Registering within Service-Worker-Allowed path with parent ' + |
| 45 'reference should pass'); | 45 'reference should pass'); |
| 46 service_worker_unregister_and_done(t, scope); | 46 service_worker_unregister_and_done(t, scope); |
| 47 }) | 47 }) |
| 48 }, 'Registering within Service-Worker-Allowed path with parent reference'); | 48 }, 'Registering within Service-Worker-Allowed path with parent reference'); |
| 49 | 49 |
| 50 promise_test(function(t) { | 50 promise_test(function(t) { |
| 51 var script = 'resources/service-worker-allowed-worker.php' + | 51 var script = 'resources/service-worker-allowed-worker.php' + |
| 52 '?ServiceWorkerAllowed=/allowed-path'; | 52 '?ServiceWorkerAllowed=/allowed-path'; |
| 53 var scope = '/disallowed-path'; | 53 var scope = '/disallowed-path'; |
| 54 return assert_promise_rejects( | 54 return promise_rejects(t, |
| 55 'SecurityError', |
| 55 navigator.serviceWorker.register(script, {scope: scope}), | 56 navigator.serviceWorker.register(script, {scope: scope}), |
| 56 'SecurityError', | |
| 57 'Registering outside Service-Worker-Allowed path should fail'); | 57 'Registering outside Service-Worker-Allowed path should fail'); |
| 58 }, 'Registering outside Service-Worker-Allowed path'); | 58 }, 'Registering outside Service-Worker-Allowed path'); |
| 59 | 59 |
| 60 promise_test(function(t) { | 60 promise_test(function(t) { |
| 61 var script = 'resources/service-worker-allowed-worker.php' + | 61 var script = 'resources/service-worker-allowed-worker.php' + |
| 62 '?ServiceWorkerAllowed=../allowed-path-with-parent'; | 62 '?ServiceWorkerAllowed=../allowed-path-with-parent'; |
| 63 var scope = '/allowed-path-with-parent'; | 63 var scope = '/allowed-path-with-parent'; |
| 64 return assert_promise_rejects( | 64 return promise_rejects(t, |
| 65 'SecurityError', |
| 65 navigator.serviceWorker.register(script, {scope: scope}), | 66 navigator.serviceWorker.register(script, {scope: scope}), |
| 66 'SecurityError', | |
| 67 'Registering outside Service-Worker-Allowed path with parent ' + | 67 'Registering outside Service-Worker-Allowed path with parent ' + |
| 68 'reference should fail'); | 68 'reference should fail'); |
| 69 }, 'Registering outside Service-Worker-Allowed path with parent reference'); | 69 }, 'Registering outside Service-Worker-Allowed path with parent reference'); |
| 70 | 70 |
| 71 promise_test(function(t) { | 71 promise_test(function(t) { |
| 72 var script = host_info.HTTPS_REMOTE_ORIGIN + | 72 var script = host_info.HTTPS_REMOTE_ORIGIN + |
| 73 '/serviceworker/chromium/resources/' + | 73 '/serviceworker/chromium/resources/' + |
| 74 'service-worker-allowed-worker.php' + | 74 'service-worker-allowed-worker.php' + |
| 75 '?ServiceWorkerAllowed=' + | 75 '?ServiceWorkerAllowed=' + |
| 76 host_info.HTTP_REMOTE_ORIGIN + '/cross-origin/'; | 76 host_info.HTTP_REMOTE_ORIGIN + '/cross-origin/'; |
| 77 var scope = '/cross-origin/'; | 77 var scope = '/cross-origin/'; |
| 78 return assert_promise_rejects( | 78 return promise_rejects(t, |
| 79 'SecurityError', |
| 79 navigator.serviceWorker.register(script, {scope: scope}), | 80 navigator.serviceWorker.register(script, {scope: scope}), |
| 80 'SecurityError', | |
| 81 'Registering cross-origin Service-Worker-Allowed should fail'); | 81 'Registering cross-origin Service-Worker-Allowed should fail'); |
| 82 }, 'Registering cross-origin Service-Worker-Allowed'); | 82 }, 'Registering cross-origin Service-Worker-Allowed'); |
| 83 | 83 |
| 84 </script> | 84 </script> |
| OLD | NEW |