test_postMessage_userpass.html (1335B)
1 <!DOCTYPE html> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=417075 5 --> 6 <head> 7 <title>postMessage from a page with username/password in its URI</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417075">Mozilla Bug 417075</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"></div> 15 16 <iframe src="http://bobhope:password@example.org/tests/dom/tests/mochitest/whatwg/postMessage_userpass_helper.html" 17 name="userPassKid"></iframe> 18 19 20 <pre id="test"> 21 <script class="testbody" type="application/javascript"> 22 /** Test for Bug 417075 */ 23 24 SimpleTest.waitForExplicitFinish(); 25 26 function receiveMessage(evt) 27 { 28 is(evt.origin, "http://example.org", "wrong origin"); 29 is(evt.data, "child-message", "wrong data"); 30 is(evt.lastEventId, "", "postMessage creates events with empty lastEventId"); 31 ok(evt.source === window.frames.userPassKid, "wrong source"); 32 SimpleTest.finish(); 33 } 34 35 window.addEventListener("message", receiveMessage); 36 37 function sendMessage(evt) 38 { 39 window.frames.userPassKid.postMessage("parent-message", "http://example.org"); 40 } 41 42 window.addEventListener("load", sendMessage); 43 </script> 44 </pre> 45 </body> 46 </html>