editor/libeditor/html/tests/test_bug674770-1.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug674770-1.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=674770
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 674770</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/packed.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="text/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=674770">Mozilla Bug 674770</a>
    1.18 +<p id="display"></p>
    1.19 +<div id="content">
    1.20 +<a href="file_bug674770-1.html" id="link1">test</a>
    1.21 +<div contenteditable>
    1.22 +<a href="file_bug674770-1.html" id="link2">test</a>
    1.23 +</div>
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script type="application/javascript">
    1.27 +
    1.28 +if (!navigator.platform.startsWith("Linux")) {
    1.29 +  SimpleTest.expectAssertions(1);
    1.30 +}
    1.31 +
    1.32 +/** Test for Bug 674770 **/
    1.33 +SimpleTest.waitForExplicitFinish();
    1.34 +SimpleTest.waitForFocus(function() {
    1.35 +  SpecialPowers.setBoolPref("middlemouse.paste", true);
    1.36 +  localStorage.removeItem("clicked");
    1.37 +  window.linkWasClicked = false;
    1.38 +
    1.39 +  var link = document.querySelector("#link1");
    1.40 +  addEventListener("storage", function(e) {
    1.41 +    is(e.key, "clicked", "Correct event");
    1.42 +    is(e.newValue, "true", "Correct value");
    1.43 +    window.linkWasClicked = true;
    1.44 +  }, false);
    1.45 +  synthesizeMouseAtCenter(link, {button: 1});
    1.46 +
    1.47 +  hitEventLoop(function() {
    1.48 +    ok(window.linkWasClicked, "The click operation worked successfully");
    1.49 +    window.linkWasClicked = false;
    1.50 +
    1.51 +    link = document.querySelector("#link2");
    1.52 +    localStorage.removeItem("clicked");
    1.53 +    synthesizeMouseAtCenter(link, {button: 1});
    1.54 +
    1.55 +    hitEventLoop(function() {
    1.56 +      ok(!window.linkWasClicked, "The click operation shouldn't work in the contenteditable area");
    1.57 +
    1.58 +      localStorage.removeItem("clicked");
    1.59 +      SpecialPowers.clearUserPref("middlemouse.paste");
    1.60 +      SimpleTest.finish();
    1.61 +    }, 100);
    1.62 +  }, 100);
    1.63 +});
    1.64 +
    1.65 +function hitEventLoop(func, times) {
    1.66 +  if (times > 0) {
    1.67 +    setTimeout(hitEventLoop, 0, func, times - 1);
    1.68 +  } else {
    1.69 +    setTimeout(func, 0);
    1.70 +  }
    1.71 +}
    1.72 +
    1.73 +</script>
    1.74 +</pre>
    1.75 +</body>
    1.76 +</html>

mercurial