gfx/tests/mochitest/test_acceleration.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial