test_bug369950.html (2757B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=369950 5 --> 6 <head> 7 <title>Test for Bug 369950</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=369950">Mozilla Bug 369950</a> 14 <p id="display"> 15 <iframe id="i" src="bug369950-subframe.xml" width="200" height="100"></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 369950 */ 24 SimpleTest.waitForExplicitFinish(); 25 26 addLoadEvent(function() { 27 // Can't just run our code here, because we might not have painting 28 // unsuppressed yet. Do it async. 29 SimpleTest.executeSoon(doTheTest); 30 }); 31 32 function doTheTest() { 33 // do a layout flush 34 var rect = $("i").getBoundingClientRect(); 35 var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect(); 36 37 // And do the rest of it later 38 SimpleTest.executeSoon(reallyDoTheTest); 39 } 40 41 function reallyDoTheTest() { 42 var rect = $("i").getBoundingClientRect(); 43 var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect(); 44 45 // We want coords relative to the iframe, so subtract off rect2.left/top. 46 // 7px is a guess to get us from the bottom of the iframe into the scrollbar 47 // groove for the horizontal scrollbar on the bottom. 48 synthesizeMouse($("i").contentDocument.documentElement, 49 -rect2.left + rect.width / 2, rect.height - rect2.top - 7, 50 {}, $("i").contentWindow); 51 // Scroll is async, so give it time 52 SimpleTest.executeSoon(checkScroll); 53 }; 54 55 function checkScroll() { 56 // do a layout flush 57 var rect = $("i").getBoundingClientRect(); 58 // And do the rest of it later 59 SimpleTest.executeSoon(reallyCheckScroll); 60 } 61 62 function reallyCheckScroll() { 63 var rect = $("i").getBoundingClientRect(); 64 var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect(); 65 isnot($("i").contentWindow.scrollX, 0, "Clicking scrollbar should scroll"); 66 67 // Not doing things below here, since avoiding the scroll arrows 68 // cross-platform is a huge pain. 69 SimpleTest.finish(); 70 return; 71 72 // 8px horizontal offset is a guess to get us into the scr 73 synthesizeMouse($("i").contentDocument.documentElement, -rect2.left + 8, 74 rect.height - rect2.top - 7, {}, $("i").contentWindow); 75 // Scroll is async, so give it time 76 SimpleTest.executeSoon(finishUp); 77 } 78 79 function finishUp() { 80 is($("i").contentWindow.scrollX, 0, "Clicking scrollbar should scroll back"); 81 SimpleTest.finish(); 82 }; 83 84 85 86 87 </script> 88 </pre> 89 </body> 90 </html>