diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html b/dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html new file mode 100644 index 0000000000..2ae7d91bf3 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/misc/bad-arguments-test.html @@ -0,0 +1,100 @@ +<!-- +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 wrong argument types"); + + +var testArguments = [ + { value: "foo", + throwsForNullables: true }, + { value: 0, + throwsForNullables: true }, + { value: null, + throwsForNullables: false }, + { value: undefined, + throwsForNullables: false } +]; + +var argument; + +var context = wtu.create3DContext(); +var program; +var shader; +var loc; +wtu.loadStandardProgramAsync(context, function(success, prog) { + program = prog; + wtu.loadStandardVertexShaderAsync(context, function(success, s) { + shader = s; + + assertMsg(program != null, "Program Compiled"); + assertMsg(shader != null, "Shader Compiled"); + + loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); + assertMsg(loc != null, "getUniformLocation succeeded"); + + for (var i = 0; i < testArguments.length; ++i) { + argument = testArguments[i].value; + + debug('Testing argument: ' + argument); + + // These functions don't accept nullable arguments any more. + shouldThrow("context.compileShader(argument)"); + shouldThrow("context.linkProgram(argument)"); + shouldThrow("context.attachShader(program, argument)"); + shouldThrow("context.attachShader(argument, shader)"); + shouldThrow("context.detachShader(program, argument)"); + shouldThrow("context.detachShader(argument, shader)"); + shouldThrow("context.shaderSource(argument, 'foo')"); + shouldThrow("context.bindAttribLocation(argument, 0, 'foo')"); + shouldThrow("context.getProgramInfoLog(argument)"); + shouldThrow("context.getProgramParameter(argument, 0)"); + shouldThrow("context.getShaderInfoLog(argument)"); + shouldThrow("context.getShaderParameter(argument, 0)"); + shouldThrow("context.getShaderSource(argument)"); + shouldThrow("context.getUniform(argument, loc)"); + shouldThrow("context.getUniform(program, argument)"); + shouldThrow("context.getUniformLocation(argument, 'u_modelViewProjMatrix')"); + + // The following entry points still accept nullable arguments. + var func; + if (testArguments[i].throwsForNullables) { + func = shouldThrow; + } else { + func = shouldBeUndefined; + } + + func("context.bindBuffer(context.ARRAY_BUFFER, argument)"); + func("context.bindFramebuffer(context.FRAMEBUFFER, argument)"); + func("context.bindRenderbuffer(context.RENDERBUFFER, argument)"); + func("context.bindTexture(context.TEXTURE_2D, argument)"); + func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)"); + func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)"); + func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))"); + func("context.uniform2iv(argument, new Int32Array([0, 0]))"); + func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))"); + func("context.useProgram(argument)"); + } + finishTest(); + }); +}); +</script> +</body> +</html> |