5 <script src='/tests/SimpleTest/SimpleTest.js'
></script>
6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'
>
11 function RunWithPrefs(prefPairList
, func
) {
12 var prefEnv
= {'set': prefPairList
};
14 SpecialPowers
.pushPrefEnv(prefEnv
, func
);
16 console
.log('Warning: Failed to set prefs: ' + JSON
.stringify(prefPairList
));
21 ////////////////////////////////////////
23 var ANGLE_IS_SINGLETON
= true;
27 // code borrowed from browser/modules/test/browser_taskbar_preview.js
28 var version
= SpecialPowers
.Services
.sysinfo
.getProperty('version');
29 version
= parseFloat(version
);
31 // Version 6.0 is Vista, 6.1 is 7.
33 expectD3DType
= 'd3d9';
35 expectD3DType
= 'd3d11';
37 expectD3DType
= 'd3d11';
40 function GetRenderer() {
41 var c
= document
.createElement('canvas');
42 var gl
= c
.getContext('experimental-webgl');
46 var ext
= gl
.getExtension('WEBGL_debug_renderer_info');
48 throw new Error('Requires WEBGL_debug_renderer_info.');
50 var renderer
= gl
.getParameter(ext
.UNMASKED_RENDERER_WEBGL
);
54 function GetRendererType() {
55 var renderer
= GetRenderer();
56 if (renderer
=== undefined)
59 if (renderer
.includes('ANGLE')) {
60 if (renderer
.includes('Microsoft Basic Render Driver')) // Also includes 'Direct3D11'.
62 if (renderer
.includes('Direct3D11'))
64 if (renderer
.includes('Direct3D9'))
71 throw new Error('Unrecognized renderer type for: ' + renderer
);
74 function TestActualType(testName
, expectedType
) {
75 var actualType
= GetRendererType();
76 ok(actualType
== expectedType
,
77 '[' + testName
+ '] Expected ' + expectedType
+ ', was ' + actualType
);
80 ////////////////////////////////////////
82 function TestDefault() {
83 var expectedType
= 'gl';
84 var isWindows
= (navigator
.platform
.indexOf('Win') == 0);
86 expectedType
= expectD3DType
;
88 TestActualType('TestDefault', expectedType
);
90 if (isWindows
&& !ANGLE_IS_SINGLETON
) {
92 ['webgl.angle.force-warp', true],
94 RunWithPrefs(prefPairList
, TestWARP
);
99 ['webgl.disabled', true],
101 RunWithPrefs(prefPairList
, TestDisabled
);
105 function TestWARP() {
106 var expectedType
= (expectD3DType
== 'd3d11') ? 'warp' : 'none';
107 TestActualType('TestWARP', expectedType
);
110 ['webgl.angle.force-warp', false],
111 ['webgl.angle.force-d3d11', true],
113 RunWithPrefs(prefPairList
, TestD3D11
);
117 function TestD3D11() {
118 var expectedType
= (expectD3DType
== 'd3d11') ? 'd3d11' : 'none';
119 TestActualType('TestD3D11', expectedType
);
122 ['webgl.angle.force-d3d11', false],
123 ['webgl.angle.try-d3d11', false],
125 RunWithPrefs(prefPairList
, TestD3D9
);
129 function TestD3D9() {
130 TestActualType('TestD3D9', 'd3d9');
133 ['webgl.angle.try-d3d11', true],
134 ['webgl.disable-angle', true],
136 RunWithPrefs(prefPairList
, TestWinGL
);
140 function TestWinGL() {
141 TestActualType('TestWinGL', 'gl');
144 ['webgl.disabled', true],
146 RunWithPrefs(prefPairList
, TestDisabled
);
150 function TestDisabled() {
151 TestActualType('TestDisabled', 'none');
156 ////////////////////////////////////////
158 SimpleTest
.waitForExplicitFinish();
161 ['webgl.force-enabled', true],
162 ['webgl.enable-debug-renderer-info', true],
164 RunWithPrefs(prefPairList
, TestDefault
);