summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-array-buffer-delete.html
blob: 4a25426f0c44ab473e023e3ed6b668c0513bbecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>

<script>
"use strict";
description("Test ARRAY_BUFFER deletion when a vertex attrib array with location != 0 is pointing to it and preserveDrawingBuffer is true.");

var canvas = document.createElement('canvas');
document.body.appendChild(canvas);

canvas.addEventListener(
    "webglcontextlost",
    function(event) {
        testFailed("Context lost");
        event.preventDefault();
    },
    false);

var wtu = WebGLTestUtils;
var gl = wtu.create3DContext(canvas, {preserveDrawingBuffer: true});

if (!gl) {
    testFailed("context does not exist");
    finishTest();
} else {
    var array = new Float32Array([0]);
    var buf = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, buf);
    gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR);

    var attribLocation = 1;
    gl.enableVertexAttribArray(attribLocation);
    gl.vertexAttribPointer(attribLocation, 1, gl.FLOAT, false, 0, 0);

    gl.deleteBuffer(buf);

    setTimeout(function() {
        // Wait for possible context loss
        finishTest();
    }, 2000);
}

var successfullyParsed = true;
</script>

</body>
</html>