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