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 RefTestCmdLineHandler() {} michael@0: RefTestCmdLineHandler.prototype = michael@0: { michael@0: classID: Components.ID('{32530271-8c1b-4b7d-a812-218e42c6bb23}'), 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("reftest", 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("reftest", true); michael@0: } michael@0: michael@0: try { michael@0: var nocache = cmdLine.handleFlag("reftestnocache", false); michael@0: args.nocache = nocache; michael@0: } michael@0: catch (e) { michael@0: } michael@0: michael@0: try { michael@0: var skipslowtests = cmdLine.handleFlag("reftestskipslowtests", false); michael@0: args.skipslowtests = skipslowtests; michael@0: } michael@0: catch (e) { michael@0: } michael@0: michael@0: /* Ignore the platform's online/offline status while running reftests. */ michael@0: var ios = Components.classes["@mozilla.org/network/io-service;1"] michael@0: .getService(Components.interfaces.nsIIOService2); michael@0: ios.manageOfflineStatus = false; michael@0: ios.offline = false; 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 force sRGB as an output profile for color management michael@0: * before we load a window. 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: #include reftest-preferences.js michael@0: michael@0: var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] michael@0: .getService(nsIWindowWatcher); michael@0: michael@0: function loadReftests() { michael@0: wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank", michael@0: "chrome,dialog=no,all", args); michael@0: } michael@0: michael@0: var remote = false; michael@0: try { michael@0: remote = prefs.getBoolPref("reftest.remote"); michael@0: } catch (ex) { michael@0: } michael@0: michael@0: // If we are running on a remote machine, assume that we can't open another michael@0: // window for transferring focus to when tests don't require focus. michael@0: if (remote) { michael@0: loadReftests(); michael@0: } michael@0: else { michael@0: // This dummy window exists solely for enforcing proper focus discipline. michael@0: var dummy = wwatch.openWindow(null, "about:blank", "dummy", michael@0: "chrome,dialog=no,left=800,height=200,width=200,all", null); michael@0: dummy.onload = function dummyOnload() { michael@0: dummy.focus(); michael@0: loadReftests(); michael@0: } michael@0: } michael@0: michael@0: cmdLine.preventDefault = true; michael@0: }, michael@0: michael@0: helpInfo : " -reftest Run layout acceptance tests on given manifest.\n" michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RefTestCmdLineHandler]);