layout/base/tests/test_bug369950.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/test_bug369950.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=369950
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 369950</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=369950">Mozilla Bug 369950</a>
    1.18 +<p id="display">
    1.19 +  <iframe id="i" src="bug369950-subframe.xml" width="200" height="100"></iframe>
    1.20 +</p>
    1.21 +<div id="content" style="display: none">
    1.22 +  
    1.23 +</div>
    1.24 +<pre id="test">
    1.25 +<script type="application/javascript">
    1.26 +
    1.27 +/** Test for Bug 369950 **/
    1.28 +SimpleTest.waitForExplicitFinish();
    1.29 +
    1.30 +addLoadEvent(function() {
    1.31 +  // Can't just run our code here, because we might not have painting
    1.32 +  // unsuppressed yet.  Do it async.
    1.33 +  SimpleTest.executeSoon(doTheTest);
    1.34 +});
    1.35 +
    1.36 +function doTheTest() {
    1.37 +  // do a layout flush
    1.38 +  var rect = $("i").getBoundingClientRect();
    1.39 +  var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect();
    1.40 +
    1.41 +  // And do the rest of it later
    1.42 +  SimpleTest.executeSoon(reallyDoTheTest);
    1.43 +}
    1.44 +
    1.45 +function reallyDoTheTest() {
    1.46 +  var rect = $("i").getBoundingClientRect();
    1.47 +  var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect();
    1.48 +
    1.49 +  // We want coords relative to the iframe, so subtract off rect2.left/top.
    1.50 +  // 7px is a guess to get us from the bottom of the iframe into the scrollbar
    1.51 +  // groove for the horizontal scrollbar on the bottom.
    1.52 +  synthesizeMouse($("i").contentDocument.documentElement,
    1.53 +                  -rect2.left + rect.width / 2,  rect.height - rect2.top - 7,
    1.54 +                  {}, $("i").contentWindow);
    1.55 +  // Scroll is async, so give it time
    1.56 +  SimpleTest.executeSoon(checkScroll);
    1.57 +};
    1.58 +
    1.59 +function checkScroll() {
    1.60 +  // do a layout flush
    1.61 +  var rect = $("i").getBoundingClientRect();
    1.62 +  // And do the rest of it later
    1.63 +  SimpleTest.executeSoon(reallyCheckScroll);
    1.64 +}
    1.65 +
    1.66 +function reallyCheckScroll() {
    1.67 +  var rect = $("i").getBoundingClientRect();
    1.68 +  var rect2 = $("i").contentDocument.documentElement.getBoundingClientRect();
    1.69 +  isnot($("i").contentWindow.scrollX, 0, "Clicking scrollbar should scroll");
    1.70 +
    1.71 +  // Not doing things below here, since avoiding the scroll arrows
    1.72 +  // cross-platform is a huge pain.
    1.73 +  SimpleTest.finish();
    1.74 +  return;
    1.75 +
    1.76 +  // 8px horizontal offset is a guess to get us into the scr
    1.77 +  synthesizeMouse($("i").contentDocument.documentElement, -rect2.left + 8,
    1.78 +                  rect.height - rect2.top - 7, {}, $("i").contentWindow);
    1.79 +  // Scroll is async, so give it time
    1.80 +  SimpleTest.executeSoon(finishUp);
    1.81 +}
    1.82 +
    1.83 +function finishUp() {
    1.84 +  is($("i").contentWindow.scrollX, 0, "Clicking scrollbar should scroll back");
    1.85 +  SimpleTest.finish();
    1.86 +};
    1.87 +
    1.88 +
    1.89 +
    1.90 +
    1.91 +</script>
    1.92 +</pre>
    1.93 +</body>
    1.94 +</html>

mercurial