Backed out changeset 8fc3326bce7f (bug 1943032) for causing failures at browser_tab_g...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / programs / active-built-in-attribs.html
blob68b62cdcf2f2048129fea2b1f793a9aa41628ab5
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL Conformance Tests: Verify validation for active built-in attribs</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>
16 </head>
17 <body>
18 <div id="description"></div>
19 <canvas id="canvas" style="width: 64px; height: 64px;"> </canvas>
20 <div id="console"></div>
21 <script id="vs" type="x-shader/x-vertex">#version 300 es
22 void main() {
23 gl_Position = vec4(gl_VertexID % 2, (gl_VertexID/2) % 2, 0, 1);
25 </script>
27 <script id="fs" type="x-shader/x-fragment">#version 300 es
28 precision mediump float;
29 out vec4 fragColor;
30 void main() {
31 fragColor = vec4(0, 1, 0, 1);
33 </script>
35 <script>
36 "use strict";
37 description("This test verifies validation for active built-in attribs.");
39 debug("");
41 var wtu = WebGLTestUtils;
42 var canvas = document.getElementById("canvas");
43 var gl = wtu.create3DContext(canvas, null, 2);
45 if (!gl) {
46 testFailed("WebGL context does not exist");
47 } else {
48 testPassed("WebGL context exists");
49 runTests();
52 var activeInfo, attribLoc;
54 function runTests() {
55 var prog = wtu.setupProgram(gl, ["vs", "fs"]);
56 if (!prog) {
57 testFailed("Set up program failed");
58 return;
60 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL error from set up");
62 var numActive = gl.getProgramParameter(prog, gl.ACTIVE_ATTRIBUTES);
63 if (numActive != 1) {
64 testFailed('ACTIVE_ATTRIBUTES should be 1.');
65 return;
67 testPassed('ACTIVE_ATTRIBUTES should be 1.');
69 activeInfo = gl.getActiveAttrib(prog, 0);
70 if (!activeInfo) {
71 testFailed('getActiveAttrib should return an info object.');
72 return;
75 shouldBe('activeInfo.name', '"gl_VertexID"');
76 attribLoc = gl.getAttribLocation(prog, 'gl_VertexID');
77 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to request the location of a built-in.");
78 shouldBe('attribLoc', '-1');
81 var successfullyParsed = true;
82 </script>
83 <script src="../../js/js-test-post.js"></script>
85 </body>
86 </html>