Bug 728538. (Bv2) browser_ConsoleStorageAPITests.js: Set "browser.tabs.max_tabs_undo" preference, Document code. r=gavin.sharp.
authorSerge Gautherie <sgautherie.bz@free.fr>
Fri, 24 Feb 2012 07:04:55 +0100
changeset 87567 cd120efbe4c6c8a8f2348deab6d3c87da63cf31c
parent 87566 d23600a1d4a7be931888752767978407df29edb0
child 87568 06b24fa2aae445ee443555693da29ca8ff4573ab
push id22131
push usersgautherie.bz@free.fr
push dateFri, 24 Feb 2012 06:06:25 +0000
treeherdermozilla-central@cd120efbe4c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs728538
milestone13.0a1
first release with
nightly linux32
cd120efbe4c6 / 13.0a1 / 20120224031039 / files
nightly linux64
cd120efbe4c6 / 13.0a1 / 20120224031039 / files
nightly mac
cd120efbe4c6 / 13.0a1 / 20120224031039 / files
nightly win32
cd120efbe4c6 / 13.0a1 / 20120224031039 / files
nightly win64
cd120efbe4c6 / 13.0a1 / 20120224031039 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 728538. (Bv2) browser_ConsoleStorageAPITests.js: Set "browser.tabs.max_tabs_undo" preference, Document code. r=gavin.sharp.
dom/tests/browser/browser_ConsoleStorageAPITests.js
--- a/dom/tests/browser/browser_ConsoleStorageAPITests.js
+++ b/dom/tests/browser/browser_ConsoleStorageAPITests.js
@@ -19,17 +19,16 @@ var ConsoleObserver = {
     apiCallCount = 0;
   },
 
   observe: function CO_observe(aSubject, aTopic, aData)
   {
     if (aTopic == "console-storage-cache-event") {
       apiCallCount ++;
       if (apiCallCount == 4) {
-        // remove the observer so we don't trigger this test again
         Services.obs.removeObserver(this, "console-storage-cache-event");
 
         try {
         let tab = gBrowser.selectedTab;
         let browser = gBrowser.selectedBrowser;
         let win = XPCNativeWrapper.unwrap(browser.contentWindow);
         let windowID = getWindowId(win);
         let messages = ConsoleAPIStorage.getEvents(windowID);
@@ -37,22 +36,23 @@ var ConsoleObserver = {
 
         ConsoleAPIStorage.clearEvents();
         messages = ConsoleAPIStorage.getEvents(windowID);
         is(messages.length, 0, "Cleared Storage");
 
         // make sure a closed window's events are in fact removed from the
         // storage cache
         win.console.log("adding a new event");
-
-        // close the window - the storage cache should now be empty
+        // Close the window.
         gBrowser.removeTab(tab, {animate: false});
-
+        // Ensure actual window destruction is not delayed (too long).
         window.QueryInterface(Ci.nsIInterfaceRequestor)
               .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
+        // Ensure "inner-window-destroyed" event is processed,
+        // so the storage cache is cleared.
         executeSoon(function () {
           // use the old windowID again to see if we have any stray cached messages
           messages = ConsoleAPIStorage.getEvents(windowID);
           is(messages.length, 0, "tab close is clearing the cache");
           finish();
         });
         } catch (ex) {
           dump(ex + "\n\n\n");
@@ -66,16 +66,22 @@ var ConsoleObserver = {
 function tearDown()
 {
   while (gBrowser.tabs.length > 1)
     gBrowser.removeCurrentTab();
 }
 
 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);
 
   ConsoleObserver.init();
 
   waitForExplicitFinish();
 
   var tab = gBrowser.addTab(TEST_URI);
   gBrowser.selectedTab = tab;