tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_acceleration.html (4380B)


      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 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">
     15 
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 
     20 // Make sure that acceleration is enabled/disabled the way we expect it to be
     21 // based on platform.
     22 
     23 SimpleTest.waitForExplicitFinish();
     24 
     25 addEventListener("pageshow", runTest, false);
     26 
     27 function runTest() {
     28  var Cc = SpecialPowers.Cc;
     29  var Ci = SpecialPowers.Ci;
     30 
     31  var sysInfo = SpecialPowers.Services.sysinfo;
     32  var xr = SpecialPowers.Services.appinfo;
     33 
     34  var windows = SpecialPowers.Services.ww.getWindowEnumerator();
     35  var windowutils;
     36  var acceleratedWindows = 0;
     37  var webrenderWindows = 0;
     38  var layerManagerLog = [];
     39  while (windows.hasMoreElements()) {
     40    try {
     41      windowutils = windows.getNext().windowUtils;
     42    } catch (e) {
     43      todo(false, "Bug X - don't expose BFCached pages through window enumerator");
     44    }
     45    try {
     46      var layerManager = windowutils.layerManagerType;
     47      if (layerManager != "Basic" && layerManager != "WebRender (Software)") {
     48        acceleratedWindows++;
     49      }
     50      if (layerManager.startsWith("WebRender")) {
     51        webrenderWindows++;
     52      }
     53      layerManagerLog.push(layerManager);
     54    } catch (e) {
     55      // The window may not have a layer manager, in which case we get an error.
     56      // Don't count it as an accelerated window.
     57      dump("Didn't get a layer manager! " + e);
     58    }
     59  }
     60 
     61  var osName = sysInfo.getProperty("name");
     62  switch (osName) {
     63    case "Darwin": // Mac OS X.
     64      // We only enable OpenGL layers on machines that don't support QuickDraw
     65      // plugins. x86-64 architecture is a good proxy for this plugin support.
     66      if (sysInfo.getProperty("arch") != "x86-64") {
     67        is(acceleratedWindows, 0, "Acceleration not supported on x86 OS X");
     68      } else {
     69        // Workaround for SeaMonkey tinderboxes which don't support acceleration.
     70        if (navigator.userAgent.match(/ SeaMonkey\//)) {
     71          if (acceleratedWindows == 0) {
     72            todo(false, "Acceleration not supported on x86-64 OS X" +
     73                        " (This is expected on SeaMonkey (tinderboxes).)");
     74            break;
     75          }
     76        }
     77 
     78        isnot(acceleratedWindows, 0, "Acceleration enabled on x86-64 OS X");
     79      }
     80      break;
     81 
     82    case "Windows_NT": // Windows.
     83      var version = parseFloat(sysInfo.getProperty("version"));
     84      if (version == 5.0) {
     85        is(acceleratedWindows, 0, "Acceleration not supported on Windows 2000");
     86      } else {
     87        // Workaround for SeaMonkey tinderboxes which don't support acceleration.
     88        if (navigator.userAgent.match(/ SeaMonkey\//)) {
     89          if (acceleratedWindows == 0) {
     90            todo(false, "Acceleration not supported on Windows XP or newer" +
     91                        " (This is expected on SeaMonkey (tinderboxes).)");
     92            break;
     93          }
     94        }
     95 
     96        isnot(acceleratedWindows, 0, "Acceleration enabled on Windows XP or newer");
     97      }
     98 
     99      var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
    100      if (version < 6.1) {
    101        ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2008 or older");
    102      } else {
    103        ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
    104      }
    105 
    106      var shouldGetWR = false;
    107      try {
    108        shouldGetWR = SpecialPowers.DOMWindowUtils.isWebRenderRequested;
    109      } catch (e) {}
    110 
    111      if (shouldGetWR) {
    112        isnot(webrenderWindows, 0, "WebRender enabled on Windows");
    113      } else {
    114        is(webrenderWindows, 0, "WebRender disabled on Windows");
    115      }
    116      break;
    117 
    118    case "Linux":
    119      todo(false, "Acceleration supported on Linux, but only on taskcluster instances (bug 1296086)");
    120      break;
    121 
    122    default:
    123      if (xr.OS == "Android") {
    124        isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
    125      } else {
    126        is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
    127      }
    128  }
    129 
    130  SimpleTest.finish();
    131 }
    132 
    133 </script>
    134 </pre>
    135 </body>
    136 </html>