| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>register on a secure page after redirect from an non-secure url</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="../resources/get-host-info.js?pipe=sub"></script> | |
| 6 <script src="resources/test-helpers.js"></script> | |
| 7 <body> | |
| 8 <script> | |
| 9 | |
| 10 // Loads a non-secure url in an iframe, which redirects to |target_url|. | |
| 11 // That page then registers a service worker, and messages back with the result. | |
| 12 // Returns a promise that resolves with the result. | |
| 13 function redirect_and_register(target_url) { | |
| 14 var redirect_url = get_host_info()['UNAUTHENTICATED_ORIGIN'] + | |
| 15 '/serviceworker/resources/redirect.php?Redirect='; | |
| 16 var message_promise = new Promise(resolve => { | |
| 17 window.addEventListener('message', e => resolve(e.data)); | |
| 18 }); | |
| 19 var iframe_promise = with_iframe(redirect_url + encodeURIComponent(target_url)
); | |
| 20 return Promise.all([message_promise, iframe_promise]) | |
| 21 .then(results => { | |
| 22 results[1].remove(); | |
| 23 return results[0]; | |
| 24 }); | |
| 25 } | |
| 26 | |
| 27 promise_test(function(t) { | |
| 28 var target_url = window.location.origin + | |
| 29 '/serviceworker/resources/register.html'; | |
| 30 | |
| 31 return redirect_and_register(target_url) | |
| 32 .then(result => { assert_equals(result, 'OK'); }); | |
| 33 }, 'register on a secure page after redirect from an non-secure url'); | |
| 34 | |
| 35 promise_test(function(t) { | |
| 36 var target_url = get_host_info()['UNAUTHENTICATED_ORIGIN'] + | |
| 37 '/serviceworker/resources/register.html'; | |
| 38 | |
| 39 return redirect_and_register(target_url) | |
| 40 .then(result => {assert_equals(result, 'FAIL: SecurityError');}); | |
| 41 }, 'register on a non-secure page after redirect from an non-secure url'); | |
| 42 </script> | |
| 43 </body> | |
| OLD | NEW |