toolkit/components/console/jsconsole-clhandler.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/console/jsconsole-clhandler.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:sw=4:sr:sta:et:sts: */
     1.6 +
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +const Cc = Components.classes;
    1.12 +const Ci = Components.interfaces;
    1.13 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    1.14 +
    1.15 +function jsConsoleHandler() {}
    1.16 +jsConsoleHandler.prototype = {
    1.17 +  handle: function clh_handle(cmdLine) {
    1.18 +    if (!cmdLine.handleFlag("jsconsole", false))
    1.19 +      return;
    1.20 +
    1.21 +    var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
    1.22 +             getService(Ci.nsIWindowMediator);
    1.23 +    var console = wm.getMostRecentWindow("global:console");
    1.24 +    if (!console) {
    1.25 +      var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"].
    1.26 +                   getService(Ci.nsIWindowWatcher);
    1.27 +      wwatch.openWindow(null, "chrome://global/content/console.xul", "_blank",
    1.28 +                        "chrome,dialog=no,all", cmdLine);
    1.29 +    } else {
    1.30 +      console.focus(); // the Error console was already open
    1.31 +    }
    1.32 +
    1.33 +    if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO)
    1.34 +      cmdLine.preventDefault = true;
    1.35 +  },
    1.36 +
    1.37 +  helpInfo : "  -jsconsole         Open the Error console.\n",
    1.38 +
    1.39 +  classID: Components.ID("{2cd0c310-e127-44d0-88fc-4435c9ab4d4b}"),
    1.40 +  QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
    1.41 +};
    1.42 +
    1.43 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([jsConsoleHandler]);

mercurial