layout/tools/recording/recording-cmdline.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
     7 const nsISupports                    = Components.interfaces.nsISupports;
     9 const nsICommandLine                 = Components.interfaces.nsICommandLine;
    10 const nsICommandLineHandler          = Components.interfaces.nsICommandLineHandler;
    11 const nsISupportsString              = Components.interfaces.nsISupportsString;
    12 const nsIWindowWatcher               = Components.interfaces.nsIWindowWatcher;
    14 function RecordingCmdLineHandler() {}
    15 RecordingCmdLineHandler.prototype =
    16 {
    17     classID: Components.ID('{86FB70EC-90FF-45AD-A1C1-F77D3C1184E9}'),
    19     /* nsISupports */
    20     QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]),
    22     /* nsICommandLineHandler */
    23     handle : function handler_handle(cmdLine) {
    24         var args = { };
    25         args.wrappedJSObject = args;
    26         try {
    27             var uristr = cmdLine.handleFlagWithParam("recording", false);
    28             if (uristr == null)
    29                 return;
    30             try {
    31                 args.uri = cmdLine.resolveURI(uristr).spec;
    32             }
    33             catch (e) {
    34                 return;
    35             }
    36         }
    37         catch (e) {
    38             cmdLine.handleFlag("recording", true);
    39         }
    41         /**
    42          * Manipulate preferences by adding to the *default* branch.  Adding
    43          * to the default branch means the changes we make won't get written
    44          * back to user preferences.
    45          *
    46          * We want to do this here rather than in reftest.js because it's
    47          * important to set the recording pref before the platform Init gets
    48          * called.
    49          */
    50         var prefs = Components.classes["@mozilla.org/preferences-service;1"].
    51                     getService(Components.interfaces.nsIPrefService);
    52         var branch = prefs.getDefaultBranch("");
    54         try {
    55             var outputstr = cmdLine.handleFlagWithParam("recording-output", false);
    56             if (outputstr != null) {
    57                 branch.setCharPref("gfx.2d.recordingfile", outputstr);
    58             }
    59         } catch (e) { }
    61         branch.setBoolPref("gfx.2d.recording", true);
    63         var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
    64                                .getService(nsIWindowWatcher);
    65         wwatch.openWindow(null, "chrome://recording/content/recording.xul", "_blank",
    66                           "chrome,dialog=no,all", args);
    67         cmdLine.preventDefault = true;
    68     },
    70     helpInfo : "  -recording <file>  Record drawing for a given URL.\n" +
    71                "  -recording-output <file> Specify destination file for a drawing recording.\n"
    72 };
    74 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]);

mercurial