2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL gl.ENABLE enums Conformance Tests
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/desktop-gl-constants.js"></script>
14 <script src=
"../../js/js-test-pre.js"></script>
15 <script src=
"../../js/webgl-test-utils.js"></script>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
22 description("This test ensures WebGL implementations allow OpenGL ES 2.0 features to be turned on but not non OpenGL ES 2.0 features.");
24 var wtu
= WebGLTestUtils
;
48 'MAP1_TEXTURE_COORD_1',
49 'MAP1_TEXTURE_COORD_2',
50 'MAP1_TEXTURE_COORD_3',
51 'MAP1_TEXTURE_COORD_4',
57 'MAP2_TEXTURE_COORD_1',
58 'MAP2_TEXTURE_COORD_2',
59 'MAP2_TEXTURE_COORD_3',
60 'MAP2_TEXTURE_COORD_4',
68 'POLYGON_OFFSET_LINE',
69 'POLYGON_OFFSET_POINT',
72 'POST_COLOR_MATRIX_COLOR_TABLE',
73 'POST_CONVOLUTION_COLOR_TABLE',
75 'SAMPLE_ALPHA_TO_ONE',
85 'VERTEX_PROGRAM_POINT_SIZE',
86 'VERTEX_PROGRAM_TWO_SIDE'
93 'POLYGON_OFFSET_FILL',
94 'SAMPLE_ALPHA_TO_COVERAGE',
102 function runNegativeTests() {
104 debug("Running negative tests");
106 gl
= wtu
.create3DContext();
108 testFailed("context does not exist");
111 testPassed("context exists");
113 for (var ii
= 0; ii
< invalidEnums
.length
; ++ii
) {
114 var name
= invalidEnums
[ii
];
115 gl
.enable(desktopGL
[name
]);
116 wtu
.glErrorShouldBe(gl
, gl
.INVALID_ENUM
,
117 "gl.enable must set INVALID_ENUM when passed GL_" + name
);
121 function runPositiveTestsWithParameters(params
) {
123 debug("Running positive tests with parameters: " + JSON
.stringify(params
));
125 // Pass null for the canvas, to make sure we create a new context each time.
126 var newgl
= wtu
.create3DContext(null, params
);
128 testFailed("got an old context");
133 testFailed("context does not exist");
136 testPassed("context exists");
138 debug("Checking gl.ENABLE enums.");
140 for (var ii
= 0; ii
< validEnums
.length
; ++ii
) {
141 var name
= validEnums
[ii
];
143 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
,
144 "gl.enable must succeed when passed gl." + name
);
145 shouldBe('gl.isEnabled(gl.' + name
+ ')', 'true');
146 shouldBe('gl.getParameter(gl.' + name
+ ')', 'true');
147 gl
.disable(gl
[name
]);
148 shouldBe('gl.isEnabled(gl.' + name
+ ')', 'false');
149 shouldBe('gl.getParameter(gl.' + name
+ ')', 'false');
150 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
,
151 "gl.isEnabled and gl.GetParameter must not set errors when passed GL_" + name
);
154 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "there should be no errors");
158 runPositiveTestsWithParameters({alpha
: true, antialias
: true, stencil
: true, depth
: true});
159 runPositiveTestsWithParameters({alpha
: false, antialias
: true, stencil
: true, depth
: true});
160 runPositiveTestsWithParameters({alpha
: true, antialias
: false, stencil
: true, depth
: true});
161 runPositiveTestsWithParameters({alpha
: true, antialias
: true, stencil
: false, depth
: true});
162 runPositiveTestsWithParameters({alpha
: true, antialias
: true, stencil
: true, depth
: false});
165 var successfullyParsed
= true;
168 <script src=
"../../js/js-test-post.js"></script>