From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../sessionstore/test/browser_formdata_password.js | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 browser/components/sessionstore/test/browser_formdata_password.js (limited to 'browser/components/sessionstore/test/browser_formdata_password.js') diff --git a/browser/components/sessionstore/test/browser_formdata_password.js b/browser/components/sessionstore/test/browser_formdata_password.js new file mode 100644 index 0000000000..14abdb89f5 --- /dev/null +++ b/browser/components/sessionstore/test/browser_formdata_password.js @@ -0,0 +1,69 @@ +"use strict"; + +/** + * Ensures that s that are/were type=password are not saved. + */ + +addCoopTask("file_formdata_password.html", test_hasBeenTypePassword, HTTPSROOT); + +addNonCoopTask( + "file_formdata_password.html", + test_hasBeenTypePassword, + HTTPROOT +); +addNonCoopTask( + "file_formdata_password.html", + test_hasBeenTypePassword, + HTTPSROOT +); + +async function test_hasBeenTypePassword(aURL) { + let tab = BrowserTestUtils.addTab(gBrowser, aURL); + let browser = tab.linkedBrowser; + await promiseBrowserLoaded(browser); + + await SpecialPowers.spawn(browser, [], async function fillFields() { + let doc = content.document; + + doc.getElementById("TextValue").setUserInput("abc"); + + doc.getElementById("TextValuePassword").setUserInput("def"); + doc.getElementById("TextValuePassword").type = "password"; + + doc.getElementById("TextPasswordValue").type = "password"; + doc.getElementById("TextPasswordValue").setUserInput("ghi"); + + doc.getElementById("PasswordValueText").setUserInput("jkl"); + doc.getElementById("PasswordValueText").type = "text"; + + doc.getElementById("PasswordTextValue").type = "text"; + doc.getElementById("PasswordTextValue").setUserInput("mno"); + + doc.getElementById("PasswordValue").setUserInput("pqr"); + }); + + // Remove the tab. + await promiseRemoveTabAndSessionState(tab); + + let [ + { + state: { formdata }, + }, + ] = ss.getClosedTabDataForWindow(window); + let expected = [ + ["TextValue", "abc"], + ["TextValuePassword", undefined], + ["TextPasswordValue", undefined], + ["PasswordValueText", undefined], + ["PasswordTextValue", undefined], + ["PasswordValue", undefined], + ]; + + for (let [id, expectedValue] of expected) { + is( + formdata.id[id], + expectedValue, + `Value should be ${expectedValue} for ${id}` + ); + } +} -- cgit v1.2.3