Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | const nsISupports = Components.interfaces.nsISupports; |
michael@0 | 8 | |
michael@0 | 9 | const nsICommandLine = Components.interfaces.nsICommandLine; |
michael@0 | 10 | const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler; |
michael@0 | 11 | const nsISupportsString = Components.interfaces.nsISupportsString; |
michael@0 | 12 | const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; |
michael@0 | 13 | |
michael@0 | 14 | function RefTestCmdLineHandler() {} |
michael@0 | 15 | RefTestCmdLineHandler.prototype = |
michael@0 | 16 | { |
michael@0 | 17 | classID: Components.ID('{32530271-8c1b-4b7d-a812-218e42c6bb23}'), |
michael@0 | 18 | |
michael@0 | 19 | /* nsISupports */ |
michael@0 | 20 | QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]), |
michael@0 | 21 | |
michael@0 | 22 | /* nsICommandLineHandler */ |
michael@0 | 23 | handle : function handler_handle(cmdLine) { |
michael@0 | 24 | var args = { }; |
michael@0 | 25 | args.wrappedJSObject = args; |
michael@0 | 26 | try { |
michael@0 | 27 | var uristr = cmdLine.handleFlagWithParam("reftest", false); |
michael@0 | 28 | if (uristr == null) |
michael@0 | 29 | return; |
michael@0 | 30 | try { |
michael@0 | 31 | args.uri = cmdLine.resolveURI(uristr).spec; |
michael@0 | 32 | } |
michael@0 | 33 | catch (e) { |
michael@0 | 34 | return; |
michael@0 | 35 | } |
michael@0 | 36 | } |
michael@0 | 37 | catch (e) { |
michael@0 | 38 | cmdLine.handleFlag("reftest", true); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | try { |
michael@0 | 42 | var nocache = cmdLine.handleFlag("reftestnocache", false); |
michael@0 | 43 | args.nocache = nocache; |
michael@0 | 44 | } |
michael@0 | 45 | catch (e) { |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | try { |
michael@0 | 49 | var skipslowtests = cmdLine.handleFlag("reftestskipslowtests", false); |
michael@0 | 50 | args.skipslowtests = skipslowtests; |
michael@0 | 51 | } |
michael@0 | 52 | catch (e) { |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | /* Ignore the platform's online/offline status while running reftests. */ |
michael@0 | 56 | var ios = Components.classes["@mozilla.org/network/io-service;1"] |
michael@0 | 57 | .getService(Components.interfaces.nsIIOService2); |
michael@0 | 58 | ios.manageOfflineStatus = false; |
michael@0 | 59 | ios.offline = false; |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Manipulate preferences by adding to the *default* branch. Adding |
michael@0 | 63 | * to the default branch means the changes we make won't get written |
michael@0 | 64 | * back to user preferences. |
michael@0 | 65 | * |
michael@0 | 66 | * We want to do this here rather than in reftest.js because it's |
michael@0 | 67 | * important to force sRGB as an output profile for color management |
michael@0 | 68 | * before we load a window. |
michael@0 | 69 | */ |
michael@0 | 70 | var prefs = Components.classes["@mozilla.org/preferences-service;1"]. |
michael@0 | 71 | getService(Components.interfaces.nsIPrefService); |
michael@0 | 72 | var branch = prefs.getDefaultBranch(""); |
michael@0 | 73 | |
michael@0 | 74 | #include reftest-preferences.js |
michael@0 | 75 | |
michael@0 | 76 | var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] |
michael@0 | 77 | .getService(nsIWindowWatcher); |
michael@0 | 78 | |
michael@0 | 79 | function loadReftests() { |
michael@0 | 80 | wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank", |
michael@0 | 81 | "chrome,dialog=no,all", args); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | var remote = false; |
michael@0 | 85 | try { |
michael@0 | 86 | remote = prefs.getBoolPref("reftest.remote"); |
michael@0 | 87 | } catch (ex) { |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | // If we are running on a remote machine, assume that we can't open another |
michael@0 | 91 | // window for transferring focus to when tests don't require focus. |
michael@0 | 92 | if (remote) { |
michael@0 | 93 | loadReftests(); |
michael@0 | 94 | } |
michael@0 | 95 | else { |
michael@0 | 96 | // This dummy window exists solely for enforcing proper focus discipline. |
michael@0 | 97 | var dummy = wwatch.openWindow(null, "about:blank", "dummy", |
michael@0 | 98 | "chrome,dialog=no,left=800,height=200,width=200,all", null); |
michael@0 | 99 | dummy.onload = function dummyOnload() { |
michael@0 | 100 | dummy.focus(); |
michael@0 | 101 | loadReftests(); |
michael@0 | 102 | } |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | cmdLine.preventDefault = true; |
michael@0 | 106 | }, |
michael@0 | 107 | |
michael@0 | 108 | helpInfo : " -reftest <file> Run layout acceptance tests on given manifest.\n" |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RefTestCmdLineHandler]); |