Bug 674770 part.3 Add tests for middle-clicking on anchor element when the page has contenteditable element r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 26 Nov 2011 13:51:49 +0900
changeset 80804 1ab2c7d4c91d27a7d60be36016286077ce640930
parent 80803 1a9cc49f9cf1276defa2726c8849d1d83c1780d5
child 80805 b5782f6da550cb181a7ee27a1b7f6d9de872f133
push id21530
push userbmo@edmorley.co.uk
push dateSat, 26 Nov 2011 08:27:28 +0000
treeherdermozilla-central@c58bad0b4640 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs674770
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 674770 part.3 Add tests for middle-clicking on anchor element when the page has contenteditable element r=roc
editor/libeditor/html/tests/Makefile.in
editor/libeditor/html/tests/file_bug674770-1.html
editor/libeditor/html/tests/test_bug674770-1.html
--- a/editor/libeditor/html/tests/Makefile.in
+++ b/editor/libeditor/html/tests/Makefile.in
@@ -80,16 +80,18 @@ include $(topsrcdir)/config/rules.mk
 		test_bug607584.html \
 		test_bug611182.html \
 		test_bug612447.html \
 		test_bug620906.html \
 		test_bug622371.html \
 		test_bug629845.html \
 		test_bug640321.html \
 		test_bug668599.html \
+		test_bug674770-1.html \
+		file_bug674770-1.html \
 		test_bug674861.html \
 		test_bug676401.html \
 		test_bug677752.html \
 		test_CF_HTML_clipboard.html \
 		test_contenteditable_focus.html \
 		test_htmleditor_keyevent_handling.html \
 		test_select_all_without_body.html \
 		file_select_all_without_body.html \
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/file_bug674770-1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE>
+<script>
+  localStorage["clicked"] = "true";
+  close();
+</script>
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/test_bug674770-1.html
@@ -0,0 +1,69 @@
+<!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">
+
+/** Test for Bug 674770 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  SpecialPowers.setBoolPref("middlemouse.paste", true);
+  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");
+      SpecialPowers.clearUserPref("middlemouse.paste");
+      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>