tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug558663.html (3721B)


      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 </head>
      9 <body>
     10 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=558663">Mozilla Bug 558663</a></p>
     11 
     12 <!-- 20x20 of red -->
     13 <iframe id="iframe" srcdoc="<img id='image' border='0' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC'>"></iframe>
     14 
     15 <pre id="test">
     16 <script type="application/javascript">
     17 
     18 /** Test for Bug 558663 */
     19 var ok = parent.ok;
     20 var SimpleTest = parent.SimpleTest;
     21 var compareSnapshots = parent.compareSnapshots;
     22 var snapshotWindow = parent.snapshotWindow;
     23 var synthesizeMouse = parent.synthesizeMouse;
     24 
     25 window.addEventListener("load", runTest);
     26 
     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 }
     36 
     37 function runTest() {
     38  var contentDocument = document.getElementById("iframe").contentDocument;
     39  contentDocument.designMode = "on";
     40  contentDocument.execCommand("enableObjectResizing", false, true);
     41 
     42  // The editor requires the event loop to spin after you turn on design mode
     43  // before it takes effect.
     44  setTimeout(continueTest, 100);
     45 }
     46 
     47 function continueTest() {
     48  var win = document.getElementById("iframe").contentWindow;
     49  var doc = win.document;
     50  var image = doc.getElementById("image");
     51 
     52  // We want to test that clicking on the image and then clicking on one of the
     53  // draggers doesn't make the draggers disappear.
     54 
     55  // clean snapshot
     56  var before = snapshotWindow(win);
     57 
     58  // click to get the draggers
     59  synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
     60  synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
     61 
     62  // mouse over a dragger will change its color, so move the mouse away
     63  synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
     64 
     65  // snapshot with hopefully draggers
     66  var middle = snapshotWindow(win);
     67 
     68  // clicking on the top left dragger shouldn't change anything
     69  synthesizeMouse(image, 1, 1, {type: "mousedown"}, win);
     70  synthesizeMouse(image, 1, 1, {type: "mouseup"}, win);
     71 
     72  // mouse over a dragger will change its color, so move the mouse away
     73  synthesizeMouse(doc.documentElement, 50, 50, {type: "mousemove"}, win);
     74 
     75  // snapshot with hopefully draggers again
     76  var middle2 = snapshotWindow(win);
     77 
     78  // click outside the image (but inside the document) to unselect it
     79  synthesizeMouse(doc.documentElement, 50, 50, {type: "mousedown"}, win);
     80  synthesizeMouse(doc.documentElement, 50, 50, {type: "mouseup"}, win);
     81 
     82  // and then click outside the document so we don't draw a caret
     83  synthesizeMouse(document.documentElement, 1, 1, {type: "mousedown"}, window);
     84  synthesizeMouse(document.documentElement, 1, 1, {type: "mouseup"}, window);
     85 
     86  // hopefully clean snapshot
     87  var end = snapshotWindow(win);
     88 
     89  // before == end && middle == middle2 && before/end != middle/middle2
     90  checkSnapshots(before, end, true, "before and after should be the same")
     91  checkSnapshots(middle, middle2, true, "middle two should be the same");
     92  checkSnapshots(before, middle, false, "before and middle should not be the same");
     93  checkSnapshots(before, middle2, false, "before and middle2 should not be the same");
     94  checkSnapshots(middle, end, false, "middle and end should not be the same");
     95  checkSnapshots(middle2, end, false, "middle2 and end should not be the same");
     96 
     97  SimpleTest.finish();
     98 }
     99 
    100 </script>
    101 </pre>
    102 </body>
    103 </html>