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