Bug 664324 - [session restore cleanup] Remove trailing whitespace; r=zpao

This commit is contained in:
Tim Taubert 2012-05-25 23:39:22 +02:00
Родитель 51f70a1731
Коммит 94ec7ae1dc
42 изменённых файлов: 235 добавлений и 235 удалений

Просмотреть файл

@ -40,14 +40,14 @@ window.onload = function() {
sessionData.dispatchEvent(event);
initTreeView();
document.getElementById("errorTryAgain").focus();
};
function initTreeView() {
var tabList = document.getElementById("tabList");
var winLabel = tabList.getAttribute("_window_label");
gTreeData = [];
gStateObject.windows.forEach(function(aWinData, aIx) {
var winState = {
@ -73,7 +73,7 @@ function initTreeView() {
for each (var tab in winState.tabs)
gTreeData.push(tab);
}, this);
tabList.view = treeView;
tabList.view.selection.select(0);
}
@ -82,7 +82,7 @@ function initTreeView() {
function restoreSession() {
document.getElementById("errorTryAgain").disabled = true;
// remove all unselected tabs from the state before restoring it
var ix = gStateObject.windows.length - 1;
for (var t = gTreeData.length - 1; t >= 0; t--) {
@ -99,10 +99,10 @@ function restoreSession() {
}
}
var stateString = JSON.stringify(gStateObject);
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var top = getBrowserWindow();
// if there's only this page open, reuse the window for restoring the session
if (top.gBrowser.tabs.length == 1) {
ss.setWindowState(top, stateString, true);
@ -114,7 +114,7 @@ function restoreSession() {
newWindow.addEventListener("load", function() {
newWindow.removeEventListener("load", arguments.callee, true);
ss.setWindowState(newWindow, stateString, true);
var tabbrowser = top.gBrowser;
var tabIndex = tabbrowser.getBrowserIndexForDocument(document);
tabbrowser.removeTab(tabbrowser.tabs[tabIndex]);
@ -133,7 +133,7 @@ function onListClick(aEvent) {
// don't react to right-clicks
if (aEvent.button == 2)
return;
var row = {}, col = {};
treeView.treeBox.getCellAt(aEvent.clientX, aEvent.clientY, row, col, {});
if (col.value) {
@ -189,9 +189,9 @@ function toggleRowChecked(aIx) {
var item = gTreeData[aIx];
item.checked = !item.checked;
treeView.treeBox.invalidateRow(aIx);
function isChecked(aItem) aItem.checked;
if (treeView.isContainer(aIx)) {
// (un)check all tabs of this window as well
for each (var tab in item.tabs) {
@ -205,7 +205,7 @@ function toggleRowChecked(aIx) {
item.parent.tabs.some(isChecked) ? 0 : false;
treeView.treeBox.invalidateRow(gTreeData.indexOf(item.parent));
}
document.getElementById("errorTryAgain").disabled = !gTreeData.some(isChecked);
}
@ -213,14 +213,14 @@ function restoreSingleTab(aIx, aShifted) {
var tabbrowser = getBrowserWindow().gBrowser;
var newTab = tabbrowser.addTab();
var item = gTreeData[aIx];
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var tabState = gStateObject.windows[item.parent.ix]
.tabs[aIx - gTreeData.indexOf(item.parent) - 1];
// ensure tab would be visible on the tabstrip.
tabState.hidden = false;
ss.setTabState(newTab, JSON.stringify(tabState));
// respect the preference as to whether to select the tab (the Shift key inverses)
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
if (prefBranch.getBoolPref("browser.tabs.loadInBackground") != !aShifted)

Просмотреть файл

@ -29,15 +29,15 @@
<!-- PAGE CONTAINER (for styling purposes only) -->
<div id="errorPageContainer">
<!-- Error Title -->
<div id="errorTitle">
<h1 id="errorTitleText">&restorepage.errorTitle;</h1>
</div>
<!-- LONG CONTENT (the section most likely to require scrolling) -->
<div id="errorLongContent">
<!-- Short Description -->
<div id="errorShortDesc">
<p id="errorShortDescText">&restorepage.problemDesc;</p>

Просмотреть файл

@ -3,5 +3,5 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
* content/browser/aboutSessionRestore.xhtml (content/aboutSessionRestore.xhtml)
* content/browser/aboutSessionRestore.xhtml (content/aboutSessionRestore.xhtml)
* content/browser/aboutSessionRestore.js (content/aboutSessionRestore.js)

Просмотреть файл

@ -17,7 +17,7 @@ interface nsISessionStartup: nsISupports
readonly attribute jsval state;
/**
* Determine if session should be restored
* Determine if session should be restored
*/
boolean doRestore();

Просмотреть файл

@ -68,7 +68,7 @@ interface nsISessionStore : nsISupports
/**
* @param aWindow is the browser window whose state is to be returned.
*
*
* @returns a JSON string representing a session state with only one window.
*/
AString getWindowState(in nsIDOMWindow aWindow);
@ -82,7 +82,7 @@ interface nsISessionStore : nsISupports
/**
* @param aTab is the tabbrowser tab whose state is to be returned.
*
*
* @returns a JSON string representing the state of the tab
* (note: doesn't contain cookies - if you need them, use getWindowState instead).
*/
@ -160,7 +160,7 @@ interface nsISessionStore : nsISupports
/**
* @param aWindow is the window to get the value for.
* @param aKey is the value's name.
*
*
* @returns A string value or an empty string if none is set.
*/
AString getWindowValue(in nsIDOMWindow aWindow, in AString aKey);
@ -171,7 +171,7 @@ interface nsISessionStore : nsISupports
* @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects).
*/
void setWindowValue(in nsIDOMWindow aWindow, in AString aKey, in AString aStringValue);
/**
* @param aWindow is the browser window to get the value for.
* @param aKey is the value's name.
@ -181,7 +181,7 @@ interface nsISessionStore : nsISupports
/**
* @param aTab is the tabbrowser tab to get the value for.
* @param aKey is the value's name.
*
*
* @returns A string value or an empty string if none is set.
*/
AString getTabValue(in nsIDOMNode aTab, in AString aKey);

Просмотреть файл

@ -35,7 +35,7 @@ let DocumentUtils = {
let node;
let ret = {id: {}, xpath: {}};
// Limit the number of XPath expressions for performance reasons. See
// bug 477564.
const MAX_TRAVERSED_XPATHS = 100;
@ -121,7 +121,7 @@ let DocumentUtils = {
if ("xpath" in aData) {
for each (let [xpath, value] in Iterator(aData.xpath)) {
let node = XPathGenerator.resolve(aDocument, xpath);
if (node) {
this.restoreFormValue(node, value, aDocument);
}
@ -131,7 +131,7 @@ let DocumentUtils = {
if ("id" in aData) {
for each (let [id, value] in Iterator(aData.id)) {
let node = aDocument.getElementById(id);
if (node) {
this.restoreFormValue(node, value, aDocument);
}
@ -159,7 +159,7 @@ let DocumentUtils = {
aDocument = aDocument || aNode.ownerDocument;
let eventType;
if (typeof aValue == "string" && aNode.type != "file") {
// Don't dispatch an input event if there is no change.
if (aNode.value == aValue) {
@ -173,7 +173,7 @@ let DocumentUtils = {
if (aNode.checked == aValue) {
return;
}
aNode.checked = aValue;
eventType = "change";
} else if (typeof aValue == "number") {
@ -183,11 +183,11 @@ let DocumentUtils = {
if (aNode.selectedIndex == aValue) {
return;
}
if (aValue < aNode.options.length) {
aNode.selectedIndex = aValue;
eventType = "change";
}
}
} else if (aValue && aValue.selectedIndex >= 0 && aValue.value) {
// handle select new format
@ -212,7 +212,7 @@ let DocumentUtils = {
Array.forEach(aNode.options, function(opt, index) {
// don't worry about malformed options with same values
opt.selected = aValue.indexOf(opt.value) > -1;
// Only fire the event here if this wasn't selected by default
if (!opt.defaultSelected) {
eventType = "change";

Просмотреть файл

@ -16,18 +16,18 @@ let XPathGenerator = {
// have we reached the document node already?
if (!aNode.parentNode)
return "";
// Access localName, namespaceURI just once per node since it's expensive.
let nNamespaceURI = aNode.namespaceURI;
let nLocalName = aNode.localName;
let prefix = this.namespacePrefixes[nNamespaceURI] || null;
let tag = (prefix ? prefix + ":" : "") + this.escapeName(nLocalName);
// stop once we've found a tag with an ID
if (aNode.id)
return "//" + tag + "[@id=" + this.quoteArgument(aNode.id) + "]";
// count the number of previous sibling nodes of the same tag
// (and possible also the same name)
let count = 0;
@ -36,7 +36,7 @@ let XPathGenerator = {
if (n.localName == nLocalName && n.namespaceURI == nNamespaceURI &&
(!nName || n.name == nName))
count++;
// recurse until hitting either the document node or an ID'd node
return this.generate(aNode.parentNode) + "/" + tag +
(nName ? "[@name=" + this.quoteArgument(nName) + "]" : "") +
@ -90,7 +90,7 @@ let XPathGenerator = {
ignoreTypes.join("' or translate(@type, " + toLowerCase + ")='") + "')";
let formNodesXPath = "//textarea|//select|//xhtml:textarea|//xhtml:select|" +
"//input[" + ignore + "]|//xhtml:input[" + ignore + "]";
delete this.restorableFormNodes;
return (this.restorableFormNodes = formNodesXPath);
}

Просмотреть файл

@ -1,4 +1,4 @@
/*
/*
# 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/.
@ -6,28 +6,28 @@
/**
# * Session Storage and Restoration
# *
# *
# * Overview
# * This service reads user's session file at startup, and makes a determination
# * as to whether the session should be restored. It will restore the session
# * This service reads user's session file at startup, and makes a determination
# * as to whether the session should be restored. It will restore the session
# * under the circumstances described below. If the auto-start Private Browsing
# * mode is active, however, the session is never restored.
# *
# *
# * Crash Detection
# * The session file stores a session.state property, that
# * indicates whether the browser is currently running. When the browser shuts
# * The session file stores a session.state property, that
# * indicates whether the browser is currently running. When the browser shuts
# * down, the field is changed to "stopped". At startup, this field is read, and
# * if its value is "running", then it's assumed that the browser had previously
# * crashed, or at the very least that something bad happened, and that we should
# * restore the session.
# *
# *
# * Forced Restarts
# * In the event that a restart is required due to application update or extension
# * installation, set the browser.sessionstore.resume_session_once pref to true,
# * and the session will be restored the next time the browser starts.
# *
# *
# * Always Resume
# * This service will always resume the session if the integer pref
# * This service will always resume the session if the integer pref
# * browser.startup.page is set to 3.
*/
@ -161,11 +161,11 @@ SessionStartup.prototype = {
*/
observe: function sss_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "app-startup":
case "app-startup":
Services.obs.addObserver(this, "final-ui-startup", true);
Services.obs.addObserver(this, "quit-application", true);
break;
case "final-ui-startup":
case "final-ui-startup":
Services.obs.removeObserver(this, "final-ui-startup");
Services.obs.removeObserver(this, "quit-application");
this.init();
@ -206,7 +206,7 @@ SessionStartup.prototype = {
var wType = aWindow.document.documentElement.getAttribute("windowtype");
if (wType != "navigator:browser")
return;
/**
* Note: this relies on the fact that nsBrowserContentHandler will return
* a different value the first time its getter is called after an update,

Просмотреть файл

@ -15,17 +15,17 @@
<input type="radio" name="group" checked> Radio 3
<h3>Selects</h3>
<select name="any">
<option value="1"> Select 1
<option value="some"> Select 2
<select name="any">
<option value="1"> Select 1
<option value="some"> Select 2
<option>Select 3
</select>
<select multiple="multiple">
<select multiple="multiple">
<option value=1> Multi-select 1
<option value=2> Multi-select 2
<option value=2> Multi-select 2
<option value=3> Multi-select 3
<option value=4> Multi-select 4
</select>
</select>
<h3>Text Areas</h3>
<textarea name="testarea"></textarea>

Просмотреть файл

@ -4,30 +4,30 @@
function test() {
/** Test for Bug 339445 **/
waitForExplicitFinish();
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_339445_sample.html";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let doc = tab.linkedBrowser.contentDocument;
is(doc.getElementById("storageTestItem").textContent, "PENDING",
"sessionStorage value has been set");
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let doc2 = tab2.linkedBrowser.contentDocument;
is(doc2.getElementById("storageTestItem").textContent, "SUCCESS",
"sessionStorage value has been duplicated");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, true);
}, true);

Просмотреть файл

@ -4,7 +4,7 @@
function test() {
/** Test for Bug 345898 **/
function test(aLambda) {
try {
aLambda();

Просмотреть файл

@ -17,7 +17,7 @@ function test() {
file.append("346337_test2.file");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
var filePath2 = file.path;
let fieldList = {
"//input[@name='input']": Date.now().toString(),
"//input[@name='spaced 1']": Math.random().toString(),
@ -35,13 +35,13 @@ function test() {
"//input[@type='file'][1]": [filePath1],
"//input[@type='file'][2]": [filePath1, filePath2]
};
function getElementByXPath(aTab, aQuery) {
let doc = aTab.linkedBrowser.contentDocument;
let xptype = Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE;
return doc.evaluate(aQuery, doc, null, xptype, null).singleNodeValue;
}
function setFormValue(aTab, aQuery, aValue) {
let node = getElementByXPath(aTab, aQuery);
if (typeof aValue == "string")
@ -56,7 +56,7 @@ function test() {
Array.forEach(node.options, function(aOpt, aIx)
(aOpt.selected = aValue.indexOf(aIx) > -1));
}
function compareFormValue(aTab, aQuery, aValue) {
let node = getElementByXPath(aTab, aQuery);
if (!node)
@ -77,14 +77,14 @@ function test() {
return Array.every(node.options, function(aOpt, aIx)
(aValue.indexOf(aIx) > -1) == aOpt.selected);
}
// test setup
let tabbrowser = gBrowser;
waitForExplicitFinish();
// make sure we don't save form data at all (except for tab duplication)
gPrefService.setIntPref("browser.sessionstore.privacy_level", 2);
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_346337_sample.html";
let tab = tabbrowser.addTab(testURL);
@ -92,18 +92,18 @@ function test() {
this.removeEventListener("load", arguments.callee, true);
for (let xpath in fieldList)
setFormValue(tab, xpath, fieldList[xpath]);
let tab2 = tabbrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
for (let xpath in fieldList)
ok(compareFormValue(tab2, xpath, fieldList[xpath]),
"The value for \"" + xpath + "\" was correctly restored");
// clean up
tabbrowser.removeTab(tab2);
tabbrowser.removeTab(tab);
tab = undoCloseTab();
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
@ -111,7 +111,7 @@ function test() {
if (fieldList[xpath])
ok(!compareFormValue(tab, xpath, fieldList[xpath]),
"The value for \"" + xpath + "\" was correctly discarded");
if (gPrefService.prefHasUserValue("browser.sessionstore.privacy_level"))
gPrefService.clearUserPref("browser.sessionstore.privacy_level");
// undoCloseTab can reuse a single blank tab, so we have to

Просмотреть файл

@ -15,17 +15,17 @@
<input type="radio" name="group" checked> Radio 3
<h3>Selects</h3>
<select name="any">
<option value="1"> Select 1
<option value="some"> Select 2
<select name="any">
<option value="1"> Select 1
<option value="some"> Select 2
<option>Select 3
</select>
<select multiple="multiple">
<select multiple="multiple">
<option value=1> Multi-select 1
<option value=2> Multi-select 2
<option value=2> Multi-select 2
<option value=3> Multi-select 3
<option value=4> Multi-select 4
</select>
</select>
<h3>Text Areas</h3>
<textarea name="testarea"></textarea>

Просмотреть файл

@ -1,6 +1,6 @@
function test() {
/** Test for Bug 350525 **/
function test(aLambda) {
try {
return aLambda() || true;
@ -16,22 +16,22 @@ function test() {
////////////////////////////
let key = "Unique name: " + Date.now();
let value = "Unique value: " + Math.random();
// test adding
ok(test(function() ss.setWindowValue(window, key, value)), "set a window value");
// test retrieving
is(ss.getWindowValue(window, key), value, "stored window value matches original");
// test deleting
// test deleting
ok(test(function() ss.deleteWindowValue(window, key)), "delete the window value");
// value should not exist post-delete
is(ss.getWindowValue(window, key), "", "window value was deleted");
// test deleting a non-existent value
ok(test(function() ss.deleteWindowValue(window, key)), "delete non-existent window value");
/////////////////////////
// setTabValue, et al. //
/////////////////////////
@ -39,35 +39,35 @@ function test() {
value = "Unique value: " + Date.now();
let tab = gBrowser.addTab();
tab.linkedBrowser.stop();
// test adding
ok(test(function() ss.setTabValue(tab, key, value)), "store a tab value");
// test retrieving
is(ss.getTabValue(tab, key), value, "stored tab value match original");
// test deleting
// test deleting
ok(test(function() ss.deleteTabValue(tab, key)), "delete the tab value");
// value should not exist post-delete
is(ss.getTabValue(tab, key), "", "tab value was deleted");
// test deleting a non-existent value
ok(test(function() ss.deleteTabValue(tab, key)), "delete non-existent tab value");
// clean up
gBrowser.removeTab(tab);
/////////////////////////////////////
// getClosedTabCount, undoCloseTab //
/////////////////////////////////////
// get closed tab count
let count = ss.getClosedTabCount(window);
let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo");
ok(0 <= count && count <= max_tabs_undo,
"getClosedTabCount returns zero or at most max_tabs_undo");
// create a new tab
let testURL = "about:";
tab = gBrowser.addTab(testURL);
@ -75,22 +75,22 @@ function test() {
this.removeEventListener("load", arguments.callee, true);
// make sure that the next closed tab will increase getClosedTabCount
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
// remove tab
gBrowser.removeTab(tab);
// getClosedTabCount
var newcount = ss.getClosedTabCount(window);
ok(newcount > count, "after closing a tab, getClosedTabCount has been incremented");
// undoCloseTab
tab = test(function() ss.undoCloseTab(window, 0));
ok(tab, "undoCloseTab doesn't throw")
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
is(this.currentURI.spec, testURL, "correct tab was reopened");
// clean up
if (gPrefService.prefHasUserValue("browser.sessionstore.max_tabs_undo"))
gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");

Просмотреть файл

@ -6,29 +6,29 @@ function test() {
/** Test for Bug 367052 **/
waitForExplicitFinish();
// make sure that the next closed tab will increase getClosedTabCount
let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo");
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
let closedTabCount = ss.getClosedTabCount(window);
// restore a blank tab
let tab = gBrowser.addTab("about:");
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let history = tab.linkedBrowser.webNavigation.sessionHistory;
ok(history.count >= 1, "the new tab does have at least one history entry");
ss.setTabState(tab, JSON.stringify({ entries: [] }));
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
ok(history.count == 0, "the tab was restored without any history whatsoever");
gBrowser.removeTab(tab);
ok(ss.getClosedTabCount(window) == closedTabCount,
"The closed blank tab wasn't added to Recently Closed Tabs");
// clean up
if (gPrefService.prefHasUserValue("browser.sessionstore.max_tabs_undo"))
gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");

Просмотреть файл

@ -2,14 +2,14 @@ function test() {
/** Test for Bug 393716 **/
waitForExplicitFinish();
/////////////////
// getTabState //
/////////////////
let key = "Unique key: " + Date.now();
let value = "Unique value: " + Math.random();
let testURL = "about:config";
// create a new tab
let tab = gBrowser.addTab(testURL);
ss.setTabValue(tab, key, value);
@ -18,7 +18,7 @@ function test() {
// get the tab's state
let state = ss.getTabState(tab);
ok(state, "get the tab's state");
// verify the tab state's integrity
state = JSON.parse(state);
ok(state instanceof Object && state.entries instanceof Array && state.entries.length > 0,
@ -27,11 +27,11 @@ function test() {
"Got the expected state object (test URL)");
ok(state.extData && state.extData[key] == value,
"Got the expected state object (test manually set tab value)");
// clean up
gBrowser.removeTab(tab);
}, true);
//////////////////////////////////
// setTabState and duplicateTab //
//////////////////////////////////
@ -39,7 +39,7 @@ function test() {
let value2 = "Value " + Math.random();
let value3 = "Another value: " + Date.now();
let state = { entries: [{ url: testURL }], extData: { key2: value2 } };
// create a new tab
let tab2 = gBrowser.addTab();
// set the tab's state
@ -49,15 +49,15 @@ function test() {
// verify the correctness of the restored tab
ok(ss.getTabValue(tab2, key2) == value2 && this.currentURI.spec == testURL,
"the tab's state was correctly restored");
// add text data
let textbox = this.contentDocument.getElementById("textbox");
textbox.value = value3;
// duplicate the tab
let duplicateTab = ss.duplicateTab(window, tab2);
gBrowser.removeTab(tab2);
duplicateTab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
// verify the correctness of the duplicated tab
@ -65,7 +65,7 @@ function test() {
"correctly duplicated the tab's state");
let textbox = this.contentDocument.getElementById("textbox");
is(textbox.value, value3, "also duplicated text data");
// clean up
gBrowser.removeTab(duplicateTab);
finish();

Просмотреть файл

@ -74,7 +74,7 @@ function test() {
}
]
};
// set browser to test state
ss.setBrowserState(JSON.stringify(testState));
@ -93,7 +93,7 @@ function test() {
is(win.selected, 1, "Selected tab has changed");
is(win.title, REMEMBER, "The window title was correctly updated");
// Test more complicated case
// Test more complicated case
win = closedWindowData[1];
is(win.tabs.length, 3, "2 tabs were removed");
is(countOpenTabsByTitle(win.tabs, FORGET), 0,

Просмотреть файл

@ -4,14 +4,14 @@
function test() {
/** Test for Bug 408470 **/
waitForExplicitFinish();
let pendingCount = 1;
let rootDir = getRootDirectory(gTestPath);
let testUrl = rootDir + "browser_408470_sample.html";
let tab = gBrowser.addTab(testUrl);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
// enable all stylesheets and verify that they're correctly persisted
@ -26,18 +26,18 @@ function test() {
let states = Array.map(newTab.linkedBrowser.contentDocument.styleSheets,
function(aSS) !aSS.disabled);
let correct = states.indexOf(true) == aIx && states.indexOf(true, aIx + 1) == -1;
if (/^fail_/.test(ssTitle))
ok(!correct, "didn't restore stylesheet " + ssTitle);
else
ok(correct, "restored stylesheet " + ssTitle);
gBrowser.removeTab(newTab);
if (--pendingCount == 0)
finish();
}, true);
});
// disable all styles and verify that this is correctly persisted
tab.linkedBrowser.markupDocumentViewer.authorStyleDisabled = true;
let newTab = gBrowser.duplicateTab(tab);
@ -45,12 +45,12 @@ function test() {
newTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
is(newTab.linkedBrowser.markupDocumentViewer.authorStyleDisabled, true,
"disabled all stylesheets");
gBrowser.removeTab(newTab);
if (--pendingCount == 0)
finish();
}, true);
gBrowser.removeTab(tab);
}, true);
}

Просмотреть файл

@ -4,34 +4,34 @@
function test() {
/** Test for Bug 447951 **/
waitForExplicitFinish();
const baseURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_447951_sample.html#";
let tab = gBrowser.addTab();
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
let tabState = { entries: [] };
let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
for (let i = 0; i < max_entries; i++)
tabState.entries.push({ url: baseURL + i });
ss.setTabState(tab, JSON.stringify(tabState));
tab.addEventListener("SSTabRestored", function(aEvent) {
tab.removeEventListener("SSTabRestored", arguments.callee, false);
tabState = JSON.parse(ss.getTabState(tab));
is(tabState.entries.length, max_entries, "session history filled to the limit");
is(tabState.entries[0].url, baseURL + 0, "... but not more");
// visit yet another anchor (appending it to session history)
let doc = tab.linkedBrowser.contentDocument;
let event = doc.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, doc.defaultView, 1,
0, 0, 0, 0, false, false, false, false, 0, null);
doc.querySelector("a").dispatchEvent(event);
executeSoon(function() {
tabState = JSON.parse(ss.getTabState(tab));
is(tab.linkedBrowser.currentURI.spec, baseURL + "end",
@ -40,7 +40,7 @@ function test() {
"... and ignored");
is(tabState.entries[0].url, baseURL + 1,
"... and the first item was removed");
// clean up
gBrowser.removeTab(tab);
finish();

Просмотреть файл

@ -4,17 +4,17 @@
function test() {
/** Test for Bug 454908 **/
waitForExplicitFinish();
let fieldValues = {
username: "User " + Math.random(),
passwd: "pwd" + Date.now()
};
// make sure we do save form data
gPrefService.setIntPref("browser.sessionstore.privacy_level", 0);
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_454908_sample.html";
let tab = gBrowser.addTab(testURL);
@ -23,9 +23,9 @@ function test() {
let doc = tab.linkedBrowser.contentDocument;
for (let id in fieldValues)
doc.getElementById(id).value = fieldValues[id];
gBrowser.removeTab(tab);
tab = undoCloseTab();
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
@ -37,7 +37,7 @@ function test() {
else
is(node.value, fieldValues[id], "username was saved/restored");
}
// clean up
if (gPrefService.prefHasUserValue("browser.sessionstore.privacy_level"))
gPrefService.clearUserPref("browser.sessionstore.privacy_level");

Просмотреть файл

@ -4,12 +4,12 @@
function test() {
/** Test for Bug 456342 **/
waitForExplicitFinish();
// make sure we do save form data
gPrefService.setIntPref("browser.sessionstore.privacy_level", 0);
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_456342_sample.xhtml";
let tab = gBrowser.addTab(testURL);
@ -24,10 +24,10 @@ function test() {
formEls[i].value = expectedValue;
gBrowser.removeTab(tab);
let undoItems = JSON.parse(ss.getClosedTabData(window));
let savedFormData = undoItems[0].state.entries[0].formdata;
let countGood = 0, countBad = 0;
for each (let value in savedFormData.id) {
if (value == expectedValue)
@ -44,7 +44,7 @@ function test() {
is(countGood, 4, "Saved text for non-standard input fields");
is(countBad, 0, "Didn't save text for ignored field types");
// clean up
if (gPrefService.prefHasUserValue("browser.sessionstore.privacy_level"))
gPrefService.clearUserPref("browser.sessionstore.privacy_level");

Просмотреть файл

@ -23,7 +23,7 @@
document.getElementsByTagName("iframe")[0].onload =
function() { documentInjected = true; };
frames[0].location = "browser_459906_empty.html";
// ... and ensure that it has time to load
for (var c = 0; !documentInjected && c < 20; c++) {
var r = new XMLHttpRequest();

Просмотреть файл

@ -4,9 +4,9 @@
function test() {
/** Test for Bug 463205 **/
waitForExplicitFinish();
let rootDir = "http://mochi.test:8888/browser/browser/components/sessionstore/test/";
let testURL = rootDir + "browser_463205_sample.html";
@ -18,7 +18,7 @@ function test() {
let frame3URL = "data:text/html,mark2";
let frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
// wait for all frames to load completely
@ -50,15 +50,15 @@ function test() {
return;
}
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
function typeText(aTextField, aValue) {
aTextField.value = aValue;
let event = aTextField.ownerDocument.createEvent("UIEvents");
event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0);
aTextField.dispatchEvent(event);
}
let uniqueValue = "Unique: " + Math.random();
let win = tab.linkedBrowser.contentWindow;
typeText(win.frames[0].document.getElementById("original"), uniqueValue);
@ -112,11 +112,11 @@ function test() {
"subframes must match URL to get text restored");
is(win.frames[1].document.getElementById("original").value, uniqueValue,
"text still gets restored for all other subframes");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, true);
}, true);

Просмотреть файл

@ -11,7 +11,7 @@
<script type="application/javascript">
frames[2].addEventListener("DOMContentLoaded", function() {
frames[2].removeEventListener("DOMContentLoaded", arguments.callee, false);
if (frames[2].document.location.href == "data:text/html,mark1") {
frames[2].document.location = "data:text/html,mark2";
}

Просмотреть файл

@ -4,12 +4,12 @@
function test() {
/** Test for Bug 463206 **/
waitForExplicitFinish();
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_463206_sample.html";
var frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
@ -17,20 +17,20 @@ function test() {
if (frameCount++ < 5)
return;
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
function typeText(aTextField, aValue) {
aTextField.value = aValue;
let event = aTextField.ownerDocument.createEvent("UIEvents");
event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0);
aTextField.dispatchEvent(event);
}
let doc = tab.linkedBrowser.contentDocument;
typeText(doc.getElementById("out1"), Date.now());
typeText(doc.getElementsByName("1|#out2")[0], Math.random());
typeText(doc.defaultView.frames[0].frames[1].document.getElementById("in1"), new Date());
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
@ -53,11 +53,11 @@ function test() {
// "id prefixes aren't mixed up");
is(win.frames[1].frames[0].document.getElementById("in1").value, "",
"id prefixes aren't mixed up");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, true);
}, true);

Просмотреть файл

@ -46,7 +46,7 @@ function test() {
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
test_state.windows[0]._closedTabs.length);
ss.setWindowState(newWin, JSON.stringify(test_state), true);
let closedTabs = JSON.parse(ss.getClosedTabData(newWin));
is(closedTabs.length, test_state.windows[0]._closedTabs.length,
"Closed tab list has the expected length");

Просмотреть файл

@ -9,7 +9,7 @@
var targetUrl = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_464620_xd.html";
var firstPass;
function setup() {
if (firstPass !== undefined)
return;
@ -19,7 +19,7 @@
}
frames[1].location = targetUrl;
}
function step() {
var x = frames[0].document.getElementById("x");
if (x.value == "")
@ -27,15 +27,15 @@
x.style.display = "none";
frames[0].document.designMode = "on";
}
function xss() {
step();
var documentInjected = false;
document.getElementsByTagName("iframe")[0].onload =
function() { documentInjected = true; };
frames[0].location = targetUrl;
for (var c = 0; !documentInjected && c < 20; c++) {
var r = new XMLHttpRequest();
r.open("GET", location.href, false);
@ -43,7 +43,7 @@
r.send(null);
}
document.getElementById("state").textContent = "done";
var event = document.createEvent("MessageEvent");
event.initMessageEvent("464620_a", true, false, "done", location.href, "", window);
document.dispatchEvent(event);

Просмотреть файл

@ -4,12 +4,12 @@
function test() {
/** Test for Bug 464620 (injection on input) **/
waitForExplicitFinish();
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_464620_a.html";
var frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
@ -17,14 +17,14 @@ function test() {
if (frameCount++ < 4)
return;
this.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("464620_a", function(aEvent) {
tab2.linkedBrowser.removeEventListener("464620_a", arguments.callee, true);
is(aEvent.data, "done", "XSS injection was attempted");
// let form restoration complete and take into account the
// setTimeout(..., 0) in sss_restoreDocument_proxy
executeSoon(function() {
@ -34,11 +34,11 @@ function test() {
"cross domain document was loaded");
ok(!/XXX/.test(win.frames[0].document.body.innerHTML),
"no content was injected");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, 0);
});

Просмотреть файл

@ -10,7 +10,7 @@
var targetUrl = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_464620_xd.html";
var firstPass;
function setup() {
if (firstPass !== undefined)
return;
@ -21,25 +21,25 @@
}
frames[2].location = targetUrl;
}
function step() {
frames[0].document.designMode = "on";
if (firstPass)
return;
var body = frames[0].document.body;
body.addEventListener("DOMNodeInserted", function() {
body.removeEventListener("DOMNodeInserted", arguments.callee, true);
xss();
}, true);
}
function xss() {
var documentInjected = false;
document.getElementsByTagName("iframe")[1].onload =
function() { documentInjected = true; };
frames[1].location = targetUrl;
for (var c = 0; !documentInjected && c < 20; c++) {
var r = new XMLHttpRequest();
r.open("GET", location.href, false);
@ -47,7 +47,7 @@
r.send(null);
}
document.getElementById("state").textContent = "done";
var event = document.createEvent("MessageEvent");
event.initMessageEvent("464620_b", true, false, "done", location.href, "", window);
document.dispatchEvent(event);

Просмотреть файл

@ -4,12 +4,12 @@
function test() {
/** Test for Bug 464620 (injection on DOM node insertion) **/
waitForExplicitFinish();
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_464620_b.html";
var frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
@ -17,14 +17,14 @@ function test() {
if (frameCount++ < 6)
return;
this.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("464620_b", function(aEvent) {
tab2.linkedBrowser.removeEventListener("464620_b", arguments.callee, true);
is(aEvent.data, "done", "XSS injection was attempted");
// let form restoration complete and take into account the
// setTimeout(..., 0) in sss_restoreDocument_proxy
executeSoon(function() {
@ -34,11 +34,11 @@ function test() {
"cross domain document was loaded");
ok(!/XXX/.test(win.frames[1].document.body.innerHTML),
"no content was injected");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, 0);
});

Просмотреть файл

@ -4,32 +4,32 @@
function test() {
/** Test for Bug 465215 **/
waitForExplicitFinish();
let uniqueName = "bug 465215";
let uniqueValue1 = "as good as unique: " + Date.now();
let uniqueValue2 = "as good as unique: " + Math.random();
// set a unique value on a new, blank tab
let tab1 = gBrowser.addTab();
tab1.linkedBrowser.addEventListener("load", function() {
tab1.linkedBrowser.removeEventListener("load", arguments.callee, true);
ss.setTabValue(tab1, uniqueName, uniqueValue1);
// duplicate the tab with that value
let tab2 = ss.duplicateTab(window, tab1);
is(ss.getTabValue(tab2, uniqueName), uniqueValue1, "tab value was duplicated");
ss.setTabValue(tab2, uniqueName, uniqueValue2);
isnot(ss.getTabValue(tab1, uniqueName), uniqueValue2, "tab values aren't sync'd");
// overwrite the tab with the value which should remove it
ss.setTabState(tab1, JSON.stringify({ entries: [] }));
tab1.linkedBrowser.addEventListener("load", function() {
tab1.linkedBrowser.removeEventListener("load", arguments.callee, true);
is(ss.getTabValue(tab1, uniqueName), "", "tab value was cleared");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab1);

Просмотреть файл

@ -4,7 +4,7 @@
function test() {
/** Test for Bug 466937 **/
waitForExplicitFinish();
var file = Components.classes["@mozilla.org/file/directory_service;1"]
@ -13,17 +13,17 @@ function test() {
file.append("466937_test.file");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
let testPath = file.path;
let testURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_466937_sample.html";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
let doc = tab.linkedBrowser.contentDocument;
doc.getElementById("reverse_thief").value = "/home/user/secret2";
doc.getElementById("bystander").value = testPath;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
@ -34,11 +34,11 @@ function test() {
"text field value wasn't set to full file path");
is(doc.getElementById("bystander").value, testPath,
"normal case: file path was correctly preserved");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
}, true);
}, true);

Просмотреть файл

@ -5,7 +5,7 @@
function test() {
/** Test for Bug 477657 **/
waitForExplicitFinish();
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
newWin.addEventListener("load", function(aEvent) {
newWin.removeEventListener("load", arguments.callee, false);

Просмотреть файл

@ -4,11 +4,11 @@
function test() {
/** Test for Bug 485482 **/
waitForExplicitFinish();
let uniqueValue = Math.random();
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_485482_sample.html";
let tab = gBrowser.addTab(testURL);
@ -17,7 +17,7 @@ function test() {
let doc = tab.linkedBrowser.contentDocument;
doc.querySelector("input[type=text]").value = uniqueValue;
doc.querySelector("input[type=checkbox]").checked = true;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
@ -26,7 +26,7 @@ function test() {
"generated XPath expression was valid");
ok(doc.querySelector("input[type=checkbox]").checked,
"generated XPath expression was valid");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);

Просмотреть файл

@ -4,11 +4,11 @@
function test() {
/** Test for Bug 485563 **/
waitForExplicitFinish();
let uniqueValue = Math.random() + "\u2028Second line\u2029Second paragraph\u2027";
let tab = gBrowser.addTab();
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
@ -20,7 +20,7 @@ function test() {
ss.setTabState(tab, JSON.stringify(tabState));
is(ss.getTabValue(tab, "bug485563"), uniqueValue,
"unicode line separator was correctly preserved");
gBrowser.removeTab(tab);
finish();
}, true);

Просмотреть файл

@ -4,10 +4,10 @@
function test() {
/** Test for Bug 491577 **/
// test setup
waitForExplicitFinish();
const REMEMBER = Date.now(), FORGET = Math.random();
let test_state = {
windows: [ { tabs: [{ entries: [{ url: "http://example.com/" }] }], selected: 1 } ],
@ -64,10 +64,10 @@ function test() {
]
};
let remember_count = 1;
function countByTitle(aClosedWindowList, aTitle)
aClosedWindowList.filter(function(aData) aData.title == aTitle).length;
function testForError(aFunction) {
try {
aFunction();
@ -77,7 +77,7 @@ function test() {
return ex.name == "NS_ERROR_ILLEGAL_VALUE";
}
}
// open a window and add the above closed window list
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
newWin.addEventListener("load", function(aEvent) {
@ -85,7 +85,7 @@ function test() {
gPrefService.setIntPref("browser.sessionstore.max_windows_undo",
test_state._closedWindows.length);
ss.setWindowState(newWin, JSON.stringify(test_state), true);
let closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, test_state._closedWindows.length,
"Closed window list has the expected length");
@ -94,17 +94,17 @@ function test() {
"The correct amount of windows are to be forgotten");
is(countByTitle(closedWindows, REMEMBER), remember_count,
"Everything is set up.");
// all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
ok(testForError(function() ss.forgetClosedWindow(-1)),
"Invalid window for forgetClosedWindow throws");
ok(testForError(function() ss.forgetClosedWindow(test_state._closedWindows.length + 1)),
"Invalid window for forgetClosedWindow throws");
// Remove third window, then first window
ss.forgetClosedWindow(2);
ss.forgetClosedWindow(null);
closedWindows = JSON.parse(ss.getClosedWindowData());
is(closedWindows.length, remember_count,
"The correct amount of windows were removed");

Просмотреть файл

@ -9,7 +9,7 @@ function test() {
tab.linkedBrowser.stop();
let tabState = JSON.parse(ss.getTabState(tab));
is(tabState.disallow || "", "", "Everything is allowed per default");
// collect all permissions that can be set on a docShell (i.e. all
// attributes starting with "allow" such as "allowJavascript") and
// disallow them all, as SessionStore only remembers disallowed ones
@ -21,7 +21,7 @@ function test() {
docShell[attribute] = false;
}
}
// make sure that all available permissions have been remembered
tabState = JSON.parse(ss.getTabState(tab));
let disallow = tabState.disallow.split(",");
@ -30,6 +30,6 @@ function test() {
});
// IF A TEST FAILS, please add the missing permission's name (without the
// leading "allow") to nsSessionStore.js's CAPABILITIES array. Thanks.
gBrowser.removeTab(tab);
}

Просмотреть файл

@ -4,7 +4,7 @@
function test() {
/** Test for Bug 495495 **/
waitForExplicitFinish();
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no,toolbar=yes");

Просмотреть файл

@ -25,7 +25,7 @@ function test() {
return -1;
}
// delete existing sessionstore.js, to make sure we're not reading
// delete existing sessionstore.js, to make sure we're not reading
// the mtime of an old one initialy
let (sessionStoreJS = getSessionstoreFile()) {
if (sessionStoreJS.exists())
@ -62,7 +62,7 @@ function test() {
tab.linkedBrowser.contentWindow.scrollTo(1100, 1200);
setTimeout(function step2(e) {
let mtime2 = getSessionstorejsModificationTime();
is(mtime2, mtime1,
is(mtime2, mtime1,
"tab selection and scrolling: sessionstore.js not updated");
// ok, done, cleanup and finish

Просмотреть файл

@ -4,7 +4,7 @@
function test() {
/** Test for Bug 526613 **/
// test setup
waitForExplicitFinish();

Просмотреть файл

@ -12,7 +12,7 @@ function test() {
};
let pageData = {
url: "about:sessionrestore",
formdata: { id: { "sessionData": oldState } }
formdata: { id: { "sessionData": oldState } }
};
let state = { windows: [{ tabs: [{ entries: [pageData] }] }] };

Просмотреть файл

@ -36,7 +36,7 @@ function test() {
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);