layout/base/tests/test_bug369950.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial