| <!DOCTYPE html> |
| <title>Location of origin-signed HTTP response</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../../resources/get-host-info.js?pipe=sub"></script> |
| <body> |
| <script> |
| function with_iframe(url) { |
| return new Promise(function(resolve) { |
| const frame = document.createElement('iframe'); |
| frame.src = url; |
| frame.onload = function() { resolve(frame); }; |
| document.body.appendChild(frame); |
| }); |
| } |
| |
| promise_test(function(t) { |
| const url = 'resources/origin-signed-response-iframe.php'; |
| return with_iframe(url) |
| .then((frame) => { |
| var channel = new MessageChannel(); |
| var promise = |
| new Promise((resolve) => { channel.port1.onmessage = resolve; }); |
| frame.contentWindow.postMessage( |
| {port: channel.port2}, '*', [channel.port2]); |
| return promise; |
| }) |
| .then((event) => { |
| assert_equals(event.data.location, 'https://example.com/test.html'); |
| }); |
| }, 'Location of origin-signed HTTP response'); |
| </script> |
| </body> |
| |