summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html b/dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html
new file mode 100644
index 0000000000..7cd91959f0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/context/context-attributes-depth-stencil-antialias-obeyed.html
@@ -0,0 +1,89 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+
+function getWebGL(attribs) {
+ var canvas = document.createElement("canvas");
+ if (!canvas)
+ return null;
+
+ // We can't use wtu.create3DContext because it defaults to antialias=false.
+ var names = ["webgl2"];
+ var gl = null;
+ for (var i = 0; i < names.length; ++i) {
+ try {
+ gl = canvas.getContext(names[i], attribs);
+ } catch (e) {
+ }
+ if (gl) {
+ break;
+ }
+ }
+ if (!gl)
+ return null;
+ return gl;
+}
+
+function testAttribs(attribs) {
+ var antialias, depth, stencil;
+ if (!attribs) {
+ antialias = true;
+ depth = true;
+ stencil = false;
+ debug("Testing default attributes: { antialias: true, depth: true, stencil:false }");
+ } else {
+ antialias = attribs.antialias;
+ depth = attribs.depth;
+ stencil = attribs.stencil;
+ debug("Testing specified attributes: { antialias: " + antialias + ", depth: " + depth + ", stencil: " + stencil + " }");
+ }
+ var gl = getWebGL(attribs);
+ if (!gl) {
+ testFailed("Fail to create a context");
+ return;
+ }
+ var actual_attribs = gl.getContextAttributes();
+ if (antialias != actual_attribs.antialias)
+ testFailed("antialias = " + antialias + " is not obeyed")
+ if (depth != actual_attribs.depth)
+ testFailed("depth = " + depth + " is not obeyed")
+ if (stencil != actual_attribs.stencil)
+ testFailed("stencil = " + stencil + " is not obeyed")
+ if (antialias == actual_attribs.antialias &&
+ depth == actual_attribs.depth &&
+ stencil == actual_attribs.stencil) {
+ testPassed("Context created with the correct antialias, depth, and stencil.");
+ }
+}
+
+description('Verify WebGLContextAttributes are working as specified, including depth, stencil, antialias');
+testAttribs(null); // Default attribs
+testAttribs({antialias: true, depth: true, stencil: true});
+testAttribs({antialias: false, depth: true, stencil: true});
+testAttribs({antialias: true, depth: false, stencil: true});
+testAttribs({antialias: false, depth: false, stencil: true});
+testAttribs({antialias: true, depth: true, stencil: false});
+testAttribs({antialias: false, depth: true, stencil: false});
+testAttribs({antialias: true, depth: false, stencil: false});
+testAttribs({antialias: false, depth: false, stencil: false});
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>