test_bug287446.html (2115B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=287446 5 --> 6 <head> 7 <title>Test for Bug 287446</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=287446">Mozilla Bug 287446</a> 13 <p id="display"> 14 <iframe id="i" 15 src="http://example.com/tests/layout/forms/test/bug287446_subframe.html"></iframe> 16 </p> 17 <div id="content" style="display: none"> 18 19 </div> 20 <pre id="test"> 21 <script type="application/javascript"> 22 23 /** Test for Bug 287446 */ 24 SimpleTest.waitForExplicitFinish(); 25 addLoadEvent(function() { 26 isnot(window.location.host, "example.com", "test is not testing cross-site"); 27 var accessed = false; 28 try { 29 $("i").contentDocument.documentElement; 30 accessed = true; 31 } catch(e) {} 32 is(accessed, false, "Shouldn't be able to access cross-site"); 33 34 $("i").style.display = "none"; 35 document.body.offsetWidth; 36 is(document.defaultView.getComputedStyle($("i")).display, "none", 37 "toggling display failed"); 38 $("i").style.display = ""; 39 document.body.offsetWidth; 40 is(document.defaultView.getComputedStyle($("i")).display, "inline", 41 "toggling display back failed"); 42 43 $("i").contentWindow.postMessage("start", "*"); 44 }); 45 46 function continueTest() { 47 $("i").style.display = "none"; 48 document.body.offsetWidth; 49 is(document.defaultView.getComputedStyle($("i")).display, "none", 50 "toggling display second time failed"); 51 $("i").style.display = ""; 52 document.body.offsetWidth; 53 is(document.defaultView.getComputedStyle($("i")).display, "inline", 54 "toggling display back second time failed"); 55 56 $("i").contentWindow.postMessage("continue", "*"); 57 } 58 59 window.addEventListener("message", 60 function(evt) { 61 var arr = evt.data.split(/ /).map(decodeURIComponent); 62 if (arr[0] == 't') { 63 is(arr[1], arr[2], arr[3]); 64 } else if (arr[0] == 'c') { 65 continueTest(); 66 } else if (arr[0] == 'f') { 67 SimpleTest.finish(); 68 } 69 }); 70 71 </script> 72 </pre> 73 </body> 74 </html>