1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug547996-2.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,125 @@ 1.4 +<?xml version="1.0"?> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml" 1.6 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=547996 1.9 +--> 1.10 +<head> 1.11 + <title>Test for Bug 547996</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/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=547996">Mozilla Bug 547996</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"></div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"><![CDATA[ 1.22 + 1.23 +/** Test for Bug 547996 **/ 1.24 +/* mouseEvent.mozInputSource attribute */ 1.25 + 1.26 +var expectedInputSource = null; 1.27 + 1.28 +function check(event) { 1.29 + is(event.mozInputSource, expectedInputSource, ".mozInputSource"); 1.30 +} 1.31 + 1.32 +function doTest() { 1.33 + setup(); 1.34 + 1.35 + expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD; 1.36 + testKeyboard(); 1.37 + 1.38 + expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE; 1.39 + testMouse(); 1.40 + 1.41 + expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN; 1.42 + testScriptedClicks(); 1.43 + 1.44 + cleanup(); 1.45 + SimpleTest.finish(); 1.46 +} 1.47 + 1.48 +function testKeyboard() { 1.49 + 1.50 + $("inputTarget").focus(); 1.51 + synthesizeKey("VK_SPACE", {}); 1.52 + synthesizeKey("VK_RETURN", {}); 1.53 + 1.54 + $("buttonTarget").focus(); 1.55 + synthesizeKey("VK_SPACE", {}); 1.56 + synthesizeKey("VK_RETURN", {}); 1.57 + 1.58 + //XUL buttons do not generate click on ENTER or SPACE, 1.59 + //they do only on accessKey 1.60 + 1.61 + $("anchorTarget").focus(); 1.62 + synthesizeKey("VK_RETURN", {}); 1.63 + 1.64 + synthesizeKey("VK_TAB", {}); 1.65 + synthesizeKey("VK_SPACE", {}); 1.66 + synthesizeKey("VK_RIGHT", {}); 1.67 + 1.68 + $("checkboxTarget").focus(); 1.69 + synthesizeKey("VK_SPACE", {}); 1.70 + 1.71 + var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ? 1.72 + { ctrlKey : true } : { altKey : true, shiftKey: true }; 1.73 + 1.74 + synthesizeKey("o", accessKeyDetails); 1.75 + synthesizeKey("t", accessKeyDetails); 1.76 +} 1.77 + 1.78 +function testMouse() { 1.79 + synthesizeMouse($("inputTarget"), 0, 0, {}); 1.80 + synthesizeMouse($("buttonTarget"), 0, 0, {}); 1.81 + synthesizeMouse($("xulButtonTarget"), 0, 0, {}); 1.82 + synthesizeMouse($("anchorTarget"), 0, 0, {}); 1.83 + synthesizeMouse($("radioTarget1"), 0, 0, {}); 1.84 + synthesizeMouse($("radioTarget2"), 0, 0, {}); 1.85 + synthesizeMouse($("checkboxTarget"), 0, 0, {}); 1.86 +} 1.87 + 1.88 +function testScriptedClicks() { 1.89 + $("inputTarget").click(); 1.90 + $("buttonTarget").click(); 1.91 + $("xulButtonTarget").click(); 1.92 +} 1.93 + 1.94 +function setup() { 1.95 + $("inputTarget").addEventListener("click", check, false); 1.96 + $("buttonTarget").addEventListener("click", check, false); 1.97 + $("anchorTarget").addEventListener("click", check, false); 1.98 + $("xulButtonTarget").addEventListener("click", check, false); 1.99 + $("radioTarget1").addEventListener("click", check, false); 1.100 + $("radioTarget2").addEventListener("click", check, false); 1.101 + $("checkboxTarget").addEventListener("click", check, false); 1.102 + 1.103 +} 1.104 + 1.105 +function cleanup() { 1.106 + $("inputTarget").removeEventListener("click", check, false); 1.107 + $("buttonTarget").removeEventListener("click", check, false); 1.108 + $("xulButtonTarget").removeEventListener("click", check, false); 1.109 + $("anchorTarget").removeEventListener("click", check, false); 1.110 + $("radioTarget1").removeEventListener("click", check, false); 1.111 + $("radioTarget2").removeEventListener("click", check, false); 1.112 + $("checkboxTarget").removeEventListener("click", check, false); 1.113 +} 1.114 + 1.115 +SimpleTest.waitForExplicitFinish(); 1.116 +SimpleTest.waitForFocus(doTest, window); 1.117 + 1.118 +]]></script> 1.119 +</pre> 1.120 +<input type="checkbox" id="checkboxTarget">Checkbox target</input> 1.121 +<input id="inputTarget" type="button" value="HTML Input" accesskey="o"/> 1.122 +<button id="buttonTarget">HTML Button</button> 1.123 +<xul:button id="xulButtonTarget" accesskey="t">XUL Button</xul:button> 1.124 +<a href="#" id="anchorTarget">Anchor</a> 1.125 +<input type="radio" id="radioTarget1" name="group">Radio Target 1</input> 1.126 +<input type="radio" id="radioTarget2" name="group">Radio Target 2</input> 1.127 +</body> 1.128 +</html>