summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/state/gl-enable-enum-test.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/state/gl-enable-enum-test.html171
1 files changed, 171 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/state/gl-enable-enum-test.html b/dom/canvas/test/webgl-conf/checkout/conformance/state/gl-enable-enum-test.html
new file mode 100644
index 0000000000..89efc94209
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/state/gl-enable-enum-test.html
@@ -0,0 +1,171 @@
+<!--
+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">
+<title>WebGL gl.ENABLE enums Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/desktop-gl-constants.js"></script>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("This test ensures WebGL implementations allow OpenGL ES 2.0 features to be turned on but not non OpenGL ES 2.0 features.");
+
+var wtu = WebGLTestUtils;
+
+var invalidEnums = [
+ 'ALPHA_TEST',
+ 'AUTO_NORMAL',
+ 'CLIP_PLANE0',
+ 'CLIP_PLANE1',
+ 'COLOR_LOGIC_OP',
+ 'COLOR_MATERIAL',
+ 'COLOR_SUM',
+ 'COLOR_TABLE',
+ //'CONVOLUTION_1D',
+ //'CONVOLUTION_2D',
+ 'FOG',
+ 'HISTOGRAM',
+ 'INDEX_LOGIC_OP',
+ 'LIGHT0',
+ 'LIGHT1',
+ 'LIGHTING',
+ 'LINE_SMOOTH',
+ 'LINE_STIPPLE',
+ 'MAP1_COLOR_4',
+ 'MAP1_INDEX',
+ 'MAP1_NORMAL',
+ 'MAP1_TEXTURE_COORD_1',
+ 'MAP1_TEXTURE_COORD_2',
+ 'MAP1_TEXTURE_COORD_3',
+ 'MAP1_TEXTURE_COORD_4',
+ 'MAP1_VERTEX_3',
+ 'MAP1_VERTEX_4',
+ 'MAP2_COLOR_4',
+ 'MAP2_INDEX',
+ 'MAP2_NORMAL',
+ 'MAP2_TEXTURE_COORD_1',
+ 'MAP2_TEXTURE_COORD_2',
+ 'MAP2_TEXTURE_COORD_3',
+ 'MAP2_TEXTURE_COORD_4',
+ 'MAP2_VERTEX_3',
+ 'MAP2_VERTEX_4',
+ 'MINMAX',
+ 'MULTISAMPLE',
+ 'NORMALIZE',
+ 'POINT_SMOOTH',
+ 'POINT_SPRITE',
+ 'POLYGON_OFFSET_LINE',
+ 'POLYGON_OFFSET_POINT',
+ 'POLYGON_SMOOTH',
+ 'POLYGON_STIPPLE',
+ 'POST_COLOR_MATRIX_COLOR_TABLE',
+ 'POST_CONVOLUTION_COLOR_TABLE',
+ 'RESCALE_NORMAL',
+ 'SAMPLE_ALPHA_TO_ONE',
+ //'SEPARABLE_2D',
+ 'TEXTURE_1D',
+ 'TEXTURE_2D',
+ 'TEXTURE_3D',
+ 'TEXTURE_CUBE_MAP',
+ 'TEXTURE_GEN_Q',
+ 'TEXTURE_GEN_R',
+ 'TEXTURE_GEN_S',
+ 'TEXTURE_GEN_T',
+ 'VERTEX_PROGRAM_POINT_SIZE',
+ 'VERTEX_PROGRAM_TWO_SIDE'
+];
+var validEnums = [
+ 'BLEND',
+ 'CULL_FACE',
+ 'DEPTH_TEST',
+ 'DITHER',
+ 'POLYGON_OFFSET_FILL',
+ 'SAMPLE_ALPHA_TO_COVERAGE',
+ 'SAMPLE_COVERAGE',
+ 'SCISSOR_TEST',
+ 'STENCIL_TEST'
+];
+
+var gl;
+
+function runNegativeTests() {
+ debug("");
+ debug("Running negative tests");
+
+ gl = wtu.create3DContext();
+ if (!gl) {
+ testFailed("context does not exist");
+ return;
+ }
+ testPassed("context exists");
+
+ for (var ii = 0; ii < invalidEnums.length; ++ii) {
+ var name = invalidEnums[ii];
+ gl.enable(desktopGL[name]);
+ wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
+ "gl.enable must set INVALID_ENUM when passed GL_" + name );
+ }
+}
+
+function runPositiveTestsWithParameters(params) {
+ debug("");
+ debug("Running positive tests with parameters: " + JSON.stringify(params));
+
+ // Pass null for the canvas, to make sure we create a new context each time.
+ var newgl = wtu.create3DContext(null, params);
+ if (gl == newgl) {
+ testFailed("got an old context");
+ return;
+ }
+ gl = newgl;
+ if (!gl) {
+ testFailed("context does not exist");
+ return;
+ }
+ testPassed("context exists");
+
+ debug("Checking gl.ENABLE enums.");
+
+ for (var ii = 0; ii < validEnums.length; ++ii) {
+ var name = validEnums[ii];
+ gl.enable(gl[name]);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.enable must succeed when passed gl." + name );
+ shouldBe('gl.isEnabled(gl.' + name + ')', 'true');
+ shouldBe('gl.getParameter(gl.' + name + ')', 'true');
+ gl.disable(gl[name]);
+ shouldBe('gl.isEnabled(gl.' + name + ')', 'false');
+ shouldBe('gl.getParameter(gl.' + name + ')', 'false');
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "gl.isEnabled and gl.GetParameter must not set errors when passed GL_" + name );
+ }
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+}
+
+runNegativeTests();
+runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: true, depth: true});
+runPositiveTestsWithParameters({alpha: false, antialias: true, stencil: true, depth: true});
+runPositiveTestsWithParameters({alpha: true, antialias: false, stencil: true, depth: true});
+runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: false, depth: true});
+runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: true, depth: false});
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>