Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | "use strict"; |
michael@0 | 5 | |
michael@0 | 6 | let tmp = {}; |
michael@0 | 7 | Cu.import("resource:///modules/sessionstore/SessionSaver.jsm", tmp); |
michael@0 | 8 | let {SessionSaver} = tmp; |
michael@0 | 9 | |
michael@0 | 10 | const URL = ROOT + "browser_454908_sample.html"; |
michael@0 | 11 | const PASS = "pwd-" + Math.random(); |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * Bug 454908 - Don't save/restore values of password fields. |
michael@0 | 15 | */ |
michael@0 | 16 | add_task(function test_dont_save_passwords() { |
michael@0 | 17 | // Make sure we do save form data. |
michael@0 | 18 | Services.prefs.clearUserPref("browser.sessionstore.privacy_level"); |
michael@0 | 19 | |
michael@0 | 20 | // Add a tab with a password field. |
michael@0 | 21 | let tab = gBrowser.addTab(URL); |
michael@0 | 22 | let browser = tab.linkedBrowser; |
michael@0 | 23 | yield promiseBrowserLoaded(browser); |
michael@0 | 24 | |
michael@0 | 25 | // Fill in some values. |
michael@0 | 26 | let usernameValue = "User " + Math.random(); |
michael@0 | 27 | yield setInputValue(browser, {id: "username", value: usernameValue}); |
michael@0 | 28 | yield setInputValue(browser, {id: "passwd", value: PASS}); |
michael@0 | 29 | |
michael@0 | 30 | // Close and restore the tab. |
michael@0 | 31 | gBrowser.removeTab(tab); |
michael@0 | 32 | tab = ss.undoCloseTab(window, 0); |
michael@0 | 33 | browser = tab.linkedBrowser; |
michael@0 | 34 | yield promiseTabRestored(tab); |
michael@0 | 35 | |
michael@0 | 36 | // Check that password fields aren't saved/restored. |
michael@0 | 37 | let username = yield getInputValue(browser, {id: "username"}); |
michael@0 | 38 | is(username, usernameValue, "username was saved/restored"); |
michael@0 | 39 | let passwd = yield getInputValue(browser, {id: "passwd"}); |
michael@0 | 40 | is(passwd, "", "password wasn't saved/restored"); |
michael@0 | 41 | |
michael@0 | 42 | // Write to disk and read our file. |
michael@0 | 43 | yield SessionSaver.run(); |
michael@0 | 44 | let path = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js"); |
michael@0 | 45 | let data = yield OS.File.read(path); |
michael@0 | 46 | let state = new TextDecoder().decode(data); |
michael@0 | 47 | |
michael@0 | 48 | // Ensure that sessionstore.js doesn't contain our password. |
michael@0 | 49 | is(state.indexOf(PASS), -1, "password has not been written to disk"); |
michael@0 | 50 | |
michael@0 | 51 | // Cleanup. |
michael@0 | 52 | gBrowser.removeTab(tab); |
michael@0 | 53 | }); |