browser_formdata_password.js (1831B)
1 "use strict"; 2 3 /** 4 * Ensures that <input>s that are/were type=password are not saved. 5 */ 6 7 addCoopTask("file_formdata_password.html", test_hasBeenTypePassword, HTTPSROOT); 8 9 addNonCoopTask( 10 "file_formdata_password.html", 11 test_hasBeenTypePassword, 12 HTTPROOT 13 ); 14 addNonCoopTask( 15 "file_formdata_password.html", 16 test_hasBeenTypePassword, 17 HTTPSROOT 18 ); 19 20 async function test_hasBeenTypePassword(aURL) { 21 let tab = BrowserTestUtils.addTab(gBrowser, aURL); 22 let browser = tab.linkedBrowser; 23 await promiseBrowserLoaded(browser); 24 25 await SpecialPowers.spawn(browser, [], async function fillFields() { 26 let doc = content.document; 27 28 doc.getElementById("TextValue").setUserInput("abc"); 29 30 doc.getElementById("TextValuePassword").setUserInput("def"); 31 doc.getElementById("TextValuePassword").type = "password"; 32 33 doc.getElementById("TextPasswordValue").type = "password"; 34 doc.getElementById("TextPasswordValue").setUserInput("ghi"); 35 36 doc.getElementById("PasswordValueText").setUserInput("jkl"); 37 doc.getElementById("PasswordValueText").type = "text"; 38 39 doc.getElementById("PasswordTextValue").type = "text"; 40 doc.getElementById("PasswordTextValue").setUserInput("mno"); 41 42 doc.getElementById("PasswordValue").setUserInput("pqr"); 43 }); 44 45 // Remove the tab. 46 await promiseRemoveTabAndSessionState(tab); 47 48 let [ 49 { 50 state: { formdata }, 51 }, 52 ] = ss.getClosedTabDataForWindow(window); 53 let expected = [ 54 ["TextValue", "abc"], 55 ["TextValuePassword", undefined], 56 ["TextPasswordValue", undefined], 57 ["PasswordValueText", undefined], 58 ["PasswordTextValue", undefined], 59 ["PasswordValue", undefined], 60 ]; 61 62 for (let [id, expectedValue] of expected) { 63 is( 64 formdata.id[id], 65 expectedValue, 66 `Value should be ${expectedValue} for ${id}` 67 ); 68 } 69 }