michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: const nsISupports = Components.interfaces.nsISupports; michael@0: michael@0: const nsICommandLine = Components.interfaces.nsICommandLine; michael@0: const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler; michael@0: const nsISupportsString = Components.interfaces.nsISupportsString; michael@0: const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; michael@0: michael@0: function RecordingCmdLineHandler() {} michael@0: RecordingCmdLineHandler.prototype = michael@0: { michael@0: classID: Components.ID('{86FB70EC-90FF-45AD-A1C1-F77D3C1184E9}'), michael@0: michael@0: /* nsISupports */ michael@0: QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]), michael@0: michael@0: /* nsICommandLineHandler */ michael@0: handle : function handler_handle(cmdLine) { michael@0: var args = { }; michael@0: args.wrappedJSObject = args; michael@0: try { michael@0: var uristr = cmdLine.handleFlagWithParam("recording", false); michael@0: if (uristr == null) michael@0: return; michael@0: try { michael@0: args.uri = cmdLine.resolveURI(uristr).spec; michael@0: } michael@0: catch (e) { michael@0: return; michael@0: } michael@0: } michael@0: catch (e) { michael@0: cmdLine.handleFlag("recording", true); michael@0: } michael@0: michael@0: /** michael@0: * Manipulate preferences by adding to the *default* branch. Adding michael@0: * to the default branch means the changes we make won't get written michael@0: * back to user preferences. michael@0: * michael@0: * We want to do this here rather than in reftest.js because it's michael@0: * important to set the recording pref before the platform Init gets michael@0: * called. michael@0: */ michael@0: var prefs = Components.classes["@mozilla.org/preferences-service;1"]. michael@0: getService(Components.interfaces.nsIPrefService); michael@0: var branch = prefs.getDefaultBranch(""); michael@0: michael@0: try { michael@0: var outputstr = cmdLine.handleFlagWithParam("recording-output", false); michael@0: if (outputstr != null) { michael@0: branch.setCharPref("gfx.2d.recordingfile", outputstr); michael@0: } michael@0: } catch (e) { } michael@0: michael@0: branch.setBoolPref("gfx.2d.recording", true); michael@0: michael@0: var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] michael@0: .getService(nsIWindowWatcher); michael@0: wwatch.openWindow(null, "chrome://recording/content/recording.xul", "_blank", michael@0: "chrome,dialog=no,all", args); michael@0: cmdLine.preventDefault = true; michael@0: }, michael@0: michael@0: helpInfo : " -recording Record drawing for a given URL.\n" + michael@0: " -recording-output Specify destination file for a drawing recording.\n" michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]);