michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: let tmp = {}; michael@0: Cu.import("resource:///modules/sessionstore/SessionSaver.jsm", tmp); michael@0: let {SessionSaver} = tmp; michael@0: michael@0: const URL = ROOT + "browser_454908_sample.html"; michael@0: const PASS = "pwd-" + Math.random(); michael@0: michael@0: /** michael@0: * Bug 454908 - Don't save/restore values of password fields. michael@0: */ michael@0: add_task(function test_dont_save_passwords() { michael@0: // Make sure we do save form data. michael@0: Services.prefs.clearUserPref("browser.sessionstore.privacy_level"); michael@0: michael@0: // Add a tab with a password field. michael@0: let tab = gBrowser.addTab(URL); michael@0: let browser = tab.linkedBrowser; michael@0: yield promiseBrowserLoaded(browser); michael@0: michael@0: // Fill in some values. michael@0: let usernameValue = "User " + Math.random(); michael@0: yield setInputValue(browser, {id: "username", value: usernameValue}); michael@0: yield setInputValue(browser, {id: "passwd", value: PASS}); michael@0: michael@0: // Close and restore the tab. michael@0: gBrowser.removeTab(tab); michael@0: tab = ss.undoCloseTab(window, 0); michael@0: browser = tab.linkedBrowser; michael@0: yield promiseTabRestored(tab); michael@0: michael@0: // Check that password fields aren't saved/restored. michael@0: let username = yield getInputValue(browser, {id: "username"}); michael@0: is(username, usernameValue, "username was saved/restored"); michael@0: let passwd = yield getInputValue(browser, {id: "passwd"}); michael@0: is(passwd, "", "password wasn't saved/restored"); michael@0: michael@0: // Write to disk and read our file. michael@0: yield SessionSaver.run(); michael@0: let path = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js"); michael@0: let data = yield OS.File.read(path); michael@0: let state = new TextDecoder().decode(data); michael@0: michael@0: // Ensure that sessionstore.js doesn't contain our password. michael@0: is(state.indexOf(PASS), -1, "password has not been written to disk"); michael@0: michael@0: // Cleanup. michael@0: gBrowser.removeTab(tab); michael@0: });