summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream/115.8.0esr.tar.xz
firefox-esr-upstream/115.8.0esr.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html')
-rw-r--r--dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html b/dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html
new file mode 100644
index 0000000000..ef880f9c22
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/test_backbuffer_channels.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML>
+<title>WebGL test: bug 958723</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+<script src="driver-info.js"></script>
+<script src="webgl-util.js"></script>
+<body>
+<script>
+
+function TestAttribs(attribs) {
+ ok(true, 'Testing attribs: ' + JSON.stringify(attribs));
+ var canvas = document.createElement('canvas');
+ var gl = canvas.getContext('experimental-webgl', attribs);
+ ok(gl, 'No tested attribs should result in failure to create a context');
+ if (!gl)
+ return;
+
+ var actual = gl.getContextAttributes();
+
+ ok(actual.alpha == attribs.alpha,
+ 'Resulting `alpha` should match request.');
+ ok(actual.premultipliedAlpha == attribs.premultipliedAlpha,
+ 'Resulting `premultipliedAlpha` should match request.');
+ ok(actual.preserveDrawingBuffer == attribs.preserveDrawingBuffer,
+ 'Resulting `preserveDrawingBuffer` should match request.');
+
+ // "The depth, stencil and antialias attributes, when set to true, are
+ // requests, not requirements."
+ if (!attribs.antialias) {
+ ok(!actual.antialias, 'No `antialias` if not requested.');
+ }
+ if (!attribs.depth) {
+ ok(!actual.depth, 'No `depth` if not requested.');
+ }
+ if (!attribs.stencil) {
+ ok(!actual.stencil, 'No `stencil` if not requested.');
+ }
+
+ var hasAlpha = !!gl.getParameter(gl.ALPHA_BITS);
+ var hasDepth = !!gl.getParameter(gl.DEPTH_BITS);
+ var hasStencil = !!gl.getParameter(gl.STENCIL_BITS);
+ var hasAntialias = !!gl.getParameter(gl.SAMPLES);
+
+ ok(hasAlpha == actual.alpha, 'Bits should match `alpha` attrib.');
+ ok(hasAntialias == actual.antialias, 'Bits should match `antialias` attrib.');
+ ok(hasDepth == actual.depth, 'Bits should match `depth` attrib.');
+ ok(hasStencil == actual.stencil, 'Bits should match `stencil` attrib.');
+}
+
+function CloneAttribs(attribs) {
+ return {
+ alpha: attribs.alpha,
+ antialias: attribs.antialias,
+ depth: attribs.depth,
+ premultipliedAlpha: attribs.premultipliedAlpha,
+ preserveDrawingBuffer: attribs.preserveDrawingBuffer,
+ stencil: attribs.stencil,
+ };
+}
+
+function SplitForAttrib(list, attrib) {
+ var ret = [];
+
+ for (var i in list) {
+ var cur = list[i];
+ if (cur[attrib])
+ throw 'Attrib is already true.';
+
+ var clone = CloneAttribs(cur);
+ clone[attrib] = true;
+
+ ret.push(cur);
+ ret.push(clone);
+ }
+
+ return ret;
+}
+
+function GenAttribList() {
+ var base = {
+ alpha: false,
+ antialias: false,
+ depth: false,
+ premultipliedAlpha: false,
+ preserveDrawingBuffer: false,
+ stencil: false,
+ };
+ var list = [base];
+ list = SplitForAttrib(list, 'alpha');
+ list = SplitForAttrib(list, 'antialias');
+ list = SplitForAttrib(list, 'depth');
+ list = SplitForAttrib(list, 'premultipliedAlpha');
+ list = SplitForAttrib(list, 'preserveDrawingBuffer');
+ list = SplitForAttrib(list, 'stencil');
+
+ if (list.length != 1<<6)
+ throw 'Attribs list length wrong: ' + list.length;
+
+ return list;
+}
+
+var list = GenAttribList();
+for (var i in list) {
+ var attribs = list[i];
+ TestAttribs(attribs);
+}
+
+ok(true, 'Test complete.');
+
+</script>
+