Bug 728538. (Av1) browser_ConsoleStorageAPITests.js: Improve code a little. r=gavin.sharp.
authorSerge Gautherie <sgautherie.bz@free.fr>
Sun, 19 Feb 2012 06:21:57 +0100
changeset 87155 4d47329bb02ec69afbddaa9034abd5a15516840e
parent 87154 e06ab2cf18b88511abdcefbc94eea743d6e3391d
child 87156 88c69fa60ec2639cf1cedd7b8e40a55a4f08bd32
child 87307 9320be63a49b61fdc261fa433373fd587bbd540e
push id22086
push usersgautherie.bz@free.fr
push dateSun, 19 Feb 2012 05:25:20 +0000
treeherdermozilla-central@4d47329bb02e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin.sharp
bugs728538
milestone13.0a1
first release with
nightly linux32
4d47329bb02e / 13.0a1 / 20120219031223 / files
nightly linux64
4d47329bb02e / 13.0a1 / 20120219031223 / files
nightly mac
4d47329bb02e / 13.0a1 / 20120219031223 / files
nightly win32
4d47329bb02e / 13.0a1 / 20120219031223 / files
nightly win64
4d47329bb02e / 13.0a1 / 20120219031223 / 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. (Av1) browser_ConsoleStorageAPITests.js: Improve code a little. r=gavin.sharp.
dom/tests/browser/browser_ConsoleStorageAPITests.js
--- a/dom/tests/browser/browser_ConsoleStorageAPITests.js
+++ b/dom/tests/browser/browser_ConsoleStorageAPITests.js
@@ -19,82 +19,76 @@ 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 {
-                  var tab = gBrowser.selectedTab;
+        let tab = gBrowser.selectedTab;
         let browser = gBrowser.selectedBrowser;
         let win = XPCNativeWrapper.unwrap(browser.contentWindow);
         let windowID = getWindowId(win);
         let messages = ConsoleAPIStorage.getEvents(windowID);
-
         ok(messages.length >= 4, "Some messages found in the storage service");
 
         ConsoleAPIStorage.clearEvents();
         messages = ConsoleAPIStorage.getEvents(windowID);
-        ok(messages.length == 0, "Cleared Storage, no events found");
-
-        // remove the observer so we don't trigger this test again
-        Services.obs.removeObserver(this, "console-storage-cache-event");
+        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
         gBrowser.removeTab(tab, {animate: false});
 
         window.QueryInterface(Ci.nsIInterfaceRequestor)
-          .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
-        executeSoon(function (){
+              .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
+        executeSoon(function () {
           // use the old windowID again to see if we have any stray cached messages
           messages = ConsoleAPIStorage.getEvents(windowID);
-          ok(messages.length == 0, "0 events found, tab close is clearing the cache");
+          is(messages.length, 0, "tab close is clearing the cache");
           finish();
         });
         } catch (ex) {
           dump(ex + "\n\n\n");
           dump(ex.stack + "\n\n\n");
         }
-        }
-
+      }
     }
   }
 };
 
 function tearDown()
 {
-   while (gBrowser.tabs.length > 1) {
+  while (gBrowser.tabs.length > 1)
     gBrowser.removeCurrentTab();
-  }
 }
 
 function test()
 {
   registerCleanupFunction(tearDown);
 
   ConsoleObserver.init();
 
   waitForExplicitFinish();
 
   var tab = gBrowser.addTab(TEST_URI);
   gBrowser.selectedTab = tab;
   var browser = gBrowser.selectedBrowser;
   browser.addEventListener("DOMContentLoaded", function onLoad(event) {
     browser.removeEventListener("DOMContentLoaded", onLoad, false);
     executeSoon(function test_executeSoon() {
-      var contentWin = browser.contentWindow;
-
-      let win = XPCNativeWrapper.unwrap(contentWin);
-
+      let win = XPCNativeWrapper.unwrap(browser.contentWindow);
       win.console.log("this", "is", "a", "log message");
       win.console.info("this", "is", "a", "info message");
       win.console.warn("this", "is", "a", "warn message");
       win.console.error("this", "is", "a", "error message");
     });
   }, false);
 }