Bug 965860 - patch 1 - Convert ConsoleAPIStorage in a Service, r=msucan, r=khuey
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 27 Feb 2014 23:38:54 +0000
changeset 171457 ed97de4f1d285cf6fb1b197652b2e90890127de8
parent 171456 0be8765182a349372f0e4964e161002469e57a70
child 171458 3f528e61aacfeb743a6fab6fb47a9bfc10e282e2
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmsucan, khuey
bugs965860
milestone30.0a1
Bug 965860 - patch 1 - Convert ConsoleAPIStorage in a Service, r=msucan, r=khuey
b2g/installer/package-manifest.in
browser/devtools/webconsole/test/browser_console_consolejsm_output.js
browser/devtools/webconsole/test/browser_console_private_browsing.js
browser/installer/package-manifest.in
dom/base/ConsoleAPI.js
dom/base/ConsoleAPI.manifest
dom/base/ConsoleAPIStorage.js
dom/base/ConsoleAPIStorage.jsm
dom/base/moz.build
dom/base/nsIConsoleAPIStorage.idl
dom/tests/browser/browser_ConsoleStorageAPITests.js
dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
mobile/android/installer/package-manifest.in
toolkit/devtools/Console.jsm
toolkit/devtools/server/actors/webconsole.js
toolkit/devtools/webconsole/test/common.js
toolkit/devtools/webconsole/utils.js
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -335,16 +335,17 @@
 @BINPATH@/components/xul.xpt
 @BINPATH@/components/xuldoc.xpt
 @BINPATH@/components/xultmpl.xpt
 @BINPATH@/components/zipwriter.xpt
 
 ; JavaScript components
 @BINPATH@/components/ConsoleAPI.manifest
 @BINPATH@/components/ConsoleAPI.js
+@BINPATH@/components/ConsoleAPIStorage.js
 @BINPATH@/components/BrowserElementParent.manifest
 @BINPATH@/components/BrowserElementParent.js
 @BINPATH@/components/ContactManager.js
 @BINPATH@/components/ContactManager.manifest
 @BINPATH@/components/PhoneNumberService.js
 @BINPATH@/components/PhoneNumberService.manifest
 @BINPATH@/components/NotificationStorage.js
 @BINPATH@/components/NotificationStorage.manifest
