4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
12 function getStrings() {
14 renderer
: gl
.getParameter(gl
.RENDERER
),
15 vendor
: gl
.getParameter(gl
.VENDOR
),
18 ret
.unmasked_renderer
= gl
.getParameter(ext
.UNMASKED_RENDERER_WEBGL
);
19 ret
.unmasked_vendor
= gl
.getParameter(ext
.UNMASKED_VENDOR_WEBGL
);
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
) {
34 const wasStr
= JSON
.stringify(was
);
35 const expectedStr
= JSON
.stringify(expected
);
36 let str
= `${when}Was ${wasStr}`;
37 const matches
= (wasStr
== expectedStr
);
39 str
+= `, expected ${expectedStr}`;
44 async
function testKnownCiStrings() {
45 gl
= document
.createElement('canvas').getContext('webgl');
48 await SpecialPowers
.pushPrefEnv({'set': [
49 ['webgl.sanitize-unmasked-renderer', false],
51 ext
= gl
.getExtension('WEBGL_debug_renderer_info');
52 const was
= getStrings();
56 'Adreno (TM) 540', // Android
57 'Adreno (TM) 650', // Android pixel5
59 'Intel(R) HD Graphics 400', // Mac
62 'ANGLE (NVIDIA, NVIDIA GeForce 8800 GTX Direct3D11 vs_5_0 ps_5_0)', // Windows
63 ].map(x
=> x
+ ', or similar'),
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
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
80 'Qualcomm', // Android
81 'VMware, Inc.', // Linux
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();
99 async
function testPrefBehaviorForExampleRtx3070() {
100 const canvas
= document
.createElement('canvas');
101 gl
= canvas
.getContext('webgl');
104 todo(gl
, 'Get WebGL working here first.');
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
],
123 await SpecialPowers
.pushPrefEnv({'set': [
124 ['webgl.enable-debug-renderer-info', false],
127 ext
= gl
.getExtension('WEBGL_debug_renderer_info');
129 'When pref disabled: Should not have access to \'WEBGL_debug_renderer_info\'.');
133 renderer
: RTX3070_R_SANITIZED
,
136 const was
= getStrings();
137 expectJsonEqual(was
, EXPECTED
, 'v92 behavior w/o ext');
140 await SpecialPowers
.popPrefEnv();
145 await SpecialPowers
.pushPrefEnv({'set': [
146 ['privacy.resistFingerprinting', true],
149 ext
= gl
.getExtension('WEBGL_debug_renderer_info');
151 'With RFP: Should not have access to \'WEBGL_debug_renderer_info\'.');
158 const was
= getStrings();
159 expectJsonEqual(was
, EXPECTED
, 'RFP behavior');
162 await SpecialPowers
.popPrefEnv();
165 // Test default state (v92+)
167 ext
= gl
.getExtension('WEBGL_debug_renderer_info');
169 'By default: Should have access to \'WEBGL_debug_renderer_info\'.');
173 renderer
: RTX3070_R_SANITIZED
,
175 unmasked_renderer
: RTX3070_R_SANITIZED
,
176 unmasked_vendor
: RTX3070_V
,
178 const was
= getStrings();
179 expectJsonEqual(was
, EXPECTED
, 'v92 behavior');
185 await SpecialPowers
.pushPrefEnv({'set': [
186 ['webgl.enable-renderer-query', false],
193 unmasked_renderer
: RTX3070_R_SANITIZED
,
194 unmasked_vendor
: RTX3070_V
,
196 const was
= getStrings();
197 expectJsonEqual(was
, EXPECTED
, 'v91 behavior');
203 await SpecialPowers
.pushPrefEnv({'set': [
204 ['webgl.sanitize-unmasked-renderer', false],
211 unmasked_renderer
: RTX3070_R
,
212 unmasked_vendor
: RTX3070_V
,
214 const was
= getStrings();
215 expectJsonEqual(was
, EXPECTED
, 'v90 behavior');
221 SimpleTest
.waitForExplicitFinish();
223 await
testKnownCiStrings();
224 await
testPrefBehaviorForExampleRtx3070();
226 ok(true, 'Test complete.');