Parse reftest conditions based on content gfx settings instead of chrome. (bug 1313260, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Thu, 27 Oct 2016 18:52:51 -0700
changeset 319850 230f4a048880c06cb660839ea46d1b80af633f0e
parent 319849 378639d730e476941e68d69ee7157a253b54879c
child 319851 75fe0970cbbc3dee96def8172cc0d1fae508cb32
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1313260
milestone52.0a1
Parse reftest conditions based on content gfx settings instead of chrome. (bug 1313260, r=mattwoodrow)
layout/tools/reftest/reftest-content.js
layout/tools/reftest/reftest.jsm
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -10,16 +10,17 @@ const CR = Components.results;
 const CU = Components.utils;
 
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 
 const DEBUG_CONTRACTID = "@mozilla.org/xpcom/debug;1";
 const PRINTSETTINGS_CONTRACTID = "@mozilla.org/gfx/printsettings-service;1";
 const ENVIRONMENT_CONTRACTID = "@mozilla.org/process/environment;1";
 const NS_OBSERVER_SERVICE_CONTRACTID = "@mozilla.org/observer-service;1";
+const NS_GFXINFO_CONTRACTID = "@mozilla.org/gfx/info;1";
 
 // "<!--CLEAR-->"
 const BLANK_URL_FOR_CLEARING = "data:text/html;charset=UTF-8,%3C%21%2D%2DCLEAR%2D%2D%3E";
 
 CU.import("resource://gre/modules/Timer.jsm");
 CU.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
 
 var gBrowserIsRemote;
@@ -1023,17 +1024,27 @@ function RecvResetRenderingState()
 
 function SendAssertionCount(numAssertions)
 {
     sendAsyncMessage("reftest:AssertionCount", { count: numAssertions });
 }
 
 function SendContentReady()
 {
-    return sendSyncMessage("reftest:ContentReady")[0];
+    let gfxInfo = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo);
+    let info = gfxInfo.getInfo();
+    try {
+        info.D2DEnabled = gfxInfo.D2DEnabled;
+        info.DWriteEnabled = gfxInfo.DWriteEnabled;
+    } catch (e) {
+        info.D2DEnabled = false;
+        info.DWriteEnabled = false;
+    }
+
+    return sendSyncMessage("reftest:ContentReady", { 'gfx': info })[0];
 }
 
 function SendException(what)
 {
     sendAsyncMessage("reftest:Exception", { what: what });
 }
 
 function SendFailedLoad(why)
--- a/layout/tools/reftest/reftest.jsm
+++ b/layout/tools/reftest/reftest.jsm
@@ -45,16 +45,17 @@ var gRemote = false;
 var gIgnoreWindowSize = false;
 var gShuffle = false;
 var gRepeat = null;
 var gRunUntilFailure = false;
 var gTotalChunks = 0;
 var gThisChunk = 0;
 var gContainingWindow = null;
 var gURLFilterRegex = {};
+var gContentGfxInfo = null;
 const FOCUS_FILTER_ALL_TESTS = "all";
 const FOCUS_FILTER_NEEDS_FOCUS_TESTS = "needs-focus";
 const FOCUS_FILTER_NON_NEEDS_FOCUS_TESTS = "non-needs-focus";
 var gFocusFilterMode = FOCUS_FILTER_ALL_TESTS;
 
 // "<!--CLEAR-->"
 const BLANK_URL_FOR_CLEARING = "data:text/html;charset=UTF-8,%3C%21%2D%2DCLEAR%2D%2D%3E";
 
@@ -635,32 +636,44 @@ function BuildConditionSandbox(aURL) {
 
     var testRect = gBrowser.getBoundingClientRect();
     sandbox.smallScreen = false;
     if (gContainingWindow.innerWidth < 800 || gContainingWindow.innerHeight < 1000) {
         sandbox.smallScreen = true;
     }
 
     var gfxInfo = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo);
