gfx/tests/mochitest/test_acceleration.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/tests/mochitest/test_acceleration.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=627498
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test hardware acceleration</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=627498">Mozilla Bug 627498</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script type="application/javascript">
    1.22 +
    1.23 +// Make sure that acceleration is enabled/disabled the way we expect it to be
    1.24 +// based on platform.
    1.25 +
    1.26 +var importObj = {};
    1.27 +
    1.28 +var Cc = SpecialPowers.Cc;
    1.29 +var Ci = SpecialPowers.Ci;
    1.30 +
    1.31 +var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
    1.32 +var xr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
    1.33 +
    1.34 +var windows = SpecialPowers.Services.ww.getWindowEnumerator();
    1.35 +var windowutils;
    1.36 +var acceleratedWindows = 0;
    1.37 +while (windows.hasMoreElements()) {
    1.38 +  windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
    1.39 +                                 .getInterface(Ci.nsIDOMWindowUtils);
    1.40 +  try {
    1.41 +    if (windowutils.layerManagerType != "Basic") {
    1.42 +      acceleratedWindows++;
    1.43 +    }
    1.44 +  } catch (e) {
    1.45 +    // The window may not have a layer manager, in which case we get an error.
    1.46 +    // Don't count it as an accelerated window.
    1.47 +  }
    1.48 +}
    1.49 +
    1.50 +var osName = sysInfo.getProperty("name");
    1.51 +switch(osName)
    1.52 +{
    1.53 +  case "Darwin": // Mac OS X.
    1.54 +    // We only enable OpenGL layers on machines that don't support QuickDraw
    1.55 +    // plugins. x86-64 architecture is a good proxy for this plugin support.
    1.56 +    if (sysInfo.getProperty("arch") != "x86-64") {
    1.57 +      is(acceleratedWindows, 0, "Acceleration not supported on x86 OS X");
    1.58 +    } else {
    1.59 +      // Workaround for SeaMonkey tinderboxes which don't support acceleration.
    1.60 +      if (navigator.userAgent.match(/ SeaMonkey\//)) {
    1.61 +        if (acceleratedWindows == 0) {
    1.62 +          todo(false, "Acceleration not supported on x86-64 OS X" +
    1.63 +                      " (This is expected on SeaMonkey (tinderboxes).)");
    1.64 +          break;
    1.65 +        }
    1.66 +      }
    1.67 +
    1.68 +      isnot(acceleratedWindows, 0, "Acceleration enabled on x86-64 OS X");
    1.69 +    }
    1.70 +    break;
    1.71 +
    1.72 +  case "Windows_NT": // Windows.
    1.73 +    var version = parseFloat(sysInfo.getProperty("version"));
    1.74 +    if (version == 5.0) {
    1.75 +      is(acceleratedWindows, 0, "Acceleration not supported on Windows 2000");
    1.76 +    } else {
    1.77 +      // Workaround for SeaMonkey tinderboxes which don't support acceleration.
    1.78 +      if (navigator.userAgent.match(/ SeaMonkey\//)) {
    1.79 +        if (acceleratedWindows == 0) {
    1.80 +          todo(false, "Acceleration not supported on Windows XP or newer" +
    1.81 +                      " (This is expected on SeaMonkey (tinderboxes).)");
    1.82 +          break;
    1.83 +        }
    1.84 +      }
    1.85 +
    1.86 +      isnot(acceleratedWindows, 0, "Acceleration enabled on Windows XP or newer");
    1.87 +    }
    1.88 +
    1.89 +    var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
    1.90 +    if (version < 6.0) {
    1.91 +      ok(!gfxInfo.D2DEnabled, "Direct2D not supported on Windows 2003 or older");
    1.92 +      ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2003 or older");
    1.93 +    } else {
    1.94 +      ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows Vista or newer");
    1.95 +      ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows Vista or newer");
    1.96 +    }
    1.97 +    break;
    1.98 +
    1.99 +  default: // Linux and others.
   1.100 +    if (xr.OS == "Android" && xr.widgetToolkit != "gonk") {
   1.101 +      isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
   1.102 +    } else {
   1.103 +      is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
   1.104 +    }
   1.105 +}
   1.106 +
   1.107 +</script>
   1.108 +</pre>
   1.109 +</body>
   1.110 +</html>

mercurial