DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (1aeaa33a64f9)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=547996
-->
<head>
  <title>Test for Bug 547996</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/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=547996">Mozilla Bug 547996</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript"><![CDATA[

/** Test for Bug 547996 **/
/* mouseEvent.mozInputSource attribute */

var expectedInputSource = null;

function check(event) {
  is(event.mozInputSource, expectedInputSource, ".mozInputSource");
}

function doTest() {
  setup();

  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
  testKeyboard();

  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
  testMouse();

  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN;
  testScriptedClicks();

  cleanup();
  SimpleTest.finish();
}

function testKeyboard() {

  $("inputTarget").focus();
  synthesizeKey("VK_SPACE", {});
  synthesizeKey("VK_RETURN", {});

  $("buttonTarget").focus();
  synthesizeKey("VK_SPACE", {});
  synthesizeKey("VK_RETURN", {});

  //XUL buttons do not generate click on ENTER or SPACE,
  //they do only on accessKey

  $("anchorTarget").focus();
  synthesizeKey("VK_RETURN", {});

  synthesizeKey("VK_TAB", {});
  synthesizeKey("VK_SPACE", {});
  synthesizeKey("VK_RIGHT", {});

  $("checkboxTarget").focus();
  synthesizeKey("VK_SPACE", {});

  var accessKeyDetails = (navigator.platform.includes("Mac")) ?
                          { ctrlKey : true } : { altKey : true, shiftKey: true };

  synthesizeKey("o", accessKeyDetails);
  synthesizeKey("t", accessKeyDetails);
}

function testMouse() {
  synthesizeMouse($("inputTarget"), 0, 0, {});
  synthesizeMouse($("buttonTarget"), 0, 0, {});
  synthesizeMouse($("xulButtonTarget"), 0, 0, {});
  synthesizeMouse($("anchorTarget"), 0, 0, {});
  synthesizeMouse($("radioTarget1"), 0, 0, {});
  synthesizeMouse($("radioTarget2"), 0, 0, {});
  synthesizeMouse($("checkboxTarget"), 0, 0, {});
}

function testScriptedClicks() {
  $("inputTarget").click();
  $("buttonTarget").click();
  $("xulButtonTarget").click();
}

function setup() {
  $("inputTarget").addEventListener("click", check);
  $("buttonTarget").addEventListener("click", check);
  $("anchorTarget").addEventListener("click", check);
  $("xulButtonTarget").addEventListener("click", check);
  $("radioTarget1").addEventListener("click", check);
  $("radioTarget2").addEventListener("click", check);
  $("checkboxTarget").addEventListener("click", check);

}

function cleanup() {
  $("inputTarget").removeEventListener("click", check);
  $("buttonTarget").removeEventListener("click", check);
  $("xulButtonTarget").removeEventListener("click", check);
  $("anchorTarget").removeEventListener("click", check);
  $("radioTarget1").removeEventListener("click", check);
  $("radioTarget2").removeEventListener("click", check);
  $("checkboxTarget").removeEventListener("click", check);
}

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(doTest, window);

]]></script>
</pre>
<input type="checkbox" id="checkboxTarget">Checkbox target</input>
<input id="inputTarget" type="button" value="HTML Input" accesskey="o"/>
<button id="buttonTarget">HTML Button</button>
<xul:button id="xulButtonTarget" accesskey="t">XUL Button</xul:button>
<a href="#" id="anchorTarget">Anchor</a>
<input type="radio" id="radioTarget1" name="group">Radio Target 1</input>
<input type="radio" id="radioTarget2" name="group">Radio Target 2</input>
</body>
</html>