4 <title>Test for secure input mode
</title>
5 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
6 <script src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
7 <script src=
"chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script>
8 <link rel=
"stylesheet" type=
"text/css"
9 href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
12 <div id=
"content" style=
"display: none">
19 <input id=
"input_text" type=
"text"><br>
20 <input id=
"input_password" type=
"password"><br>
21 <input id=
"input_text_readonly" type=
"text" readonly
><br>
22 <input id=
"input_text_ime_mode_disabled" type=
"text" style=
"ime-mode: disabled;"><br>
23 <input id=
"input_change" type=
"text"><br>
24 <textarea id=
"textarea"></textarea><br>
26 <div id=
"contenteditable" contenteditable
style=
"min-height: 3em;"></div>
28 <script class=
"testbody" type=
"application/javascript">
30 SimpleTest.waitForExplicitFinish();
32 function sendAKeyEvent() {
33 synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {},
"a",
"a");
36 function isFocused(aElement) {
37 return (SpecialPowers.focusManager.focusedElement == aElement);
42 ok(true,
"Not crashed: input on the document");
43 $(
"input_text").focus();
45 ok(true,
"Not crashed: input on <input type=\"text\
">");
46 $(
"input_password").focus();
48 ok(true,
"Not crashed: input on <input type=\"password\
">");
49 $(
"input_password").blur();
51 ok(true,
"Not crashed: input on the document after blur() of <input type=\"password\
">");
52 $(
"input_password").focus();
53 $(
"input_text_readonly").focus();
55 ok(true,
"Not crashed: input on <input type=\"text\
" readonly>");
56 $(
"input_password").focus();
57 $(
"input_text_ime_mode_disabled").focus();
59 ok(true,
"Not crashed: input on <input type=\"text\
" style=\"ime-mode: disabled;\
">");
60 $(
"input_password").focus();
61 $(
"textarea").focus();
63 ok(true,
"Not crashed: input on <textarea>");
64 $(
"input_password").focus();
65 $(
"contenteditable").focus();
67 ok(true,
"Not crashed: input on <div contenteditable>");
69 $(
"input_change").focus();
70 $(
"input_change").type =
"password";
72 ok(true,
"Not crashed: input on <input type=\"password\
"> changed from type=\"text\
"");
73 $(
"input_change").type =
"text";
75 ok(true,
"Not crashed: input on <input type=\"text\
"> changed from type=\"password\
"");
78 window.browsingContext.topChromeWindow.open(
"file_secure_input.html",
79 "_blank",
"chrome,width=100,height=100");
80 ok(otherWindow,
"failed to open other window");
86 $(
"input_text").focus();
89 SimpleTest.waitForFocus(function() {
92 ok(isFocused($(
"input_text")),
"focused element isn't <input type=\"text\
">");
93 ok(true,
"Not crashed: input on <input type=\"text\
"> after the other document has focus");
95 $(
"input_password").focus();
99 ok(isFocused($(
"input_password")),
"focused element isn't <input type=\"password\
">");
100 ok(true,
"Not crashed: input on <input type=\"password\
"> after the other document has focus");
102 $(
"input_text").focus();
104 otherWindow.document.getElementById(
"text").focus();
107 ok(isFocused($(
"input_text")),
"focused element isn't <input type=\"text\
">");
108 ok(true,
"Not crashed: input on <input type=\"text\
"> after the other document's <input type=\"text\
"> has focus");
110 $(
"input_password").focus();
112 otherWindow.document.getElementById(
"text").focus();
115 ok(isFocused($(
"input_password")),
"focused element isn't <input type=\"password\
">");
116 ok(true,
"Not crashed: input on <input type=\"password\
"> after the other document's <input type=\"text\
"> has focus");
118 $(
"input_text").focus();
120 otherWindow.document.getElementById(
"password").focus();
123 ok(isFocused($(
"input_text")),
"focused element isn't <input type=\"text\
">");
124 ok(true,
"Not crashed: input on <input type=\"text\
"> after the other document's <input type=\"password\
"> has focus");
126 $(
"input_password").focus();
128 otherWindow.document.getElementById(
"password").focus();
131 ok(isFocused($(
"input_password")),
"focused element isn't <input type=\"password\
">");
132 ok(true,
"Not crashed: input on <input type=\"password\
"> after the other document's <input type=\"password\
"> has focus");
138 SimpleTest.waitForFocus(runTest);