4 <title>Test for masking password
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <script src=
"/tests/SimpleTest/WindowSnapshot.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <div id=
"content" style=
"display: none;">
15 <input type=
"password" id=
"input1" value=
"abcdef">
18 <script class=
"testbody" type=
"application/javascript">
19 function getEditor() {
20 return SpecialPowers.wrap(document.getElementById(
"input1")).editor;
23 function getLoadContext() {
24 return SpecialPowers.wrap(window).docShell.QueryInterface(
25 SpecialPowers.Ci.nsILoadContext);
28 function pasteText(str) {
29 const Cc = SpecialPowers.Cc;
30 const Ci = SpecialPowers.Ci;
31 let trans = Cc[
"@mozilla.org/widget/transferable;1"].
32 createInstance(Ci.nsITransferable);
33 trans.init(getLoadContext());
34 let s = Cc[
"@mozilla.org/supports-string;1"].
35 createInstance(Ci.nsISupportsString);
37 trans.setTransferData(
"text/plain", s);
38 let inputEvent = null;
39 window.addEventListener(
"input", aEvent =
> { inputEvent = aEvent; }, {once: true});
40 getEditor().pasteTransferable(trans);
41 is(inputEvent.type,
"input",
"input event should be fired");
42 is(inputEvent.inputType,
"insertFromPaste",
"inputType should be insertFromPaste");
43 is(inputEvent.data, str, `data should be
"${str}"`);
44 is(inputEvent.dataTransfer, null,
"dataTransfer should be null on password field");
47 SimpleTest.waitForFocus(async () =
> {
48 let input1 = document.getElementById(
"input1");
50 let reference = snapshotWindow(window, false);
52 // Bug
1501376 - Password should be masked immediately when pasting text
55 assertSnapshots(reference, snapshotWindow(window), true, null,
56 "Password should be masked immediately when pasting text",
57 "reference is masked");
61 SimpleTest.waitForExplicitFinish();