layout/base/tests/test_bug558663.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=558663
     5 -->
     6 <head>
     7   <title>Test for Bug 558663</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
    11   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    12 </head>
    13 <body>
    14 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=558663">Mozilla Bug 514127</a></p>
    16  <!-- 20x20 of red -->
    17 <iframe id="iframe" src="data:text/html,<img id='image' border='0' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC'>"></iframe>
    19 <pre id="test">
    20 <script type="application/javascript">
    22 /** Test for Bug 558663 **/
    24 SimpleTest.waitForExplicitFinish();
    25 window.addEventListener("load", runTest, false);
    27 function checkSnapshots(s1, s2, shouldBeEqual, testName) {
    28   var res = compareSnapshots(s1, s2, shouldBeEqual);
    29   if (res[0]) {
    30     ok(true, testName + " snapshots compare correctly");
    31   } else {
    32     ok(false, testName + " snapshots compare incorrectly. snapshot 1: " +
    33               res[1] + " snapshot 2: " + res[2]); 
    34   }
    35 }
    37 function runTest() {
    38   document.getElementById("iframe").contentWindow.document.designMode = "on";
    40   // The editor requires the event loop to spin after you turn on design mode
    41   // before it takes effect.
    42   setTimeout(continueTest, 100);
    43 }
    45 function continueTest() {
    46   var win = document.getElementById("iframe").contentWindow;
    47   var doc = win.document;
    48   var image = doc.getElementById("image");
    50   // We want to test that clicking on the image and then clicking on one of the
    51   // draggers doesn't make the draggers disappear.
    53   // clean snapshot
    54   var before = snapshotWindow(win);
    56   // click to get the draggers
    57   synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
    58   synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
    60   // mouse over a dragger will change its color, so move the mouse away
    61   synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
    63   // snapshot with hopefully draggers
    64   var middle = snapshotWindow(win);
    66   // clicking on the top left dragger shouldn't change anything
    67   synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
    68   synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
    70   // mouse over a dragger will change its color, so move the mouse away
    71   synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
    73   // snapshot with hopefully draggers again
    74   var middle2 = snapshotWindow(win);
    76   // click outside the image (but inside the document) to unselect it
    77   synthesizeMouse(doc.documentElement, 50, 50, {type: "mousedown"}, win);
    78   synthesizeMouse(doc.documentElement, 50, 50, {type: "mouseup"}, win);
    80   // and then click outside the document so we don't draw a caret
    81   synthesizeMouse(document.documentElement, 1, 1, {type: "mousedown"}, window);
    82   synthesizeMouse(document.documentElement, 1, 1, {type: "mouseup"}, window);
    84   // hopefully clean snapshot
    85   var end = snapshotWindow(win);
    87   // before == end && middle == middle2 && before/end != middle/middle2
    88   checkSnapshots(before, end, true, "before and after should be the same")
    89   checkSnapshots(middle, middle2, true, "middle two should be the same");
    90   checkSnapshots(before, middle, false, "before and middle should not be the same");
    91   checkSnapshots(before, middle2, false, "before and middle2 should not be the same");
    92   checkSnapshots(middle, end, false, "middle and end should not be the same");
    93   checkSnapshots(middle2, end, false, "middle2 and end should not be the same");
    95   SimpleTest.finish();
    96 }
    98 </script>
    99 </pre>
   100 </body>
   101 </html>

mercurial