зеркало из https://github.com/mozilla/pjs.git
Bug 507784 - Some session restore tests don't correctly remove event listeners. r=trivial-cleanup
This commit is contained in:
Родитель
6bfb40e73d
Коммит
dd1db45dac
|
@ -44,12 +44,14 @@ function test() {
|
|||
|
||||
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");
|
||||
|
|
|
@ -99,11 +99,13 @@ function test() {
|
|||
"browser/components/sessionstore/test/browser/browser_346337_sample.html";
|
||||
let tab = tabbrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
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");
|
||||
|
@ -114,6 +116,7 @@ function test() {
|
|||
|
||||
tab = undoCloseTab();
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
for (let xpath in fieldList)
|
||||
if (fieldList[xpath])
|
||||
ok(!compareFormValue(tab, xpath, fieldList[xpath]),
|
||||
|
|
|
@ -74,6 +74,7 @@ function test() {
|
|||
let testURL = "about:";
|
||||
tab = tabbrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
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);
|
||||
|
||||
|
@ -89,6 +90,7 @@ function test() {
|
|||
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
|
||||
|
|
|
@ -248,6 +248,7 @@ function test() {
|
|||
// The previously closed window should be restored
|
||||
newWin = openDialog(location, "_blank", CHROME_FEATURES);
|
||||
newWin.addEventListener("load", function() {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1,
|
||||
"Restored window in-session with otherpopup windows around");
|
||||
|
@ -281,6 +282,7 @@ function test() {
|
|||
// The previously closed window should NOT be restored
|
||||
newWin = openDialog(location, "_blank", CHROME_FEATURES);
|
||||
newWin.addEventListener("load", function() {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
is(newWin.gBrowser.browsers.length, 1,
|
||||
"Did not restore in private browing mode");
|
||||
|
@ -293,6 +295,7 @@ function test() {
|
|||
|
||||
newWin = openDialog(location, "_blank", CHROME_FEATURES);
|
||||
newWin.addEventListener("load", function() {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1,
|
||||
"Restored after leaving private browsing again");
|
||||
|
@ -334,6 +337,7 @@ function test() {
|
|||
// open a new window the previously closed window should be restored to
|
||||
newWin = openDialog(location, "_blank", CHROME_FEATURES);
|
||||
newWin.addEventListener("load", function() {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
is(newWin.gBrowser.browsers.length, TEST_URLS.length + 1,
|
||||
"Restored window and associated tabs in session");
|
||||
|
@ -364,6 +368,7 @@ function test() {
|
|||
// gets a chance.
|
||||
let popup = openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[1]);
|
||||
popup.addEventListener("load", function() {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
is(popup.gBrowser.browsers.length, 1,
|
||||
"Did not restore the popup window (1)");
|
||||
popup.BrowserTryToCloseWindow();
|
||||
|
|
|
@ -57,6 +57,7 @@ function test() {
|
|||
|
||||
ss.setTabState(tab, "{ 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");
|
||||
|
||||
tabbrowser.removeTab(tab);
|
||||
|
|
|
@ -21,6 +21,7 @@ function test() {
|
|||
let tab = tabbrowser.addTab(testURL);
|
||||
ss.setTabValue(tab, key, value);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
// get the tab's state
|
||||
let state = ss.getTabState(tab);
|
||||
ok(state, "get the tab's state");
|
||||
|
@ -51,6 +52,7 @@ function test() {
|
|||
// set the tab's state
|
||||
ss.setTabState(tab2, state.toSource());
|
||||
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
// verify the correctness of the restored tab
|
||||
ok(ss.getTabValue(tab2, key2) == value2 && this.currentURI.spec == testURL,
|
||||
"the tab's state was correctly restored");
|
||||
|
@ -64,6 +66,7 @@ function test() {
|
|||
tabbrowser.removeTab(tab2);
|
||||
|
||||
duplicateTab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
// verify the correctness of the duplicated tab
|
||||
ok(ss.getTabValue(duplicateTab, key2) == value2 && this.currentURI.spec == testURL,
|
||||
"correctly duplicated the tab's state");
|
||||
|
|
|
@ -87,6 +87,7 @@ function test() {
|
|||
"The reopened window was removed from Recently Closed Windows");
|
||||
|
||||
newWin2.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
newWin2.gBrowser.addEventListener("SSTabRestored", function(aEvent) {
|
||||
newWin2.gBrowser.removeEventListener("SSTabRestored", arguments.callee, true);
|
||||
|
||||
|
@ -142,12 +143,14 @@ function test() {
|
|||
let url = "http://window" + windowsToOpen.length + ".example.com";
|
||||
let window = openDialog(location, "_blank", settings, url);
|
||||
window.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
window.gBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
// the window _should_ have state with a tab of url, but it doesn't
|
||||
// always happend before window.close(). addTab ensure we don't treat
|
||||
// this window as a stateless window
|
||||
window.gBrowser.addTab();
|
||||
window.gBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
executeSoon(function() {
|
||||
window.close();
|
||||
executeSoon(function() {
|
||||
|
|
|
@ -45,6 +45,7 @@ function test() {
|
|||
let tab = gBrowser.addTab(testUrl);
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
// enable all stylesheets and verify that they're correctly persisted
|
||||
Array.forEach(tab.linkedBrowser.contentDocument.styleSheets, function(aSS, aIx) {
|
||||
pendingCount++;
|
||||
|
@ -53,6 +54,7 @@ function test() {
|
|||
|
||||
let newTab = gBrowser.duplicateTab(tab);
|
||||
newTab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
let states = Array.map(newTab.linkedBrowser.contentDocument.styleSheets,
|
||||
function(aSS) !aSS.disabled);
|
||||
let correct = states.indexOf(true) == aIx && states.indexOf(true, aIx + 1) == -1;
|
||||
|
@ -72,6 +74,7 @@ function test() {
|
|||
tab.linkedBrowser.markupDocumentViewer.authorStyleDisabled = true;
|
||||
let newTab = gBrowser.duplicateTab(tab);
|
||||
newTab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
is(newTab.linkedBrowser.markupDocumentViewer.authorStyleDisabled, true,
|
||||
"disabled all stylesheets");
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ function test() {
|
|||
"browser/components/sessionstore/test/browser/browser_454908_sample.html";
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
for (let id in fieldValues)
|
||||
doc.getElementById(id).value = fieldValues[id];
|
||||
|
@ -59,6 +60,7 @@ function test() {
|
|||
|
||||
tab = undoCloseTab();
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
for (let id in fieldValues) {
|
||||
let node = doc.getElementById(id);
|
||||
|
|
|
@ -46,6 +46,7 @@ function test() {
|
|||
"browser/components/sessionstore/test/browser/browser_456342_sample.xhtml";
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"]
|
||||
|
|
|
@ -60,7 +60,8 @@ function test() {
|
|||
// wait for all frames to load (and reload!) completely
|
||||
if (frameCount++ < 2)
|
||||
return;
|
||||
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let maxWait = Date.now() + 1000;
|
||||
executeSoon(function() {
|
||||
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
||||
|
|
|
@ -67,6 +67,7 @@ function test() {
|
|||
// open a window and add the above closed tab list
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
|
||||
test_state.windows[0]._closedTabs.length);
|
||||
ss.setWindowState(newWin, JSON.stringify(test_state), true);
|
||||
|
|
|
@ -69,7 +69,8 @@ function test() {
|
|||
// wait for all frames to load (and reload!) completely
|
||||
if (frameCount++ < 4)
|
||||
return;
|
||||
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let win = tab2.linkedBrowser.contentWindow;
|
||||
isnot(win.frames[0].document.getElementById("original").value, uniqueValue,
|
||||
"subframes must match URL to get text restored");
|
||||
|
|
|
@ -69,7 +69,8 @@ function test() {
|
|||
// wait for all frames to load completely
|
||||
if (frameCount++ < 5)
|
||||
return;
|
||||
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let doc = tab2.linkedBrowser.contentDocument;
|
||||
let win = tab2.linkedBrowser.contentWindow;
|
||||
isnot(doc.getElementById("out1").value,
|
||||
|
|
|
@ -75,6 +75,7 @@ function test() {
|
|||
// open a window and add the above closed tab list
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
|
||||
test_state.windows[0]._closedTabs.length);
|
||||
ss.setWindowState(newWin, JSON.stringify(test_state), true);
|
||||
|
|
|
@ -49,6 +49,7 @@ function test() {
|
|||
// open a window and set a value on it
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
ss.setWindowValue(newWin, uniqueKey1, uniqueValue1);
|
||||
|
||||
let newState = { windows: [{ tabs:[{ entries: [] }], extData: {} }] };
|
||||
|
|
|
@ -45,12 +45,14 @@ function test() {
|
|||
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.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) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
doc = tab2.linkedBrowser.contentDocument;
|
||||
is(doc.getElementById("thief").value, "",
|
||||
"file path wasn't set to text field value");
|
||||
|
|
|
@ -43,6 +43,7 @@ function test() {
|
|||
"browser/components/sessionstore/test/browser/browser_476161_sample.html";
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
|
||||
doc.getElementById("modify1").value += Math.random();
|
||||
|
@ -50,6 +51,7 @@ function test() {
|
|||
|
||||
let tab2 = gBrowser.duplicateTab(tab);
|
||||
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
let doc = tab2.linkedBrowser.contentDocument;
|
||||
let changed = doc.getElementById("changed").textContent.trim().split();
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ function test() {
|
|||
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
let newState = { windows: [{
|
||||
tabs: [{ entries: [] }],
|
||||
_closedTabs: [{
|
||||
|
|
|
@ -108,8 +108,11 @@ function test() {
|
|||
// cleanup
|
||||
this.window.close();
|
||||
// if we're all done, explicitly finish
|
||||
if (++completedTests == numTests)
|
||||
if (++completedTests == numTests) {
|
||||
this.window.removeEventListener("load", this, false);
|
||||
this.window.removeEventListener("SSTabRestoring", this, false);
|
||||
finish();
|
||||
}
|
||||
},
|
||||
|
||||
handleLoad: function (aEvent) {
|
||||
|
|
|
@ -10,7 +10,7 @@ function test() {
|
|||
|
||||
let browser = tab.linkedBrowser;
|
||||
browser.addEventListener("load", function loadListener(e) {
|
||||
browser.removeEventListener("load", arguments.callee, false);
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// Scroll the content document
|
||||
browser.contentWindow.scrollTo(1100, 1200);
|
||||
|
@ -21,7 +21,7 @@ function test() {
|
|||
|
||||
let newTab = ss.undoCloseTab(window, 0);
|
||||
newTab.addEventListener("SSTabRestored", function tabRestored(e) {
|
||||
newTab.removeEventListener("SSTabRestored", arguments.callee, false);
|
||||
newTab.removeEventListener("SSTabRestored", arguments.callee, true);
|
||||
|
||||
let newBrowser = newTab.linkedBrowser;
|
||||
|
||||
|
|
|
@ -45,12 +45,14 @@ function test() {
|
|||
"browser/components/sessionstore/test/browser/browser_485482_sample.html";
|
||||
let tab = gBrowser.addTab(testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
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) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
doc = tab2.linkedBrowser.contentDocument;
|
||||
is(doc.querySelector("input[type=text]").value, uniqueValue,
|
||||
"generated XPath expression was valid");
|
||||
|
|
|
@ -44,6 +44,7 @@ function test() {
|
|||
|
||||
let tab = gBrowser.addTab();
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
ss.setTabValue(tab, "bug485563", uniqueValue);
|
||||
let tabState = eval("(" + ss.getTabState(tab) + ")");
|
||||
is(tabState.extData["bug485563"], uniqueValue,
|
||||
|
|
|
@ -61,13 +61,13 @@ function test() {
|
|||
ss.setTabState(tab, JSON.stringify(tabState));
|
||||
|
||||
tab.addEventListener("SSTabRestored", function() {
|
||||
tab.removeEventListener("SSTabRestored", arguments.callee, false);
|
||||
tab.removeEventListener("SSTabRestored", arguments.callee, true);
|
||||
is(window.content.document.referrer, REFERRER2, "document.referrer matches referrer set via setTabState.");
|
||||
|
||||
gBrowser.removeTab(tab);
|
||||
let newTab = ss.undoCloseTab(window, 0);
|
||||
newTab.addEventListener("SSTabRestored", function() {
|
||||
newTab.removeEventListener("SSTabRestored", arguments.callee, false);
|
||||
newTab.removeEventListener("SSTabRestored", arguments.callee, true);
|
||||
|
||||
is(window.content.document.referrer, REFERRER2, "document.referrer is still correct after closing and reopening the tab.");
|
||||
gBrowser.removeTab(newTab);
|
||||
|
|
|
@ -115,6 +115,7 @@ function test() {
|
|||
// open a window and add the above closed window list
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
gPrefService.setIntPref("browser.sessionstore.max_windows_undo",
|
||||
test_state._closedWindows.length);
|
||||
ss.setWindowState(newWin, JSON.stringify(test_state), true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче