1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_454908.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +let tmp = {}; 1.10 +Cu.import("resource:///modules/sessionstore/SessionSaver.jsm", tmp); 1.11 +let {SessionSaver} = tmp; 1.12 + 1.13 +const URL = ROOT + "browser_454908_sample.html"; 1.14 +const PASS = "pwd-" + Math.random(); 1.15 + 1.16 +/** 1.17 + * Bug 454908 - Don't save/restore values of password fields. 1.18 + */ 1.19 +add_task(function test_dont_save_passwords() { 1.20 + // Make sure we do save form data. 1.21 + Services.prefs.clearUserPref("browser.sessionstore.privacy_level"); 1.22 + 1.23 + // Add a tab with a password field. 1.24 + let tab = gBrowser.addTab(URL); 1.25 + let browser = tab.linkedBrowser; 1.26 + yield promiseBrowserLoaded(browser); 1.27 + 1.28 + // Fill in some values. 1.29 + let usernameValue = "User " + Math.random(); 1.30 + yield setInputValue(browser, {id: "username", value: usernameValue}); 1.31 + yield setInputValue(browser, {id: "passwd", value: PASS}); 1.32 + 1.33 + // Close and restore the tab. 1.34 + gBrowser.removeTab(tab); 1.35 + tab = ss.undoCloseTab(window, 0); 1.36 + browser = tab.linkedBrowser; 1.37 + yield promiseTabRestored(tab); 1.38 + 1.39 + // Check that password fields aren't saved/restored. 1.40 + let username = yield getInputValue(browser, {id: "username"}); 1.41 + is(username, usernameValue, "username was saved/restored"); 1.42 + let passwd = yield getInputValue(browser, {id: "passwd"}); 1.43 + is(passwd, "", "password wasn't saved/restored"); 1.44 + 1.45 + // Write to disk and read our file. 1.46 + yield SessionSaver.run(); 1.47 + let path = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js"); 1.48 + let data = yield OS.File.read(path); 1.49 + let state = new TextDecoder().decode(data); 1.50 + 1.51 + // Ensure that sessionstore.js doesn't contain our password. 1.52 + is(state.indexOf(PASS), -1, "password has not been written to disk"); 1.53 + 1.54 + // Cleanup. 1.55 + gBrowser.removeTab(tab); 1.56 +});