Bug 735574 - Extremely frequent leak of 1 BackstagePass, 2 Mutex, 9 ProxyListener coming from fx-team; r=dietrich

This commit is contained in:
Tim Taubert 2012-03-15 23:28:22 +01:00
parent a99fbf0e66
commit 1d3fa12299
3 changed files with 38 additions and 17 deletions

View File

@ -25,7 +25,7 @@ function runTests() {
checkGrid("0,1,2,3,7,8,9,,");
// we removed a pinned site
reset();
yield restore();
setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",1");
@ -37,7 +37,7 @@ function runTests() {
// we remove the last site on the grid (which is pinned) and expect the gap
// to be re-filled and the new site to be unpinned
reset();
yield restore();
setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks(",,,,,,,,8");
@ -49,7 +49,7 @@ function runTests() {
// we remove the first site on the grid with the last one pinned. all cells
// but the last one should shift to the left and a new site fades in
reset();
yield restore();
setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks(",,,,,,,,8");

View File

@ -10,8 +10,6 @@ Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
let NewTabUtils = tmp.NewTabUtils;
registerCleanupFunction(function () {
reset();
while (gBrowser.tabs.length > 1)
gBrowser.removeTab(gBrowser.tabs[1]);
@ -57,8 +55,29 @@ let TestRunner = {
try {
TestRunner._iter.next();
} catch (e if e instanceof StopIteration) {
finish();
TestRunner.finish();
}
},
/**
* Finishes all tests and cleans up.
*/
finish: function () {
function cleanupAndFinish() {
// Restore the old provider.
NewTabUtils.links._provider = originalProvider;
whenPagesUpdated(finish);
NewTabUtils.restore();
}
let callbacks = NewTabUtils.links._populateCallbacks;
let numCallbacks = callbacks.length;
if (numCallbacks)
callbacks.splice(0, numCallbacks, cleanupAndFinish);
else
cleanupAndFinish();
}
};
@ -106,13 +125,11 @@ function setPinnedLinks(aLinksPattern) {
}
/**
* Resets the lists of blocked and pinned links and clears the storage.
* Restore the grid state.
*/
function reset() {
NewTabUtils.reset();
// Restore the old provider to prevent memory leaks.
NewTabUtils.links._provider = originalProvider;
function restore() {
whenPagesUpdated();
NewTabUtils.restore();
}
/**
@ -269,11 +286,11 @@ function simulateDrop(aDropTarget, aDragSource) {
/**
* Resumes testing when all pages have been updated.
*/
function whenPagesUpdated() {
function whenPagesUpdated(aCallback) {
let page = {
update: function () {
NewTabUtils.allPages.unregister(this);
executeSoon(TestRunner.next);
executeSoon(aCallback || TestRunner.next);
}
};

View File

@ -550,7 +550,7 @@ let Links = {
* Resets the links cache.
*/
resetCache: function Links_resetCache() {
this._links = [];
this._links = null;
},
/**
@ -584,13 +584,17 @@ let Links = {
*/
let NewTabUtils = {
/**
* Resets the NewTabUtils module, its links and its storage.
* Restores all sites that have been removed from the grid.
*/
reset: function NewTabUtils_reset() {
restore: function NewTabUtils_restore() {
Storage.clear();
Links.resetCache();
PinnedLinks.resetCache();
BlockedLinks.resetCache();
Links.populateCache(function () {
AllPages.update();
}, true);
},
allPages: AllPages,