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 (7f9f804e9dbe)

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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for masking password</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none;">

</div>

<input type="password" id="input1" value="abcdef">

<pre id="test">
<script class="testbody" type="application/javascript">
function getEditor() {
  return SpecialPowers.wrap(document.getElementById("input1")).editor;
}

function getLoadContext() {
  return SpecialPowers.wrap(window).docShell.QueryInterface(
           SpecialPowers.Ci.nsILoadContext);
}

function pasteText(str) {
  const Cc = SpecialPowers.Cc;
  const Ci = SpecialPowers.Ci;
  let trans = Cc["@mozilla.org/widget/transferable;1"].
              createInstance(Ci.nsITransferable);
  trans.init(getLoadContext());
  let s = Cc["@mozilla.org/supports-string;1"].
          createInstance(Ci.nsISupportsString);
  s.data = str;
  trans.setTransferData("text/unicode", s, str.length * 2);
  let inputEvent = null;
  window.addEventListener("input", aEvent => { inputEvent = aEvent; }, {once: true});
  getEditor().pasteTransferable(trans);
  is(inputEvent.type, "input", "input event should be fired");
  is(inputEvent.inputType, "insertFromPaste", "inputType should be insertFromPaste");
  is(inputEvent.data, str, `data should be "${str}"`);
  is(inputEvent.dataTransfer, null, "dataTransfer should be null on password field");
}

SimpleTest.waitForFocus(async () => {
  let input1 = document.getElementById("input1");
  input1.focus();
  let reference = snapshotWindow(window, false);

  // Bug 1501376 - Password should be masked immediately when pasting text
  input1.value = "";
  pasteText("abcdef");
  assertSnapshots(reference, snapshotWindow(window), true, null,
                  "Password should be masked immediately when pasting text",
                  "reference is masked");
  SimpleTest.finish();
});

SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>