diff options
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/misc/type-conversion-test.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance/misc/type-conversion-test.html | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/misc/type-conversion-test.html b/dom/canvas/test/webgl-conf/checkout/conformance/misc/type-conversion-test.html new file mode 100644 index 0000000000..bb04f3ba00 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/misc/type-conversion-test.html @@ -0,0 +1,151 @@ +<!-- +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"; +var wtu = WebGLTestUtils; +description("Tests calling WebGL APIs with various types"); + +var context = wtu.create3DContext(); +var program = wtu.loadStandardProgram(context); +var shader = wtu.loadStandardVertexShader(context); + +assertMsg(program != null, "Program Compiled"); +assertMsg(shader != null, "Shader Compiled"); + +var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); +assertMsg(loc != null, "getUniformLocation succeeded"); + +var buffer = context.createBuffer(); +context.bindBuffer(context.ARRAY_BUFFER, buffer); +var texture = context.createTexture(); +context.bindTexture(context.TEXTURE_2D, texture); +context.useProgram(program); + +var args = [ + { type: "number", value: 0 }, + { type: "number", value: 2 }, + { type: "string that is NaN", value: "foo", }, + { type: "string that is number", value: "2", }, + { type: "null", value: null }, + { type: "Empty Array", value: [] }, + { type: "Object", value: {} }, + { type: "Array of Number", value: [2] }, + { type: "Array of String", value: ["foo"] }, + { type: "Array of String that is number", value: ["0"] }, + { type: "Array of String that is number", value: ["2"] }, + { type: "TypedArray", value: new Float32Array(1) } +]; + +var argument; + +for (var i = 0; i < args.length; ++i) { + argument = args[i].value; + var func1 = shouldBeUndefined; + var func2 = shouldBeNonNull; + if (argument == 2) { + func2 = shouldBeNull; + } + var func3 = shouldBeNull; + debug(""); + debug("testing type of " + args[i].type + " : value = " + argument); + func1("context.bindAttribLocation(program, argument, 'foo')"); + func1("context.blendColor(argument, argument, argument, argument)"); + func1("context.bufferData(context.ARRAY_BUFFER, argument, context.STATIC_DRAW)"); + func1("context.bufferData(context.ARRAY_BUFFER, new Float32Array(10), context.STATIC_DRAW)"); + func1("context.bufferSubData(context.ARRAY_BUFFER, argument, new Float32Array(2))"); + func1("context.clear(argument)") + func1("context.clearColor(argument, 0, 0, 0)"); + func1("context.clearColor(0, argument, 0, 0)"); + func1("context.clearColor(0, 0, argument, 0)"); + func1("context.clearColor(0, 0, 0, argument)"); + func1("context.clearDepth(argument)"); + func1("context.clearStencil(argument)"); + func1("context.copyTexImage2D(context.TEXTURE_2D, argument, context.RGBA, 0, 0, 1, 1, 0)"); + func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, argument, 0, 1, 1, 0)"); + func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, argument, 1, 1, 0)"); + func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, argument, 1, 0)"); + func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 0, argument, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, argument, 0, 0, 0, 0, 0, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, argument, 0, 0, 0, 0, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, argument, 0, 0, 0, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, argument, 0, 0, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, argument, 0, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, argument, 0)"); + func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 0, argument)"); + func1("context.depthMask(argument)"); + func1("context.depthRange(argument, 1)"); + func1("context.depthRange(0, argument)"); + func1("context.drawArrays(context.POINTS, argument, 1)"); + func1("context.drawArrays(context.POINTS, 0, argument)"); + //func1("context.drawElements(...)"); + func1("context.enableVertexAttribArray(argument)"); + func1("context.disableVertexAttribArray(argument)"); + func2("context.getActiveAttrib(program, argument)"); + func2("context.getActiveUniform(program, argument)"); + func3("context.getParameter(argument)"); + func1("context.lineWidth(argument)"); + func1("context.polygonOffset(argument, 0)"); + func1("context.polygonOffset(0, argument)"); + //func1("context.readPixels(...)"); + //func1("context.renderbufferStorage(...)"); + func1("context.sampleCoverage(argument, 0)"); + func1("context.sampleCoverage(0, argument)"); + func1("context.scissor(argument, 0, 10, 10)"); + func1("context.scissor(0, argument, 10, 10)"); + func1("context.scissor(0, 0, argument, 10)"); + func1("context.scissor(0, 0, 10, argument)"); + func1("context.shaderSource(shader, argument)"); + func1("context.stencilFunc(context.NEVER, argument, 255)"); + func1("context.stencilFunc(context.NEVER, 0, argument)"); + //func1("context.stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)"); + func1("context.stencilMask(argument)"); + //func1("context.stencilMaskSeparate(context.FRONT, argument); + //func1("context.texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView pixels)"); + //func1("context.texParameterf(GLenum target, GLenum pname, GLfloat param)"); + //func1("context.texParameteri(GLenum target, GLenum pname, GLint param)"); + //func1("context.texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,GLsizei width, GLsizei height,GLenum format, GLenum type, ArrayBufferView pixels)"); + func1("context.uniform1i(loc, argument)"); + func1("context.uniform2i(loc, argument, 0)"); + func1("context.uniform2i(loc, 0, argument)"); + func1("context.uniform3i(loc, argument, 0, 0)"); + func1("context.uniform3i(loc, 0, argument, 0)"); + func1("context.uniform3i(loc, 0, 0, argument)"); + func1("context.uniform4i(loc, argument, 0, 0, 0)"); + func1("context.uniform4i(loc, 0, argument, 0, 0)"); + func1("context.uniform4i(loc, 0, 0, argument, 0)"); + func1("context.uniform4i(loc, 0, 0, 0, argument)"); + func1("context.uniform1f(loc, argument)"); + func1("context.uniform2f(loc, argument, 0)"); + func1("context.uniform2f(loc, 0, argument)"); + func1("context.uniform3f(loc, argument, 0, 0)"); + func1("context.uniform3f(loc, 0, argument, 0)"); + func1("context.uniform3f(loc, 0, 0, argument)"); + func1("context.uniform4f(loc, argument, 0, 0, 0)"); + func1("context.uniform4f(loc, 0, argument, 0, 0)"); + func1("context.uniform4f(loc, 0, 0, argument, 0)"); + func1("context.uniform4f(loc, 0, 0, 0, argument)"); +} + +var successfullyParsed = true; +</script> + +<script src="../../js/js-test-post.js"></script> +</body> +</html> + |