layout/tools/recording/recording-cmdline.js

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:b161785333a3
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/. */
4
5 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
6
7 const nsISupports = Components.interfaces.nsISupports;
8
9 const nsICommandLine = Components.interfaces.nsICommandLine;
10 const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler;
11 const nsISupportsString = Components.interfaces.nsISupportsString;
12 const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
13
14 function RecordingCmdLineHandler() {}
15 RecordingCmdLineHandler.prototype =
16 {
17 classID: Components.ID('{86FB70EC-90FF-45AD-A1C1-F77D3C1184E9}'),
18
19 /* nsISupports */
20 QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]),
21
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 }
40
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("");
53
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) { }
60
61 branch.setBoolPref("gfx.2d.recording", true);
62
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 },
69
70 helpInfo : " -recording <file> Record drawing for a given URL.\n" +
71 " -recording-output <file> Specify destination file for a drawing recording.\n"
72 };
73
74 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]);

mercurial