Mercurial > hg > config
comparison components/tp-cmdline.js @ 208:3f290bcae11a
wtf
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 13 Feb 2012 16:24:06 -0800 |
parents | beca399c3a16 |
children |
comparison
equal
deleted
inserted
replaced
207:7bad4b7281f2 | 208:3f290bcae11a |
---|---|
1 /* ***** BEGIN LICENSE BLOCK ***** | |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |
3 * | |
4 * The contents of this file are subject to the Mozilla Public License Version | |
5 * 1.1 (the "License"); you may not use this file except in compliance with | |
6 * the License. You may obtain a copy of the License at | |
7 * http://www.mozilla.org/MPL/ | |
8 * | |
9 * Software distributed under the License is distributed on an "AS IS" basis, | |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
11 * for the specific language governing rights and limitations under the | |
12 * License. | |
13 * | |
14 * The Original Code is DOM Inspector. | |
15 * | |
16 * The Initial Developer of the Original Code is | |
17 * Christopher A. Aillon <christopher@aillon.com>. | |
18 * Portions created by the Initial Developer are Copyright (C) 2003 | |
19 * the Initial Developer. All Rights Reserved. | |
20 * | |
21 * Contributor(s): | |
22 * Christopher A. Aillon <christopher@aillon.com> | |
23 * L. David Baron, Mozilla Corporation <dbaron@dbaron.org> (modified for reftest) | |
24 * Vladimir Vukicevic, Mozilla Corporation <dbaron@dbaron.org> (modified for tp) | |
25 * | |
26 * Alternatively, the contents of this file may be used under the terms of | |
27 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
29 * in which case the provisions of the GPL or the LGPL are applicable instead | |
30 * of those above. If you wish to allow use of your version of this file only | |
31 * under the terms of either the GPL or the LGPL, and not to allow others to | |
32 * use your version of this file under the terms of the MPL, indicate your | |
33 * decision by deleting the provisions above and replace them with the notice | |
34 * and other provisions required by the GPL or the LGPL. If you do not delete | |
35 * the provisions above, a recipient may use your version of this file under | |
36 * the terms of any one of the MPL, the GPL or the LGPL. | |
37 * | |
38 * ***** END LICENSE BLOCK ***** */ | |
39 | |
40 // This only implements nsICommandLineHandler, since it needs | |
41 // to handle multiple arguments. | |
42 | |
43 const TP_CMDLINE_CONTRACTID = "@mozilla.org/commandlinehandler/general-startup;1?type=tp"; | |
44 const TP_CMDLINE_CLSID = Components.ID('{8AF052F5-8EFE-4359-8266-E16498A82E8B}'); | |
45 const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1"; | |
46 const nsISupports = Components.interfaces.nsISupports; | |
47 | |
48 const nsICategoryManager = Components.interfaces.nsICategoryManager; | |
49 const nsICommandLine = Components.interfaces.nsICommandLine; | |
50 const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler; | |
51 const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar; | |
52 const nsISupportsString = Components.interfaces.nsISupportsString; | |
53 const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; | |
54 | |
55 function PageLoaderCmdLineHandler() {} | |
56 PageLoaderCmdLineHandler.prototype = | |
57 { | |
58 /* nsISupports */ | |
59 QueryInterface : function handler_QI(iid) { | |
60 if (iid.equals(nsISupports)) | |
61 return this; | |
62 | |
63 if (nsICommandLineHandler && iid.equals(nsICommandLineHandler)) | |
64 return this; | |
65 | |
66 throw Components.results.NS_ERROR_NO_INTERFACE; | |
67 }, | |
68 | |
69 /* nsICommandLineHandler */ | |
70 handle : function handler_handle(cmdLine) { | |
71 var args = {}; | |
72 try { | |
73 var uristr = cmdLine.handleFlagWithParam("tp", false); | |
74 if (uristr == null) | |
75 return; | |
76 try { | |
77 args.manifest = cmdLine.resolveURI(uristr).spec; | |
78 } catch (e) { | |
79 return; | |
80 } | |
81 | |
82 args.numCycles = cmdLine.handleFlagWithParam("tpcycles", false); | |
83 args.startIndex = cmdLine.handleFlagWithParam("tpstart", false); | |
84 args.endIndex = cmdLine.handleFlagWithParam("tpend", false); | |
85 args.filter = cmdLine.handleFlagWithParam("tpfilter", false); | |
86 args.format = cmdLine.handleFlagWithParam("tpformat", false); | |
87 args.useBrowserChrome = cmdLine.handleFlag("tpchrome", false); | |
88 args.doRender = cmdLine.handleFlag("tprender", false); | |
89 args.width = cmdLine.handleFlagWithParam("tpwidth", false); | |
90 args.height = cmdLine.handleFlagWithParam("tpheight", false); | |
91 args.offline = cmdLine.handleFlag("tpoffline", false); | |
92 args.noisy = cmdLine.handleFlag("tpnoisy", false); | |
93 args.timeout = cmdLine.handleFlagWithParam("tptimeout", false); | |
94 args.delay = cmdLine.handleFlagWithParam("tpdelay", false); | |
95 args.noForceCC = cmdLine.handleFlag("tpnoforcecc", false); | |
96 args.mozafterpaint = cmdLine.handleFlag("tpmozafterpaint", false); | |
97 args.rss = cmdLine.handleFlag("rss", false); | |
98 } | |
99 catch (e) { | |
100 return; | |
101 } | |
102 | |
103 // get our data through xpconnect | |
104 args.wrappedJSObject = args; | |
105 | |
106 var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] | |
107 .getService(nsIWindowWatcher); | |
108 wwatch.openWindow(null, "chrome://pageloader/content/pageloader.xul", "_blank", | |
109 "chrome,dialog=no,all", args); | |
110 cmdLine.preventDefault = true; | |
111 }, | |
112 | |
113 helpInfo : | |
114 " -tp <file> Run pageload perf tests on given manifest\n" + | |
115 " -tpfilter str Only include pages from manifest that contain str (regexp)\n" + | |
116 " -tpcycles n Loop through pages n times\n" + | |
117 " -tpstart n Start at index n in the manifest\n" + | |
118 " -tpend n End with index n in the manifest\n" + | |
119 " -tpformat f1,f2,.. Report format(s) to use\n" + | |
120 " -tpchrome Test with normal browser chrome\n" + | |
121 " -tprender Run render-only benchmark for each page\n" + | |
122 " -tpwidth width Width of window\n" + | |
123 " -tpheight height Height of window\n" + | |
124 " -tpoffline Force offline mode\n" + | |
125 " -tpnoisy Dump the name of the last loaded page to console\n" + | |
126 " -tptimeout Max amount of time given for a page to load, quit if exceeded\n" + | |
127 " -tpdelay Amount of time to wait between each pageload\n" + | |
128 " -tpnoforcecc Don't force cycle collection between each pageload\n" + | |
129 " -tpmozafterpaint Measure Time after recieving MozAfterPaint event instead of load event\n" + | |
130 " -rss Dump RSS after each page is loaded\n" | |
131 | |
132 }; | |
133 | |
134 | |
135 var PageLoaderCmdLineFactory = | |
136 { | |
137 createInstance : function(outer, iid) | |
138 { | |
139 if (outer != null) { | |
140 throw Components.results.NS_ERROR_NO_AGGREGATION; | |
141 } | |
142 | |
143 return new PageLoaderCmdLineHandler().QueryInterface(iid); | |
144 } | |
145 }; | |
146 | |
147 function NSGetFactory(cid) { | |
148 if (!cid.equals(TP_CMDLINE_CLSID)) | |
149 throw Components.results.NS_ERROR_NOT_IMPLEMENTED; | |
150 | |
151 return PageLoaderCmdLineFactory; | |
152 } | |
153 | |
154 var PageLoaderCmdLineModule = | |
155 { | |
156 registerSelf : function(compMgr, fileSpec, location, type) | |
157 { | |
158 compMgr = compMgr.QueryInterface(nsIComponentRegistrar); | |
159 | |
160 compMgr.registerFactoryLocation(TP_CMDLINE_CLSID, | |
161 "PageLoader CommandLine Service", | |
162 TP_CMDLINE_CONTRACTID, | |
163 fileSpec, | |
164 location, | |
165 type); | |
166 | |
167 var catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager); | |
168 catman.addCategoryEntry("command-line-handler", | |
169 "m-tp", | |
170 TP_CMDLINE_CONTRACTID, true, true); | |
171 }, | |
172 | |
173 unregisterSelf : function(compMgr, fileSpec, location) | |
174 { | |
175 compMgr = compMgr.QueryInterface(nsIComponentRegistrar); | |
176 | |
177 compMgr.unregisterFactoryLocation(TP_CMDLINE_CLSID, fileSpec); | |
178 catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager); | |
179 catman.deleteCategoryEntry("command-line-handler", | |
180 "m-tp", true); | |
181 }, | |
182 | |
183 getClassObject : function(compMgr, cid, iid) | |
184 { | |
185 return NSGetFactory(cid); | |
186 }, | |
187 | |
188 canUnload : function(compMgr) | |
189 { | |
190 return true; | |
191 } | |
192 }; | |
193 | |
194 | |
195 function NSGetModule(compMgr, fileSpec) { | |
196 return PageLoaderCmdLineModule; | |
197 } |