--- a/browser/devtools/webconsole/test/browser_console_consolejsm_output.js
+++ b/browser/devtools/webconsole/test/browser_console_consolejsm_output.js
@@ -2,17 +2,17 @@
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Test that Console.jsm outputs messages to the Browser Console, bug 851231.
 
 function test()
 {
-  let storage = Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", {}).ConsoleAPIStorage;
+  let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
   storage.clearEvents();
 
   let console = Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
   console.log("bug861338-log-cached");
 
   HUDService.toggleBrowserConsole().then(consoleOpened);
   let hud = null;
 
--- a/browser/devtools/webconsole/test/browser_console_private_browsing.js
+++ b/browser/devtools/webconsole/test/browser_console_private_browsing.js
@@ -6,17 +6,18 @@
 // Bug 874061: test for how the browser and web consoles display messages coming
 // from private windows. See bug for description of expected behavior.
 
 function test()
 {
   const TEST_URI = "data:text/html;charset=utf8,<p>hello world! bug 874061" +
                    "<button onclick='console.log(\"foobar bug 874061\");" +
                    "fooBazBaz.yummy()'>click</button>";
-  let ConsoleAPIStorage = Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", {}).ConsoleAPIStorage;
+  let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                            .getService(Ci.nsIConsoleAPIStorage);
   let privateWindow, privateBrowser, privateTab, privateContent;
   let hud, expectedMessages, nonPrivateMessage;
 
   // This test is slightly more involved: it opens the web console twice,
   // a new private window once, and the browser console twice. We can get
   // a timeout with debug builds on slower machines.
   requestLongerTimeout(2);
   start();
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -342,16 +342,17 @@
 @BINPATH@/components/xuldoc.xpt
 @BINPATH@/components/xultmpl.xpt
 @BINPATH@/components/zipwriter.xpt
 @BINPATH@/components/telemetry.xpt
 
 ; JavaScript components
 @BINPATH@/components/ConsoleAPI.manifest
 @BINPATH@/components/ConsoleAPI.js
+@BINPATH@/components/ConsoleAPIStorage.js
 @BINPATH@/components/BrowserElementParent.manifest
 @BINPATH@/components/BrowserElementParent.js
 @BINPATH@/components/FeedProcessor.manifest
 @BINPATH@/components/FeedProcessor.js
 @BINPATH@/browser/components/BrowserFeeds.manifest
 @BINPATH@/browser/components/FeedConverter.js
 @BINPATH@/browser/components/FeedWriter.js
 @BINPATH@/browser/components/fuelApplication.manifest
--- a/dom/base/ConsoleAPI.js
+++ b/dom/base/ConsoleAPI.js
@@ -26,19 +26,22 @@ const DEFAULT_MAX_STACKTRACE_DEPTH = 200
 // delay tells how much later.
 const CALL_DELAY = 15; // milliseconds
 
 // This constant tells how many messages to process in a single timer execution.
 const MESSAGES_IN_INTERVAL = 1500;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm");
 Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 
+XPCOMUtils.defineLazyServiceGetter(this, "ConsoleAPIStorage",
+                                   "@mozilla.org/consoleAPI-storage;1",
+                                   "nsIConsoleAPIStorage");
+
 /**
  * The window.console API implementation. One instance is lazily created for
  * every inner window, when the window.console object is accessed.
  */
 function ConsoleAPI() {}
 ConsoleAPI.prototype = {
 
   classID: Components.ID("{b49c18f8-3379-4fc0-8c90-d7772c1a9ff3}"),
--- a/dom/base/ConsoleAPI.manifest
+++ b/dom/base/ConsoleAPI.manifest
@@ -1,3 +1,5 @@
 component {b49c18f8-3379-4fc0-8c90-d7772c1a9ff3} ConsoleAPI.js
 contract @mozilla.org/console-api;1 {b49c18f8-3379-4fc0-8c90-d7772c1a9ff3}
 category JavaScript-global-property console @mozilla.org/console-api;1
+component {96cf7855-dfa9-4c6d-8276-f9705b4890f2} ConsoleAPIStorage.js
+contract @mozilla.org/consoleAPI-storage;1 {96cf7855-dfa9-4c6d-8276-f9705b4890f2}
rename from dom/base/ConsoleAPIStorage.jsm
rename to dom/base/ConsoleAPIStorage.js
--- a/dom/base/ConsoleAPIStorage.jsm
+++ b/dom/base/ConsoleAPIStorage.js
@@ -8,19 +8,19 @@ let Cu = Components.utils;
 let Ci = Components.interfaces;
 let Cc = Components.classes;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 const STORAGE_MAX_EVENTS = 200;
 
-this.EXPORTED_SYMBOLS = ["ConsoleAPIStorage"];
+var _consoleStorage = new Map();
 
-var _consoleStorage = new Map();
+const CONSOLEAPISTORAGE_CID = Components.ID('{96cf7855-dfa9-4c6d-8276-f9705b4890f2}');
 
 /**
  * The ConsoleAPIStorage is meant to cache window.console API calls for later
  * reuse by other components when needed. For example, the Web Console code can
  * display the cached messages when it opens for the active tab.
  *
  * ConsoleAPI messages are stored as they come from the ConsoleAPI code, with
  * all their properties. They are kept around until the inner window object that
@@ -33,19 +33,30 @@ var _consoleStorage = new Map();
  *    // Get the cached events array for the window you want (use the inner
  *    // window ID).
  *    let events = ConsoleAPIStorage.getEvents(innerWindowID);
  *    events.forEach(function(event) { ... });
  *
  *    // Clear the events for the given inner window ID.
  *    ConsoleAPIStorage.clearEvents(innerWindowID);
  */
-this.ConsoleAPIStorage = {
+function ConsoleAPIStorageService() {
+  this.init();
+}
 
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
+ConsoleAPIStorageService.prototype = {
+  classID : CONSOLEAPISTORAGE_CID,
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleAPIStorage,
+                                         Ci.nsIObserver]),
+  classInfo: XPCOMUtils.generateCI({
+    classID: CONSOLEAPISTORAGE_CID,
+    contractID: '@mozilla.org/consoleAPI-storage;1',
+    interfaces: [Ci.nsIConsoleAPIStorage, Ci.nsIObserver],
+    flags: Ci.nsIClassInfo.SINGLETON
+  }),
 
   observe: function CS_observe(aSubject, aTopic, aData)
   {
     if (aTopic == "xpcom-shutdown") {
       Services.obs.removeObserver(this, "xpcom-shutdown");
       Services.obs.removeObserver(this, "inner-window-destroyed");
       Services.obs.removeObserver(this, "memory-pressure");
     }
@@ -135,9 +146,9 @@ this.ConsoleAPIStorage = {
     }
     else {
       _consoleStorage.clear();
       Services.obs.notifyObservers(null, "console-storage-reset", null);
     }
   },
 };
 
-ConsoleAPIStorage.init();
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ConsoleAPIStorageService]);
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -2,16 +2,17 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
+    'nsIConsoleAPIStorage.idl',
     'nsIDOMDOMCursor.idl',
     'nsIDOMDOMRequest.idl',
     'nsIEntropyCollector.idl',
     'nsIScriptChannel.idl',
     'nsISiteSpecificUserAgent.idl',
 ]
 
 XPIDL_MODULE = 'dom'
