buffer-data-array-buffer-delete.html (1585B)
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 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 10 <meta charset="utf-8"> 11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> 12 <script src="../../js/js-test-pre.js"></script> 13 <script src="../../js/webgl-test-utils.js"></script> 14 </head> 15 <body> 16 <div id="description"></div> 17 <div id="console"></div> 18 19 <script> 20 "use strict"; 21 description("Test ARRAY_BUFFER deletion when a vertex attrib array with location != 0 is pointing to it and preserveDrawingBuffer is true."); 22 23 var canvas = document.createElement('canvas'); 24 document.body.appendChild(canvas); 25 26 canvas.addEventListener( 27 "webglcontextlost", 28 function(event) { 29 testFailed("Context lost"); 30 event.preventDefault(); 31 }, 32 false); 33 34 var wtu = WebGLTestUtils; 35 var gl = wtu.create3DContext(canvas, {preserveDrawingBuffer: true}); 36 37 if (!gl) { 38 testFailed("context does not exist"); 39 finishTest(); 40 } else { 41 var array = new Float32Array([0]); 42 var buf = gl.createBuffer(); 43 gl.bindBuffer(gl.ARRAY_BUFFER, buf); 44 gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW); 45 wtu.glErrorShouldBe(gl, gl.NO_ERROR); 46 47 var attribLocation = 1; 48 gl.enableVertexAttribArray(attribLocation); 49 gl.vertexAttribPointer(attribLocation, 1, gl.FLOAT, false, 0, 0); 50 51 gl.deleteBuffer(buf); 52 53 setTimeout(function() { 54 // Wait for possible context loss 55 finishTest(); 56 }, 2000); 57 } 58 59 var successfullyParsed = true; 60 </script> 61 62 </body> 63 </html>