Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / buffers / delete-buffer.html
blobd438d655216d649a2d5bb33c406837228de26452
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 buffer deletion behavior 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 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <script>
20 "use strict";
21 description("Test buffer deletion behavior.");
22 // This is a regression test for https://crbug.com/822976
24 var wtu = WebGLTestUtils;
26 var gl = wtu.create3DContext(undefined, undefined, 2);
27 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
29 function runTexImageTest(gl) {
30 debug("");
31 var buffer = gl.createBuffer();
32 gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, buffer);
33 gl.bufferData(gl.PIXEL_UNPACK_BUFFER, 4, gl.DYNAMIC_DRAW);
34 gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer);
35 gl.deleteBuffer(buffer);
36 // Indexed uniform buffer bindings should not prevent a buffer from being
37 // deleted. Therefore, PIXEL_UNPACK_BUFFER binding should also be 0.
38 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no error");
40 var tex = gl.createTexture();
41 gl.bindTexture(gl.TEXTURE_2D, tex);
42 var data = new Uint8Array(1024);
43 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 16, 16, 0,
44 gl.RGBA, gl.UNSIGNED_BYTE, data);
45 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texImage2D should succeed");
47 // Clean up bindings just in case an implementation gets it wrong.
48 gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null);
49 gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, null);
52 function runReadPixelsTest(gl) {
53 debug("");
54 var buffer = gl.createBuffer();
55 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buffer);
56 gl.bufferData(gl.PIXEL_PACK_BUFFER, 4, gl.DYNAMIC_DRAW);
57 gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer);
58 gl.deleteBuffer(buffer);
59 // Indexed transform feedback buffer bindings should not prevent a buffer
60 // from being deleted. Therefore, PIXEL_PACK_BUFFER binding should also be 0.
61 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no error");
63 var buffer = new Uint8Array(1024);
64 gl.readPixels(0, 0, 16, 16, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
65 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels should succeed");
67 // Clean up bindings just in case an implementation gets it wrong.
68 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
69 gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, null);
72 runTexImageTest(gl);
73 runReadPixelsTest(gl);
75 debug("");
76 var successfullyParsed = true;
77 </script>
78 <script src="../../js/js-test-post.js"></script>
79 </body>
80 </html>