@@ -114,22 +115,22 @@ SOURCES += [
     'nsJSEnvironment.cpp',
     # nsPluginArray.cpp includes npapi.h indirectly, and that includes a lot of system headers
     'nsPluginArray.cpp',
 ]
 
 EXTRA_COMPONENTS += [
     'ConsoleAPI.js',
     'ConsoleAPI.manifest',
+    'ConsoleAPIStorage.js',
     'SiteSpecificUserAgent.js',
     'SiteSpecificUserAgent.manifest',
 ]
 
 EXTRA_JS_MODULES += [
-    'ConsoleAPIStorage.jsm',
     'DOMRequestHelper.jsm',
     'IndexedDBHelper.jsm',
     'ObjectWrapper.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
new file mode 100644
--- /dev/null
+++ b/dom/base/nsIConsoleAPIStorage.idl
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(6701600a-17ca-417e-98f9-4ceb175dd15d)]
+interface nsIConsoleAPIStorage : nsISupports
+{
+  /**
+   * Get the events array by inner window ID or all events from all windows.
+   *
+   * @param string [aId]
+   *        Optional, the inner window ID for which you want to get the array of
+   *        cached events.
+   * @returns array
+   *          The array of cached events for the given window. If no |aId| is
+   *          given this function returns all of the cached events, from any
+   *          window.
+   */
+  jsval getEvents([optional] in DOMString aId);
+
+  /**
+   * Record an event associated with the given window ID.
+   *
+   * @param string aId
+   *        The ID of the inner window for which the event occurred or "jsm" for
+   *        messages logged from JavaScript modules..
+   * @param object aEvent
+   *        A JavaScript object you want to store.
+   */
+  void recordEvent(in DOMString aId, in jsval aEvent);
+
+  /**
+   * Clear storage data for the given window.
+   *
+   * @param string [aId]
+   *        Optional, the inner window ID for which you want to clear the
+   *        messages. If this is not specified all of the cached messages are
+   *        cleared, from all window objects.
+   */
+  void clearEvents([optional] in DOMString aId);
+};
--- a/dom/tests/browser/browser_ConsoleStorageAPITests.js
+++ b/dom/tests/browser/browser_ConsoleStorageAPITests.js
@@ -1,17 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const TEST_URI = "http://example.com/browser/dom/tests/browser/test-console-api.html";
 const TEST_URI_NAV = "http://example.com/browser/dom/tests/browser/";
 
