test_bug114649.html (2080B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=114649 5 --> 6 <head> 7 <title>Test for Bug 114649</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 onload="run()"> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=114649">Mozilla Bug 114649</a> 13 <iframe id="display" style="width: 500px; height: 500px;"></iframe> 14 <pre id="test"> 15 <script type="application/javascript"> 16 17 /** Test for Bug 114649 */ 18 19 var gIFrame; 20 var gCurrentWidth = 500; 21 var gGotEventsAt = []; 22 var gInterval; 23 var gFinished = false; 24 25 function run() { 26 SimpleTest.waitForExplicitFinish(); 27 SimpleTest.requestFlakyTimeout("Simulating dragging to resize a window"); 28 29 gIFrame = document.getElementById("display"); 30 31 var subdoc = gIFrame.contentDocument; 32 subdoc.open(); 33 subdoc.write("<body onresize='window.parent.handle_resize_event()'>"); 34 subdoc.close(); 35 36 setTimeout(do_a_resize, 50); 37 } 38 39 function do_a_resize() 40 { 41 // decrease the width by 10 until we hit 400, then stop 42 gCurrentWidth -= 10; 43 gIFrame.style.width = gCurrentWidth + "px"; 44 45 if (gCurrentWidth > 400) { 46 setTimeout(do_a_resize, 50); 47 } 48 } 49 50 function handle_resize_event() 51 { 52 gGotEventsAt.push(gCurrentWidth); 53 54 if (gCurrentWidth == 400) { 55 check_resize_events(); 56 } 57 } 58 59 function check_resize_events() 60 { 61 if (gFinished) { 62 // We can get here when the browser can't process the resizes and 63 // dispatch resize events as fast as we're doing the resizing. We can 64 // then end up with multiple resize events queued up after we set our 65 // final size. This return makes sure that in that case we avoid 66 // calling SimpleTest.finish() more than once. 67 return; 68 } 69 gFinished = true; 70 ok(gGotEventsAt.length >= 2, "We should get more than one event"); 71 isnot(gGotEventsAt[0], 400, "The first event shouldn't be for the final size"); 72 SimpleTest.finish(); 73 } 74 75 </script> 76 </pre> 77 </body> 78 </html>