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
|
<!DOCTYPE HTML>
<html>
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<script>
function AssertError(gl, expected, info) {
var actual = gl.getError();
while (gl.getError()) {}
ok(actual == expected,
'For ' + info + ', expected GL error 0x' + expected.toString(16) + ', got 0x'
+ actual.toString(16));
}
var gl;
var RENDERER_OVERRIDE = 'overridden renderer';
var VENDOR_OVERRIDE = 'overridden vendor';
function TestExt() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(ext, 'When pref enabled: Should have access to \'WEBGL_debug_renderer_info\'.');
AssertError(gl, 0, 'start of test');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
AssertError(gl, 0, 'UNMASKED_RENDERER_WEBGL');
ok(renderer,
'When pref enabled: UNMASKED_RENDERER_WEBGL value should not be empty, was \''
+ renderer + '\'');
var vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
AssertError(gl, 0, 'UNMASKED_VENDOR_WEBGL');
ok(vendor,
'When pref enabled: UNMASKED_VENDOR_WEBGL value should not be empty, was \''
+ vendor + '\'');
var prefArrArr = [
['webgl.renderer-string-override', RENDERER_OVERRIDE],
['webgl.vendor-string-override', VENDOR_OVERRIDE],
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, TestOverrides);
}
function TestOverrides() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(ext, 'When overrides set: Should have access to \'WEBGL_debug_renderer_info\'.');
AssertError(gl, 0, 'start of test');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
AssertError(gl, 0, 'UNMASKED_RENDERER_WEBGL');
ok(renderer == RENDERER_OVERRIDE,
'When overrides set: UNMASKED_RENDERER_WEBGL value should be \'' + RENDERER_OVERRIDE
+ '\', was \'' + renderer + '\'');
var vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
AssertError(gl, 0, 'UNMASKED_VENDOR_WEBGL');
ok(vendor == VENDOR_OVERRIDE,
'When overrides set: UNMASKED_VENDOR_WEBGL value should be \'' + VENDOR_OVERRIDE
+ '\', was \'' + vendor + '\'');
var prefArrArr = [
['webgl.enable-debug-renderer-info', false],
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, TestDisable);
}
function TestDisable() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(!ext,
'When pref disabled: Should not have access to \'WEBGL_debug_renderer_info\'.');
ok(true, 'Test complete.');
SimpleTest.finish();
}
(function() {
var canvas = document.createElement('canvas');
gl = canvas.getContext('experimental-webgl');
if (!gl) {
todo(gl, 'Get WebGL working here first.');
ok(true, 'Test complete.');
return;
}
SimpleTest.waitForExplicitFinish();
var prefArrArr = [
['webgl.enable-debug-renderer-info', true],
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, TestExt);
})();
</script>
</body>
</html>
|