Index: LayoutTests/fast/events/mid-button-link-click.html |
diff --git a/LayoutTests/fast/events/mid-button-link-click.html b/LayoutTests/fast/events/mid-button-link-click.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd0217fb42150f8480d187d6f48ce932b5ba9be8 |
--- /dev/null |
+++ b/LayoutTests/fast/events/mid-button-link-click.html |
@@ -0,0 +1,72 @@ |
+<!DOCTYPE html> |
+<script src="../js/resources/js-test-pre.js"></script> |
+<body> |
+ <a href="#" id=testlink1 style="display:block; width:300px; height:100px">Test content</a> |
+ <a href="#"><div id=testlink2 style="width:300px; height:100px">Test content</div></a> |
+<script> |
+description('Mousedown and mouseup with middle button on link should not result in a click event.'); |
+jsTestIsAsync = true; |
+window.onload = function() { |
+ testMiddle("testlink1", false); |
+ testMiddle("testlink2", true); |
+} |
+function testMiddle(testElmId, finishWhenDone) { |
+ var testElm = document.getElementById(testElmId); |
+ var mouseDownCount = 0; |
+ testElm.addEventListener("mousedown", function(event) { |
+ if (event.button != 1) { |
+ testFailed("Unexpected mouse button. Use the middle button on the mouse."); |
+ return; |
+ } |
+ mouseDownCount++; |
+ if (mouseDownCount == 3 && !seenClick) { |
+ testPassed("No unexpected click event seen at " + testElmId + ".") |
+ if (finishWhenDone) |
+ finishJSTest(); |
+ } |
+ }, false); |
+ testElm.addEventListener("mouseup", function(event) { |
+ if (event.button != 1) { |
+ testFailed("Unexpected mouse button. Use the middle button on the mouse."); |
+ return; |
+ } |
+ }, false); |
+ var seenClick = false; |
+ testElm.addEventListener("click", function(event) { |
+ seenClick = true; |
+ testFailed("There was an unexpected click event."); |
+ if (event.button != 1) { |
+ testFailed("The click event had an even more unexpected button. Use the middle button on the mouse."); |
+ } |
+ if (finishWhenDone) |
+ finishJSTest(); |
+ }, false); |
+ var seenDblClick |
+ testElm.addEventListener("dblclick", function(event) { |
+ seenDblClick = true; |
+ testFailed("There was an unexpected dblclick event at " + testElmId + "."); |
+ if (event.button != 1) { |
+ testFailed("The dblclick event had an even more unexpected button. Use the middle button on the mouse."); |
+ } |
+ if (finishWhenDone) |
+ finishJSTest(); |
+ }, false); |
+ |
+ if ("eventSender" in window) { |
+ // Mousedown on the iframe, but no mouseup. |
+ eventSender.mouseMoveTo(testElm.offsetLeft + testElm.offsetWidth / 2, |
+ testElm.offsetTop + testElm.offsetHeight / 2); |
+ // Button 0 (default) is left, 2 is right, everything else is middle. |
+ eventSender.mouseDown(1); |
+ eventSender.mouseUp(1); |
+ eventSender.mouseDown(1); |
+ eventSender.mouseUp(1); |
+ eventSender.mouseDown(1); |
+ eventSender.mouseUp(1); |
+ } |
+ else { |
+ testElm.innerHTML = "window.eventSender not available. To test manually press and release the mouse middle button *twice* on this text."; |
+ } |
+} |
+</script> |
+<script src="../js/resources/js-test-post.js"></script> |