test_bug400204.html (2574B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=400204 5 --> 6 <head> 7 <title>Test for Bug 400204</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=400204">Mozilla Bug 400204</a> 13 <p id="display"></p> 14 <iframe id="content" src="about:blank" style="display: none"></iframe> 15 <pre id="test"> 16 <script class="testbody" type="text/javascript"> 17 var c = document.getElementById("content"); 18 var success = false; 19 // try to access innerWidth 20 try { success = (c.contentWindow.innerWidth == 0); } catch(ex) { success = false; } 21 ok(success, "can't access hidden iframe innerWidth, or it's not 0"); 22 23 // try to access innerHeight 24 success = false; 25 try { success = (c.contentWindow.innerHeight == 0); } catch(ex) { success = false; } 26 ok(success, "can't access hidden iframe innerHeight, or it's not 0"); 27 28 // Snag the canonical getter and setter 29 var innerWidthGetter = Object.getOwnPropertyDescriptor(c.contentWindow, "innerWidth").get; 30 var innerHeightGetter = Object.getOwnPropertyDescriptor(c.contentWindow, "innerHeight").get; 31 32 // try to set innerWidth 33 success = false; 34 try { c.contentWindow.innerWidth = 100; success = true; } catch(ex) { success = false; } 35 ok(success, "can't set hidden iframe innerWidth"); 36 37 // try to set innerHeight 38 success = false; 39 try { c.contentWindow.innerHeight = 100; success = true; } catch(ex) { success = false; } 40 ok(success, "can't set hidden iframe innerHeight"); 41 42 // now try these again for good measure, and to ensure the values 43 // haven't changed except via getting replaced 44 // try to access innerWidth 45 success = false; 46 try { success = (c.contentWindow.innerWidth == 100); } catch(ex) { success = false; } 47 ok(success, "can't access hidden iframe innerWidth, or it's not 100"); 48 49 success = false; 50 try { success = (innerWidthGetter.call(c.contentWindow) == 0); } catch(ex) { success = false; } 51 ok(success, "can't access hidden iframe innerWidth, or it's not 0"); 52 53 // try to access innerHeight 54 success = false; 55 try { success = (c.contentWindow.innerHeight == 100); } catch(ex) { success = false; } 56 ok(success, "can't access hidden iframe innerHeight, or it's not 100"); 57 58 success = false; 59 try { success = (innerHeightGetter.call(c.contentWindow) == 0); } catch(ex) { success = false; } 60 ok(success, "can't access hidden iframe innerHeight, or it's not 0"); 61 </script> 62 </pre> 63 </body> 64 </html>