Bug 1401551 - Only check for acceleration after the page is shown and we know the layer managers have been initialized. r=dvander
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 18 Dec 2017 12:48:47 -0500
changeset 396760 f333d8197a5b3cf323048c9a7db3611d1b865e47
parent 396759 6239a7c3e034937f2b1d0e83053f163d22c24363
child 396761 e8d7f5f691c6c9312a2b7c60d36b4a54dfb845d2
push id33111
push userdluca@mozilla.com
push dateTue, 19 Dec 2017 10:06:26 +0000
treeherdermozilla-central@c76ff8b1c4d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1401551
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1401551 - Only check for acceleration after the page is shown and we know the layer managers have been initialized. r=dvander MozReview-Commit-ID: CA2gQxMIuXn
gfx/tests/mochitest/test_acceleration.html
--- a/gfx/tests/mochitest/test_acceleration.html
+++ b/gfx/tests/mochitest/test_acceleration.html
@@ -15,126 +15,133 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 // Make sure that acceleration is enabled/disabled the way we expect it to be
 // based on platform.
 
-var importObj = {};
+SimpleTest.waitForExplicitFinish();
+
+addEventListener("pageshow", runTest, false);
 
-var Cc = SpecialPowers.Cc;
-var Ci = SpecialPowers.Ci;
+function runTest() {
+  var Cc = SpecialPowers.Cc;
+  var Ci = SpecialPowers.Ci;
 
-var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
-var xr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
+  var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
+  var xr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
 
-var windows = SpecialPowers.Services.ww.getWindowEnumerator();
-var windowutils;
-var acceleratedWindows = 0;
-var advancedLayersWindows = 0;
-var layerManagerLog = [];
-while (windows.hasMoreElements()) {
-  windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
-                                 .getInterface(Ci.nsIDOMWindowUtils);
-  try {
-    if (windowutils.layerManagerType != "Basic") {
-      acceleratedWindows++;
-    }
-    if (windowutils.usingAdvancedLayers) {
-      advancedLayersWindows++;
+  var windows = SpecialPowers.Services.ww.getWindowEnumerator();
+  var windowutils;
+  var acceleratedWindows = 0;
+  var advancedLayersWindows = 0;
+  var layerManagerLog = [];
+  while (windows.hasMoreElements()) {
+    windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
+                                   .getInterface(Ci.nsIDOMWindowUtils);
+    try {
+      if (windowutils.layerManagerType != "Basic") {
+        acceleratedWindows++;
+      }
+      if (windowutils.usingAdvancedLayers) {
+        advancedLayersWindows++;
+      }
+      layerManagerLog.push(windowutils.layerManagerType + ":" +
+                           windowutils.usingAdvancedLayers);
+    } catch (e) {
+      // The window may not have a layer manager, in which case we get an error.
+      // Don't count it as an accelerated window.
+      dump("Didn't get a layer manager! " + e);
     }
-    layerManagerLog.push(windowutils.layerManagerType + ":" +
-                         windowutils.usingAdvancedLayers);
-  } catch (e) {
-    // The window may not have a layer manager, in which case we get an error.
-    // Don't count it as an accelerated window.
   }
-}
+
+  var osName = sysInfo.getProperty("name");
+  switch(osName)
+  {
+    case "Darwin": // Mac OS X.
+      // We only enable OpenGL layers on machines that don't support QuickDraw
+      // plugins. x86-64 architecture is a good proxy for this plugin support.
+      if (sysInfo.getProperty("arch") != "x86-64") {
+        is(acceleratedWindows, 0, "Acceleration not supported on x86 OS X");
+      } else {
+        // Workaround for SeaMonkey tinderboxes which don't support acceleration.
+        if (navigator.userAgent.match(/ SeaMonkey\//)) {
+          if (acceleratedWindows == 0) {
+            todo(false, "Acceleration not supported on x86-64 OS X" +
+                        " (This is expected on SeaMonkey (tinderboxes).)");
+            break;
+          }
+        }
 
-var osName = sysInfo.getProperty("name");
-switch(osName)
-{
-  case "Darwin": // Mac OS X.
-    // We only enable OpenGL layers on machines that don't support QuickDraw
-    // plugins. x86-64 architecture is a good proxy for this plugin support.
-    if (sysInfo.getProperty("arch") != "x86-64") {
-      is(acceleratedWindows, 0, "Acceleration not supported on x86 OS X");
-    } else {
-      // Workaround for SeaMonkey tinderboxes which don't support acceleration.
-      if (navigator.userAgent.match(/ SeaMonkey\//)) {
-        if (acceleratedWindows == 0) {
-          todo(false, "Acceleration not supported on x86-64 OS X" +
-                      " (This is expected on SeaMonkey (tinderboxes).)");
-          break;
+        isnot(acceleratedWindows, 0, "Acceleration enabled on x86-64 OS X");
+      }
+      break;
+
+    case "Windows_NT": // Windows.
+      var version = parseFloat(sysInfo.getProperty("version"));
+      if (version == 5.0) {
+        is(acceleratedWindows, 0, "Acceleration not supported on Windows 2000");
+      } else {
+        // Workaround for SeaMonkey tinderboxes which don't support acceleration.
+        if (navigator.userAgent.match(/ SeaMonkey\//)) {
+          if (acceleratedWindows == 0) {
+            todo(false, "Acceleration not supported on Windows XP or newer" +
+                        " (This is expected on SeaMonkey (tinderboxes).)");
+            break;
+
+          }
         }
+
+        isnot(acceleratedWindows, 0, "Acceleration enabled on Windows XP or newer");
       }
 
-      isnot(acceleratedWindows, 0, "Acceleration enabled on x86-64 OS X");
-    }
-    break;
-
-  case "Windows_NT": // Windows.
-    var version = parseFloat(sysInfo.getProperty("version"));
-    if (version == 5.0) {
-      is(acceleratedWindows, 0, "Acceleration not supported on Windows 2000");
-    } else {
-      // Workaround for SeaMonkey tinderboxes which don't support acceleration.
-      if (navigator.userAgent.match(/ SeaMonkey\//)) {
-        if (acceleratedWindows == 0) {
-          todo(false, "Acceleration not supported on Windows XP or newer" +
-                      " (This is expected on SeaMonkey (tinderboxes).)");
-          break;
-
+      var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+      if (version < 6.2) {
+        ok(!gfxInfo.D2DEnabled, "Direct2D not supported on Windows 2008 or older");
+        if (version < 6.1) {
+          ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2008 or older");
+        } else {
+          ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
         }
-      }
-
-      isnot(acceleratedWindows, 0, "Acceleration enabled on Windows XP or newer");
-    }
-
-    var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
-    if (version < 6.2) {
-      ok(!gfxInfo.D2DEnabled, "Direct2D not supported on Windows 2008 or older");
-      if (version < 6.1) {
-        ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2008 or older");
       } else {
+        ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows 8 or newer");
         ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
       }
-    } else {
-      ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows 8 or newer");
-      ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
-    }
 
-    var advancedLayersEnabled = false;
-    var advancedLayersEnabledOnWin7 = false;
-    try {
-      advancedLayersEnabled = SpecialPowers.getBoolPref("layers.mlgpu.enabled");
-      advancedLayersEnabledOnWin7 = SpecialPowers.getBoolPref("layers.mlgpu.enable-on-windows7");
-    } catch (e) {}
-    var shouldGetAL = advancedLayersEnabled;
-    if (version < 6.2) {
-      shouldGetAL &= advancedLayersEnabledOnWin7;
-    }
-    if (shouldGetAL) {
-      isnot(advancedLayersWindows, 0, "Advanced Layers enabled on Windows; "
-                                      + layerManagerLog.join(","));
-    } else {
-      is(advancedLayersWindows, 0, "Advanced Layers disabled on Windows");
-    }
-    break;
+      var advancedLayersEnabled = false;
+      var advancedLayersEnabledOnWin7 = false;
+      try {
+        advancedLayersEnabled = SpecialPowers.getBoolPref("layers.mlgpu.enabled");
+        advancedLayersEnabledOnWin7 = SpecialPowers.getBoolPref("layers.mlgpu.enable-on-windows7");
+      } catch (e) {}
+      var shouldGetAL = advancedLayersEnabled;
+      if (version < 6.2) {
+        shouldGetAL &= advancedLayersEnabledOnWin7;
+      }
+      if (shouldGetAL) {
+        isnot(advancedLayersWindows, 0, "Advanced Layers enabled on Windows; "
+                                        + layerManagerLog.join(","));
+      } else {
+        is(advancedLayersWindows, 0, "Advanced Layers disabled on Windows");
+      }
+      break;
 
-  case "Linux":
-    todo(false, "Acceleration supported on Linux, but only on taskcluster instances (bug 1296086)");
-    break;
+    case "Linux":
+      todo(false, "Acceleration supported on Linux, but only on taskcluster instances (bug 1296086)");
+      break;
 
-  default:
-    if (xr.OS == "Android") {
-      isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
-    } else {
-      is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
-    }
+    default:
+      if (xr.OS == "Android") {
+        isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
+      } else {
+        is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
+      }
+  }
+
+  SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
 </html>