Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / canvas / test / webgl-mochitest / test_backbuffer_channels.html
blobef880f9c221d6a567e4f9e284547ab8bff366cc7
1 <!DOCTYPE HTML>
2 <title>WebGL test: bug 958723</title>
3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
4 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
5 <script src="driver-info.js"></script>
6 <script src="webgl-util.js"></script>
7 <body>
8 <script>
10 function TestAttribs(attribs) {
11 ok(true, 'Testing attribs: ' + JSON.stringify(attribs));
12 var canvas = document.createElement('canvas');
13 var gl = canvas.getContext('experimental-webgl', attribs);
14 ok(gl, 'No tested attribs should result in failure to create a context');
15 if (!gl)
16 return;
18 var actual = gl.getContextAttributes();
20 ok(actual.alpha == attribs.alpha,
21 'Resulting `alpha` should match request.');
22 ok(actual.premultipliedAlpha == attribs.premultipliedAlpha,
23 'Resulting `premultipliedAlpha` should match request.');
24 ok(actual.preserveDrawingBuffer == attribs.preserveDrawingBuffer,
25 'Resulting `preserveDrawingBuffer` should match request.');
27 // "The depth, stencil and antialias attributes, when set to true, are
28 // requests, not requirements."
29 if (!attribs.antialias) {
30 ok(!actual.antialias, 'No `antialias` if not requested.');
32 if (!attribs.depth) {
33 ok(!actual.depth, 'No `depth` if not requested.');
35 if (!attribs.stencil) {
36 ok(!actual.stencil, 'No `stencil` if not requested.');
39 var hasAlpha = !!gl.getParameter(gl.ALPHA_BITS);
40 var hasDepth = !!gl.getParameter(gl.DEPTH_BITS);
41 var hasStencil = !!gl.getParameter(gl.STENCIL_BITS);
42 var hasAntialias = !!gl.getParameter(gl.SAMPLES);
44 ok(hasAlpha == actual.alpha, 'Bits should match `alpha` attrib.');
45 ok(hasAntialias == actual.antialias, 'Bits should match `antialias` attrib.');
46 ok(hasDepth == actual.depth, 'Bits should match `depth` attrib.');
47 ok(hasStencil == actual.stencil, 'Bits should match `stencil` attrib.');
50 function CloneAttribs(attribs) {
51 return {
52 alpha: attribs.alpha,
53 antialias: attribs.antialias,
54 depth: attribs.depth,
55 premultipliedAlpha: attribs.premultipliedAlpha,
56 preserveDrawingBuffer: attribs.preserveDrawingBuffer,
57 stencil: attribs.stencil,
61 function SplitForAttrib(list, attrib) {
62 var ret = [];
64 for (var i in list) {
65 var cur = list[i];
66 if (cur[attrib])
67 throw 'Attrib is already true.';
69 var clone = CloneAttribs(cur);
70 clone[attrib] = true;
72 ret.push(cur);
73 ret.push(clone);
76 return ret;
79 function GenAttribList() {
80 var base = {
81 alpha: false,
82 antialias: false,
83 depth: false,
84 premultipliedAlpha: false,
85 preserveDrawingBuffer: false,
86 stencil: false,
88 var list = [base];
89 list = SplitForAttrib(list, 'alpha');
90 list = SplitForAttrib(list, 'antialias');
91 list = SplitForAttrib(list, 'depth');
92 list = SplitForAttrib(list, 'premultipliedAlpha');
93 list = SplitForAttrib(list, 'preserveDrawingBuffer');
94 list = SplitForAttrib(list, 'stencil');
96 if (list.length != 1<<6)
97 throw 'Attribs list length wrong: ' + list.length;
99 return list;
102 var list = GenAttribList();
103 for (var i in list) {
104 var attribs = list[i];
105 TestAttribs(attribs);
108 ok(true, 'Test complete.');
110 </script>