gfx/tests/mochitest/test_acceleration.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=627498
     5 -->
     6 <head>
     7   <title>Test hardware acceleration</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=627498">Mozilla Bug 627498</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 <script type="application/javascript">
    20 // Make sure that acceleration is enabled/disabled the way we expect it to be
    21 // based on platform.
    23 var importObj = {};
    25 var Cc = SpecialPowers.Cc;
    26 var Ci = SpecialPowers.Ci;
    28 var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
    29 var xr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
    31 var windows = SpecialPowers.Services.ww.getWindowEnumerator();
    32 var windowutils;
    33 var acceleratedWindows = 0;
    34 while (windows.hasMoreElements()) {
    35   windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
    36                                  .getInterface(Ci.nsIDOMWindowUtils);
    37   try {
    38     if (windowutils.layerManagerType != "Basic") {
    39       acceleratedWindows++;
    40     }
    41   } catch (e) {
    42     // The window may not have a layer manager, in which case we get an error.
    43     // Don't count it as an accelerated window.
    44   }
    45 }
    47 var osName = sysInfo.getProperty("name");
    48 switch(osName)
    49 {
    50   case "Darwin": // Mac OS X.
    51     // We only enable OpenGL layers on machines that don't support QuickDraw
    52     // plugins. x86-64 architecture is a good proxy for this plugin support.
    53     if (sysInfo.getProperty("arch") != "x86-64") {
    54       is(acceleratedWindows, 0, "Acceleration not supported on x86 OS X");
    55     } else {
    56       // Workaround for SeaMonkey tinderboxes which don't support acceleration.
    57       if (navigator.userAgent.match(/ SeaMonkey\//)) {
    58         if (acceleratedWindows == 0) {
    59           todo(false, "Acceleration not supported on x86-64 OS X" +
    60                       " (This is expected on SeaMonkey (tinderboxes).)");
    61           break;
    62         }
    63       }
    65       isnot(acceleratedWindows, 0, "Acceleration enabled on x86-64 OS X");
    66     }
    67     break;
    69   case "Windows_NT": // Windows.
    70     var version = parseFloat(sysInfo.getProperty("version"));
    71     if (version == 5.0) {
    72       is(acceleratedWindows, 0, "Acceleration not supported on Windows 2000");
    73     } else {
    74       // Workaround for SeaMonkey tinderboxes which don't support acceleration.
    75       if (navigator.userAgent.match(/ SeaMonkey\//)) {
    76         if (acceleratedWindows == 0) {
    77           todo(false, "Acceleration not supported on Windows XP or newer" +
    78                       " (This is expected on SeaMonkey (tinderboxes).)");
    79           break;
    80         }
    81       }
    83       isnot(acceleratedWindows, 0, "Acceleration enabled on Windows XP or newer");
    84     }
    86     var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
    87     if (version < 6.0) {
    88       ok(!gfxInfo.D2DEnabled, "Direct2D not supported on Windows 2003 or older");
    89       ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2003 or older");
    90     } else {
    91       ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows Vista or newer");
    92       ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows Vista or newer");
    93     }
    94     break;
    96   default: // Linux and others.
    97     if (xr.OS == "Android" && xr.widgetToolkit != "gonk") {
    98       isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
    99     } else {
   100       is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
   101     }
   102 }
   104 </script>
   105 </pre>
   106 </body>
   107 </html>

mercurial