Update WebGL conformance suite 1.0.3 from upstream

This commit is contained in:
Imanol Fernandez 2017-10-30 19:07:01 +01:00
parent c4bb30413c
commit 4989f00916
1568 changed files with 27218 additions and 27288 deletions

View file

@ -53,7 +53,7 @@ FILE_PATTERNS_TO_CHECK = ["*.rs", "*.rc", "*.cpp", "*.c",
"*.yml"]
# File patterns that are ignored for all tidy and lint checks.
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh"]
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh", "*.ogv", "*.webm"]
SPEC_BASE_PATH = "components/script/dom/"

View file

@ -85,8 +85,7 @@ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, null);
wtu.glErrorShouldBe(gl, [gl.NO_ERROR, gl.INVALID_VALUE]);
wtu.shouldThrowOrGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_VALUE], "gl.bufferSubData(gl.ARRAY_BUFFER, 10, null)");
var successfullyParsed = true;
</script>

View file

@ -58,13 +58,15 @@ context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
var indexValidationError = wtu.shouldGenerateGLError(context,
[context.INVALID_OPERATION, context.NO_ERROR],
"context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -60,9 +60,9 @@ var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
var indexValidationError = wtu.shouldGenerateGLError(context, [context.INVALID_OPERATION, context.NO_ERROR], "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -112,7 +112,7 @@ gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT),
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, [gl.INVALID_OPERATION, gl.NO_ERROR]);
debug("Test with enabled attribute that does not belong to current program");

View file

@ -418,7 +418,6 @@ RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
@ -475,6 +474,7 @@ canvas : "implementation-dependent"
// added in versions of the spec that are backward-compatible with
// this version
var ignoredProperties = [
'STENCIL_INDEX',
];
// Constants removed from the WebGL spec compared to ES 2.0

View file

@ -64,8 +64,7 @@ void main()
var wtu = WebGLTestUtils;
var gl;
var contextAttribs = null;
var pixel_1 = [0, 0, 0, 1];
var pixel_2 = [0, 0, 0, 1];
var redChannels = [0, 0, 0];
var correctColor = null;
var framebuffer;
var fbHasColor;
@ -304,10 +303,13 @@ function testStencilAndDepth(stencil, depth)
function testAntialias(antialias)
{
debug("Testing antialias = " + antialias);
// Both the width and height of canvas are N.
// Note that "N = 2" doesn't work for some post processing AA per the discussion at https://github.com/KhronosGroup/WebGL/pull/1977.
var N = 3;
if (antialias)
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
else
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
var vertices = new Float32Array([
@ -319,17 +321,13 @@ function testAntialias(antialias)
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
var buf_1 = new Uint8Array(1 * 1 * 4);
var buf_2 = new Uint8Array(1 * 1 * 4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_1);
gl.readPixels(0, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_2);
pixel_1[0] = buf_1[0];
pixel_2[0] = buf_2[0];
// For some anti-alias algorithms, effects may be not on diagonal line pixels, so that either:
// - The red channel of the pixel at (0, 0) is not 0 and not 255, or,
// - If it is 0, expect that the red channel of the pixel at (0, 1) is not 0 and not 255.
shouldBe("pixel_1[0] != 255 && pixel_1[0] != 0 || pixel_1[0] == 0 && pixel_2[0] != 255 && pixel_2[0] != 0",
"contextAttribs.antialias");
var buf = new Uint8Array(N * N * 4);
gl.readPixels(0, 0, N, N, gl.RGBA, gl.UNSIGNED_BYTE, buf);
redChannels[0] = buf[4 * (N + 1)]; // (1, 1)
redChannels[1] = buf[4 * N * (N - 1)]; // left top
redChannels[2] = buf[4 * (N - 1)]; // right bottom
shouldBeTrue("redChannels[1] == 255 && redChannels[2] == 0");
shouldBe("redChannels[0] != 255 && redChannels[0] != 0", "contextAttribs.antialias");
}
function runTest()

View file

@ -87,6 +87,9 @@ function init()
canvas.addEventListener("webglcontextlost", testLostContext, false);
// We need to initialize |uniformLocation| before losing context.
// Otherwise gl.getUniform() when context is lost will throw.
uniformLocation = gl.getUniformLocation(program, "tex");
loseContext();
}

View file

@ -290,8 +290,8 @@ function runIndexValidationTests(drawType) {
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
'gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
debug("Test with enabled attribute that does not belong to current program");
@ -331,13 +331,14 @@ function runCopiesIndicesTests(drawType) {
var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runResizedBufferTests(drawType) {
@ -423,8 +424,9 @@ function runVerifiesTooManyIndicesTests(drawType) {
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]), drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runCrashWithBufferSubDataTests(drawType) {

View file

@ -127,8 +127,9 @@ function getSharedArrayBufferSize() {
sharedArrayBufferSize = bufferSizeNeeded;
}
bufferSizeNeeded = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// ArrayBuffers can be at most 4GB (minus 1 byte)
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= 4294967295) {
// ArrayBuffers can be at most 4GB (minus 1 byte), but any allocations larger than 1 GB are unreliable in practice. So limit allocations to 1 GB.
// Textures that are wide in just one dimension can still be used to test max TEXTURE_2D size limit even if we don't allocate space for huge square textures.
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= Math.pow(2, 30)) {
sharedArrayBufferSize = bufferSizeNeeded;
}
}
@ -195,7 +196,7 @@ function testFormatType(t, test) {
for (var j = 0; j < t.targets.length; ++j) {
var target = t.targets[j];
debug("");
debug(wtu.glEnumToString(gl, target));
debug(wtu.glEnumToString(gl, target) + " " + wtu.glEnumToString(ext, test.format));
// positive test
var size = positiveTestSize;
@ -219,11 +220,25 @@ function testFormatType(t, test) {
var dataSize = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// this check assumes that each element is 1 byte
if (dataSize > sharedArrayBuffer.byteLength) {
if (t.target == gl.TEXTURE_CUBE_MAP) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
} else {
var wideAndShortDataSize = test.func(t.maxSize + test.sizeStep, test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, wideAndShortDataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (test.sizeStep));
var narrowAndTallDataSize = test.func(test.sizeStep, t.maxSize + test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, narrowAndTallDataSize);
gl.compressedTexImage2D(target, 0, test.format, test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
} else {
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, dataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds: should generate INVALID_VALUE."
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width and height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
// level out of bounds

View file

@ -62,6 +62,13 @@ void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderRedWithExtension" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderMacroDisabled" type="x-shader/x-fragment">
#ifdef GL_EXT_draw_buffers
bad code here
@ -104,7 +111,7 @@ var canvas = document.getElementById("canvas");
var output = document.getElementById("console");
var gl = wtu.create3DContext(canvas);
var ext = null;
var vao = null;
var programWithMaxDrawBuffersEqualOne = null;
var extensionConstants = [
{ name: "MAX_COLOR_ATTACHMENTS_WEBGL", enum: 0x8CDF, expectedFn: function(v) { return v >= 4; }, passMsg: " should be >= 4"},
@ -179,8 +186,7 @@ if (!gl) {
function createExtDrawBuffersProgram(scriptId, sub) {
var fsource = wtu.getScript(scriptId);
fsource = wtu.replaceParams(fsource, sub);
wtu.addShaderSource(output, "fragment shader", fsource);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"]);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"], undefined, true);
}
function runSupportedTest(extensionEnabled) {
@ -246,9 +252,7 @@ function runEnumTestEnabled() {
function testShaders(tests, sub) {
tests.forEach(function(test) {
var shaders = [wtu.getScript(test.shaders[0]), wtu.replaceParams(wtu.getScript(test.shaders[1]), sub)];
wtu.addShaderSource(output, "vertex shader", shaders[0]);
wtu.addShaderSource(output, "fragment shader", shaders[1]);
var program = wtu.setupProgram(gl, shaders, ["a_position"]);
var program = wtu.setupProgram(gl, shaders, ["a_position"], undefined, true);
var programLinkedSuccessfully = (program != null);
var expectedProgramToLinkSuccessfully = (test.expectFailure == true);
expectTrue(programLinkedSuccessfully != expectedProgramToLinkSuccessfully, test.msg);
@ -260,6 +264,7 @@ function runShadersTestDisabled() {
debug("");
debug("test shaders disabled");
var sub = {numDrawingBuffers: 1};
testShaders([
{ shaders: ["vshader", "fshaderMacroDisabled"],
msg: "GL_EXT_draw_buffers should not be defined in GLSL",
@ -268,7 +273,12 @@ function runShadersTestDisabled() {
msg: "#extension GL_EXT_draw_buffers should not be allowed in GLSL",
expectFailure: true,
},
], {numDrawingBuffers: 1});
], sub);
programWithMaxDrawBuffersEqualOne = createExtDrawBuffersProgram("fshaderBuiltInConstEnabled", sub);
wtu.setupUnitQuad(gl);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
@ -410,6 +420,7 @@ function runDrawTests() {
var checkProgram = wtu.setupTexturedQuad(gl);
var redProgram = wtu.setupProgram(gl, ["vshader", "fshaderRed"], ["a_position"]);
var redProgramWithExtension = wtu.setupProgram(gl, ["vshader", "fshaderRedWithExtension"], ["a_position"]);
var drawProgram = createExtDrawBuffersProgram("fshader", {numDrawingBuffers: maxDrawingBuffers});
var width = 64;
var height = 64;
@ -548,28 +559,56 @@ function runDrawTests() {
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
debug("test that gl_FragColor broadcasts");
debug("test that gl_FragColor does not broadcast unless extension is enabled in fragment shader");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index == 0) ? [255, 0, 0, 255] : [0, 255, 0, 255];
});
debug("test that gl_FragColor broadcasts if extension is enabled in fragment shader");
gl.clear(gl.COLOR_BUFFER_BIT);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgramWithExtension);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
if (maxUsable > 1) {
// First half of color buffers disable.
var bufs1 = makeColorAttachmentArray(maxUsable);
// Second half of color buffers disable.
var bufs2 = makeColorAttachmentArray(maxUsable);
// Color buffers with even indices disabled.
var bufs3 = makeColorAttachmentArray(maxUsable);
// Color buffers with odd indices disabled.
var bufs4 = makeColorAttachmentArray(maxUsable);
for (var ii = 0; ii < maxUsable; ++ii) {
if (ii < half) {
bufs1[ii] = gl.NONE;
} else {
bufs2[ii] = gl.NONE;
}
if (ii % 2) {
bufs3[ii] = gl.NONE;
} else {
bufs4[ii] = gl.NONE;
}
}
debug("test setting first half to NONE and clearing");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
// We should clear all buffers rather than depending on the previous
// gl_FragColor broadcasts test to succeed and setting the colors.
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs1);
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -594,6 +633,7 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs2);
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -698,6 +738,7 @@ function runDrawTests() {
});
gl.deleteProgram(checkProgram);
gl.deleteProgram(redProgram);
gl.deleteProgram(redProgramWithExtension);
gl.deleteProgram(drawProgram);
}
@ -729,6 +770,7 @@ function runPreserveTests() {
finishTest();
});
}
</script>
</body>
</html>

View file

@ -47,7 +47,10 @@ description("Tests calling WebGL APIs with wrong argument types");
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
function mayThrow(expression) {
wtu.shouldThrowOrGenerateGLError(context, [context.NO_ERROR, context.INVALID_VALUE, context.INVALID_OPERATION, context.INVALID_ENUM], expression);
}
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
@ -57,29 +60,25 @@ assertMsg(loc != null, "getUniformLocation succeeded");
var testArguments = [
{ value: "foo",
throws: true },
throws: "yes" },
{ value: 0,
throws: true },
throws: "yes" },
{ value: null,
throws: false },
throws: "maybe" },
{ value: undefined,
throws: false }
throws: "maybe" }
];
var argument;
function shouldBeEmptyString(command) {
shouldBe(command, "''");
}
for (var i = 0; i < testArguments.length; ++i) {
var func, func2;
if (testArguments[i].throws) {
if (testArguments[i].throws == "yes") {
func = shouldThrow;
func2 = shouldThrow;
} else {
func = shouldBeUndefined;
func2 = shouldBeNull;
func = mayThrow;
func2 = shouldBeUndefined;
}
argument = testArguments[i].value;
func("context.compileShader(argument)");
@ -88,28 +87,27 @@ for (var i = 0; i < testArguments.length; ++i) {
func("context.attachShader(argument, shader)");
func("context.detachShader(program, argument)");
func("context.detachShader(argument, shader)");
func("context.useProgram(argument)");
func("context.shaderSource(argument, 'foo')");
func("context.bindAttribLocation(argument, 0, 'foo')");
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]))");
func2("context.getProgramInfoLog(argument)");
func2("context.getProgramParameter(argument, 0)");
func2("context.getShaderInfoLog(argument)");
func2("context.getShaderParameter(argument, 0)");
func2("context.getShaderSource(argument)");
func2("context.getUniform(argument, loc)");
func2("context.getUniform(program, argument)");
func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func("context.getProgramInfoLog(argument)");
func("context.getProgramParameter(argument, 0)");
func("context.getShaderInfoLog(argument)");
func("context.getShaderParameter(argument, 0)");
func("context.getShaderSource(argument)");
func("context.getUniform(argument, loc)");
func("context.getUniform(program, argument)");
func("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func2("context.useProgram(argument)");
func2("context.bindBuffer(context.ARRAY_BUFFER, argument)");
func2("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
func2("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
func2("context.bindTexture(context.TEXTURE_2D, argument)");
func2("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
func2("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
func2("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
func2("context.uniform2iv(argument, new Int32Array([0, 0]))");
func2("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
}
var successfullyParsed = true;

View file

@ -53,9 +53,7 @@ var program = wtu.loadStandardProgram(context);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveAttrib");
// Synthetic OpenGL error
shouldBeNull("context.getActiveAttrib(null, 2)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveAttrib(null, 2)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error
@ -65,9 +63,7 @@ wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveUniform");
// Synthetic OpenGL error
shouldBeNull("context.getActiveUniform(null, 0)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveUniform(null, 0)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error

View file

@ -48,19 +48,20 @@ var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
var shouldThrowOrGenerateGLError = wtu.shouldThrowOrGenerateGLError;
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)");
shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
@ -75,13 +76,13 @@ shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
debug("");
debug("check with bindings");

View file

@ -100,7 +100,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isTexture(tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
var texCubeMap = gl.createTexture();
@ -110,7 +110,7 @@ shouldBe("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)", "texCubeMap");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(texCubeMap)");
shouldBeFalse("gl.isTexture(texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
var t = gl.createTexture();
@ -118,7 +118,7 @@ shouldBeNonNull("t");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
var t2 = gl.createTexture();
@ -152,7 +152,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isRenderbuffer(rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo2)");
shouldBe("gl.getParameter(gl.RENDERBUFFER_BINDING)", "rbo2");
@ -337,7 +337,7 @@ shouldBe("gl.getParameter(gl.ARRAY_BUFFER_BINDING)", "buffer");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer)");
shouldBeFalse("gl.isBuffer(buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var buffer2 = gl.createBuffer();
@ -348,7 +348,7 @@ shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, null)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer2)");
shouldBeFalse("gl.isBuffer(buffer2)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var bufferElement = gl.createBuffer();
@ -358,7 +358,7 @@ shouldBe("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)", "bufferElement");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(bufferElement)");
shouldBeFalse("gl.isBuffer(bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
var b = gl.createBuffer();
@ -366,7 +366,7 @@ shouldBeNonNull("b");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
var b1 = gl.createBuffer();
@ -399,7 +399,7 @@ shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteFramebuffer(fbo)");
shouldBeFalse("gl.isFramebuffer(fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo2)");
shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo2");

View file

@ -51,6 +51,7 @@ gl.useProgram(program);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed");
debug("");

View file

@ -27,7 +27,6 @@ functions/deleteBufferBadArgs.html
functions/drawArrays.html
functions/drawArraysOutOfBounds.html
functions/drawElements.html
functions/drawElementsBadArgs.html
functions/isTests.html
--min-version 1.0.2 functions/isTestsBadArgs.html
functions/readPixels.html

View file

@ -22,7 +22,7 @@ Want to contribute?
1. Fork this repo
2. Run <code>gen_tests.rb</code>
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
1. copy methodName.html to functions/methodName.html and write tests that test the results of valid inputs.
2. copy methodNameBadArgs.html to functions/methodNameBadArgs.html and write tests to assert that invalid inputs throw exceptions.
3. If your test causes a segfault, add the following to the top of the script tag: <code>Tests.autorun = false; Tests.message = "Caution: this may crash your browser";</code>

View file

@ -306,7 +306,6 @@ RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
RENDERBUFFER_WIDTH : 0x8D42,

View file

@ -1,211 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<link rel="stylesheet" type="text/css" href="../unit.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script type="application/x-javascript" src="../unit.js"></script>
<script type="application/x-javascript" src="../util.js"></script>
<script type="application/x-javascript">
// Tests.autorun = false;
// Tests.message = "Caution: May crash your browser";
var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
var indices = [60000000,1,2]
Tests.startUnit = function () {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(getGLContext(canvas));
var prog = new Shader(gl, 'vert', 'frag');
prog.use();
var sh = prog.shader.program;
var v = gl.getAttribLocation(sh, 'Vertex');
var n = gl.getAttribLocation(sh, 'Normal');
var t = gl.getAttribLocation(sh, 'Tex');
return [gl,prog,v,n,t];
}
Tests.setup = function(gl, prog, v,n,t) {
assert(0 == gl.getError());
return [gl, prog, v,n,t];
}
Tests.teardown = function(gl, prog, v,n,t) {
gl.disableVertexAttribArray(v);
gl.disableVertexAttribArray(n);
gl.disableVertexAttribArray(t);
}
Tests.endUnit = function(gl, prog, v,n,t) {
prog.destroy();
}
Tests.testDrawElementsVBO = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOByte = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMulti = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 2*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 3*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMultiByte = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, -1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, -1, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 3);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testSharedBuffers = function(gl, prog, v,n,t) {
var vbo = gl.createBuffer();
var vertsArr = new Uint16Array([0,1,3,3,4,5,6,7,8]);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
assertFail(function(){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo)});
gl.deleteBuffer(vbo);
}
</script>
<script id="vert" type="x-shader/x-vertex">
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec2 Tex;
varying vec4 texCoord0;
void main()
{
gl_Position = vec4(Vertex * Normal, 1.0);
texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
}
</script>
<script id="frag" type="x-shader/x-fragment">
precision mediump float;
varying vec4 texCoord0;
void main()
{
vec4 c = texCoord0;
gl_FragColor = c;
}
</script>
<style>canvas{ position:absolute; }</style>
</head><body>
<canvas id="gl" width="1" height="1"></canvas>
</body></html>

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/opengl_logo.jpg";
var localImgUrl = "../../resources/opengl_logo.jpg";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -93,8 +93,8 @@ Tests.testVertexAttribPointerVBO = function(gl, prog, v,n,t) {
assertFail("bad index (big positive)",
function(){gl.vertexAttribPointer(8693948, 3, gl.FLOAT, false, 0, 0);});
gl.bindBuffer(gl.ARRAY_BUFFER, null);
assertFail("binding to null buffer",
function(){gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);});
assertFail("binding to null buffer with offset!=0",
function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 16);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);

View file

@ -59,8 +59,7 @@ shouldBeNull("context.getActiveUniform(program, 1)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
shouldBeNull("context.getActiveUniform(program, -1)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
shouldBeNull("context.getActiveUniform(null, 0)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveUniform(null, 0)");
// we don't know the order the attribs will appear.
var info = [
@ -116,8 +115,7 @@ shouldBeNull("context.getActiveAttrib(program, 2)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
shouldBeNull("context.getActiveAttrib(program, -1)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
shouldBeNull("context.getActiveAttrib(null, 0)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveAttrib(null, 0)");
wtu.glErrorShouldBe(context2, context.NO_ERROR);

View file

@ -83,7 +83,7 @@
assertMsg(gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE,
"framebuffer should be FRAMEBUFFER_COMPLETE.");
var program = wtu.setupProgram(gl, ["vs", "fs"], ["vPosition", "vTexCoord"]);
var program = wtu.setupProgram(gl, ["vs", "fs"], ["a_position", "a_texCoord"]);
gl.uniform1i(gl.getUniformLocation(program, "u_texture"), 0);
gl.disable(gl.BLEND);
gl.disable(gl.DEPTH_TEST);

View file

@ -58,67 +58,59 @@
<script>
"use strict";
function init()
{
description(document.title);
function checkDrawElements(mode, count, type, expect, msg) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawElements(mode, count, type, 0);
wtu.glErrorShouldBe(gl, expect, msg);
}
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 0, 1, 2]), gl.STATIC_DRAW);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR,
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)");
checkDrawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT,
gl.NO_ERROR, "can call gl.DrawElements with UNSIGNED_SHORT");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2, 0]), gl.STATIC_DRAW);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR,
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0)");
checkDrawElements(
gl.TRIANGLES, 3, gl.UNSIGNED_BYTE,
gl.NO_ERROR, "can call gl.DrawElements with UNSIGNED_BYTE");
checkDrawElements(
desktopGL['QUAD_STRIP'], 4, gl.UNSIGNED_BYTE,
gl.INVALID_ENUM, "gl.DrawElements with QUAD_STRIP should return INVALID_ENUM");
checkDrawElements(
desktopGL['QUADS'], 4, gl.UNSIGNED_BYTE,
gl.INVALID_ENUM, "gl.DrawElements with QUADS should return INVALID_ENUM");
checkDrawElements(
desktopGL['POLYGON'], 4, gl.UNSIGNED_BYTE,
gl.INVALID_ENUM, "gl.DrawElements with POLYGON should return INVALID_ENUM");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(desktopGL.QUAD_STRIP, 4, gl.UNSIGNED_BYTE, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(desktopGL.QUADS, 4, gl.UNSIGNED_BYTE, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(desktopGL.POLYGON, 4, gl.UNSIGNED_BYTE, 0)");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 0, 1, 2]), gl.STATIC_DRAW);
checkDrawElements(
gl.TRIANGLES, 3, gl.UNSIGNED_INT,
gl.INVALID_ENUM, "gl.DrawElements should return INVALID_ENUM with UNSIGNED_INT");
checkDrawElements(
gl.TRIANGLES, 3, gl.FLOAT,
gl.INVALID_ENUM, "gl.DrawElements should return INVALID_ENUM with FLOAT");
checkDrawElements(
gl.TRIANGLES, 3, gl.SHORT,
gl.INVALID_ENUM, "gl.DrawElements should return INVALID_ENUM with SHORT");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(gl.TRIANGLES, 3, gl.FLOAT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM,
"gl.drawElements(gl.TRIANGLES, 3, gl.SHORT, 0)");
}
// Index validation
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0,1,2,2000, 40802, 5887992]), gl.STATIC_DRAW);
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION,
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 1)");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR,
"gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 2)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION,
"gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 3)");
wtu.shouldGenerateGLError(gl, indexValidationError,
"gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION,
"gl.drawElements(gl.TRIANGLES, 7, gl.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION,
"gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 2)");
init();
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>

