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