editor/libeditor/tests/test_bug674770-1.html
author Markus Stange <mstange@themasta.com>
Mon, 15 Jun 2015 19:20:59 -0400
changeset 249905 3f025568ad349d7b4a4da45feef6812c4e4d4101
parent 229897 cb099675e6a532d9de0037d390a2ffc0baf3c9bc
child 314905 6aa8b6ad3d29fed813f5e423809dd679387e0f3c
child 314947 e3876a85aa0cf830855fb02796a40feb30efd73c
permissions -rw-r--r--
Bug 1165185 - Try to avoid invalidations when scrolling transformed elements. r=roc

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=674770
-->
<head>
  <title>Test for Bug 674770</title>
  <script type="application/javascript" src="/MochiKit/packed.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=674770">Mozilla Bug 674770</a>
<p id="display"></p>
<div id="content">
<a href="file_bug674770-1.html" id="link1">test</a>
<div contenteditable>
<a href="file_bug674770-1.html" id="link2">test</a>
</div>
</div>
<pre id="test">
<script type="application/javascript">

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
  SpecialPowers.pushPrefEnv({"set":[["middlemouse.paste", true]]}, startTest);
});
function startTest() {
  localStorage.removeItem("clicked");
  window.linkWasClicked = false;

  var link = document.querySelector("#link1");
  addEventListener("storage", function(e) {
    is(e.key, "clicked", "Correct event");
    is(e.newValue, "true", "Correct value");
    window.linkWasClicked = true;
  }, false);
  synthesizeMouseAtCenter(link, {button: 1});

  hitEventLoop(function() {
    ok(window.linkWasClicked, "The click operation worked successfully");
    window.linkWasClicked = false;

    link = document.querySelector("#link2");
    localStorage.removeItem("clicked");
    synthesizeMouseAtCenter(link, {button: 1});

    hitEventLoop(function() {
      ok(!window.linkWasClicked, "The click operation shouldn't work in the contenteditable area");

      localStorage.removeItem("clicked");
      SimpleTest.finish();
    }, 100);
  }, 100);
}

function hitEventLoop(func, times) {
  if (times > 0) {
    setTimeout(hitEventLoop, 0, func, times - 1);
  } else {
    setTimeout(func, 0);
  }
}

</script>
</pre>
</body>
</html>