test_resizeby.html (1742B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for Bug 1369627</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 8 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=1369627">Mozilla Bug 1369627</a> 13 <p id="display"></p> 14 <div id="content"> 15 </div> 16 <pre id="test"> 17 </pre> 18 19 <script> 20 /** Test for Bug 1369627 */ 21 add_task(async function resizeby() { 22 await SimpleTest.promiseFocus(); 23 24 const popup = window.open("about:blank", "_blank", "width=500,height=500"); 25 26 is(popup.document.location.href, "about:blank"); 27 is(popup.document.readyState, "complete"); 28 29 // This fails flakily, see bug 1974454 30 is(popup.innerHeight, 500, "starting height is 500"); 31 is(popup.innerWidth, 500, "starting width in 500"); 32 33 // When this test was written, it said that resizeBy can occur sync without a resize event. 34 // Since bug 543435, window.open can fire a resize event. 35 // So there can be up to two resize, we only care for the correct innerWidth. 36 const resizeByDone = new Promise(resolve => { 37 const checkResized = () => { 38 info(`Checking target width: ${popup.innerWidth} vs ${550}`); 39 if (popup.innerWidth == 550) { 40 popup.removeEventListener("resize", checkResized); 41 resolve(); 42 } 43 } 44 popup.addEventListener("resize", checkResized); 45 checkResized(); 46 }); 47 48 popup.resizeBy(50, 0); 49 50 await resizeByDone; 51 52 is(popup.innerHeight, 500, "ending height is 500"); 53 is(popup.innerWidth, 550, "ending width is 550"); 54 55 popup.close(); 56 }); 57 </script> 58 </body> 59 </html>