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
|
<!DOCTYPE HTML>
<html>
<script>
// This file has the portion of the test_webgl_renderer_info chrome mochitest
// that has to run as non-chrome to check that this WebGL extension is not exposed to content
// we can't call the chrome Mochitest ok() function ourselves from non-chrome code.
// So we remote it to the chrome test.
function ok(res, msg) {
// Note we post to ourselves as posting to the chrome code doesn't seem to work here.
// This works by having the chrome code put an event handler on our own window.
window.postMessage({ subTestFinished: true, result: res, message: msg }, "*");
}
function messageListener(e) {
// This is how the chrome test tells us to start running -- we have to wait for this
// message to avoid running before it's set up its event handler.
if (e.data.run) {
var canBeUnprivileged = e.data.canBeUnprivileged;
run(canBeUnprivileged);
}
}
window.addEventListener("message", messageListener, true);
function run(canBeUnprivileged) {
const UNMASKED_VENDOR_WEBGL = 0x9245;
const UNMASKED_RENDERER_WEBGL = 0x9246;
var canvas = document.createElement("canvas");
var gl = canvas.getContext("experimental-webgl");
ok(!gl.getError(), "getError on newly created WebGL context should return NO_ERROR");
ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM,
"Should not be able to query UNMASKED_VENDOR_WEBGL without having enabled the"
+ " WEBGL_debug_renderer_info extension");
ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM,
"Should not be able to query UNMASKED_RENDERER_WEBGL without having enabled the"
+ " WEBGL_debug_renderer_info extension");
var exts = gl.getSupportedExtensions();
if (canBeUnprivileged) {
ok(exts.indexOf("WEBGL_debug_renderer_info") != -1,
"WEBGL_debug_renderer_info should be listed by getSupportedExtensions in"
+ " non-chrome contexts on non-RELEASE_OR_BETAs");
var ext = gl.getExtension("WEBGL_debug_renderer_info");
ok(!!ext,
"WEBGL_debug_renderer_info should be available through getExtension in non-chrome"
+ " contexts on non-RELEASE_OR_BETAs");
ok(gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.NO_ERROR,
"Should be able to query UNMASKED_VENDOR_WEBGL if enabling"
+ " WEBGL_debug_renderer_info succeeded");
ok(gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.NO_ERROR,
"Should be able to query UNMASKED_RENDERER_WEBGL if enabling"
+ " WEBGL_debug_renderer_info succeeded");
} else {
ok(exts.indexOf("WEBGL_debug_renderer_info") == -1,
"WEBGL_debug_renderer_info should not be listed by getSupportedExtensions in"
+ " non-chrome contexts");
var ext = gl.getExtension("WEBGL_debug_renderer_info");
ok(!ext,
"WEBGL_debug_renderer_info should not be available through getExtension in"
+ " non-chrome contexts");
ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM,
"Should not be able to query UNMASKED_VENDOR_WEBGL if enabling"
+ " WEBGL_debug_renderer_info failed");
ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM,
"Should not be able to query UNMASKED_RENDERER_WEBGL if enabling"
+ " WEBGL_debug_renderer_info failed");
}
window.postMessage({allTestsFinished: true}, "*");
}
</script>
</html>
|