+    let readGfxInfo = function (obj, key) {
+      if (gContentGfxInfo && (key in gContentGfxInfo)) {
+        return gContentGfxInfo[key];
+      }
+      return obj[key];
+    }
+
     try {
-      sandbox.d2d = gfxInfo.D2DEnabled;
-      sandbox.dwrite = gfxInfo.DWriteEnabled;
+      sandbox.d2d = readGfxInfo(gfxInfo, "D2DEnabled");
+      sandbox.dwrite = readGfxInfo(gfxInfo, "DWriteEnabled");
     } catch (e) {
       sandbox.d2d = false;
       sandbox.dwrite = false;
     }
+
     var info = gfxInfo.getInfo();
-    sandbox.azureCairo = info.AzureCanvasBackend == "cairo";
-    sandbox.azureQuartz = info.AzureCanvasBackend == "quartz";
-    sandbox.azureSkia = info.AzureCanvasBackend == "skia";
-    sandbox.skiaContent = info.AzureContentBackend == "skia";
-    sandbox.azureSkiaGL = info.AzureCanvasAccelerated; // FIXME: assumes GL right now
+    var canvasBackend = readGfxInfo(info, "AzureCanvasBackend");
+    var contentBackend = readGfxInfo(info, "AzureContentBackend");
+    var canvasAccelerated = readGfxInfo(info, "AzureCanvasAccelerated");
+
+    sandbox.azureCairo = canvasBackend == "cairo";
+    sandbox.azureQuartz = canvasBackend == "quartz";
+    sandbox.azureSkia = canvasBackend == "skia";
+    sandbox.skiaContent = contentBackend == "skia";
+    sandbox.azureSkiaGL = canvasAccelerated; // FIXME: assumes GL right now
     // true if we are using the same Azure backend for rendering canvas and content
-    sandbox.contentSameGfxBackendAsCanvas = info.AzureContentBackend == info.AzureCanvasBackend
-                                            || (info.AzureContentBackend == "none" && info.AzureCanvasBackend == "cairo");
+    sandbox.contentSameGfxBackendAsCanvas = contentBackend == canvasBackend
+                                            || (contentBackend == "none" && canvasBackend == "cairo");
 
     sandbox.layersGPUAccelerated =
       gWindowUtils.layerManagerType != "Basic";
     sandbox.d3d11 =
       gWindowUtils.layerManagerType == "Direct3D 11";
     sandbox.d3d9 =
       gWindowUtils.layerManagerType == "Direct3D 9";
     sandbox.layersOpenGL =
@@ -1900,17 +1913,17 @@ function RestoreChangedPreferences()
 function RegisterMessageListenersAndLoadContentScript()
 {
     gBrowserMessageManager.addMessageListener(
         "reftest:AssertionCount",
         function (m) { RecvAssertionCount(m.json.count); }
     );
     gBrowserMessageManager.addMessageListener(
         "reftest:ContentReady",
-        function (m) { return RecvContentReady() }
+        function (m) { return RecvContentReady(m.data); }
     );
     gBrowserMessageManager.addMessageListener(
         "reftest:Exception",
         function (m) { RecvException(m.json.what) }
     );
     gBrowserMessageManager.addMessageListener(
         "reftest:FailedLoad",
         function (m) { RecvFailedLoad(m.json.why); }
@@ -1959,18 +1972,19 @@ function RegisterMessageListenersAndLoad
     gBrowserMessageManager.loadFrameScript("chrome://reftest/content/reftest-content.js", true, true);
 }
 
 function RecvAssertionCount(count)
 {
     DoAssertionCheck(count);
 }
 
-function RecvContentReady()
+function RecvContentReady(info)
 {
+    gContentGfxInfo = info.gfx;
     InitAndStartRefTests();
     return { remote: gBrowserIsRemote };
 }
 
 function RecvException(what)
 {
     logger.error(gCurrentURL + " | " + what);
     ++gTestResults.Exception;