5 var element = testnode;
6 var securechar = document.defaultView.getComputedStyle(element, "").getPropertyValue("-webkit-text-security");
9 return String.fromCharCode(0x25A0);
11 return String.fromCharCode(0x2022);
13 return String.fromCharCode(0x25E6);
17 function secureText(textLength)
20 for (var counter = 0; counter < textLength; counter++)
27 var console = document.getElementById("console");
28 var li = document.createElement("li");
29 li.appendChild(document.createTextNode(msg));
30 console.appendChild(li);
33 function assert(expected, actual, msg)
35 if (expected != actual)
36 log("Error: " + msg + " expected=" + expected + ", actual=" + actual);
38 log("Success: " + msg + " expected=" + expected + ", actual=" + actual);
41 function run(tests, testIdx)
43 var expectedSecureTextLen;
45 eventSender.keyDown("rightArrow");
47 assert(tests[testIdx][2], window.find(secureText(testnode.value.length), false, true), "secured after delay.");
50 if (testIdx >= tests.length) {
51 testRunner.notifyDone();
56 eventSender.keyDown("rightArrow");
58 var charSequence = tests[testIdx][0];
59 for (var i = 0; i < charSequence.length - 1; i++) {
60 textInputController.setMarkedText(charSequence[i], testnode.value.length, testnode.value.length);
62 if (charSequence[charSequence.length - 1] == "backspace") {
63 eventSender.keyDown("leftArrow");
64 eventSender.keyDown("delete");
66 textInputController.insertText(charSequence[charSequence.length - 1]);
69 assert(tests[testIdx][1], window.find(secureText(testnode.value.length), false, true), "secured right after.");
72 window.setTimeout(function(){ run(tests, testIdx); }, 600);
74 window.setTimeout(function(){ run(tests, testIdx); }, 0);
77 function setTestNode(testNode)
84 if (window.testRunner && window.textInputController && window.eventSender) {
85 testRunner.dumpAsText();
86 testRunner.waitUntilDone();
87 if (window.internals) {
88 window.internals.settings.setPasswordEchoEnabled(true);
89 window.internals.settings.setPasswordEchoDurationInSeconds(0.1);
90 testnode = document.getElementById('testnode');