diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /editor/libeditor/tests/test_password_paste.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | editor/libeditor/tests/test_password_paste.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_password_paste.html b/editor/libeditor/tests/test_password_paste.html new file mode 100644 index 0000000000..817de9b277 --- /dev/null +++ b/editor/libeditor/tests/test_password_paste.html @@ -0,0 +1,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/plain", s); + 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> |