Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" |
michael@0 | 3 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 4 | <!-- |
michael@0 | 5 | https://bugzilla.mozilla.org/show_bug.cgi?id=547996 |
michael@0 | 6 | --> |
michael@0 | 7 | <head> |
michael@0 | 8 | <title>Test for Bug 547996</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547996">Mozilla Bug 547996</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"></div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"><![CDATA[ |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 547996 **/ |
michael@0 | 21 | /* mouseEvent.mozInputSource attribute */ |
michael@0 | 22 | |
michael@0 | 23 | var expectedInputSource = null; |
michael@0 | 24 | |
michael@0 | 25 | function check(event) { |
michael@0 | 26 | is(event.mozInputSource, expectedInputSource, ".mozInputSource"); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function doTest() { |
michael@0 | 30 | setup(); |
michael@0 | 31 | |
michael@0 | 32 | expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD; |
michael@0 | 33 | testKeyboard(); |
michael@0 | 34 | |
michael@0 | 35 | expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE; |
michael@0 | 36 | testMouse(); |
michael@0 | 37 | |
michael@0 | 38 | expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN; |
michael@0 | 39 | testScriptedClicks(); |
michael@0 | 40 | |
michael@0 | 41 | cleanup(); |
michael@0 | 42 | SimpleTest.finish(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function testKeyboard() { |
michael@0 | 46 | |
michael@0 | 47 | $("inputTarget").focus(); |
michael@0 | 48 | synthesizeKey("VK_SPACE", {}); |
michael@0 | 49 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 50 | |
michael@0 | 51 | $("buttonTarget").focus(); |
michael@0 | 52 | synthesizeKey("VK_SPACE", {}); |
michael@0 | 53 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 54 | |
michael@0 | 55 | //XUL buttons do not generate click on ENTER or SPACE, |
michael@0 | 56 | //they do only on accessKey |
michael@0 | 57 | |
michael@0 | 58 | $("anchorTarget").focus(); |
michael@0 | 59 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 60 | |
michael@0 | 61 | synthesizeKey("VK_TAB", {}); |
michael@0 | 62 | synthesizeKey("VK_SPACE", {}); |
michael@0 | 63 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 64 | |
michael@0 | 65 | $("checkboxTarget").focus(); |
michael@0 | 66 | synthesizeKey("VK_SPACE", {}); |
michael@0 | 67 | |
michael@0 | 68 | var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ? |
michael@0 | 69 | { ctrlKey : true } : { altKey : true, shiftKey: true }; |
michael@0 | 70 | |
michael@0 | 71 | synthesizeKey("o", accessKeyDetails); |
michael@0 | 72 | synthesizeKey("t", accessKeyDetails); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function testMouse() { |
michael@0 | 76 | synthesizeMouse($("inputTarget"), 0, 0, {}); |
michael@0 | 77 | synthesizeMouse($("buttonTarget"), 0, 0, {}); |
michael@0 | 78 | synthesizeMouse($("xulButtonTarget"), 0, 0, {}); |
michael@0 | 79 | synthesizeMouse($("anchorTarget"), 0, 0, {}); |
michael@0 | 80 | synthesizeMouse($("radioTarget1"), 0, 0, {}); |
michael@0 | 81 | synthesizeMouse($("radioTarget2"), 0, 0, {}); |
michael@0 | 82 | synthesizeMouse($("checkboxTarget"), 0, 0, {}); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | function testScriptedClicks() { |
michael@0 | 86 | $("inputTarget").click(); |
michael@0 | 87 | $("buttonTarget").click(); |
michael@0 | 88 | $("xulButtonTarget").click(); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | function setup() { |
michael@0 | 92 | $("inputTarget").addEventListener("click", check, false); |
michael@0 | 93 | $("buttonTarget").addEventListener("click", check, false); |
michael@0 | 94 | $("anchorTarget").addEventListener("click", check, false); |
michael@0 | 95 | $("xulButtonTarget").addEventListener("click", check, false); |
michael@0 | 96 | $("radioTarget1").addEventListener("click", check, false); |
michael@0 | 97 | $("radioTarget2").addEventListener("click", check, false); |
michael@0 | 98 | $("checkboxTarget").addEventListener("click", check, false); |
michael@0 | 99 | |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | function cleanup() { |
michael@0 | 103 | $("inputTarget").removeEventListener("click", check, false); |
michael@0 | 104 | $("buttonTarget").removeEventListener("click", check, false); |
michael@0 | 105 | $("xulButtonTarget").removeEventListener("click", check, false); |
michael@0 | 106 | $("anchorTarget").removeEventListener("click", check, false); |
michael@0 | 107 | $("radioTarget1").removeEventListener("click", check, false); |
michael@0 | 108 | $("radioTarget2").removeEventListener("click", check, false); |
michael@0 | 109 | $("checkboxTarget").removeEventListener("click", check, false); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 113 | SimpleTest.waitForFocus(doTest, window); |
michael@0 | 114 | |
michael@0 | 115 | ]]></script> |
michael@0 | 116 | </pre> |
michael@0 | 117 | <input type="checkbox" id="checkboxTarget">Checkbox target</input> |
michael@0 | 118 | <input id="inputTarget" type="button" value="HTML Input" accesskey="o"/> |
michael@0 | 119 | <button id="buttonTarget">HTML Button</button> |
michael@0 | 120 | <xul:button id="xulButtonTarget" accesskey="t">XUL Button</xul:button> |
michael@0 | 121 | <a href="#" id="anchorTarget">Anchor</a> |
michael@0 | 122 | <input type="radio" id="radioTarget1" name="group">Radio Target 1</input> |
michael@0 | 123 | <input type="radio" id="radioTarget2" name="group">Radio Target 2</input> |
michael@0 | 124 | </body> |
michael@0 | 125 | </html> |