-let tempScope = {};
-Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", tempScope);
-let ConsoleAPIStorage = tempScope.ConsoleAPIStorage;
+let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                          .getService(Ci.nsIConsoleAPIStorage);
 
 var apiCallCount;
 
 var ConsoleObserver = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 
   init: function CO_init()
   {
--- a/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
+++ b/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
@@ -7,18 +7,18 @@ function test() {
   let windowsToClose = [];
   let innerID;
   let beforeEvents;
   let afterEvents;
   let storageShouldOccur;
   let consoleObserver;
   let testURI =
     "http://example.com/browser/dom/tests/browser/test-console-api.html";
-  let CSS = {};
-  Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", CSS);
+  let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                            .getService(Ci.nsIConsoleAPIStorage);
 
   function getInnerWindowId(aWindow) {
     return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIDOMWindowUtils)
                   .currentInnerWindowID;
   }
 
   function whenNewWindowLoaded(aOptions, aCallback) {
@@ -31,17 +31,17 @@ function test() {
 
   function doTest(aIsPrivateMode, aWindow, aCallback) {
     aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
       aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
 
       consoleObserver = {
         observe: function(aSubject, aTopic, aData) {
           if (aTopic == "console-api-log-event") {
-            afterEvents = CSS.ConsoleAPIStorage.getEvents(innerID);
+            afterEvents = ConsoleAPIStorage.getEvents(innerID);
             is(beforeEvents.length == afterEvents.length - 1, storageShouldOccur,
               "storage should" + (storageShouldOccur ? "" : " not") + " occur");
 
             executeSoon(function() {
               Services.obs.removeObserver(consoleObserver, "console-api-log-event");
               aCallback();
             });
           }
@@ -51,17 +51,17 @@ function test() {
       aWindow.Services.obs.addObserver(
         consoleObserver, "console-api-log-event", false);
       aWindow.console.log("foo bar baz (private: " + aIsPrivateMode + ")");
     }, true);
 
     // We expect that console API messages are always stored.
     storageShouldOccur = true;
     innerID = getInnerWindowId(aWindow);
-    beforeEvents = CSS.ConsoleAPIStorage.getEvents(innerID);
+    beforeEvents = ConsoleAPIStorage.getEvents(innerID);
     aWindow.gBrowser.selectedBrowser.loadURI(testURI);
   }
 
   function testOnWindow(aOptions, aCallback) {
     whenNewWindowLoaded(aOptions, function(aWin) {
       windowsToClose.push(aWin);
       // execute should only be called when need, like when you are opening
       // web pages on the test. If calling executeSoon() is not necesary, then
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -276,16 +276,17 @@
 @BINPATH@/components/xul.xpt
 @BINPATH@/components/xuldoc.xpt
 @BINPATH@/components/xultmpl.xpt
 @BINPATH@/components/zipwriter.xpt
 
 ; JavaScript components
 @BINPATH@/components/ConsoleAPI.manifest
 @BINPATH@/components/ConsoleAPI.js
+@BINPATH@/components/ConsoleAPIStorage.js
 @BINPATH@/components/ContactManager.js
 @BINPATH@/components/ContactManager.manifest
 @BINPATH@/components/PhoneNumberService.js
 @BINPATH@/components/PhoneNumberService.manifest
 @BINPATH@/components/NotificationStorage.js
 @BINPATH@/components/NotificationStorage.manifest
 @BINPATH@/components/SettingsManager.js
 @BINPATH@/components/SettingsManager.manifest
--- a/toolkit/devtools/Console.jsm
+++ b/toolkit/devtools/Console.jsm
@@ -17,20 +17,19 @@
  * - The Firebug console is a rich display compared with dump(), so there will
  *   be many things that we can't replicate
  * - The primary use of this API is debugging and error logging so the perfect
  *   implementation isn't always required (or even well defined)
  */
 
 this.EXPORTED_SYMBOLS = [ "console", "ConsoleAPI" ];
 
-const Cu = Components.utils;
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 
 let gTimerRegistry = new Map();
 
 /**
  * String utility to ensure that strings are a specified length. Strings
@@ -553,16 +552,18 @@ function sendConsoleAPIMessage(aLevel, a
         Cu.reportError(ex);
         Cu.reportError(ex.stack);
         return;
       }
       break;
   }
 
   Services.obs.notifyObservers(consoleEvent, "console-api-log-event", null);
+  let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                            .getService(Ci.nsIConsoleAPIStorage);
   ConsoleAPIStorage.recordEvent("jsm", consoleEvent);
 }
 
 /**
  * This creates a console object that somewhat replicates Firebug's console
  * object
  *
  * @param {object} aConsoleOptions
--- a/toolkit/devtools/server/actors/webconsole.js
+++ b/toolkit/devtools/server/actors/webconsole.js
@@ -12,19 +12,16 @@ let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIStorage",
-                                  "resource://gre/modules/ConsoleAPIStorage.jsm");
-
 for (let name of ["WebConsoleUtils", "ConsoleServiceListener",
                   "ConsoleAPIListener", "ConsoleProgressListener",
                   "JSTermHelpers", "JSPropertyProvider", "NetworkMonitor",
                   "ConsoleReflowListener"]) {
   Object.defineProperty(this, name, {
     get: function(prop) {
       if (prop == "WebConsoleUtils") {
         prop = "Utils";
@@ -773,17 +770,20 @@ WebConsoleActor.prototype =
   /**
    * The "clearMessagesCache" request handler.
    */
   onClearMessagesCache: function WCA_onClearMessagesCache()
   {
     // TODO: Bug 717611 - Web Console clear button does not clear cached errors
     let windowId = !this.parentActor.isRootActor ?
                    WebConsoleUtils.getInnerWindowId(this.window) : null;
+    let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                              .getService(Ci.nsIConsoleAPIStorage);
     ConsoleAPIStorage.clearEvents(windowId);
+
     if (this.parentActor.isRootActor) {
       Services.console.logStringMessage(null); // for the Error Console
       Services.console.reset();
     }
     return {};
   },
 
   /**
--- a/toolkit/devtools/webconsole/test/common.js
+++ b/toolkit/devtools/webconsole/test/common.js
@@ -3,21 +3,23 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm");
 
 let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
 let WebConsoleUtils = devtools.require("devtools/toolkit/webconsole/utils").Utils;
 
+let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                          .getService(Ci.nsIConsoleAPIStorage);
+
 let {ConsoleServiceListener, ConsoleAPIListener} =
   devtools.require("devtools/toolkit/webconsole/utils");
 
 function initCommon()
 {
   //Services.prefs.setBoolPref("devtools.debugger.log", true);
 
   Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
--- a/toolkit/devtools/webconsole/utils.js
+++ b/toolkit/devtools/webconsole/utils.js
@@ -7,17 +7,16 @@
 "use strict";
 
 const {Cc, Ci, Cu, components} = require("chrome");
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 loader.lazyGetter(this, "NetworkHelper", () => require("devtools/toolkit/webconsole/network-helper"));
 loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
-loader.lazyImporter(this, "ConsoleAPIStorage", "resource://gre/modules/ConsoleAPIStorage.jsm");
 loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
 loader.lazyImporter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm");
 loader.lazyImporter(this, "LayoutHelpers", "resource://gre/modules/devtools/LayoutHelpers.jsm");
 loader.lazyServiceGetter(this, "gActivityDistributor",
                          "@mozilla.org/network/http-activity-distributor;1",
                          "nsIHttpActivityDistributor");
 
 // TODO: Bug 842672 - toolkit/ imports modules from browser/.
@@ -1322,16 +1321,18 @@ ConsoleAPIListener.prototype =
    *        Tells if you want to also retrieve messages coming from private
    *        windows. Defaults to false.
    * @return array
    *         The array of cached messages.
    */
   getCachedMessages: function CAL_getCachedMessages(aIncludePrivate = false)
   {
     let messages = [];
+    let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
+                              .getService(Ci.nsIConsoleAPIStorage);
 
     // if !this.window, we're in a browser console. Retrieve all events
     // for filtering based on privacy.
     if (!this.window) {
       messages = ConsoleAPIStorage.getEvents();
     } else {
       let ids = WebConsoleUtils.getInnerWindowIDsForFrames(this.window);
       ids.forEach((id) => {