Bug 728538. (Bv2) browser_ConsoleStorageAPITests.js: Set "browser.tabs.max_tabs_undo" preference, Document code. r=gavin.sharp.

This commit is contained in:
Serge Gautherie 2012-02-24 07:04:55 +01:00
parent 85840c2035
commit 1d4b64c3a6

View File

@ -24,7 +24,6 @@ var ConsoleObserver = {
if (aTopic == "console-storage-cache-event") { if (aTopic == "console-storage-cache-event") {
apiCallCount ++; apiCallCount ++;
if (apiCallCount == 4) { if (apiCallCount == 4) {
// remove the observer so we don't trigger this test again
Services.obs.removeObserver(this, "console-storage-cache-event"); Services.obs.removeObserver(this, "console-storage-cache-event");
try { try {
@ -42,12 +41,13 @@ var ConsoleObserver = {
// make sure a closed window's events are in fact removed from the // make sure a closed window's events are in fact removed from the
// storage cache // storage cache
win.console.log("adding a new event"); win.console.log("adding a new event");
// Close the window.
// close the window - the storage cache should now be empty
gBrowser.removeTab(tab, {animate: false}); gBrowser.removeTab(tab, {animate: false});
// Ensure actual window destruction is not delayed (too long).
window.QueryInterface(Ci.nsIInterfaceRequestor) window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).garbageCollect(); .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
// Ensure "inner-window-destroyed" event is processed,
// so the storage cache is cleared.
executeSoon(function () { executeSoon(function () {
// use the old windowID again to see if we have any stray cached messages // use the old windowID again to see if we have any stray cached messages
messages = ConsoleAPIStorage.getEvents(windowID); messages = ConsoleAPIStorage.getEvents(windowID);
@ -71,6 +71,12 @@ function tearDown()
function test() function test()
{ {
// Don't cache removed tabs, so "clear console cache on tab close" triggers.
Services.prefs.setIntPref("browser.tabs.max_tabs_undo", 0);
registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.tabs.max_tabs_undo");
});
registerCleanupFunction(tearDown); registerCleanupFunction(tearDown);
ConsoleObserver.init(); ConsoleObserver.init();