!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
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 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 // NOTE: this file implements both the seamonkey nsICmdLineHandler and
40 // the toolkit nsICommandLineHandler, using runtime detection.
41
42 const REFTEST_CMDLINE_CONTRACTID = "@mozilla.org/commandlinehandler/general-startup;1?type=reftest";
43 const REFTEST_CMDLINE_CLSID = Components.ID('{32530271-8c1b-4b7d-a812-218e42c6bb23}');
44 const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
45 const nsISupports = Components.interfaces.nsISupports;
46
47 const nsICategoryManager = Components.interfaces.nsICategoryManager;
48 const nsICmdLineHandler = Components.interfaces.nsICmdLineHandler;
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
RefTestCmdLineHandler
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
55 function RefTestCmdLineHandler() {}
56 RefTestCmdLineHandler.prototype =
57 {
58 /* nsISupports */
handler_QI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
59 QueryInterface : function handler_QI(iid) {
60 if (iid.equals(nsISupports))
61 return this;
62
63 if (nsICmdLineHandler && iid.equals(nsICmdLineHandler))
64 return this;
65
66 if (nsICommandLineHandler && iid.equals(nsICommandLineHandler))
67 return this;
68
69 throw Components.results.NS_ERROR_NO_INTERFACE;
70 },
71
72 /* nsICmdLineHandler */
73 commandLineArgument : "-reftest",
74 prefNameForStartup : "general.startup.reftest",
75 chromeUrlForTask : "chrome://reftest/content/reftest.xul",
76 helpText : "Run layout acceptance tests on given manifest.",
77 handlesArgs : true,
78 defaultArgs : "",
79 openWindowWithArgs : true,
80
81 /* nsICommandLineHandler */
handler_handle
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
82 handle : function handler_handle(cmdLine) {
83 var args = Components.classes["@mozilla.org/supports-string;1"]
84 .createInstance(nsISupportsString);
85 try {
86 var uristr = cmdLine.handleFlagWithParam("reftest", false);
87 if (uristr == null)
88 return;
89 try {
90 args.data = cmdLine.resolveURI(uristr).spec;
91 }
92 catch (e) {
93 return;
94 }
95 }
96 catch (e) {
97 cmdLine.handleFlag("reftest", true);
98 }
99
100 var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
101 .getService(nsIWindowWatcher);
102 wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank",
103 "chrome,dialog=no,all", args);
104 cmdLine.preventDefault = true;
105 },
106
107 helpInfo : " -reftest <file> Run layout acceptance tests on given manifest.\n"
108 };
109
110
111 var RefTestCmdLineFactory =
112 {
createInstance
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
113 createInstance : function(outer, iid)
114 {
115 if (outer != null) {
116 throw Components.results.NS_ERROR_NO_AGGREGATION;
117 }
118
119 return new RefTestCmdLineHandler().QueryInterface(iid);
120 }
121 };
122
123
124 var RefTestCmdLineModule =
125 {
registerSelf
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
126 registerSelf : function(compMgr, fileSpec, location, type)
127 {
128 compMgr = compMgr.QueryInterface(nsIComponentRegistrar);
129
130 compMgr.registerFactoryLocation(REFTEST_CMDLINE_CLSID,
131 "RefTest CommandLine Service",
132 REFTEST_CMDLINE_CONTRACTID,
133 fileSpec,
134 location,
135 type);
136
137 var catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager);
138 catman.addCategoryEntry("command-line-argument-handlers",
139 "reftest command line handler",
140 REFTEST_CMDLINE_CONTRACTID, true, true);
141 catman.addCategoryEntry("command-line-handler",
142 "m-reftest",
143 REFTEST_CMDLINE_CONTRACTID, true, true);
144 },
145
unregisterSelf
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
146 unregisterSelf : function(compMgr, fileSpec, location)
147 {
148 compMgr = compMgr.QueryInterface(nsIComponentRegistrar);
149
150 compMgr.unregisterFactoryLocation(REFTEST_CMDLINE_CLSID, fileSpec);
151 catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager);
152 catman.deleteCategoryEntry("command-line-argument-handlers",
153 "reftest command line handler", true);
154 catman.deleteCategoryEntry("command-line-handler",
155 "m-reftest", true);
156 },
157
getClassObject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
158 getClassObject : function(compMgr, cid, iid)
159 {
160 if (cid.equals(REFTEST_CMDLINE_CLSID)) {
161 return RefTestCmdLineFactory;
162 }
163
164 if (!iid.equals(Components.interfaces.nsIFactory)) {
165 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
166 }
167
168 throw Components.results.NS_ERROR_NO_INTERFACE;
169 },
170
canUnload
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
171 canUnload : function(compMgr)
172 {
173 return true;
174 }
175 };
176
177
NSGetModule
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
178 function NSGetModule(compMgr, fileSpec) {
179 return RefTestCmdLineModule;
180 }