OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset=utf-8> |
| 3 <title></title> |
| 4 <script src=/resources/testharness.js></script> |
| 5 <script src=/resources/testharnessreport.js></script> |
| 6 <div id=log></div> |
| 7 <iframe id="existing" src="resources/post-your-protocol.html?existing"></iframe> |
| 8 <iframe id="http-and-gunk" src="resources/post-your-protocol.html?http-and-gunk"
></iframe> |
| 9 <iframe id="https-and-gunk" src="resources/post-your-protocol.html?https-and-gun
k"></iframe> |
| 10 <script> |
| 11 // NOTE: we do not listen to message events until our load event fires, so we |
| 12 // only get them for the things we actually care about. |
| 13 var wrapper_test = async_test("General setup"); |
| 14 var tests = { |
| 15 "existing": { test: async_test("Set location.protocol = location.protocol"), |
| 16 result: location.protocol }, |
| 17 "http-and-gunk": { test: async_test("Set location.protocol to http:gunk"), |
| 18 result: "http:" }, |
| 19 // We should really test the "https:gunk" case too, and assert that it ends up |
| 20 // with a protocol of "https:", but can't. See comments below for why. |
| 21 }; |
| 22 |
| 23 function messageListener(e) { |
| 24 test(function() { |
| 25 var data = e.data; |
| 26 var id = data.id; |
| 27 var t = tests[id].test; |
| 28 t.step(function() { |
| 29 assert_equals(data.protocol, tests[id].result, "Protocol should match"); |
| 30 }) |
| 31 t.done(); |
| 32 }, "Message listener"); |
| 33 } |
| 34 |
| 35 addEventListener("load", wrapper_test.step_func_done(function() { |
| 36 addEventListener("message", messageListener); |
| 37 |
| 38 tests["existing"].test.step(function() { |
| 39 var loc = document.getElementById("existing").contentWindow.location; |
| 40 loc.protocol = loc.protocol; |
| 41 }); |
| 42 tests["http-and-gunk"].test.step(function() { |
| 43 var loc = document.getElementById("http-and-gunk").contentWindow.location; |
| 44 loc.protocol = "http:gunk"; |
| 45 }); |
| 46 // I wish we could test the https bit, but can't figure out a non-racy way to |
| 47 // do it, because we need to change both protocol (to https) _and_ port to |
| 48 // {{ports[https][0]}} to get a successful load unless we're running on the |
| 49 // default http port, but the setter uses the current value, which doesn't get |
| 50 // updated sync, as the url to start with for the set. Oh, and there's no |
| 51 // good way to detect when the port set is "done" either. |
| 52 })); |
| 53 |
| 54 </script> |
OLD | NEW |