<!--
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>
<canvas id="canvas">
<script>
"use strict";
var wtu;
var canvas;
var gl;
var shouldGenerateGLError;

var buffer;
var framebuffer;
var program;
var renderbuffer;
var shader;
var texture;

description("Tests 'is' calls against non-bound and deleted objects");

wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
shouldGenerateGLError = wtu.shouldGenerateGLError;

shouldGenerateGLError(gl, gl.NO_ERROR, "buffer = gl.createBuffer()");
shouldBeFalse("gl.isBuffer(buffer)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldBeTrue("gl.isBuffer(buffer)");
debug("");

shouldGenerateGLError(gl, gl.NO_ERROR, "framebuffer = gl.createFramebuffer()");
shouldBeFalse("gl.isFramebuffer(framebuffer)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer)");
shouldBeTrue("gl.isFramebuffer(framebuffer)");
debug("");

shouldGenerateGLError(gl, gl.NO_ERROR, "renderbuffer = gl.createRenderbuffer()");
shouldBeFalse("gl.isRenderbuffer(renderbuffer)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer)");
shouldBeTrue("gl.isRenderbuffer(renderbuffer)");
debug("");

shouldGenerateGLError(gl, gl.NO_ERROR, "texture = gl.createTexture()");
shouldBeFalse("gl.isTexture(texture)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, texture)");
shouldBeTrue("gl.isTexture(texture)");
debug("");

shouldGenerateGLError(gl, gl.NO_ERROR, "program = gl.createProgram()");
shouldBeTrue("gl.isProgram(program)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteProgram(program)");
shouldBeFalse("gl.isProgram(program)");
debug("");

shouldGenerateGLError(gl, gl.NO_ERROR, "shader = gl.createShader(gl.VERTEX_SHADER)");
shouldBeTrue("gl.isShader(shader)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteShader(shader)");
shouldBeFalse("gl.isShader(shader)");
debug("");

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>
