Bug 932898 - Fix leaks in /browser/base/content/test/general/ r=jaws

From 703bffabe0374690ecce1ca6a82cfb1f1ace30e8 Mon Sep 17 00:00:00 2001
This commit is contained in:
Tim Taubert 2013-11-02 16:14:52 +01:00
parent 118dc19653
commit c1760d1877
4 changed files with 27 additions and 8 deletions

View File

@ -3243,10 +3243,22 @@ function OpenBrowserWindow(options)
doc != document && doc != document &&
doc.defaultView == win) { doc.defaultView == win) {
Services.obs.removeObserver(newDocumentShown, "document-shown"); Services.obs.removeObserver(newDocumentShown, "document-shown");
Services.obs.removeObserver(windowClosed, "domwindowclosed");
TelemetryStopwatch.finish("FX_NEW_WINDOW_MS", telemetryObj); TelemetryStopwatch.finish("FX_NEW_WINDOW_MS", telemetryObj);
} }
}; }
function windowClosed(subject) {
if (subject == win) {
Services.obs.removeObserver(newDocumentShown, "document-shown");
Services.obs.removeObserver(windowClosed, "domwindowclosed");
}
}
// Make sure to remove the 'document-shown' observer in case the window
// is being closed right after it was opened to avoid leaking.
Services.obs.addObserver(newDocumentShown, "document-shown", false); Services.obs.addObserver(newDocumentShown, "document-shown", false);
Services.obs.addObserver(windowClosed, "domwindowclosed", false);
var charsetArg = new String(); var charsetArg = new String();
var handler = Components.classes["@mozilla.org/browser/clh;1"] var handler = Components.classes["@mozilla.org/browser/clh;1"]

View File

@ -95,5 +95,6 @@ function part8() {
ok(objLoadingContent.activated, "plugin should be activated now"); ok(objLoadingContent.activated, "plugin should be activated now");
gNewWindow.close(); gNewWindow.close();
gNewWindow = null;
finish(); finish();
} }

View File

@ -42,7 +42,14 @@ function finishTest() {
gPermissionManager.remove("127.0.0.1:8888", gSecondTestPermissionString); gPermissionManager.remove("127.0.0.1:8888", gSecondTestPermissionString);
Services.prefs.clearUserPref("plugins.click_to_play"); Services.prefs.clearUserPref("plugins.click_to_play");
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
finish();
gPageInfo = null;
gNextTest = null;
gTestBrowser = null;
gPluginHost = null;
gPermissionManager = null;
executeSoon(finish);
} }
function test() { function test() {

View File

@ -1,13 +1,12 @@
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
var privateWin = OpenBrowserWindow({private: true}); var privateWin = OpenBrowserWindow({private: true});
privateWin.addEventListener("load", function onload() {
privateWin.removeEventListener("load", onload, false);
ok(true, "Load listener called");
whenDelayedStartupFinished(privateWin, function () {
privateWin.BrowserOpenTab(); privateWin.BrowserOpenTab();
privateWin.BrowserTryToCloseWindow(); privateWin.BrowserTryToCloseWindow();
ok(true, "didn't prompt"); ok(true, "didn't prompt");
finish();
}, false); executeSoon(finish);
} });
}