Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / manual / canvas-clear-on-zero-count-draw.html
blobc18c8ab96ebef5709a71f24e78bc47c09ca967ad
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>Check that the canvas is NOT recomposited after unsucessful draw call</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 <style>
16 canvas {
17 border: 1px solid black;
19 .correct {
20 border: 1px solid black;
21 background-color: #ffffff;
23 </style>
24 </head>
25 <body>
26 <pre>
27 This test must be run manually.
29 This test tests that a canvas is cleared
30 even when a draw call has a zero count.
32 You should see three <span class="correct">white rectangles</span>
33 with black outlines on success.
34 </pre>
35 <canvas id='c1'></canvas>
36 <canvas id='c2'></canvas>
37 <canvas id='c3'></canvas>
38 <div id="console"></div>
39 <script id="vshader" type="x-shader/x-vertex">
40 void main() {
41 gl_Position = vec4(0,0,0,1);
43 </script>
44 <script id="fshader" type="x-shader/x-fragment">
45 precision mediump float;
46 void main() {
47 discard;
49 </script>
50 <script>
51 "use strict";
52 var wtu = WebGLTestUtils;
53 var c1 = document.getElementById("c1");
54 var c2 = document.getElementById("c2");
55 var c3 = document.getElementById("c2");
56 var gl1 = wtu.create3DContext(c1);
57 var gl2 = wtu.create3DContext(c2);
58 var gl3 = wtu.create3DContext(c2);
59 gl1.clearColor(0,1,0,1);
60 gl1.clear(gl1.COLOR_BUFFER_BIT);
61 gl2.clearColor(0,1,0,1);
62 gl2.clear(gl2.COLOR_BUFFER_BIT);
63 gl3.clearColor(0,1,0,1);
64 gl3.clear(gl2.COLOR_BUFFER_BIT);
66 wtu.waitForComposite(function() {
67 // test drawArrays
68 gl1.drawArrays(gl1.TRIANGLES, 0, 0);
69 wtu.glErrorShouldBe(gl1, gl1.NO_ERROR, "no errors");
70 });
72 wtu.waitForComposite(function() {
73 // test drawElements
74 var buf = gl2.createBuffer();
75 gl2.bindBuffer(gl2.ELEMENT_ARRAY_BUFFER, buf);
76 gl2.bufferData(gl2.ELEMENT_ARRAY_BUFFER, new Uint8Array(1), gl2.STATIC_DRAW);
77 gl2.drawElements(gl2.TRIANGLES, 0, gl2.UNSIGNED_SHORT, 0);
78 wtu.glErrorShouldBe(gl2, gl2.NO_ERROR, "no errors");
79 });
81 wtu.waitForComposite(function() {
82 // test draw with program.
83 wtu.setupProgram(gl3, ["vshader", "fshader"]);
84 gl1.drawArrays(gl3.TRIANGLES, 0, 0);
85 wtu.glErrorShouldBe(gl3, gl2.NO_ERROR, "no errors");
86 });
88 </script>
89 </body>
90 </html>