1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/tools/reftest/reftest-cmdline.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 1.9 + 1.10 +const nsISupports = Components.interfaces.nsISupports; 1.11 + 1.12 +const nsICommandLine = Components.interfaces.nsICommandLine; 1.13 +const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler; 1.14 +const nsISupportsString = Components.interfaces.nsISupportsString; 1.15 +const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; 1.16 + 1.17 +function RefTestCmdLineHandler() {} 1.18 +RefTestCmdLineHandler.prototype = 1.19 +{ 1.20 + classID: Components.ID('{32530271-8c1b-4b7d-a812-218e42c6bb23}'), 1.21 + 1.22 + /* nsISupports */ 1.23 + QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]), 1.24 + 1.25 + /* nsICommandLineHandler */ 1.26 + handle : function handler_handle(cmdLine) { 1.27 + var args = { }; 1.28 + args.wrappedJSObject = args; 1.29 + try { 1.30 + var uristr = cmdLine.handleFlagWithParam("reftest", false); 1.31 + if (uristr == null) 1.32 + return; 1.33 + try { 1.34 + args.uri = cmdLine.resolveURI(uristr).spec; 1.35 + } 1.36 + catch (e) { 1.37 + return; 1.38 + } 1.39 + } 1.40 + catch (e) { 1.41 + cmdLine.handleFlag("reftest", true); 1.42 + } 1.43 + 1.44 + try { 1.45 + var nocache = cmdLine.handleFlag("reftestnocache", false); 1.46 + args.nocache = nocache; 1.47 + } 1.48 + catch (e) { 1.49 + } 1.50 + 1.51 + try { 1.52 + var skipslowtests = cmdLine.handleFlag("reftestskipslowtests", false); 1.53 + args.skipslowtests = skipslowtests; 1.54 + } 1.55 + catch (e) { 1.56 + } 1.57 + 1.58 + /* Ignore the platform's online/offline status while running reftests. */ 1.59 + var ios = Components.classes["@mozilla.org/network/io-service;1"] 1.60 + .getService(Components.interfaces.nsIIOService2); 1.61 + ios.manageOfflineStatus = false; 1.62 + ios.offline = false; 1.63 + 1.64 + /** 1.65 + * Manipulate preferences by adding to the *default* branch. Adding 1.66 + * to the default branch means the changes we make won't get written 1.67 + * back to user preferences. 1.68 + * 1.69 + * We want to do this here rather than in reftest.js because it's 1.70 + * important to force sRGB as an output profile for color management 1.71 + * before we load a window. 1.72 + */ 1.73 + var prefs = Components.classes["@mozilla.org/preferences-service;1"]. 1.74 + getService(Components.interfaces.nsIPrefService); 1.75 + var branch = prefs.getDefaultBranch(""); 1.76 + 1.77 +#include reftest-preferences.js 1.78 + 1.79 + var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] 1.80 + .getService(nsIWindowWatcher); 1.81 + 1.82 + function loadReftests() { 1.83 + wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank", 1.84 + "chrome,dialog=no,all", args); 1.85 + } 1.86 + 1.87 + var remote = false; 1.88 + try { 1.89 + remote = prefs.getBoolPref("reftest.remote"); 1.90 + } catch (ex) { 1.91 + } 1.92 + 1.93 + // If we are running on a remote machine, assume that we can't open another 1.94 + // window for transferring focus to when tests don't require focus. 1.95 + if (remote) { 1.96 + loadReftests(); 1.97 + } 1.98 + else { 1.99 + // This dummy window exists solely for enforcing proper focus discipline. 1.100 + var dummy = wwatch.openWindow(null, "about:blank", "dummy", 1.101 + "chrome,dialog=no,left=800,height=200,width=200,all", null); 1.102 + dummy.onload = function dummyOnload() { 1.103 + dummy.focus(); 1.104 + loadReftests(); 1.105 + } 1.106 + } 1.107 + 1.108 + cmdLine.preventDefault = true; 1.109 + }, 1.110 + 1.111 + helpInfo : " -reftest <file> Run layout acceptance tests on given manifest.\n" 1.112 +}; 1.113 + 1.114 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RefTestCmdLineHandler]);