blob: 98176cbfebe01691c68211660062dd4b4eb11660 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<canvas id="c" width="40" height="40"></canvas>
<script>
description("Checks that using WebGL 2 buffer targets don't cause errors");
if (window.internals)
internals.settings.setWebGL2Enabled(true);
var canvas = document.getElementById("c");
var context = canvas.getContext("webgl2");
shouldBe("context.getError()", "context.NO_ERROR");
checkBufferSuccess(context, context.ARRAY_BUFFER);
checkBufferSuccess(context, context.COPY_READ_BUFFER);
checkBufferSuccess(context, context.COPY_WRITE_BUFFER);
checkBufferSuccess(context, context.ELEMENT_ARRAY_BUFFER);
checkBufferSuccess(context, context.PIXEL_PACK_BUFFER);
checkBufferSuccess(context, context.PIXEL_UNPACK_BUFFER);
checkBufferSuccess(context, context.TRANSFORM_FEEDBACK_BUFFER);
checkBufferSuccess(context, context.UNIFORM_BUFFER);
canvas = document.createElement("canvas");
canvas.width = 40;
canvas.height = 40;
context = canvas.getContext("webgl");
shouldBe("context.getError()", "context.NO_ERROR");
shouldBe("context.getError()", "context.NO_ERROR");
checkBufferSuccess(context, context.ARRAY_BUFFER);
checkBufferFailure(context, context.COPY_READ_BUFFER);
checkBufferFailure(context, context.COPY_WRITE_BUFFER);
checkBufferSuccess(context, context.ELEMENT_ARRAY_BUFFER);
checkBufferFailure(context, context.PIXEL_PACK_BUFFER);
checkBufferFailure(context, context.PIXEL_UNPACK_BUFFER);
checkBufferFailure(context, context.TRANSFORM_FEEDBACK_BUFFER);
checkBufferFailure(context, context.UNIFORM_BUFFER);
function checkBufferSuccess(context, target) {
var buffer = context.createBuffer();
shouldBe("context.getError()", "context.NO_ERROR");
context.bindBuffer(target, buffer);
shouldBe("context.getError()", "context.NO_ERROR");
context.bufferData(target, new Int32Array(16), context.STATIC_DRAW);
shouldBe("context.getError()", "context.NO_ERROR");
context.deleteBuffer(buffer);
shouldBe("context.getError()", "context.NO_ERROR");
}
function checkBufferFailure(context, target) {
var buffer = context.createBuffer();
shouldBe("context.getError()", "context.NO_ERROR");
context.bindBuffer(target, buffer);
shouldBe("context.getError()", "context.INVALID_ENUM");
context.bufferData(target, new Int32Array(16), context.STATIC_DRAW);
shouldBe("context.getError()", "context.INVALID_ENUM");
context.deleteBuffer(buffer);
shouldBe("context.getError()", "context.NO_ERROR");
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>