2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-09-25 16:19:03 +00:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
/** Test for Bug 454908 **/
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-09-25 16:19:03 +00:00
|
|
|
waitForExplicitFinish();
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-09-25 16:19:03 +00:00
|
|
|
let fieldValues = {
|
|
|
|
username: "User " + Math.random(),
|
|
|
|
passwd: "pwd" + Date.now()
|
|
|
|
};
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-09-25 16:19:03 +00:00
|
|
|
// make sure we do save form data
|
|
|
|
gPrefService.setIntPref("browser.sessionstore.privacy_level", 0);
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2010-09-10 17:20:38 +00:00
|
|
|
let rootDir = getRootDirectory(gTestPath);
|
|
|
|
let testURL = rootDir + "browser_454908_sample.html";
|
2008-09-25 16:19:03 +00:00
|
|
|
let tab = gBrowser.addTab(testURL);
|
2013-11-23 20:13:15 +00:00
|
|
|
whenBrowserLoaded(tab.linkedBrowser, function() {
|
2008-09-25 16:19:03 +00:00
|
|
|
let doc = tab.linkedBrowser.contentDocument;
|
|
|
|
for (let id in fieldValues)
|
|
|
|
doc.getElementById(id).value = fieldValues[id];
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-09-25 16:19:03 +00:00
|
|
|
gBrowser.removeTab(tab);
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-11-04 08:18:39 +00:00
|
|
|
tab = undoCloseTab();
|
2013-11-23 20:13:15 +00:00
|
|
|
whenTabRestored(tab, function() {
|
2008-09-25 16:19:03 +00:00
|
|
|
let doc = tab.linkedBrowser.contentDocument;
|
|
|
|
for (let id in fieldValues) {
|
|
|
|
let node = doc.getElementById(id);
|
|
|
|
if (node.type == "password")
|
|
|
|
is(node.value, "", "password wasn't saved/restored");
|
|
|
|
else
|
|
|
|
is(node.value, fieldValues[id], "username was saved/restored");
|
|
|
|
}
|
2012-05-25 21:39:22 +00:00
|
|
|
|
2008-09-25 16:19:03 +00:00
|
|
|
// clean up
|
2009-10-29 13:44:10 +00:00
|
|
|
if (gPrefService.prefHasUserValue("browser.sessionstore.privacy_level"))
|
|
|
|
gPrefService.clearUserPref("browser.sessionstore.privacy_level");
|
2008-11-04 08:18:39 +00:00
|
|
|
// undoCloseTab can reuse a single blank tab, so we have to
|
|
|
|
// make sure not to close the window when closing our last tab
|
2010-03-22 16:04:18 +00:00
|
|
|
if (gBrowser.tabs.length == 1)
|
2008-11-04 08:18:39 +00:00
|
|
|
gBrowser.addTab();
|
2008-09-25 16:19:03 +00:00
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
finish();
|
2013-11-23 20:13:15 +00:00
|
|
|
});
|
|
|
|
});
|
2008-09-25 16:19:03 +00:00
|
|
|
}
|