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="/common/get-host-info.sub.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> |
| 7 <body> |
| 8 <script> |
| 9 'use strict'; |
| 10 |
| 11 // Loads a non-secure url in a new window, 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'] + base_path() + |
| 16 'resources/redirect.py?Redirect='; |
| 17 var child = window.open(redirect_url + encodeURIComponent(target_url)); |
| 18 return new Promise(resolve => { |
| 19 window.addEventListener('message', e => resolve(e.data)); |
| 20 }) |
| 21 .then(function(result) { |
| 22 child.close(); |
| 23 return result; |
| 24 }); |
| 25 } |
| 26 |
| 27 promise_test(function(t) { |
| 28 var target_url = window.location.origin + base_path() + |
| 29 'resources/http-to-https-redirect-and-register-iframe.html'; |
| 30 |
| 31 return redirect_and_register(target_url) |
| 32 .then(result => { |
| 33 assert_equals(result, 'OK'); |
| 34 }); |
| 35 }, 'register on a secure page after redirect from an non-secure url'); |
| 36 |
| 37 promise_test(function(t) { |
| 38 var target_url = get_host_info()['UNAUTHENTICATED_ORIGIN'] + base_path() + |
| 39 'resources/http-to-https-redirect-and-register-iframe.html'; |
| 40 |
| 41 return redirect_and_register(target_url) |
| 42 .then(result => { |
| 43 assert_equals(result, 'FAIL: SecurityError'); |
| 44 }); |
| 45 }, 'register on a non-secure page after redirect from an non-secure url'); |
| 46 </script> |
| 47 </body> |
OLD | NEW |