View file

@ -165,7 +165,7 @@ var runDrawElementsTest = function(callTemplate, gl, wtu, ext) {
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1), gl.STATIC_DRAW)');
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, new Uint8Array([ 3, 0, 1]))');
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR], wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, (new Uint8Array([ 3, 0, 1, 2 ])).subarray(1))');
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_BYTE', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, wtu.replaceParams(callTemplate, {count: 0, type: 'gl.UNSIGNED_BYTE', offset: 0}));
@ -204,10 +204,10 @@ var runDrawElementsTest = function(callTemplate, gl, wtu, ext) {
// invalid operation with indices that would be valid with correct bindings
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 9, type: 'gl.UNSIGNED_SHORT', offset: 1000}));
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 12, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 15, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 18, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_SHORT', offset: 2*15}));
wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 12, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 15, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 18, type: 'gl.UNSIGNED_SHORT', offset: 0}));
wtu.shouldGenerateGLError(gl, indexValidationError, wtu.replaceParams(callTemplate, {count: 3, type: 'gl.UNSIGNED_SHORT', offset: 2*15}));
// 0xffffffff needs to convert to a 'long' IDL argument as -1, as per
// WebIDL 4.1.7. JS ToInt32(0xffffffff) == -1. Thus INVALID_VALUE.

