Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / textures / misc / tex-base-level-bug.html
blob47f049fd8ab8a478bd48569eecb9780db58b27f5
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>WebGL2 texture base level bug conformance test.</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 <script src="../../../js/tests/tex-image-and-sub-image-utils.js"></script>
16 </head>
17 <body>
18 <canvas id="example" width="2" height="2" style="width: 2px; height: 2px;"></canvas>
19 <div id="description"></div>
20 <div id="console"></div>
22 <script>
23 "use strict";
24 description(document.title);
25 var wtu = WebGLTestUtils;
26 var canvas = document.getElementById("example");
27 var gl = wtu.create3DContext("example", undefined, 2);
28 var tiu = TexImageUtils;
30 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
32 function runtest() {
33 debug("");
34 debug("This is a regression test for <a href='https://crbug.com/705865'>Chromium Issue 705865</a>");
35 var tex = gl.createTexture();
36 var program = tiu.setupTexturedQuad(gl, "RGBA");
38 // Test that filling partial levels is enough for mipmapping.
39 var width = 2;
40 var height = 2;
41 gl.bindTexture(gl.TEXTURE_2D, tex);
42 wtu.fillTexture(gl, tex, width, height, [255, 0, 0, 255], 2, gl.RGBA, gl.UNSIGNED_BYTE);
43 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 2);
44 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
45 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
46 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Texture setup should succeed");
48 canvas.width = width;
49 canvas.height = height;
50 gl.viewport(0, 0, width, height);
52 wtu.clearAndDrawUnitQuad(gl);
53 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearAndDrawQuad should succeed");
54 wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
56 width = 1;
57 height = 1;
58 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
59 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texImage2D should succeed");
61 wtu.clearAndDrawUnitQuad(gl);
62 wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
63 wtu.glErrorShouldBe(gl, gl.NO_ERROR,"checkCanvas should succeed");
65 gl.deleteTexture(tex);
69 runtest();
70 var successfullyParsed = true;
72 </script>
73 <script src="../../../js/js-test-post.js"></script>
75 </body>
76 </html>