|
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 RefTestCmdLineHandler() {} |
|
15 RefTestCmdLineHandler.prototype = |
|
16 { |
|
17 classID: Components.ID('{32530271-8c1b-4b7d-a812-218e42c6bb23}'), |
|
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("reftest", 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("reftest", true); |
|
39 } |
|
40 |
|
41 try { |
|
42 var nocache = cmdLine.handleFlag("reftestnocache", false); |
|
43 args.nocache = nocache; |
|
44 } |
|
45 catch (e) { |
|
46 } |
|
47 |
|
48 try { |
|
49 var skipslowtests = cmdLine.handleFlag("reftestskipslowtests", false); |
|
50 args.skipslowtests = skipslowtests; |
|
51 } |
|
52 catch (e) { |
|
53 } |
|
54 |
|
55 /* Ignore the platform's online/offline status while running reftests. */ |
|
56 var ios = Components.classes["@mozilla.org/network/io-service;1"] |
|
57 .getService(Components.interfaces.nsIIOService2); |
|
58 ios.manageOfflineStatus = false; |
|
59 ios.offline = false; |
|
60 |
|
61 /** |
|
62 * Manipulate preferences by adding to the *default* branch. Adding |
|
63 * to the default branch means the changes we make won't get written |
|
64 * back to user preferences. |
|
65 * |
|
66 * We want to do this here rather than in reftest.js because it's |
|
67 * important to force sRGB as an output profile for color management |
|
68 * before we load a window. |
|
69 */ |
|
70 var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
|
71 getService(Components.interfaces.nsIPrefService); |
|
72 var branch = prefs.getDefaultBranch(""); |
|
73 |
|
74 #include reftest-preferences.js |
|
75 |
|
76 var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] |
|
77 .getService(nsIWindowWatcher); |
|
78 |
|
79 function loadReftests() { |
|
80 wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank", |
|
81 "chrome,dialog=no,all", args); |
|
82 } |
|
83 |
|
84 var remote = false; |
|
85 try { |
|
86 remote = prefs.getBoolPref("reftest.remote"); |
|
87 } catch (ex) { |
|
88 } |
|
89 |
|
90 // If we are running on a remote machine, assume that we can't open another |
|
91 // window for transferring focus to when tests don't require focus. |
|
92 if (remote) { |
|
93 loadReftests(); |
|
94 } |
|
95 else { |
|
96 // This dummy window exists solely for enforcing proper focus discipline. |
|
97 var dummy = wwatch.openWindow(null, "about:blank", "dummy", |
|
98 "chrome,dialog=no,left=800,height=200,width=200,all", null); |
|
99 dummy.onload = function dummyOnload() { |
|
100 dummy.focus(); |
|
101 loadReftests(); |
|
102 } |
|
103 } |
|
104 |
|
105 cmdLine.preventDefault = true; |
|
106 }, |
|
107 |
|
108 helpInfo : " -reftest <file> Run layout acceptance tests on given manifest.\n" |
|
109 }; |
|
110 |
|
111 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RefTestCmdLineHandler]); |