View file

@ -1274,7 +1274,7 @@ var create3DContext = function(opt_canvas, opt_attributes, opt_version) {
var names;
switch (opt_version) {
case 2:
names = ["webgl2", "experimental-webgl2"]; break;
names = ["webgl2"]; break;
default:
names = ["webgl", "experimental-webgl"]; break;
}
@ -1352,8 +1352,34 @@ var shouldGenerateGLError = function(gl, glErrors, evalStr) {
}
if (exception) {
testFailed(evalStr + " threw exception " + exception);
return -1;
} else {
glErrorShouldBe(gl, glErrors, "after evaluating: " + evalStr);
return glErrorShouldBe(gl, glErrors, "after evaluating: " + evalStr);
}
};
/**
* Tests that an evaluated expression either throws an exception or generates a specific GL error.
* @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use.
* @param {number|Array.<number>} glErrors The expected gl error or an array of expected errors.
* @param {string} evalStr The string to evaluate.
* @param {string} opt_msg The optional message to display.
*/
var shouldThrowOrGenerateGLError = function(gl, glErrors, evalStr, opt_msg) {
var exception;
try {
eval(evalStr);
} catch (e) {
exception = e;
}
if (exception) {
testPassed(evalStr + " threw exception " + exception);
return 0;
} else {
if (!opt_msg) {
opt_msg = "after evaluating: " + evalStr;
}
return glErrorShouldBe(gl, glErrors, opt_msg);
}
};
@ -1382,6 +1408,7 @@ var glErrorShouldBe = function(gl, glErrors, opt_msg) {
var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: ");
testPassed(msg + expected + " : " + opt_msg);
}
return err;
};
/**
@ -2731,6 +2758,7 @@ return {
startPlayingAndWaitForVideo: startPlayingAndWaitForVideo,
startsWith: startsWith,
shouldGenerateGLError: shouldGenerateGLError,
shouldThrowOrGenerateGLError: shouldThrowOrGenerateGLError,
readFile: readFile,
readFileList: readFileList,
replaceParams: replaceParams,

View file

@ -74,8 +74,7 @@ var shaders = gl.getAttachedShaders(standardProgram);
shouldBe('shaders.length', '2');
shouldBeTrue('shaders[0] == standardVert && shaders[1] == standardFrag || shaders[1] == standardVert && shaders[0] == standardFrag');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeNull('gl.getAttachedShaders(null)');
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(gl, gl.INVALID_VALUE, 'gl.getAttachedShaders(null)');
shouldThrow('gl.getAttachedShaders(standardVert)');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

View file

@ -50,7 +50,7 @@ function causedException(func) {
return hadException;
}
var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/opengl_logo.jpg";
var localImgUrl = "../resources/opengl_logo.jpg";
var imgDomain;

View file

@ -641,21 +641,27 @@ function testConstructionWithNullBuffer(type, name) {
var array;
try {
array = new type(null);
testFailed("Construction of " + name + " with null buffer should throw exception");
assertEq("Length of " + name + " constructed with null", 0, array.length);
testPassed("Construction of " + name + " with null produced a " + name + " of length 0");
} catch (e) {
testPassed("Construction of " + name + " with null buffer threw exception");
// This used to be correct, but TC39 has changed the behavior of these constructors.
testPassed("Construction of " + name + " with null threw exception");
}
try {
array = new type(null, 0);
assertEq("Length of " + name + " constructed with null", 0, array.length);
testPassed("Construction of " + name + " with null produced a " + name + " of length 0");
} catch (e) {
// This used to be correct, but TC39 has changed the behavior of these constructors.
testPassed("Construction of " + name + " with (null, 0) threw exception");
}
try {
array = new type(null, 0, 0);
testFailed("Construction of " + name + " with (null buffer, 0) should throw exception");
assertEq("Length of " + name + " constructed with null", 0, array.length);
testPassed("Construction of " + name + " with null produced a " + name + " of length 0");
} catch (e) {
testPassed("Construction of " + name + " with (null buffer, 0) threw exception");
}
try {
array = new type(null, 0, 0);
testFailed("Construction of " + name + " with (null buffer, 0, 0) should throw exception");
} catch (e) {
testPassed("Construction of " + name + " with (null buffer, 0, 0) threw exception");
// This used to be correct, but TC39 has changed the behavior of these constructors.
testPassed("Construction of " + name + " with (null, 0, 0) threw exception");
}
}

View file

@ -101,6 +101,88 @@ function checkSet(func, index, value, littleEndian)
shouldThrow(expr);
}
function checkGetWithoutArgument(func, expected)
{
var threw = false;
var value;
try {
value = view["get" + func]();
} catch (e) {
threw = true;
}
if (threw) {
// This used to be correct, but TC39 has changed the behavior of these methods.
testPassed("view.get" + func + " with no arguments throws.");
} else {
if (value === expected) {
testPassed("view.get" + func + " treats missing argument as 0.");
} else {
testFailed("view.get" + func + " accepts a missing argument but does not cast it to 0.");
}
}
}
function checkSetWithoutSecondArgument(func, index, isFloat)
{
var expected = isFloat ? NaN : 0;
var threw = false;
var value;
try {
value = view["set" + func](index);
} catch (e) {
threw = true;
}
if (threw) {
// This used to be correct, but TC39 has changed the behavior of these methods.
testPassed("view.set" + func + " with missing second argument throws.");
} else {
var stored = view["get" + func](index);
if (value === undefined && isFloat ? isNaN(stored) : stored === expected) {
testPassed("view.set" + func + " treats missing second argument as " + expected + ".");
} else {
testFailed("view.set" + func + " accepts a missing second argument but does not cast it to " + expected + ".");
}
}
}
function checkSetWithoutArguments(func, isFloat)
{
var expected = isFloat ? NaN : 0;
var threw = false;
var value;
try {
value = view["set" + func]();
} catch (e) {
threw = true;
}
if (threw) {
// This used to be correct, but TC39 has changed the behavior of these methods.
testPassed("view.set" + func + " with no arguments throws.");
} else {
var stored = view["get" + func](0);
if (value === undefined && isFloat ? isNaN(stored) : stored === expected) {
testPassed("view.set" + func + " treats missing first argument as 0.");
} else {
testFailed("view.set" + func + " accepts a missing first argument but does not cast it to 0.");
}
}
}
function testMissingArguments(func, constructor, isFloat)
{
view = new DataView((new constructor(3)).buffer);
view["set" + func](0, 1);
view["set" + func](getElementSize(func), 2);
checkGetWithoutArgument(func, 1);
checkSetWithoutSecondArgument(func, getElementSize(func), isFloat);
view = new DataView((new constructor(3)).buffer);
view["set" + func](0, 1);
checkSetWithoutArguments(func, isFloat);
}
function test(isTestingGet, func, index, value, littleEndian)
{
if (isTestingGet)
@ -306,18 +388,6 @@ function runGetTests()
debug("");
debug("Test for get methods that read from negative index");
runNegativeIndexTests(true);
debug("");
debug("Test for wrong arguments passed to get methods");
view = new DataView((new Uint8Array([1, 2])).buffer);
shouldThrow("view.getInt8()");
shouldThrow("view.getUint8()");
shouldThrow("view.getInt16()");
shouldThrow("view.getUint16()");
shouldThrow("view.getInt32()");
shouldThrow("view.getUint32()");
shouldThrow("view.getFloat32()");
shouldThrow("view.getFloat64()");
}
function runSetTests()
@ -335,26 +405,20 @@ function runSetTests()
debug("");
debug("Test for set methods that write to negative index");
runNegativeIndexTests(false);
}
function runMissingArgumentTests()
{
debug("");
debug("Test for wrong arguments passed to set methods");
view = new DataView((new Uint8Array([1, 2])).buffer);
shouldThrow("view.setInt8()");
shouldThrow("view.setUint8()");
shouldThrow("view.setInt16()");
shouldThrow("view.setUint16()");
shouldThrow("view.setInt32()");
shouldThrow("view.setUint32()");
shouldThrow("view.setFloat32()");
shouldThrow("view.setFloat64()");
shouldThrow("view.setInt8(1)");
shouldThrow("view.setUint8(1)");
shouldThrow("view.setInt16(1)");
shouldThrow("view.setUint16(1)");
shouldThrow("view.setInt32(1)");
shouldThrow("view.setUint32(1)");
shouldThrow("view.setFloat32(1)");
shouldThrow("view.setFloat64(1)");
debug("Test for get and set methods missing arguments");
testMissingArguments("Int8", Int8Array);
testMissingArguments("Uint8", Uint8Array);
testMissingArguments("Int16", Int16Array);
testMissingArguments("Uint16", Uint16Array);
testMissingArguments("Int32", Int32Array);
testMissingArguments("Uint32", Uint32Array);
testMissingArguments("Float32", Float32Array, true);
testMissingArguments("Float64", Float64Array, true);
}
function runIndexingTests()
@ -370,6 +434,7 @@ function runIndexingTests()
runConstructorTests();
runGetTests();
runSetTests();
runMissingArgumentTests();
runIndexingTests();
var successfullyParsed = true;
</script>

View file

@ -439,7 +439,7 @@ function testUniformOptimizationIssues(testIndex) {
var name = test.arrayName + "[" + test.usedUniformVector + "]";
var uniformLocation = gl.getUniformLocation(program, name);
gl.uniform4fv(uniformLocation, test.color);
wtu.setupIndexedQuad(gl, 1, positionLoc);
wtu.setupIndexedQuad(gl, 1);
wtu.clearAndDrawIndexedQuad(gl, 1);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");