Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / canvas / test / webgl-mochitest / test_renderer_strings.html
blob17c157a86056825c76260b1c88c374af4c12e771
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
6 </head>
7 <body>
8 <script>
10 let gl, ext;
12 function getStrings() {
13 const ret = {
14 renderer: gl.getParameter(gl.RENDERER),
15 vendor: gl.getParameter(gl.VENDOR),
17 if (ext) {
18 ret.unmasked_renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
19 ret.unmasked_vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
21 return ret;
24 const RTX3070_R = 'ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5751)';
25 const RTX3070_V = 'Google Inc.';
26 const RTX3070_R_SANITIZED = 'ANGLE (NVIDIA, NVIDIA GeForce GTX 980 Direct3D11 vs_5_0 ps_5_0), or similar';
28 function expectJsonEqual(was, expected, when) {
29 if (when) {
30 when = when + ': ';
31 } else {
32 when = '';
34 const wasStr = JSON.stringify(was);
35 const expectedStr = JSON.stringify(expected);
36 let str = `${when}Was ${wasStr}`;
37 const matches = (wasStr == expectedStr);
38 if (!matches) {
39 str += `, expected ${expectedStr}`;
41 ok(matches, str);
44 async function testKnownCiStrings() {
45 gl = document.createElement('canvas').getContext('webgl');
46 if (!gl) return;
48 await SpecialPowers.pushPrefEnv({'set': [
49 ['webgl.sanitize-unmasked-renderer', false],
50 ]});
51 ext = gl.getExtension('WEBGL_debug_renderer_info');
52 const was = getStrings();
54 const KNOWN_ON_CI = {
55 renderer: [
56 'Adreno (TM) 540', // Android
57 'Adreno (TM) 650', // Android pixel5
58 'llvmpipe', // Linux
59 'Intel(R) HD Graphics 400', // Mac
60 'Apple M1', // Mac
61 'Apple M2', // Mac
62 'ANGLE (NVIDIA, NVIDIA GeForce 8800 GTX Direct3D11 vs_5_0 ps_5_0)', // Windows
63 ].map(x => x + ', or similar'),
64 vendor: [
65 'Mozilla',
67 unmasked_renderer: [
68 'Adreno (TM) 540', // Android
69 'Adreno (TM) 620', // Android pixel5
70 'llvmpipe (LLVM 10.0.0, 256 bits)', // Linux (Ubuntu 18.04)
71 'llvmpipe (LLVM 17.0.6, 256 bits)', // Linux (Ubuntu 24.04)
72 'Intel(R) UHD Graphics 630', // Mac
73 'Apple M1', // Mac
74 'Apple M2', // Mac
75 'ANGLE (NVIDIA, NVIDIA Tesla M60 Direct3D11 vs_5_0 ps_5_0, D3D11-23.21.13.9181)', // Windows
76 'ANGLE (NVIDIA, NVIDIA Tesla M60 Direct3D11 vs_5_0 ps_5_0, D3D11-30.0.14.7239)', // Windows 11
77 'ANGLE (NVIDIA, NVIDIA Tesla M60 Direct3D11 vs_5_0 ps_5_0, D3D11-31.0.15.3815)', //Windows 11
79 unmasked_vendor: [
80 'Qualcomm', // Android
81 'VMware, Inc.', // Linux
82 'Mesa', // Linux
83 'Intel Inc.', // Mac
84 'Apple', // Mac
85 'Google Inc. (NVIDIA)', // Windows
88 for (const k in was) {
89 const wasVal = was[k];
90 const knownList = KNOWN_ON_CI[k];
91 ok(knownList.includes(wasVal),
92 `[ignore if not on CI] getParameter(${k}) -> '${wasVal}' must be in KNOWN_ON_CI`);
94 await SpecialPowers.popPrefEnv();
97 // -
99 async function testPrefBehaviorForExampleRtx3070() {
100 const canvas = document.createElement('canvas');
101 gl = canvas.getContext('webgl');
102 ext = null;
103 if (!gl) {
104 todo(gl, 'Get WebGL working here first.');
105 return;
108 // -
109 // Assuming that we're on CI, test against known-good strings.
110 // If we add machine configs, we'll need to add to these lists.
111 // This is to avoid situations like bug 1743734, where ANGLE added
112 // detailed driver version/date to its RENDERER strings, which
113 // we want to prevent.
115 await SpecialPowers.pushPrefEnv({'set': [
116 ['webgl.override-unmasked-renderer', RTX3070_R],
117 ['webgl.override-unmasked-vendor', RTX3070_V],
118 ]});
120 // -
121 // Test disabled
123 await SpecialPowers.pushPrefEnv({'set': [
124 ['webgl.enable-debug-renderer-info', false],
125 ]});
127 ext = gl.getExtension('WEBGL_debug_renderer_info');
128 ok(!ext,
129 'When pref disabled: Should not have access to \'WEBGL_debug_renderer_info\'.');
132 const EXPECTED = {
133 renderer: RTX3070_R_SANITIZED,
134 vendor: 'Mozilla',
136 const was = getStrings();
137 expectJsonEqual(was, EXPECTED, 'v92 behavior w/o ext');
140 await SpecialPowers.popPrefEnv();
142 // -
143 // Test RFP
145 await SpecialPowers.pushPrefEnv({'set': [
146 ['privacy.resistFingerprinting', true],
147 ]});
149 ext = gl.getExtension('WEBGL_debug_renderer_info');
150 ok(!ext,
151 'With RFP: Should not have access to \'WEBGL_debug_renderer_info\'.');
154 const EXPECTED = {
155 renderer: 'Mozilla',
156 vendor: 'Mozilla',
158 const was = getStrings();
159 expectJsonEqual(was, EXPECTED, 'RFP behavior');
162 await SpecialPowers.popPrefEnv();
164 // -
165 // Test default state (v92+)
167 ext = gl.getExtension('WEBGL_debug_renderer_info');
168 ok(ext,
169 'By default: Should have access to \'WEBGL_debug_renderer_info\'.');
172 const EXPECTED = {
173 renderer: RTX3070_R_SANITIZED,
174 vendor: 'Mozilla',
175 unmasked_renderer: RTX3070_R_SANITIZED,
176 unmasked_vendor: RTX3070_V,
178 const was = getStrings();
179 expectJsonEqual(was, EXPECTED, 'v92 behavior');
182 // -
183 // Test v91 behavior
185 await SpecialPowers.pushPrefEnv({'set': [
186 ['webgl.enable-renderer-query', false],
187 ]});
190 const EXPECTED = {
191 renderer: 'Mozilla',
192 vendor: 'Mozilla',
193 unmasked_renderer: RTX3070_R_SANITIZED,
194 unmasked_vendor: RTX3070_V,
196 const was = getStrings();
197 expectJsonEqual(was, EXPECTED, 'v91 behavior');
200 // -
201 // Test v90 behavior
203 await SpecialPowers.pushPrefEnv({'set': [
204 ['webgl.sanitize-unmasked-renderer', false],
205 ]});
208 const EXPECTED = {
209 renderer: 'Mozilla',
210 vendor: 'Mozilla',
211 unmasked_renderer: RTX3070_R,
212 unmasked_vendor: RTX3070_V,
214 const was = getStrings();
215 expectJsonEqual(was, EXPECTED, 'v90 behavior');
219 // -
221 SimpleTest.waitForExplicitFinish();
222 (async function() {
223 await testKnownCiStrings();
224 await testPrefBehaviorForExampleRtx3070();
226 ok(true, 'Test complete.');
227 SimpleTest.finish();
228 })();
230 </script>
231 </body>
232 </html>