Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / state / gl-geterror.html
blobad5c18e267ce05e82f3e8a4fbef7586d14880741
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 get error conformance test.</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 <canvas id="example" width="1" height="1" style="width: 256px; height: 48px;"></canvas>
19 <div id="description"></div><div id="console"></div>
20 <script>
21 "use strict";
22 description("Test getError.");
23 var wtu = WebGLTestUtils;
24 var gl = wtu.create3DContext("example");
25 var tex = gl.createTexture();
26 gl.bindTexture(gl.TEXTURE_2D, tex);
28 gl.enable(desktopGL.ALPHA_TEST);
29 wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "should generate INVALID_ENUM");
30 gl.viewport(-1, -1, -1, -1);
31 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "should generate INVALID_VALUE");
32 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
33 wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "should generate INVALID_OPERATION");
35 // Generate 2 errors of each type for 6 total possible errors.
36 // The OpenGL ES 2.0 spec section 2.5 says the implementation is allowed to
37 // either return the first error or many errors in an unspecied order.
38 gl.viewport(-1, -1, -1, -1);
39 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
40 gl.enable(desktopGL.ALPHA_TEST);
41 gl.viewport(-1, -1, -1, -1);
42 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
43 // Note: This error is specifically last because we know it will be synthasized
44 // by WebGL at least when implemented on top of Desktop OpenGL
45 gl.enable(desktopGL.ALPHA_TEST);
47 var err1 = gl.getError();
48 var err2 = gl.getError();
49 var err3 = gl.getError();
50 var err4 = gl.getError();
51 var err5 = gl.getError();
52 var err6 = gl.getError();
54 debug("");
55 if (err2 == gl.NO_ERROR) {
56 debug("This WebGL implementation looks like it uses the 'first error' method");
57 debug("There should be 1 error, the first one generated");
58 shouldBeTrue('err1 == gl.INVALID_VALUE && err2 == gl.NO_ERROR && err3 == gl.NO_ERROR');
59 } else {
60 debug("This WebGL implementation looks like it uses the many error method");
61 debug("Check is that at least one of the errors is the first error");
62 shouldBeTrue('err1 == gl.INVALID_VALUE || ' +
63 'err2 == gl.INVALID_VALUE || ' +
64 'err3 == gl.INVALID_VALUE || ' +
65 'err4 == gl.INVALID_VALUE || ' +
66 'err5 == gl.INVALID_VALUE || ' +
67 'err6 == gl.INVALID_VALUE');
68 shouldBeTrue('gl.getError() == gl.NO_ERROR');
71 debug("");
72 var successfullyParsed = true;
73 </script>
74 <script src="../../js/js-test-post.js"></script>
76 </body>
77 </html>