mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 722211 - Update WebGL conformance tests to r16765 and adapt mochitest to harness changes - no review
No review because this is mostly just syncing us with the upstream, https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/ as well as adjusting to test harness changes (now loading test lists asynchronously) and a patch to the harness itself which I'll send upstream (see fix-webgl-harness-async.patch)
This commit is contained in:
parent
5a665a0956
commit
fdd5a3844c
@ -1,4 +1,4 @@
|
||||
This is a local copy of the WebGL conformance suite, SVN revision 16456
|
||||
This is a local copy of the WebGL conformance suite, SVN revision 16776
|
||||
|
||||
The canonical location for this testsuite is:
|
||||
|
||||
|
@ -27,7 +27,7 @@ var array = new ArrayBuffer(128);
|
||||
shouldBeNonNull("array");
|
||||
|
||||
var buf = gl.createBuffer();
|
||||
shouldBeNonNull(buf);
|
||||
shouldBeNonNull("buf");
|
||||
|
||||
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
||||
glErrorShouldBe(gl, gl.INVALID_OPERATION);
|
||||
|
@ -102,7 +102,7 @@ if (!gl) {
|
||||
testPassed("context exists");
|
||||
|
||||
gl.program = createProgram(gl, "vshader", "fshader", ["vPosition"]);
|
||||
shouldBeNonNull(gl.program);
|
||||
shouldBeNonNull("gl.program");
|
||||
gl.useProgram(gl.program);
|
||||
gl.enable(gl.DEPTH_TEST);
|
||||
gl.disable(gl.BLEND);
|
||||
|
@ -101,7 +101,7 @@ if (!gl) {
|
||||
testPassed("context exists");
|
||||
|
||||
gl.program = createProgram(gl, "vshader", "fshader", ["vPosition"]);
|
||||
shouldBeNonNull(gl.program);
|
||||
shouldBeNonNull("gl.program");
|
||||
gl.useProgram(gl.program);
|
||||
gl.enable(gl.DEPTH_TEST);
|
||||
gl.disable(gl.BLEND);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"></script>
|
||||
@ -68,7 +67,7 @@ function testLosingContext()
|
||||
// we didn't call prevent default so we should not be able to restore the context
|
||||
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "extension.restoreContext()");
|
||||
testLosingAndRestoringContext();
|
||||
}, 1);
|
||||
}, 0);
|
||||
});
|
||||
canvas.addEventListener("webglcontextrestored", testShouldNotRestoreContext);
|
||||
allowRestore = false;
|
||||
@ -106,7 +105,7 @@ function testLosingAndRestoringContext()
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
// gl methods should still be no-ops
|
||||
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)");
|
||||
}, 1);
|
||||
}, 0);
|
||||
});
|
||||
canvas.addEventListener("webglcontextrestored", function() {
|
||||
testRestoredContext();
|
||||
@ -164,7 +163,7 @@ function testLostContext(e)
|
||||
shouldBeTrue("gl.isContextLost()");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
if (allowRestore)
|
||||
if (allowRestore)
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"></script>
|
||||
|
@ -3,6 +3,5 @@ oes-texture-float.html
|
||||
oes-vertex-array-object.html
|
||||
webgl-debug-renderer-info.html
|
||||
webgl-debug-shaders.html
|
||||
# commented out until 1.0.1 cut
|
||||
# webgl-experimental-compressed-textures.html
|
||||
--min-version 1.0.2 webgl-experimental-compressed-textures.html
|
||||
|
||||
|
@ -57,7 +57,15 @@ void main() {
|
||||
gl_FragColor = vec4(dx, dy, w, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Shaders to link with test fragment shaders -->
|
||||
<script id="goodVertexShader" type="x-shader/x-vertex">
|
||||
attribute vec4 vPosition;
|
||||
varying vec2 texCoord;
|
||||
void main() {
|
||||
texCoord = vPosition.xy;
|
||||
gl_Position = vPosition;
|
||||
}
|
||||
</script>
|
||||
<!-- Shaders to test output -->
|
||||
<script id="outputVertexShader" type="x-shader/x-vertex">
|
||||
attribute vec4 vPosition;
|
||||
@ -183,19 +191,20 @@ function runHintTestEnabled() {
|
||||
}
|
||||
|
||||
function runShaderTests(extensionEnabled) {
|
||||
debug("");
|
||||
debug("Testing various shader compiles with extension " + (extensionEnabled ? "enabled" : "disabled"));
|
||||
|
||||
// Expect the macro shader to succeed ONLY if enabled
|
||||
var macroFragmentShader = wtu.loadShaderFromScript(gl, "macroFragmentShader");
|
||||
var macroFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "macroFragmentShader");
|
||||
if (extensionEnabled) {
|
||||
if (macroFragmentShader) {
|
||||
if (macroFragmentProgram) {
|
||||
// Expected result
|
||||
testPassed("GL_OES_standard_derivatives defined in shaders when extension is enabled");
|
||||
} else {
|
||||
testFailed("GL_OES_standard_derivatives not defined in shaders when extension is enabled");
|
||||
}
|
||||
} else {
|
||||
if (macroFragmentShader) {
|
||||
if (macroFragmentProgram) {
|
||||
testFailed("GL_OES_standard_derivatives defined in shaders when extension is disabled");
|
||||
} else {
|
||||
testPassed("GL_OES_standard_derivatives not defined in shaders when extension disabled");
|
||||
@ -203,23 +212,23 @@ function runShaderTests(extensionEnabled) {
|
||||
}
|
||||
|
||||
// Always expect the shader missing the #pragma to fail (whether enabled or not)
|
||||
var missingPragmaFragmentShader = wtu.loadShaderFromScript(gl, "missingPragmaFragmentShader");
|
||||
if (missingPragmaFragmentShader) {
|
||||
var missingPragmaFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "missingPragmaFragmentShader");
|
||||
if (missingPragmaFragmentProgram) {
|
||||
testFailed("Shader built-ins allowed without #extension pragma");
|
||||
} else {
|
||||
testPassed("Shader built-ins disallowed without #extension pragma");
|
||||
}
|
||||
|
||||
// Try to compile a shader using the built-ins that should only succeed if enabled
|
||||
var testFragmentShader = wtu.loadShaderFromScript(gl, "testFragmentShader");
|
||||
var testFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "testFragmentShader");
|
||||
if (extensionEnabled) {
|
||||
if (testFragmentShader) {
|
||||
if (testFragmentProgram) {
|
||||
testPassed("Shader built-ins compiled successfully when extension enabled");
|
||||
} else {
|
||||
testFailed("Shader built-ins failed to compile when extension enabled");
|
||||
}
|
||||
} else {
|
||||
if (testFragmentShader) {
|
||||
if (testFragmentProgram) {
|
||||
testFailed("Shader built-ins compiled successfully when extension disabled");
|
||||
} else {
|
||||
testPassed("Shader built-ins failed to compile when extension disabled");
|
||||
|
@ -1,10 +1,8 @@
|
||||
functions/00_test_list.txt
|
||||
implicit/00_test_list.txt
|
||||
# commented out for version 1.0.1 of the conforamnce tests.
|
||||
#matrices/00_test_list.txt
|
||||
--min-version 1.0.2 matrices/00_test_list.txt
|
||||
misc/00_test_list.txt
|
||||
reserved/00_test_list.txt
|
||||
# commented out for version 1.0.1 of the conforamnce tests.
|
||||
#samplers/00_test_list.txt
|
||||
--min-version 1.0.2 samplers/00_test_list.txt
|
||||
variables/00_test_list.txt
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
attrib-location-length-limits.html
|
||||
embedded-struct-definitions-forbidden.html
|
||||
#glsl-2types-of-textures-on-same-unit.html
|
||||
# this test is intentionally disabled as it is too strict and to hard to simulate
|
||||
# glsl-2types-of-textures-on-same-unit.html
|
||||
glsl-function-nodes.html
|
||||
glsl-long-variable-names.html
|
||||
non-ascii-comments.vert.html
|
||||
non-ascii.vert.html
|
||||
|
||||
shader-with-256-character-identifier.frag.html
|
||||
shader-with-257-character-identifier.frag.html
|
||||
shader-with-_webgl-identifier.vert.html
|
||||
@ -13,16 +15,22 @@ shader-with-arbitrary-indexing.vert.html
|
||||
shader-with-attrib-array.vert.html
|
||||
shader-with-attrib-struct.vert.html
|
||||
shader-with-clipvertex.vert.html
|
||||
--min-version 1.0.2 shader-with-conditional-scoping.html
|
||||
shader-with-default-precision.frag.html
|
||||
shader-with-default-precision.vert.html
|
||||
shader-with-define-line-continuation.frag.html
|
||||
shader-with-dfdx-no-ext.frag.html
|
||||
shader-with-dfdx.frag.html
|
||||
--min-version 1.0.2 shader-with-do-scoping.html
|
||||
shader-with-error-directive.html
|
||||
shader-with-explicit-int-cast.vert.html
|
||||
shader-with-float-return-value.frag.html
|
||||
--min-version 1.0.2 shader-with-for-scoping.html
|
||||
--min-version 1.0.2 shader-with-for-loop.html
|
||||
shader-with-frag-depth.frag.html
|
||||
shader-with-function-recursion.frag.html
|
||||
--min-version 1.0.2 shader-with-function-scoped-struct.html
|
||||
--min-version 1.0.2 shader-with-functional-scoping.html
|
||||
shader-with-glcolor.vert.html
|
||||
shader-with-gles-1.frag.html
|
||||
shader-with-gles-symbol.frag.html
|
||||
@ -35,7 +43,10 @@ shader-with-ivec2-return-value.frag.html
|
||||
shader-with-ivec3-return-value.frag.html
|
||||
shader-with-ivec4-return-value.frag.html
|
||||
shader-with-limited-indexing.frag.html
|
||||
shader-with-line-directive.html
|
||||
# we can not check line directives because GLSL 1.0.17 says error messages
|
||||
# are implementation defined.
|
||||
#shader-with-line-directive.html
|
||||
--min-version 1.0.2 shader-with-hex-int-constant-macro.html
|
||||
shader-with-long-line.html
|
||||
shader-with-non-ascii-error.frag.html
|
||||
shader-with-precision.frag.html
|
||||
@ -45,6 +56,7 @@ shader-with-uniform-in-loop-condition.vert.html
|
||||
shader-with-vec2-return-value.frag.html
|
||||
shader-with-vec3-return-value.frag.html
|
||||
shader-with-vec4-return-value.frag.html
|
||||
--min-version 1.0.2 shader-with-vec4-vec3-vec4-conditional.html
|
||||
shader-with-version-100.frag.html
|
||||
shader-with-version-100.vert.html
|
||||
shader-with-version-120.vert.html
|
||||
|
@ -60,8 +60,8 @@ if (attribLoc == -1) {
|
||||
wtu.glErrorShouldBe(gl, gl.NONE);
|
||||
|
||||
debug("Test attrib location over the length limit");
|
||||
debug("Shader compilation should fail");
|
||||
shouldBe('wtu.loadShaderFromScript(gl, "badVertexShader", gl.VERTEX_SHADER, function (err) {})', 'null');
|
||||
debug("Shader compilation or link should fail");
|
||||
shouldBe('wtu.loadProgramFromScriptExpectError(gl, "badVertexShader", "fragmentShader")', 'null');
|
||||
wtu.glErrorShouldBe(gl, gl.NONE);
|
||||
|
||||
debug("Attempt to bind too-long attrib location should produce error");
|
||||
|
@ -13,31 +13,184 @@
|
||||
</canvas>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="vshader" type="x-shader/x-vertex">
|
||||
attribute vec4 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
|
||||
varying float alpha01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
<script id="vshader_shared_uniform" type="x-shader/x-vertex">
|
||||
attribute vec3 vPosition;
|
||||
uniform float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
void main()
|
||||
{
|
||||
alpha01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 = 1.0;
|
||||
gl_Position = vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
|
||||
gl_Position = vec4(vPosition, value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader" type="x-shader/x-fragment">
|
||||
<script id="fshader_shared_uniform" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
varying float alpha01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
uniform float color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[3];
|
||||
uniform float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="vshader_uniform_array" type="x-shader/x-vertex">
|
||||
attribute vec3 vPosition;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vPosition, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader_uniform_array" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
uniform float color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[2];
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0], color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1], 1.0, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="vshader_varying" type="x-shader/x-vertex">
|
||||
attribute vec3 vPosition;
|
||||
varying float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
void main()
|
||||
{
|
||||
value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 = 1.0;
|
||||
gl_Position = vec4(vPosition, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader_varying" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
varying float value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890, 0.0, 1.0, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="vshader_local" type="x-shader/x-vertex">
|
||||
attribute vec3 vPosition;
|
||||
void main()
|
||||
{
|
||||
for (int i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 = 0; i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 < 1; ++i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234)
|
||||
{
|
||||
gl_FragColor = vec4(color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0], color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1], color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[2], alpha01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890);
|
||||
gl_Position = vec4(vPosition, 1.0);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader_local" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
void main()
|
||||
{
|
||||
for (int i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 = 0; i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 < 1; ++i012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234)
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="vshader_attrib" type="x-shader/x-vertex">
|
||||
attribute vec3 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader_attrib" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function fail(x,y, buf, shouldBe)
|
||||
if (window.initNonKhronosFramework) {
|
||||
window.initNonKhronosFramework(false);
|
||||
}
|
||||
|
||||
description("Verify that shader long variable names works fine if they are within 256 characters.");
|
||||
|
||||
debug("Test same long uniform name in both vertex shader and fragment shader");
|
||||
var gl = initWebGL("example", "vshader_shared_uniform", "fshader_shared_uniform", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull("prog");
|
||||
var valueLoc = gl.getUniformLocation(prog, "value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
shouldBeNonNull("valueLoc");
|
||||
shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_UNIFORMS)", "1");
|
||||
var activeUniform = gl.getActiveUniform(prog, 0);
|
||||
shouldBeNonNull("activeUniform");
|
||||
shouldBe("activeUniform.type", "gl.FLOAT");
|
||||
shouldBe("activeUniform.size", "1");
|
||||
shouldBe("activeUniform.name", "'value01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'");
|
||||
gl.uniform1f(valueLoc, 1.0);
|
||||
drawAndCheckPixels(gl);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
|
||||
debug("Test long uniform array name");
|
||||
var gl = initWebGL("example", "vshader_uniform_array", "fshader_uniform_array", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull("prog");
|
||||
var redLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]");
|
||||
shouldBeNonNull("redLoc");
|
||||
var greenLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1]");
|
||||
shouldBeNonNull("greenLoc");
|
||||
shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_UNIFORMS)", "1");
|
||||
var activeUniform = gl.getActiveUniform(prog, 0);
|
||||
shouldBeNonNull("activeUniform");
|
||||
shouldBe("activeUniform.type", "gl.FLOAT");
|
||||
shouldBe("activeUniform.size", "2");
|
||||
shouldBe("activeUniform.name", "'color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]'");
|
||||
gl.uniform1f(redLoc, 1.0);
|
||||
gl.uniform1f(greenLoc, 0.0);
|
||||
drawAndCheckPixels(gl);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
|
||||
debug("Test long varying name");
|
||||
var gl = initWebGL("example", "vshader_varying", "fshader_varying", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull("prog");
|
||||
drawAndCheckPixels(gl);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
|
||||
debug("Test long local variable name");
|
||||
var gl = initWebGL("example", "vshader_varying", "fshader_varying", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull("prog");
|
||||
drawAndCheckPixels(gl);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
|
||||
debug("Test long attribute name");
|
||||
var gl = initWebGL("example", "vshader_attrib", "fshader_attrib", [ "vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull("prog");
|
||||
shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_ATTRIBUTES)", "1");
|
||||
var activeAttrib = gl.getActiveAttrib(prog, 0);
|
||||
shouldBeNonNull("activeAttrib");
|
||||
shouldBe("activeAttrib.size", "1");
|
||||
shouldBe("activeAttrib.type", "gl.FLOAT_VEC3");
|
||||
shouldBe("activeAttrib.name", "'vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'");
|
||||
drawAndCheckPixels(gl);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
debug("");
|
||||
|
||||
|
||||
function fail(x, y, buf, shouldBe)
|
||||
{
|
||||
var i = (y*50+x) * 4;
|
||||
var reason = "pixel at ("+x+","+y+") is ("+buf[i]+","+buf[i+1]+","+buf[i+2]+","+buf[i+3]+"), should be "+shouldBe;
|
||||
@ -49,56 +202,20 @@
|
||||
testPassed("drawing is correct");
|
||||
}
|
||||
|
||||
if (window.initNonKhronosFramework) {
|
||||
window.initNonKhronosFramework(false);
|
||||
}
|
||||
|
||||
description("Verify that shader long variable names works fine if they are within 256 characters.");
|
||||
|
||||
gl = initWebGL("example", "vshader", "fshader", [ "vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"], [ 0, 0, 0, 1 ], 1);
|
||||
|
||||
var prog = gl.getParameter(gl.CURRENT_PROGRAM);
|
||||
shouldBeNonNull(prog);
|
||||
var redLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]");
|
||||
shouldBeNonNull(redLoc);
|
||||
var greenLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[1]");
|
||||
shouldBeNonNull(greenLoc);
|
||||
var blueLoc = gl.getUniformLocation(prog, "color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[2]");
|
||||
shouldBeNonNull(blueLoc);
|
||||
|
||||
shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_ATTRIBUTES)", "1");
|
||||
var activeAttrib = gl.getActiveAttrib(prog, 0);
|
||||
shouldBeNonNull(activeAttrib);
|
||||
shouldBe("activeAttrib.size", "1");
|
||||
shouldBe("activeAttrib.type", "gl.FLOAT_VEC4");
|
||||
shouldBe("activeAttrib.name", "'vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'");
|
||||
|
||||
shouldBe("gl.getProgramParameter(prog, gl.ACTIVE_UNIFORMS)", "1");
|
||||
var activeUniform = gl.getActiveUniform(prog, 0);
|
||||
shouldBeNonNull(activeUniform);
|
||||
shouldBe("activeUniform.size", "3");
|
||||
shouldBe("activeUniform.type", "gl.FLOAT");
|
||||
shouldBe("activeUniform.name", "'color01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567[0]'");
|
||||
|
||||
gl.uniform1f(redLoc, 1.0);
|
||||
gl.uniform1f(greenLoc, 0.0);
|
||||
gl.uniform1f(blueLoc, 1.0);
|
||||
|
||||
var vertexObject = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||||
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);
|
||||
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
|
||||
var buf = new Uint8Array(50 * 50 * 4);
|
||||
gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
|
||||
function checkPixels()
|
||||
function drawAndCheckPixels(gl)
|
||||
{
|
||||
var vertexObject = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||||
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);
|
||||
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
|
||||
var buf = new Uint8Array(50 * 50 * 4);
|
||||
gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
||||
|
||||
// Test several locations
|
||||
// First line should be all black
|
||||
for (var i = 0; i < 50; ++i)
|
||||
@ -107,7 +224,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Line 15 should be red for at least 10 red pixels starting 20 pixels in
|
||||
// Line 15 should be magenta for at least 10 pixels starting 20 pixels in
|
||||
var offset = (15*50+20) * 4;
|
||||
for (var i = 0; i < 10; ++i)
|
||||
if (buf[offset+i*4] != 255 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 255 || buf[offset+i*4+3] != 255) {
|
||||
@ -124,7 +241,7 @@
|
||||
|
||||
pass();
|
||||
}
|
||||
checkPixels();
|
||||
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
<script src="../../../resources/js-test-post.js"></script>
|
||||
|
@ -0,0 +1,47 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with conditional scoping should succeed
|
||||
precision mediump float;
|
||||
void main() {
|
||||
int k = 3;
|
||||
|
||||
if (true) int g = k = 4;
|
||||
else int q = k = 5;
|
||||
|
||||
g = 3;
|
||||
q = 4;
|
||||
|
||||
if (true) int g = 4;
|
||||
else int k = 10;
|
||||
|
||||
if (true) { int g = 10; }
|
||||
else { int k = 20; }
|
||||
|
||||
gl_FragColor = vec4(1.);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with do scoping should succeed
|
||||
precision mediump float;
|
||||
void main() {
|
||||
int k = 0;
|
||||
do int k = 1; while (k != 0); // ok, do always introduces scope
|
||||
gl_FragColor = vec4(float(k));
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -33,10 +33,12 @@ GLSLConformanceTester.runTests([
|
||||
vShaderSuccess: true,
|
||||
fShaderId: 'fshaderWithErrorDirective',
|
||||
fShaderSuccess: false,
|
||||
fShaderTest: (function() {
|
||||
return wtu.getLastError().indexOf("testing123 testing123") >= 0; }),
|
||||
// We can't test for the actual error message as
|
||||
// GLSL 1.0.17 11 says the messages are implementation dependant.
|
||||
//fShaderTest: (function() {
|
||||
// return wtu.getLastError().indexOf("testing123 testing123") >= 0; }),
|
||||
linkSuccess: false,
|
||||
passMsg: "error directive returns error user's error message",
|
||||
passMsg: "error directive causes error",
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with for loop should succeed
|
||||
|
||||
// TODO(gman): trim to min size to test bug.
|
||||
precision highp float;
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
|
||||
// Saw-tooth function that is synced with the demo music (128bpm)
|
||||
float gBeat=fract(time*3.2/3.);
|
||||
|
||||
// Calculate the surface color
|
||||
vec3 surfColor(vec2 p)
|
||||
{
|
||||
vec2 q=vec2(sin(.08*p.x),4.*p.y);
|
||||
vec3 c=vec3(0);
|
||||
for(float i=0.;i<15.;i++)
|
||||
c+=(1.+sin(i*sin(time)+vec3(0.,1.3,2.2)))*.2/length(q-vec2(sin(i),12.*sin(.3*time+i)));
|
||||
return c+vec3(mix(mod(floor(p.x*.2)+floor(p.y*2.2),2.),.2,gBeat));
|
||||
}
|
||||
|
||||
// Ray trace (cylinder)
|
||||
vec3 trace(vec3 o,vec3 d)
|
||||
{
|
||||
d.y*=.65+.1*sin(.5*time);
|
||||
float D=1./(d.y*d.y+d.z*d.z),
|
||||
a=(o.y*d.y+o.z*d.z)*D,
|
||||
b=(o.y*o.y+o.z*o.z-36.)*D,
|
||||
t=-a-sqrt(a*a-b);
|
||||
o+=t*d;
|
||||
return surfColor(vec2(o.x,atan(o.y,o.z)))*(1.+.01*t);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Screen setup
|
||||
vec2 p=(2.*gl_FragCoord.xy-resolution)/resolution.y,
|
||||
q=2.*gl_FragCoord.xy/resolution-1.;
|
||||
|
||||
// Camera setup
|
||||
vec3 cp=vec3(-time*20.+1.,1.6*sin(time*1.2),2.+2.*cos(time*.3)),
|
||||
ct=cp+vec3(1.,.3*cos(time),-.2),
|
||||
cd=normalize(ct-cp),
|
||||
cr=normalize(cross(cd,vec3(.5*cos(.3*time),0.,1.))),
|
||||
cu=cross(cr,cd),
|
||||
rd=normalize(2.*cd+cr*p.x+cu*p.y);
|
||||
|
||||
// Trace! (+some funky lens/raster effects)
|
||||
vec3 c=trace(cp,rd)*
|
||||
min(1.,1.8-dot(q,q))*
|
||||
(.9+.1*sin(3.*sin(gBeat)*gl_FragCoord.y));
|
||||
|
||||
gl_FragColor=vec4(c,1);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with for scoping should succeed
|
||||
precision mediump float;
|
||||
void main() {
|
||||
int k = 0;
|
||||
for (int i = 0; i < 10; i++) { int i = k+i; } // ok, compound nests
|
||||
gl_FragColor = vec4(float(k));
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with private function scoped struct should fail.
|
||||
precision mediump float;
|
||||
int fun2(struct s { int m; } g) { return g.m; }
|
||||
|
||||
s a;
|
||||
|
||||
void main() {
|
||||
int e = fun2(s(3));
|
||||
|
||||
gl_FragColor = vec4(1.0);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader with functional scoping should succeed
|
||||
precision mediump float;
|
||||
int f(int k) {
|
||||
int k = k + 3;
|
||||
return k;
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(f(100));
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="vertexShader" type="text/something-not-javascript">
|
||||
// vertex shader uses the long integer constant should succeed
|
||||
attribute vec4 vPosition;
|
||||
void main()
|
||||
{
|
||||
#define TEST 0x1F
|
||||
int a = TEST;
|
||||
|
||||
gl_Position = vPosition;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL GLSL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
|
||||
<script src="../../../resources/js-test-pre.js"></script>
|
||||
<script src="../../resources/webgl-test-utils.js"></script>
|
||||
<script src="../../resources/glsl-conformance-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script id="fragmentShader" type="text/something-not-javascript">
|
||||
// fragment shader that vec4->vec3->vec4 conditional should succeed
|
||||
precision mediump float;
|
||||
uniform float x;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4((x > 0.0 ? vec4(1.0, 1.0, 1.0, 0.0) : vec4(0.1, 0.1, 0.1, 0.0)).xyz, 1.0);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
GLSLConformanceTester.runTest();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -18,10 +18,14 @@ found in the LICENSE file.
|
||||
<div id="console"></div>
|
||||
<script id="vertexShader" type="text/something-not-javascript">
|
||||
// shader with too-deep struct nesting should fail per WebGL spec
|
||||
struct nesting4 {
|
||||
struct nesting5 {
|
||||
vec4 vector;
|
||||
};
|
||||
|
||||
struct nesting4 {
|
||||
nesting5 field5;
|
||||
};
|
||||
|
||||
struct nesting3 {
|
||||
nesting4 field4;
|
||||
};
|
||||
@ -37,7 +41,7 @@ struct nesting1 {
|
||||
uniform nesting1 uniform1;
|
||||
void main()
|
||||
{
|
||||
gl_Position = uniform1.field2.field3.field4.vector;
|
||||
gl_Position = uniform1.field2.field3.field4.field5.vector;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
@ -18,10 +18,14 @@ found in the LICENSE file.
|
||||
<div id="console"></div>
|
||||
<script id="vertexShader" type="text/something-not-javascript">
|
||||
// shader with struct nesting less than maximum in WebGL spec should succeed
|
||||
struct nesting3 {
|
||||
struct nesting4 {
|
||||
vec4 vector;
|
||||
};
|
||||
|
||||
struct nesting3 {
|
||||
nesting4 field4;
|
||||
};
|
||||
|
||||
struct nesting2 {
|
||||
nesting3 field3;
|
||||
};
|
||||
@ -33,7 +37,7 @@ struct nesting1 {
|
||||
uniform nesting1 uniform1;
|
||||
void main()
|
||||
{
|
||||
gl_Position = uniform1.field2.field3.vector;
|
||||
gl_Position = uniform1.field2.field3.field4.vector;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
@ -41,101 +41,101 @@ found in the LICENSE file.
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function init()
|
||||
{
|
||||
if (window.initNonKhronosFramework) {
|
||||
window.initNonKhronosFramework(false);
|
||||
}
|
||||
if (window.initNonKhronosFramework) {
|
||||
window.initNonKhronosFramework(false);
|
||||
}
|
||||
|
||||
description("Checks gl_PointCoord and gl_PointSize");
|
||||
debug("");
|
||||
description("Checks gl_PointCoord and gl_PointSize");
|
||||
debug("");
|
||||
|
||||
// NOTE: I'm not 100% confident in this test. I think it is correct.
|
||||
// NOTE: I'm not 100% confident in this test. I think it is correct.
|
||||
|
||||
wtu = WebGLTestUtils;
|
||||
gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
wtu = WebGLTestUtils;
|
||||
var gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
|
||||
canvas = gl.canvas;
|
||||
width = canvas.width;
|
||||
height = canvas.height;
|
||||
shouldBeTrue("width == height");
|
||||
var canvas = gl.canvas;
|
||||
var width = canvas.width;
|
||||
var height = canvas.height;
|
||||
shouldBe("width", "height");
|
||||
|
||||
maxPointSize = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE)[1];
|
||||
shouldBeTrue("maxPointSize >= 1");
|
||||
shouldBeTrue("maxPointSize % 1 == 0");
|
||||
var maxPointSize = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE)[1];
|
||||
shouldBeTrue("maxPointSize >= 1");
|
||||
shouldBeTrue("maxPointSize % 1 == 0");
|
||||
|
||||
maxPointSize = Math.min(maxPointSize, 64);
|
||||
pointWidth = maxPointSize / width;
|
||||
pointStep = Math.floor(maxPointSize / 4);
|
||||
pointStep = Math.max(1, pointStep);
|
||||
maxPointSize = Math.min(maxPointSize, 64);
|
||||
var pointWidth = maxPointSize / width;
|
||||
var pointStep = Math.floor(maxPointSize / 4);
|
||||
var pointStep = Math.max(1, pointStep);
|
||||
|
||||
program = gl.program;
|
||||
pointSizeLoc = gl.getUniformLocation(program, "uPointSize");
|
||||
gl.uniform1f(pointSizeLoc, maxPointSize);
|
||||
var program = gl.program;
|
||||
var pointSizeLoc = gl.getUniformLocation(program, "uPointSize");
|
||||
gl.uniform1f(pointSizeLoc, maxPointSize);
|
||||
|
||||
var pixelOffset = (maxPointSize % 2) ? (1 / width) : 0;
|
||||
var vertexObject = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||||
gl.bufferData(
|
||||
gl.ARRAY_BUFFER,
|
||||
new Float32Array(
|
||||
[-0.5 + pixelOffset, -0.5 + pixelOffset,
|
||||
0.5 + pixelOffset, -0.5 + pixelOffset,
|
||||
-0.5 + pixelOffset, 0.5 + pixelOffset,
|
||||
0.5 + pixelOffset, 0.5 + pixelOffset]),
|
||||
gl.STATIC_DRAW);
|
||||
gl.enableVertexAttribArray(0);
|
||||
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
||||
var pixelOffset = (maxPointSize % 2) ? (1 / width) : 0;
|
||||
var vertexObject = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||||
gl.bufferData(
|
||||
gl.ARRAY_BUFFER,
|
||||
new Float32Array(
|
||||
[-0.5 + pixelOffset, -0.5 + pixelOffset,
|
||||
0.5 + pixelOffset, -0.5 + pixelOffset,
|
||||
-0.5 + pixelOffset, 0.5 + pixelOffset,
|
||||
0.5 + pixelOffset, 0.5 + pixelOffset]),
|
||||
gl.STATIC_DRAW);
|
||||
gl.enableVertexAttribArray(0);
|
||||
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
||||
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
|
||||
gl.drawArrays(gl.POINTS, 0, 4);
|
||||
function s2p(s) {
|
||||
return (s + 1.0) * 0.5 * width;
|
||||
}
|
||||
gl.drawArrays(gl.POINTS, 0, 4);
|
||||
shouldBe("gl.getError()", "gl.NO_ERROR");
|
||||
|
||||
//function print(x, y) {
|
||||
// var b = new Uint8Array(4);
|
||||
// gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, b);
|
||||
// debug("" + x + "," + y + ": " + b[0] + "," + b[1] + "," + b[2]);
|
||||
//}
|
||||
//
|
||||
//for (var ii = 0; ii < 100; ++ii) {
|
||||
// print(ii, ii);
|
||||
//}
|
||||
function s2p(s) {
|
||||
return (s + 1.0) * 0.5 * width;
|
||||
}
|
||||
|
||||
for (var py = 0; py < 2; ++py) {
|
||||
for (var px = 0; px < 2; ++px) {
|
||||
debug("");
|
||||
var pointX = -0.5 + px + pixelOffset;
|
||||
var pointY = -0.5 + py + pixelOffset;
|
||||
for (var yy = 0; yy < maxPointSize; yy += pointStep) {
|
||||
for (var xx = 0; xx < maxPointSize; xx += pointStep) {
|
||||
// formula for s and t from OpenGL ES 2.0 spec section 3.3
|
||||
var xw = s2p(pointX);
|
||||
var yw = s2p(pointY);
|
||||
//debug("xw: " + xw + " yw: " + yw);
|
||||
var u = xx / maxPointSize * 2 - 1;
|
||||
var v = yy / maxPointSize * 2 - 1;
|
||||
var xf = Math.floor(s2p(pointX + u * pointWidth));
|
||||
var yf = Math.floor(s2p(pointY + v * pointWidth));
|
||||
//debug("xf: " + xf + " yf: " + yf);
|
||||
var s = 0.5 + (xf + 0.5 - xw) / maxPointSize;
|
||||
var t = 0.5 + (yf + 0.5 - yw) / maxPointSize;
|
||||
//debug("s: " + s + " t: " + t);
|
||||
var color = [Math.floor(s * 255), Math.floor((1 - t) * 255), 0];
|
||||
var msg = "pixel " + xf + "," + yf + " should be " + color;
|
||||
wtu.checkCanvasRect(gl, xf, yf, 1, 1, color, msg, 4);
|
||||
}
|
||||
//function print(x, y) {
|
||||
// var b = new Uint8Array(4);
|
||||
// gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, b);
|
||||
// debug("" + x + "," + y + ": " + b[0] + "," + b[1] + "," + b[2]);
|
||||
//}
|
||||
//
|
||||
//for (var ii = 0; ii < 100; ++ii) {
|
||||
// print(ii, ii);
|
||||
//}
|
||||
|
||||
for (var py = 0; py < 2; ++py) {
|
||||
for (var px = 0; px < 2; ++px) {
|
||||
debug("");
|
||||
var pointX = -0.5 + px + pixelOffset;
|
||||
var pointY = -0.5 + py + pixelOffset;
|
||||
for (var yy = 0; yy < maxPointSize; yy += pointStep) {
|
||||
for (var xx = 0; xx < maxPointSize; xx += pointStep) {
|
||||
// formula for s and t from OpenGL ES 2.0 spec section 3.3
|
||||
var xw = s2p(pointX);
|
||||
var yw = s2p(pointY);
|
||||
//debug("xw: " + xw + " yw: " + yw);
|
||||
var u = xx / maxPointSize * 2 - 1;
|
||||
var v = yy / maxPointSize * 2 - 1;
|
||||
var xf = Math.floor(s2p(pointX + u * pointWidth));
|
||||
var yf = Math.floor(s2p(pointY + v * pointWidth));
|
||||
//debug("xf: " + xf + " yf: " + yf);
|
||||
var s = 0.5 + (xf + 0.5 - xw) / maxPointSize;
|
||||
var t = 0.5 + (yf + 0.5 - yw) / maxPointSize;
|
||||
//debug("s: " + s + " t: " + t);
|
||||
var color = [Math.floor(s * 255), Math.floor((1 - t) * 255), 0];
|
||||
var msg = "pixel " + xf + "," + yf + " should be " + color;
|
||||
wtu.checkCanvasRect(gl, xf, yf, 1, 1, color, msg, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
<script src="../../../resources/js-test-post.js"></script>
|
||||
<script src="../../../resources/js-test-post.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,9 +1,11 @@
|
||||
bad-arguments-test.html
|
||||
--min-version 1.0.2 delayed-drawing.html
|
||||
error-reporting.html
|
||||
instanceof-test.html
|
||||
invalid-passed-params.html
|
||||
is-object.html
|
||||
null-object-behaviour.html
|
||||
functions-returning-strings.html
|
||||
object-deletion-behaviour.html
|
||||
shader-precision-format.html
|
||||
type-conversion-test.html
|
||||
|
@ -0,0 +1,63 @@
|
||||
<!--
|
||||
Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL Delayed Drawing test.</title>
|
||||
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"> </script>
|
||||
<script src="../resources/webgl-test-utils.js"> </script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script>
|
||||
description(document.title);
|
||||
var wtu = WebGLTestUtils;
|
||||
var canvas = document.getElementById("example");
|
||||
var gl = wtu.create3DContext(canvas);
|
||||
var program = wtu.setupTexturedQuad(gl);
|
||||
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
|
||||
|
||||
var tex = gl.createTexture();
|
||||
wtu.fillTexture(gl, tex, 5, 3, [0, 192, 128, 255]);
|
||||
|
||||
var loc = gl.getUniformLocation(program, "tex");
|
||||
gl.uniform1i(loc, 0);
|
||||
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
|
||||
|
||||
drawAndCheck();
|
||||
|
||||
setTimeout(step2, 1000);
|
||||
|
||||
function step2() {
|
||||
drawAndCheck();
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function drawAndCheck() {
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors before drawing.");
|
||||
wtu.drawQuad(gl);
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from drawing.");
|
||||
wtu.checkCanvas(
|
||||
gl, [0, 192, 128, 255],
|
||||
"draw should be 0, 192, 128, 255");
|
||||
}
|
||||
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,92 @@
|
||||
<!--
|
||||
Copyright (c) 2012 Mozilla Foundation. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL Conformance Tests</title>
|
||||
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
|
||||
<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<canvas id="canvas" width="2" height="2"> </canvas>
|
||||
<script>
|
||||
description("Test that functions returning strings really do return strings (and not e.g. null)");
|
||||
debug("");
|
||||
|
||||
var validVertexShaderString =
|
||||
"attribute vec4 aVertex; attribute vec4 aColor; varying vec4 vColor; void main() { vColor = aColor; gl_Position = aVertex; }";
|
||||
var validFragmentShaderString =
|
||||
"precision mediump float; varying vec4 vColor; void main() { gl_FragColor = vColor; }";
|
||||
|
||||
function shouldReturnString(_a)
|
||||
{
|
||||
var exception;
|
||||
var _av;
|
||||
try {
|
||||
_av = eval(_a);
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
if (exception)
|
||||
testFailed(_a + ' should return a string. Threw exception ' + exception);
|
||||
else if (typeof _av == "string")
|
||||
testPassed(_a + ' returns a string: "' + _av + '"');
|
||||
else
|
||||
testFailed(_a + ' should return a string. Returns: "' + _av + '"');
|
||||
}
|
||||
|
||||
var gl = create3DContext(document.getElementById("canvas"));
|
||||
if (!gl) {
|
||||
testFailed("context does not exist");
|
||||
} else {
|
||||
var vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
shouldReturnString("gl.getShaderSource(vs)");
|
||||
shouldReturnString("gl.getShaderInfoLog(vs)");
|
||||
gl.shaderSource(vs, validVertexShaderString);
|
||||
gl.compileShader(vs);
|
||||
shouldReturnString("gl.getShaderSource(vs)");
|
||||
shouldReturnString("gl.getShaderInfoLog(vs)");
|
||||
|
||||
var fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
shouldReturnString("gl.getShaderSource(fs)");
|
||||
shouldReturnString("gl.getShaderInfoLog(fs)");
|
||||
gl.shaderSource(fs, validFragmentShaderString);
|
||||
gl.compileShader(fs);
|
||||
shouldReturnString("gl.getShaderSource(fs)");
|
||||
shouldReturnString("gl.getShaderInfoLog(fs)");
|
||||
|
||||
var prog = gl.createProgram();
|
||||
shouldReturnString("gl.getProgramInfoLog(prog)");
|
||||
gl.attachShader(prog, vs);
|
||||
gl.attachShader(prog, fs);
|
||||
gl.linkProgram(prog);
|
||||
shouldReturnString("gl.getProgramInfoLog(prog)");
|
||||
|
||||
var exts = gl.getSupportedExtensions();
|
||||
for (i in exts) {
|
||||
shouldReturnString("gl.getSupportedExtensions()[" + i + "]");
|
||||
}
|
||||
|
||||
shouldReturnString("gl.getParameter(gl.VENDOR)");
|
||||
shouldReturnString("gl.getParameter(gl.RENDERER)");
|
||||
shouldReturnString("gl.getParameter(gl.VERSION)");
|
||||
shouldReturnString("gl.getParameter(gl.SHADING_LANGUAGE_VERSION)");
|
||||
}
|
||||
|
||||
debug("");
|
||||
successfullyParsed = true;
|
||||
|
||||
</script>
|
||||
<script src="../../resources/js-test-post.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -137,7 +137,10 @@ var program = context.createProgram();
|
||||
context.attachShader(program, vShader);
|
||||
context.attachShader(program, fShader);
|
||||
context.linkProgram(program);
|
||||
shouldBeTrue("context.getProgramParameter(program, context.LINK_STATUS)");
|
||||
var linkStatus = context.getProgramParameter(program, context.LINK_STATUS);
|
||||
shouldBeTrue("linkStatus");
|
||||
if (!linkStatus)
|
||||
debug(context.getProgramInfoLog(program));
|
||||
shouldBe("context.getError()", "context.NO_ERROR");
|
||||
context.bindAttribLocation(program, 1, validAttribName);
|
||||
shouldBe("context.getError()", "context.NO_ERROR");
|
||||
|
@ -42,7 +42,7 @@ debug("");
|
||||
debug("Canvas.getContext");
|
||||
|
||||
var gl = create3DContext(document.getElementById("canvas"));
|
||||
shouldBeNonNull(gl);
|
||||
shouldBeNonNull("gl");
|
||||
|
||||
function fail(x,y, buf, shouldBe)
|
||||
{
|
||||
|
@ -81,8 +81,9 @@ function go() {
|
||||
gl.shaderSource(vsBad, "WILL NOT COMPILE;");
|
||||
gl.compileShader(vsBad);
|
||||
|
||||
assertMsg(gl.getShaderParameter(vsBad, gl.COMPILE_STATUS) == false,
|
||||
"bad vertex shader should fail to compile");
|
||||
// GLSL 1.0.17 section 10.27. compile shader does not have to return failure.
|
||||
//assertMsg(gl.getShaderParameter(vsBad, gl.COMPILE_STATUS) == false,
|
||||
// "bad vertex shader should fail to compile");
|
||||
|
||||
var fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
gl.shaderSource(fs, "precision mediump float; varying vec4 vColor; void main() { gl_FragColor = vColor; }");
|
||||
@ -102,8 +103,9 @@ function go() {
|
||||
gl.shaderSource(fsBad, "WILL NOT COMPILE;");
|
||||
gl.compileShader(fsBad);
|
||||
|
||||
assertMsg(gl.getShaderParameter(fsBad, gl.COMPILE_STATUS) == false,
|
||||
"bad fragment shader should fail to compile");
|
||||
// GLSL 1.0.17 section 10.27. compile shader does not have to return failure.
|
||||
//assertMsg(gl.getShaderParameter(fsBad, gl.COMPILE_STATUS) == false,
|
||||
// "bad fragment shader should fail to compile");
|
||||
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors at this point");
|
||||
|
||||
@ -196,8 +198,13 @@ function go() {
|
||||
if (gl.getError() != gl.NO_ERROR)
|
||||
assertMsg(false, "unexpected error in linkProgram()");
|
||||
assertMsg(gl.getProgramParameter(prog, gl.LINK_STATUS) == expected_status, errmsg);
|
||||
var infolog = gl.getProgramInfoLog(prog);
|
||||
if (gl.getError() != gl.NO_ERROR)
|
||||
assertMsg(false, "unexpected error in getProgramInfoLog()");
|
||||
if (typeof(infolog) != "string")
|
||||
assertMsg(false, "getProgramInfoLog() did not return a string");
|
||||
if (expected_status == true && gl.getProgramParameter(prog, gl.LINK_STATUS) == false)
|
||||
debug(gl.getProgramInfoLog(prog));
|
||||
debug(infolog);
|
||||
if (gl.getError() != gl.NO_ERROR)
|
||||
assertMsg(false, "unexpected error in getProgramParameter()");
|
||||
gl.useProgram(prog);
|
||||
@ -252,6 +259,10 @@ function go() {
|
||||
assertMsg(gl.getProgramParameter(progGood2, gl.LINK_STATUS) == false,
|
||||
"linking should fail with in-use formerly good program, with new bad shader attached");
|
||||
|
||||
// Invalid link leaves previous valid program intact.
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "drawing with a valid program shouldn't generate a GL error");
|
||||
|
||||
gl.useProgram(progGood1);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 4);
|
||||
glErrorShouldBe(gl, gl.NO_ERROR, "drawing with a valid when last used program shouldn't generate a GL error");
|
||||
|
@ -191,7 +191,7 @@ function runTestIteration(format, type, packAlignment, width, height)
|
||||
for (var i = numComponents; i < 4; ++i)
|
||||
pixel[i] = 0;
|
||||
expectedColor = packColor(format, type, 255, 102, 0, 255);
|
||||
shouldBeNonNull(expectedColor);
|
||||
shouldBeNonNull("expectedColor");
|
||||
shouldBe("pixel", "expectedColor");
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
if (j < w * 4 || j > w * (w - 1) * 4 || j % (w * 4) == 0 || j % (w * 4) == (w - 1) * 4) {
|
||||
correct = green;
|
||||
}
|
||||
// ignore corner pixels
|
||||
if ((j == 0) || (j == 4*(w-1)) || (j == 4*w*(w-1)) || (j== 4*(w*w - 1))) {
|
||||
continue;
|
||||
}
|
||||
if (!checkPixel(buf, j, correct)) {
|
||||
isCorrect = false;
|
||||
break;
|
||||
|
@ -11,37 +11,40 @@ found in the LICENSE file.
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"></script>
|
||||
<script id="vshader" type="x-shader/x-vertex">
|
||||
attribute vec3 pos;
|
||||
attribute vec4 colorIn;
|
||||
uniform float pointSize;
|
||||
varying vec4 color;
|
||||
attribute vec3 pos;
|
||||
attribute vec4 colorIn;
|
||||
uniform float pointSize;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_PointSize = pointSize;
|
||||
color = colorIn;
|
||||
gl_Position = vec4(pos.xyz, 3.0);
|
||||
}
|
||||
void main()
|
||||
{
|
||||
gl_PointSize = pointSize;
|
||||
color = colorIn;
|
||||
gl_Position = vec4(pos, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fshader" type="x-shader/x-fragment">
|
||||
precision mediump float;
|
||||
varying vec4 color;
|
||||
precision mediump float;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function runTest()
|
||||
{
|
||||
var gl = initWebGL('testbed', 'vshader', 'fshader', ['pos', 'colorIn'], [0, 0, 0, 1], 1, { antialias: false });
|
||||
if (!gl) {
|
||||
testFailed('initWebGL(..) failed');
|
||||
return false;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="testbed" width="2px" height="2px"></canvas>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script>
|
||||
description('Verify GL_VERTEX_PROGRAM_POINT_SIZE is enabled in WebGL');
|
||||
|
||||
var gl = initWebGL('testbed', 'vshader', 'fshader', ['pos', 'colorIn'], [0, 0, 0, 1], 1, { antialias: false });
|
||||
shouldBeNonNull("gl");
|
||||
shouldBe('gl.getError()', 'gl.NO_ERROR');
|
||||
|
||||
gl.disable(gl.BLEND);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
|
||||
@ -68,22 +71,27 @@ function runTest()
|
||||
|
||||
var locPointSize = gl.getUniformLocation(gl.program, 'pointSize');
|
||||
|
||||
shouldBe('gl.getError()', 'gl.NO_ERROR');
|
||||
|
||||
debug('Draw a point of size 1 and verify it does not touch any other pixels.');
|
||||
|
||||
gl.uniform1f(locPointSize, 1.0);
|
||||
gl.drawArrays(gl.POINTS, 0, vertices.length / 3);
|
||||
var buf = new Uint8Array(2 * 2 * 4);
|
||||
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
||||
shouldBe('gl.getError()', 'gl.NO_ERROR');
|
||||
|
||||
var index = 0;
|
||||
var correctColor;
|
||||
for (var y = 0; y < 2; ++y) {
|
||||
for (var x = 0; x < 2; ++x) {
|
||||
var correctColor = [0, 0, 0];
|
||||
correctColor = [0, 0, 0];
|
||||
if (x == 1 && y == 1)
|
||||
correctColor[0] = 255;
|
||||
if (buf[index] != correctColor[0] || buf[index + 1] != correctColor[1] || buf[index + 2] != correctColor[2]) {
|
||||
testFailed('Drawing a point of size 1 touched pixels that should not be touched');
|
||||
return false;
|
||||
}
|
||||
shouldBe('buf[index]', '255');
|
||||
else
|
||||
shouldBe('buf[index]', '0');
|
||||
shouldBe('buf[index + 1]', '0');
|
||||
shouldBe('buf[index + 2]', '0');
|
||||
index += 4;
|
||||
}
|
||||
}
|
||||
@ -92,39 +100,23 @@ function runTest()
|
||||
debug('Draw a point of size 2 and verify it fills the appropriate region.');
|
||||
|
||||
var pointSizeRange = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
|
||||
if (pointSizeRange < 2.0)
|
||||
return true;
|
||||
|
||||
gl.uniform1f(locPointSize, 2.0);
|
||||
gl.drawArrays(gl.POINTS, 0, vertices.length / 3);
|
||||
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
||||
index = 0;
|
||||
for (var y = 0; y < 2; ++y) {
|
||||
for (var x = 0; x < 2; ++x) {
|
||||
var correctColor = [255, 0, 0];
|
||||
if (buf[index] != correctColor[0] || buf[index + 1] != correctColor[1] || buf[index + 2] != correctColor[2]) {
|
||||
testFailed('Drawing a point of size 2 failed to fill the appropriate region');
|
||||
return false;
|
||||
if (pointSizeRange[1] >= 2.0) {
|
||||
gl.uniform1f(locPointSize, 2.0);
|
||||
gl.drawArrays(gl.POINTS, 0, vertices.length / 3);
|
||||
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
||||
shouldBe('gl.getError()', 'gl.NO_ERROR');
|
||||
index = 0;
|
||||
for (var y = 0; y < 2; ++y) {
|
||||
for (var x = 0; x < 2; ++x) {
|
||||
shouldBe('buf[index]', '255');
|
||||
shouldBe('buf[index + 1]', '0');
|
||||
shouldBe('buf[index + 2]', '0');
|
||||
index += 4;
|
||||
}
|
||||
index += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="testbed" width="2px" height="2px"></canvas>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script>
|
||||
description('Verify GL_VERTEX_PROGRAM_POINT_SIZE is enabled in WebGL');
|
||||
|
||||
if (runTest())
|
||||
testPassed("");
|
||||
|
||||
successfullyParsed = true;
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
|
||||
<script src="../../resources/js-test-post.js"></script>
|
||||
|
@ -71,10 +71,11 @@ function runOneTest(gl, info) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((vShader != null) != info.vShaderSuccess) {
|
||||
// As per GLSL 1.0.17 10.27 we can only check for success on
|
||||
// compileShader, not failure.
|
||||
if (info.vShaderSuccess && !vShader) {
|
||||
testFailed("[unexpected vertex shader compile status] (expected: " +
|
||||
info.vShaderSuccess + ") " + passMsg);
|
||||
return;
|
||||
info.vShaderSuccess + ") " + passMsg);
|
||||
}
|
||||
// Save the shaders so we test shared shader.
|
||||
if (vShader) {
|
||||
@ -96,7 +97,9 @@ function runOneTest(gl, info) {
|
||||
}
|
||||
}
|
||||
//debug(fShader == null ? "fail" : "succeed");
|
||||
if ((fShader != null) != info.fShaderSuccess) {
|
||||
// As per GLSL 1.0.17 10.27 we can only check for success on
|
||||
// compileShader, not failure.
|
||||
if (info.fShaderSuccess && !fShader) {
|
||||
testFailed("[unexpected fragment shader compile status] (expected: " +
|
||||
info.fShaderSuccess + ") " + passMsg);
|
||||
return;
|
||||
|
@ -587,6 +587,7 @@ var glErrorShouldBe = function(gl, glError, opt_msg) {
|
||||
* @param {function(string): void) opt_errorCallback callback for errors.
|
||||
*/
|
||||
var linkProgram = function(gl, program, opt_errorCallback) {
|
||||
errFn = opt_errorCallback || testFailed;
|
||||
// Link the program
|
||||
gl.linkProgram(program);
|
||||
|
||||
@ -596,7 +597,7 @@ var linkProgram = function(gl, program, opt_errorCallback) {
|
||||
// something went wrong with the link
|
||||
var error = gl.getProgramInfoLog (program);
|
||||
|
||||
testFailed("Error in program linking:" + error);
|
||||
errFn("Error in program linking:" + error);
|
||||
|
||||
gl.deleteProgram(program);
|
||||
}
|
||||
@ -931,7 +932,7 @@ var loadShaderFromScript = function(
|
||||
var shaderType;
|
||||
var shaderScript = document.getElementById(scriptId);
|
||||
if (!shaderScript) {
|
||||
throw("*** Error: unknown script element" + scriptId);
|
||||
throw("*** Error: unknown script element " + scriptId);
|
||||
}
|
||||
shaderSource = shaderScript.text;
|
||||
|
||||
@ -1032,6 +1033,41 @@ var loadProgram = function(
|
||||
return program;
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads shaders from source, creates a program, attaches the shaders and
|
||||
* links but expects error.
|
||||
*
|
||||
* GLSL 1.0.17 10.27 effectively says that compileShader can
|
||||
* always succeed as long as linkProgram fails so we can't
|
||||
* rely on compileShader failing. This function expects
|
||||
* one of the shader to fail OR linking to fail.
|
||||
*
|
||||
* @param {!WebGLContext} gl The WebGLContext to use.
|
||||
* @param {string} vertexShaderScriptId The vertex shader.
|
||||
* @param {string} fragmentShaderScriptId The fragment shader.
|
||||
* @return {WebGLProgram} The created program.
|
||||
*/
|
||||
var loadProgramFromScriptExpectError = function(
|
||||
gl, vertexShaderScriptId, fragmentShaderScriptId) {
|
||||
var vertexShader = loadShaderFromScript(gl, vertexShaderScriptId);
|
||||
if (!vertexShader) {
|
||||
return null;
|
||||
}
|
||||
var fragmentShader = loadShaderFromScript(gl, fragmentShaderScriptId);
|
||||
if (!fragmentShader) {
|
||||
return null;
|
||||
}
|
||||
var linkSuccess = true;
|
||||
var program = gl.createProgram();
|
||||
gl.attachShader(program, vertexShader);
|
||||
gl.attachShader(program, fragmentShader);
|
||||
linkSuccess = true;
|
||||
linkProgram(gl, program, function() {
|
||||
linkSuccess = false;
|
||||
});
|
||||
return linkSuccess ? program : null;
|
||||
};
|
||||
|
||||
var basePath;
|
||||
var getBasePath = function() {
|
||||
if (!basePath) {
|
||||
@ -1144,6 +1180,7 @@ return {
|
||||
loadProgram: loadProgram,
|
||||
loadProgramFromFile: loadProgramFromFile,
|
||||
loadProgramFromScript: loadProgramFromScript,
|
||||
loadProgramFromScriptExpectError: loadProgramFromScriptExpectError,
|
||||
loadShader: loadShader,
|
||||
loadShaderFromFile: loadShaderFromFile,
|
||||
loadShaderFromScript: loadShaderFromScript,
|
||||
|
@ -1,3 +1,4 @@
|
||||
compressed-tex-image.html
|
||||
copy-tex-image-and-sub-image-2d.html
|
||||
gl-pixelstorei.html
|
||||
gl-teximage.html
|
||||
|
@ -0,0 +1,61 @@
|
||||
<!--
|
||||
Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebGL CompressedTexImage and CompressedTexSubImage Tests</title>
|
||||
<LINK rel="stylesheet" href="../../resources/js-test-style.css"/>
|
||||
<script src="../../resources/js-test-pre.js"></script>
|
||||
<script src="../resources/webgl-test.js"></script>
|
||||
<script src="../resources/webgl-test-utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="description"></div>
|
||||
<div id="console"></div>
|
||||
<script>
|
||||
description("This test ensures WebGL implementations correctly implement compressedTexImage2D and compressedTexSubImage2D.");
|
||||
|
||||
debug("");
|
||||
|
||||
var wtu = WebGLTestUtils;
|
||||
var canvas = document.createElement("canvas");
|
||||
var gl = wtu.create3DContext(canvas);
|
||||
|
||||
const COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
|
||||
const COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
|
||||
const COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
||||
const ETC1_RGB8_OES = 0x8D64;
|
||||
const COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
||||
const COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
||||
|
||||
var formats = null;
|
||||
|
||||
if (!gl) {
|
||||
testFailed("context does not exist");
|
||||
} else {
|
||||
testPassed("context exists");
|
||||
|
||||
var tex = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, tex);
|
||||
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, new Uint8Array(16))");
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ETC1_RGB8_OES, 4, 4, 0, new Uint8Array(8))");
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
|
||||
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
|
||||
|
||||
shouldGenerateGLError(gl, gl.NO_ERROR, "formats = gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS)");
|
||||
shouldBeNonNull("formats");
|
||||
shouldBe("formats.length", "0");
|
||||
}
|
||||
|
||||
successfullyParsed = true;
|
||||
</script>
|
||||
<script src="../../resources/js-test-post.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -149,6 +149,7 @@ function testSize(size) {
|
||||
|
||||
var err = gl.getError();
|
||||
if (err == gl.OUT_OF_MEMORY) {
|
||||
debug("out of memory");
|
||||
return false;
|
||||
}
|
||||
if (err != gl.NO_ERROR) {
|
||||
|
@ -96,7 +96,7 @@ function runTest() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (doTest()) {
|
||||
@ -120,10 +120,11 @@ function checkTexture(width, height, cubeMap) {
|
||||
fillLevel(0, width, height, color.rgba, cubeMap);
|
||||
var err = gl.getError();
|
||||
if (err == gl.OUT_OF_MEMORY) {
|
||||
return false;
|
||||
debug("out of memory");
|
||||
return false;
|
||||
}
|
||||
if (err != gl.NO_ERROR) {
|
||||
testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
|
||||
testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err));
|
||||
}
|
||||
wtu.drawQuad(gl);
|
||||
wtu.checkCanvas(gl, color.rgba,
|
||||
@ -134,6 +135,7 @@ function checkTexture(width, height, cubeMap) {
|
||||
gl.generateMipmap(target);
|
||||
var err = gl.getError();
|
||||
if (err == gl.OUT_OF_MEMORY) {
|
||||
debug("out of memory");
|
||||
return false;
|
||||
}
|
||||
if (err != gl.NO_ERROR) {
|
||||
@ -182,7 +184,7 @@ function fillLevel(level, width, height, color, opt_cubemap) {
|
||||
[gl.TEXTURE_2D];
|
||||
|
||||
for (var ii = 0; ii < targets.length; ++ii) {
|
||||
// debug(wtu.glEnumToString(gl, targets[ii]));
|
||||
// debug(wtu.glEnumToString(gl, targets[ii]));
|
||||
gl.texImage2D(
|
||||
targets[ii], level, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE,
|
||||
pixels);
|
||||
|
@ -90,6 +90,58 @@ function printSummary() {
|
||||
}
|
||||
}
|
||||
|
||||
var byteLength;
|
||||
var subBuffer;
|
||||
function testSlice() {
|
||||
function test(subBuf, starts, size) {
|
||||
byteLength = size;
|
||||
subBuffer = eval(subBuf);
|
||||
var subArray = new Int8Array(subBuffer);
|
||||
assertEq(subBuf, subBuffer.byteLength, byteLength);
|
||||
for (var i = 0; i < size; ++i)
|
||||
assertEq('Element ' + i, starts + i, subArray[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
running('testSlice');
|
||||
var buffer = new ArrayBuffer(32);
|
||||
var array = new Int8Array(buffer);
|
||||
for (var i = 0; i < 32; ++i)
|
||||
array[i] = i;
|
||||
|
||||
test("buffer.slice(0)", 0, 32);
|
||||
test("buffer.slice(16)", 16, 16);
|
||||
test("buffer.slice(24)", 24, 8);
|
||||
test("buffer.slice(32)", 32, 0);
|
||||
test("buffer.slice(40)", 32, 0);
|
||||
test("buffer.slice(80)", 32, 0);
|
||||
|
||||
test("buffer.slice(-8)", 24, 8);
|
||||
test("buffer.slice(-16)", 16, 16);
|
||||
test("buffer.slice(-24)", 8, 24);
|
||||
test("buffer.slice(-32)", 0, 32);
|
||||
test("buffer.slice(-40)", 0, 32);
|
||||
test("buffer.slice(-80)", 0, 32);
|
||||
|
||||
test("buffer.slice(0, 32)", 0, 32);
|
||||
test("buffer.slice(0, 16)", 0, 16);
|
||||
test("buffer.slice(8, 24)", 8, 16);
|
||||
test("buffer.slice(16, 32)", 16, 16);
|
||||
test("buffer.slice(24, 16)", 24, 0);
|
||||
|
||||
test("buffer.slice(16, -8)", 16, 8);
|
||||
test("buffer.slice(-20, 30)", 12, 18);
|
||||
|
||||
test("buffer.slice(-8, -20)", 24, 0);
|
||||
test("buffer.slice(-20, -8)", 12, 12);
|
||||
test("buffer.slice(-40, 16)", 0, 16);
|
||||
test("buffer.slice(-40, 40)", 0, 32);
|
||||
pass();
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Tests for unsigned array variants
|
||||
//
|
||||
@ -202,7 +254,11 @@ function testIntegralArrayTruncationBehavior(type, name, unsigned) {
|
||||
|
||||
if (unsigned) {
|
||||
sourceData = [0.6, 10.6];
|
||||
expectedResults = [0, 10];
|
||||
if (type === Uint8ClampedArray) {
|
||||
expectedResults = [1, 11];
|
||||
} else {
|
||||
expectedResults = [0, 10];
|
||||
}
|
||||
} else {
|
||||
sourceData = [0.6, 10.6, -0.6, -10.6];
|
||||
expectedResults = [0, 10, 0, -10];
|
||||
@ -249,6 +305,14 @@ function testIntegralArrayTruncationBehavior(type, name, unsigned) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Uint8ClampedArray:
|
||||
for (var ii = 0; ii < sourceData.length; ++ii) {
|
||||
for (var jj = 0; jj < numIterations; ++jj) {
|
||||
array[jj] = sourceData[ii];
|
||||
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Uint16Array:
|
||||
for (var ii = 0; ii < sourceData.length; ++ii) {
|
||||
for (var jj = 0; jj < numIterations; ++jj) {
|
||||
@ -519,14 +583,18 @@ function testConstructionWithOutOfRangeValues(type, name) {
|
||||
}, "Construction of " + name + " with out-of-range offset");
|
||||
}
|
||||
|
||||
function testConstructionWithNegativeOutOfRangeValues(type, name, elementSizeInBytes) {
|
||||
if (elementSizeInBytes > 1) {
|
||||
try {
|
||||
var array = new type(-1);
|
||||
testFailed("Construction of " + name + " with negative size should throw exception");
|
||||
} catch (e) {
|
||||
testPassed("Construction of " + name + " with negative size threw exception");
|
||||
}
|
||||
function testConstructionWithNegativeOutOfRangeValues(type, name) {
|
||||
try {
|
||||
var buffer = new ArrayBuffer(-1);
|
||||
testFailed("Construction of ArrayBuffer with negative size should throw exception");
|
||||
} catch (e) {
|
||||
testPassed("Construction of ArrayBuffer with negative size threw exception");
|
||||
}
|
||||
try {
|
||||
var array = new type(-1);
|
||||
testFailed("Construction of " + name + " with negative size should throw exception");
|
||||
} catch (e) {
|
||||
testPassed("Construction of " + name + " with negative size threw exception");
|
||||
}
|
||||
shouldThrowIndexSizeErr(function() {
|
||||
var buffer = new ArrayBuffer(4);
|
||||
@ -644,20 +712,95 @@ function testSubarrayWithDefaultValues(type, name, sz) {
|
||||
}
|
||||
}
|
||||
|
||||
function testSettingFromArrayWithOutOfRangeOffset(type, name) {
|
||||
var webglArray = new type(32);
|
||||
var array = [];
|
||||
for (var i = 0; i < 16; i++) {
|
||||
array.push(i);
|
||||
}
|
||||
function setWithInvalidOffset(type, name, length,
|
||||
sourceType, sourceName, sourceLength,
|
||||
offset, offsetDescription) {
|
||||
var webglArray = new type(length);
|
||||
var sourceArray = new sourceType(sourceLength);
|
||||
for (var i = 0; i < sourceLength; i++)
|
||||
sourceArray[i] = 42 + i;
|
||||
try {
|
||||
webglArray.set(array, 0x7FFFFFF8);
|
||||
testFailed("Setting " + name + " from array with out-of-range offset was not caught");
|
||||
webglArray.set(sourceArray, offset);
|
||||
testFailed("Setting " + name + " from " + sourceName + " with " +
|
||||
offsetDescription + " offset was not caught");
|
||||
} catch (e) {
|
||||
testPassed("Setting " + name + " from array with out-of-range offset was caught");
|
||||
testPassed("Setting " + name + " from " + sourceName + " with " +
|
||||
offsetDescription + " offset was caught");
|
||||
}
|
||||
}
|
||||
|
||||
function setWithValidOffset(type, name, length,
|
||||
sourceType, sourceName, sourceLength,
|
||||
offset, offsetDescription) {
|
||||
running("Setting " + name + " from " + sourceName + " with " +
|
||||
offsetDescription + " offset");
|
||||
var webglArray = new type(length);
|
||||
var sourceArray = new sourceType(sourceLength);
|
||||
for (var i = 0; i < sourceLength; i++)
|
||||
sourceArray[i] = 42 + i;
|
||||
try {
|
||||
webglArray.set(sourceArray, offset);
|
||||
offset = Math.floor(offset);
|
||||
for (var i = 0; i < sourceLength; i++) {
|
||||
assertEq("Element " + i + offset, sourceArray[i], webglArray[i + offset]);
|
||||
}
|
||||
pass();
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testSettingFromArrayWithOutOfRangeOffset(type, name) {
|
||||
setWithInvalidOffset(type, name, 32, Array, "array", 16,
|
||||
0x7FFFFFF8, "out-of-range");
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithOutOfRangeOffset(type, name) {
|
||||
setWithInvalidOffset(type, name, 32, type, name, 16,
|
||||
0x7FFFFFF8, "out-of-range");
|
||||
}
|
||||
|
||||
function testSettingFromArrayWithNegativeOffset(type, name) {
|
||||
setWithInvalidOffset(type, name, 32, Array, "array", 16,
|
||||
-1, "negative");
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithNegativeOffset(type, name) {
|
||||
setWithInvalidOffset(type, name, 32, type, name, 16,
|
||||
-1, "negative");
|
||||
}
|
||||
|
||||
function testSettingFromArrayWithMinusZeroOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, Array, "array", 16,
|
||||
-0, "-0");
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithMinusZeroOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, type, name, 16,
|
||||
-0, "-0");
|
||||
}
|
||||
|
||||
function testSettingFromArrayWithBoundaryOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, Array, "array", 16,
|
||||
16, "boundary");
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithBoundaryOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, type, name, 16,
|
||||
16, "boundary");
|
||||
}
|
||||
|
||||
function testSettingFromArrayWithNonIntegerOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, Array, "array", 16,
|
||||
16.999, "non-integer");
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithNonIntegerOffset(type, name) {
|
||||
setWithValidOffset(type, name, 32, type, name, 16,
|
||||
16.999, "non-integer");
|
||||
}
|
||||
|
||||
function testSettingFromFakeArrayWithOutOfRangeLength(type, name) {
|
||||
var webglArray = new type(32);
|
||||
var array = {};
|
||||
@ -670,19 +813,6 @@ function testSettingFromFakeArrayWithOutOfRangeLength(type, name) {
|
||||
}
|
||||
}
|
||||
|
||||
function testSettingFromTypedArrayWithOutOfRangeOffset(type, name) {
|
||||
var webglArray = new type(32);
|
||||
var srcArray = new type(16);
|
||||
for (var i = 0; i < 16; i++) {
|
||||
srcArray[i] = i;
|
||||
}
|
||||
try {
|
||||
webglArray.set(srcArray, 0x7FFFFFF8);
|
||||
testFailed("Setting " + name + " from " + name + " with out-of-range offset was not caught");
|
||||
} catch (e) {
|
||||
testPassed("Setting " + name + " from " + name + " with out-of-range offset was caught");
|
||||
}
|
||||
}
|
||||
|
||||
function negativeTestGetAndSetMethods(type, name) {
|
||||
array = new type([2, 3]);
|
||||
@ -751,6 +881,12 @@ function testNaNConversion(type, name) {
|
||||
results[i] = array[i];
|
||||
}
|
||||
break;
|
||||
case Uint8ClampedArray:
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
array[i] = NaN;
|
||||
results[i] = array[i];
|
||||
}
|
||||
break;
|
||||
case Uint16Array:
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
array[i] = NaN;
|
||||
@ -792,6 +928,8 @@ function testNaNConversion(type, name) {
|
||||
function runTests() {
|
||||
allPassed = true;
|
||||
|
||||
testSlice();
|
||||
|
||||
// The "name" attribute is a concession to browsers which don't
|
||||
// implement the "name" property on function objects
|
||||
var testCases =
|
||||
@ -837,6 +975,13 @@ function runTests() {
|
||||
testValues: [ 0, 255, -1, 256 ],
|
||||
expectedValues: [ 0, 255, 255, 0 ]
|
||||
},
|
||||
{name: "Uint8ClampedArray",
|
||||
unsigned: true,
|
||||
integral: true,
|
||||
elementSizeInBytes: 1,
|
||||
testValues: [ 0, 255, -1, 256 ],
|
||||
expectedValues: [ 0, 255, 0, 255 ]
|
||||
},
|
||||
{name: "Uint16Array",
|
||||
unsigned: true,
|
||||
integral: true,
|
||||
@ -891,7 +1036,7 @@ function runTests() {
|
||||
testCase.expectedValues);
|
||||
testConstructionWithNullBuffer(type, name);
|
||||
testConstructionWithOutOfRangeValues(type, name);
|
||||
testConstructionWithNegativeOutOfRangeValues(type, name, testCase.elementSizeInBytes);
|
||||
testConstructionWithNegativeOutOfRangeValues(type, name);
|
||||
testConstructionWithUnalignedOffset(type, name, testCase.elementSizeInBytes);
|
||||
testConstructionWithUnalignedLength(type, name, testCase.elementSizeInBytes);
|
||||
testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes);
|
||||
@ -900,8 +1045,16 @@ function runTests() {
|
||||
testSubarrayWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
|
||||
testSubarrayWithDefaultValues(type, name, testCase.elementSizeInBytes);
|
||||
testSettingFromArrayWithOutOfRangeOffset(type, name);
|
||||
testSettingFromFakeArrayWithOutOfRangeLength(type, name);
|
||||
testSettingFromTypedArrayWithOutOfRangeOffset(type, name);
|
||||
testSettingFromArrayWithNegativeOffset(type, name);
|
||||
testSettingFromTypedArrayWithNegativeOffset(type, name);
|
||||
testSettingFromArrayWithMinusZeroOffset(type, name);
|
||||
testSettingFromTypedArrayWithMinusZeroOffset(type, name);
|
||||
testSettingFromArrayWithBoundaryOffset(type, name);
|
||||
testSettingFromTypedArrayWithBoundaryOffset(type, name);
|
||||
testSettingFromArrayWithNonIntegerOffset(type, name);
|
||||
testSettingFromTypedArrayWithNonIntegerOffset(type, name);
|
||||
testSettingFromFakeArrayWithOutOfRangeLength(type, name);
|
||||
negativeTestGetAndSetMethods(type, name);
|
||||
testNaNConversion(type, name);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# HG changeset patch
|
||||
# Parent 07fbbfde4173da7d8e513bb2d52ae07e333dbf43
|
||||
# Parent 30d84739fa6136571e995045960c3fd90b44382c
|
||||
diff --git a/content/canvas/test/webgl/conformance/more/functions/readPixelsBadArgs.html b/content/canvas/test/webgl/conformance/more/functions/readPixelsBadArgs.html
|
||||
--- a/content/canvas/test/webgl/conformance/more/functions/readPixelsBadArgs.html
|
||||
+++ b/content/canvas/test/webgl/conformance/more/functions/readPixelsBadArgs.html
|
||||
|
@ -10,5 +10,4 @@ conformance/more/conformance/quickCheckAPI-S_V.html
|
||||
conformance/more/functions/uniformfArrayLen1.html
|
||||
conformance/glsl/misc/attrib-location-length-limits.html
|
||||
conformance/glsl/misc/uniform-location-length-limits.html
|
||||
conformance/renderbuffers/framebuffer-object-attachment.html
|
||||
conformance/glsl/misc/struct-nesting-exceeds-maximum.html
|
||||
conformance/renderbuffers/framebuffer-object-attachment.html
|
@ -8,4 +8,4 @@ conformance/more/functions/uniformfBadArgs.html
|
||||
conformance/more/functions/uniformiBadArgs.html
|
||||
conformance/glsl/misc/attrib-location-length-limits.html
|
||||
conformance/glsl/misc/uniform-location-length-limits.html
|
||||
conformance/glsl/misc/struct-nesting-exceeds-maximum.html
|
||||
conformance/programs/program-test.html
|
@ -8,5 +8,4 @@ conformance/more/conformance/quickCheckAPI-S_V.html
|
||||
conformance/more/functions/uniformfArrayLen1.html
|
||||
conformance/glsl/misc/attrib-location-length-limits.html
|
||||
conformance/glsl/misc/struct-nesting-under-maximum.html
|
||||
conformance/glsl/misc/uniform-location-length-limits.html
|
||||
conformance/glsl/misc/struct-nesting-exceeds-maximum.html
|
||||
conformance/glsl/misc/uniform-location-length-limits.html
|
22
content/canvas/test/webgl/fix-webgl-harness-async.patch
Normal file
22
content/canvas/test/webgl/fix-webgl-harness-async.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/content/canvas/test/webgl/resources/webgl-test-harness.js b/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
--- a/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
+++ b/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
@@ -362,18 +362,16 @@ TestHarness.prototype.addFiles_ = functi
|
||||
}
|
||||
log("total files: " + files.length);
|
||||
for (var ii = 0; ii < files.length; ++ii) {
|
||||
log("" + ii + ": " + files[ii]);
|
||||
this.files.push(new TestFile(files[ii]));
|
||||
this.reportFunc(TestHarness.reportType.ADD_PAGE, files[ii], undefined);
|
||||
}
|
||||
this.reportFunc(TestHarness.reportType.READY, undefined, undefined);
|
||||
- this.nextFileIndex = files.length;
|
||||
- this.lastFileIndex = files.length;
|
||||
}
|
||||
|
||||
TestHarness.prototype.runTests = function(opt_start, opt_count) {
|
||||
var count = opt_count || this.files.length;
|
||||
this.nextFileIndex = opt_start || 0;
|
||||
this.lastFileIndex = this.nextFileIndex + count;
|
||||
this.startNextFile();
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
# HG changeset patch
|
||||
# Parent 1910ae60536dce7272cb0478089bf40806666de8
|
||||
# Parent 0122002fbffad16de0690a21aa87d0999d0cdcb9
|
||||
diff --git a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
|
||||
--- a/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
|
||||
+++ b/content/canvas/test/webgl/conformance/glsl/misc/glsl-function-nodes.html
|
||||
|
@ -1,9 +1,9 @@
|
||||
# HG changeset patch
|
||||
# Parent a41d853e5110aca4f2c77c63db502f670d0e50a1
|
||||
# Parent efec656cc42addae5aa96c6691031d54d46436fe
|
||||
diff --git a/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html b/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
|
||||
--- a/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
|
||||
+++ b/content/canvas/test/webgl/conformance/extensions/oes-standard-derivatives.html
|
||||
@@ -107,17 +107,18 @@ if (!gl) {
|
||||
@@ -115,17 +115,18 @@ if (!gl) {
|
||||
} else {
|
||||
testPassed("Successfully enabled OES_standard_derivatives extension");
|
||||
|
||||
|
@ -95,9 +95,11 @@ var log = function(msg) {
|
||||
/**
|
||||
* Loads text from an external file. This function is synchronous.
|
||||
* @param {string} url The url of the external file.
|
||||
* @return {string} the loaded text if the request is synchronous.
|
||||
* @param {!function(bool, string): void} callback that is sent a bool for
|
||||
* success and the string.
|
||||
*/
|
||||
var loadTextFileSynchronous = function(url) {
|
||||
var loadTextFileAsynchronous = function(url, callback) {
|
||||
log ("loading: " + url);
|
||||
var error = 'loadTextFileSynchronous failed to load url "' + url + '"';
|
||||
var request;
|
||||
if (window.XMLHttpRequest) {
|
||||
@ -108,50 +110,242 @@ var loadTextFileSynchronous = function(url) {
|
||||
} else {
|
||||
throw 'XMLHttpRequest is disabled';
|
||||
}
|
||||
request.open('GET', url, false);
|
||||
request.send(null);
|
||||
if (request.readyState != 4) {
|
||||
throw error;
|
||||
try {
|
||||
request.open('GET', url, true);
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
var text = '';
|
||||
// HTTP reports success with a 200 status. The file protocol reports
|
||||
// success with zero. HTTP does not use zero as a status code (they
|
||||
// start at 100).
|
||||
// https://developer.mozilla.org/En/Using_XMLHttpRequest
|
||||
var success = request.status == 200 || request.status == 0;
|
||||
if (success) {
|
||||
text = request.responseText;
|
||||
}
|
||||
log("loaded: " + url);
|
||||
callback(success, text);
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (e) {
|
||||
log("failed to load: " + url);
|
||||
callback(false, '');
|
||||
}
|
||||
return request.responseText;
|
||||
};
|
||||
|
||||
var getFileList = function(url) {
|
||||
var files = [];
|
||||
if (url.substr(url.length - 4) == '.txt') {
|
||||
var lines = loadTextFileSynchronous(url).split('\n');
|
||||
var prefix = '';
|
||||
var lastSlash = url.lastIndexOf('/');
|
||||
if (lastSlash >= 0) {
|
||||
prefix = url.substr(0, lastSlash + 1);
|
||||
/**
|
||||
* Compare version strings.
|
||||
*/
|
||||
var greaterThanOrEqualToVersion = function(have, want) {
|
||||
have = have.split(" ")[0].split(".");
|
||||
want = want.split(" ")[0].split(".");
|
||||
|
||||
//have 1.2.3 want 1.1
|
||||
//have 1.1.1 want 1.1
|
||||
//have 1.0.9 want 1.1
|
||||
//have 1.1 want 1.1.1
|
||||
|
||||
for (var ii = 0; ii < want.length; ++ii) {
|
||||
var wantNum = parseInt(want[ii]);
|
||||
var haveNum = have[ii] ? parseInt(have[ii]) : 0
|
||||
if (haveNum < wantNum) {
|
||||
return false;
|
||||
}
|
||||
for (var ii = 0; ii < lines.length; ++ii) {
|
||||
var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||
if (str.length > 4 &&
|
||||
str[0] != '#' &&
|
||||
str[0] != ";" &&
|
||||
str.substr(0, 2) != "//") {
|
||||
new_url = prefix + str;
|
||||
files = files.concat(getFileList(new_url));
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads a file, recursively adding files referenced inside.
|
||||
*
|
||||
* Each line of URL is parsed, comments starting with '#' or ';'
|
||||
* or '//' are stripped.
|
||||
*
|
||||
* arguments beginning with -- are extracted
|
||||
*
|
||||
* lines that end in .txt are recursively scanned for more files
|
||||
* other lines are added to the list of files.
|
||||
*
|
||||
* @param {string} url The url of the file to read.
|
||||
* @param {void function(boolean, !Array.<string>)} callback.
|
||||
* Callback that is called with true for success and an
|
||||
* array of filenames.
|
||||
* @param {Object} options. Optional options
|
||||
*
|
||||
* Options:
|
||||
* version: {string} The version of the conformance test.
|
||||
* Tests with the argument --min-version <version> will
|
||||
* be ignored version is less then <version>
|
||||
*
|
||||
*/
|
||||
var getFileList = function(url, callback, options) {
|
||||
var files = [];
|
||||
|
||||
var copyObject = function(obj) {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
};
|
||||
|
||||
var toCamelCase = function(str) {
|
||||
return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() });
|
||||
};
|
||||
|
||||
var globalOptions = copyObject(options);
|
||||
globalOptions.defaultVersion = "1.0";
|
||||
|
||||
var getFileListImpl = function(prefix, line, hierarchicalOptions, callback) {
|
||||
var files = [];
|
||||
|
||||
var args = line.split(/\s+/);
|
||||
var nonOptions = [];
|
||||
var useTest = true;
|
||||
var testOptions = {};
|
||||
for (var jj = 0; jj < args.length; ++jj) {
|
||||
var arg = args[jj];
|
||||
if (arg[0] == '-') {
|
||||
if (arg[1] != '-') {
|
||||
throw ("bad option at in " + url + ":" + (ii + 1) + ": " + str);
|
||||
}
|
||||
var option = arg.substring(2);
|
||||
switch (option) {
|
||||
case 'min-version':
|
||||
++jj;
|
||||
testOptions[toCamelCase(option)] = args[jj];
|
||||
break;
|
||||
default:
|
||||
throw ("bad unknown option '" + option + "' at in " + url + ":" + (ii + 1) + ": " + str);
|
||||
}
|
||||
} else {
|
||||
nonOptions.push(arg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
files.push(url);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
var url = prefix + nonOptions.join(" ");
|
||||
|
||||
if (url.substr(url.length - 4) != '.txt') {
|
||||
var minVersion = testOptions.minVersion;
|
||||
if (!minVersion) {
|
||||
minVersion = hierarchicalOptions.defaultVersion;
|
||||
}
|
||||
|
||||
if (globalOptions.minVersion) {
|
||||
useTest = greaterThanOrEqualToVersion(minVersion, globalOptions.minVersion);
|
||||
} else {
|
||||
useTest = greaterThanOrEqualToVersion(globalOptions.version, minVersion);
|
||||
}
|
||||
}
|
||||
|
||||
if (!useTest) {
|
||||
callback(true, []);
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.substr(url.length - 4) == '.txt') {
|
||||
// If a version was explicity specified pass it down.
|
||||
if (testOptions.minVersion) {
|
||||
hierarchicalOptions.defaultVersion = testOptions.minVersion;
|
||||
}
|
||||
loadTextFileAsynchronous(url, function() {
|
||||
return function(success, text) {
|
||||
if (!success) {
|
||||
callback(false, '');
|
||||
return;
|
||||
}
|
||||
var lines = text.split('\n');
|
||||
var prefix = '';
|
||||
var lastSlash = url.lastIndexOf('/');
|
||||
if (lastSlash >= 0) {
|
||||
prefix = url.substr(0, lastSlash + 1);
|
||||
}
|
||||
var fail = false;
|
||||
var count = 1;
|
||||
var index = 0;
|
||||
for (var ii = 0; ii < lines.length; ++ii) {
|
||||
var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||
if (str.length > 4 &&
|
||||
str[0] != '#' &&
|
||||
str[0] != ";" &&
|
||||
str.substr(0, 2) != "//") {
|
||||
++count;
|
||||
getFileListImpl(prefix, str, copyObject(hierarchicalOptions), function(index) {
|
||||
return function(success, new_files) {
|
||||
log("got files: " + new_files.length);
|
||||
if (success) {
|
||||
files[index] = new_files;
|
||||
}
|
||||
finish(success);
|
||||
};
|
||||
}(index++));
|
||||
}
|
||||
}
|
||||
finish(true);
|
||||
|
||||
function finish(success) {
|
||||
if (!success) {
|
||||
fail = true;
|
||||
}
|
||||
--count;
|
||||
log("count: " + count);
|
||||
if (!count) {
|
||||
callback(!fail, files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}());
|
||||
} else {
|
||||
files.push(url);
|
||||
callback(true, files);
|
||||
}
|
||||
};
|
||||
|
||||
getFileListImpl('', url, globalOptions, function(success, files) {
|
||||
// flatten
|
||||
var flat = [];
|
||||
flatten(files);
|
||||
function flatten(files) {
|
||||
for (var ii = 0; ii < files.length; ++ii) {
|
||||
var value = files[ii];
|
||||
if (typeof(value) == "string") {
|
||||
flat.push(value);
|
||||
} else {
|
||||
flatten(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(success, flat);
|
||||
});
|
||||
};
|
||||
|
||||
var TestFile = function(url) {
|
||||
this.url = url;
|
||||
};
|
||||
|
||||
var TestHarness = function(iframe, filelistUrl, reportFunc) {
|
||||
var TestHarness = function(iframe, filelistUrl, reportFunc, options) {
|
||||
this.window = window;
|
||||
this.iframe = iframe;
|
||||
this.reportFunc = reportFunc;
|
||||
try {
|
||||
var files = getFileList(filelistUrl);
|
||||
} catch (e) {
|
||||
this.timeoutDelay = 20000;
|
||||
this.files = [];
|
||||
|
||||
var that = this;
|
||||
getFileList(filelistUrl, function() {
|
||||
return function(success, files) {
|
||||
that.addFiles_(success, files);
|
||||
};
|
||||
}(), options);
|
||||
|
||||
};
|
||||
|
||||
TestHarness.reportType = {
|
||||
ADD_PAGE: 1,
|
||||
READY: 2,
|
||||
START_PAGE: 3,
|
||||
TEST_RESULT: 4,
|
||||
FINISH_PAGE: 5,
|
||||
FINISHED_ALL_TESTS: 6
|
||||
};
|
||||
|
||||
TestHarness.prototype.addFiles_ = function(success, files) {
|
||||
if (!success) {
|
||||
this.reportFunc(
|
||||
TestHarness.reportType.FINISHED_ALL_TESTS,
|
||||
'Unable to load tests. Are you running locally?\n' +
|
||||
@ -166,24 +360,15 @@ var TestHarness = function(iframe, filelistUrl, reportFunc) {
|
||||
false)
|
||||
return;
|
||||
}
|
||||
this.files = [];
|
||||
log("total files: " + files.length);
|
||||
for (var ii = 0; ii < files.length; ++ii) {
|
||||
log("" + ii + ": " + files[ii]);
|
||||
this.files.push(new TestFile(files[ii]));
|
||||
this.reportFunc(TestHarness.reportType.ADD_PAGE, files[ii], undefined);
|
||||
}
|
||||
this.nextFileIndex = files.length;
|
||||
this.lastFileIndex = files.length;
|
||||
this.timeoutDelay = 20000;
|
||||
this.reportFunc(TestHarness.reportType.READY, undefined, undefined);
|
||||
}
|
||||
|
||||
TestHarness.reportType = {
|
||||
ADD_PAGE: 1,
|
||||
START_PAGE: 2,
|
||||
TEST_RESULT: 3,
|
||||
FINISH_PAGE: 4,
|
||||
FINISHED_ALL_TESTS: 5
|
||||
};
|
||||
|
||||
TestHarness.prototype.runTests = function(opt_start, opt_count) {
|
||||
var count = opt_count || this.files.length;
|
||||
this.nextFileIndex = opt_start || 0;
|
||||
|
@ -10,6 +10,12 @@ Mochitest version of the WebGL Conformance Test Suite
|
||||
<script type="text/javascript" src="resources/webgl-test-harness.js"></script>
|
||||
<script>
|
||||
|
||||
var CONFORMANCE_TEST_VERSION = "1.0.1 (beta)";
|
||||
|
||||
var OPTIONS = {
|
||||
version: CONFORMANCE_TEST_VERSION
|
||||
};
|
||||
|
||||
/**
|
||||
* This is copied from webgl-test-harness.js where it is defined as a private function, not accessible to us (argh!)
|
||||
*
|
||||
@ -266,10 +272,17 @@ function start() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
Reporter.prototype.ready = function() {
|
||||
statusTextNode.textContent = 'Loaded test lists. Starting tests...';
|
||||
window.webglTestHarness.runTests();
|
||||
}
|
||||
|
||||
Reporter.prototype.reportFunc = function(type, msg, success) {
|
||||
switch (type) {
|
||||
case reportType.ADD_PAGE:
|
||||
return this.addPage(msg);
|
||||
case reportType.READY:
|
||||
return this.ready();
|
||||
case reportType.START_PAGE:
|
||||
return this.startPage(msg);
|
||||
case reportType.TEST_RESULT:
|
||||
@ -285,6 +298,25 @@ function start() {
|
||||
};
|
||||
};
|
||||
|
||||
var getURLOptions = function(obj) {
|
||||
var s = window.location.href;
|
||||
var q = s.indexOf("?");
|
||||
var e = s.indexOf("#");
|
||||
if (e < 0) {
|
||||
e = s.length;
|
||||
}
|
||||
var query = s.substring(q + 1, e);
|
||||
var pairs = query.split("&");
|
||||
for (var ii = 0; ii < pairs.length; ++ii) {
|
||||
var keyValue = pairs[ii].split("=");
|
||||
var key = keyValue[0];
|
||||
var value = decodeURIComponent(keyValue[1]);
|
||||
obj[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
getURLOptions(OPTIONS);
|
||||
|
||||
function runTestSuite() {
|
||||
var reporter = new Reporter();
|
||||
|
||||
@ -297,16 +329,17 @@ function start() {
|
||||
} catch(e) {}
|
||||
|
||||
if (ctx) {
|
||||
statusTextNode.textContent = 'Loading test lists...';
|
||||
var iframe = document.getElementById("testframe");
|
||||
var testHarness = new WebGLTestHarnessModule.TestHarness(
|
||||
iframe,
|
||||
'00_test_list.txt',
|
||||
function(type, msg, success) {
|
||||
return reporter.reportFunc(type, msg, success);
|
||||
});
|
||||
},
|
||||
OPTIONS);
|
||||
testHarness.setTimeoutDelay(20000); // and make it much higher when running under valgrind.
|
||||
window.webglTestHarness = testHarness;
|
||||
testHarness.runTests();
|
||||
} else {
|
||||
var errmsg = "Can't create a WebGL context";
|
||||
reporter.fullResultsNode.textContent = errmsg;
|
||||
|
@ -1,236 +0,0 @@
|
||||
# HG changeset patch
|
||||
# Parent fb36d18f04ef9b01ca87d3fde539d50c204f9bba
|
||||
diff --git a/content/canvas/test/webgl/resources/webgl-test-harness.js b/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
--- a/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
+++ b/content/canvas/test/webgl/resources/webgl-test-harness.js
|
||||
@@ -90,190 +90,105 @@ var log = function(msg) {
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log(msg);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads text from an external file. This function is synchronous.
|
||||
* @param {string} url The url of the external file.
|
||||
- * @param {!function(bool, string): void} callback that is sent a bool for
|
||||
- * success and the string.
|
||||
+ * @return {string} the loaded text if the request is synchronous.
|
||||
*/
|
||||
-var loadTextFileAsynchronous = function(url, callback) {
|
||||
- log ("loading: " + url);
|
||||
+var loadTextFileSynchronous = function(url) {
|
||||
var error = 'loadTextFileSynchronous failed to load url "' + url + '"';
|
||||
var request;
|
||||
if (window.XMLHttpRequest) {
|
||||
request = new XMLHttpRequest();
|
||||
if (request.overrideMimeType) {
|
||||
request.overrideMimeType('text/plain');
|
||||
}
|
||||
} else {
|
||||
throw 'XMLHttpRequest is disabled';
|
||||
}
|
||||
- try {
|
||||
- request.open('GET', url, true);
|
||||
- request.onreadystatechange = function() {
|
||||
- if (request.readyState == 4) {
|
||||
- var text = '';
|
||||
- // HTTP reports success with a 200 status. The file protocol reports
|
||||
- // success with zero. HTTP does not use zero as a status code (they
|
||||
- // start at 100).
|
||||
- // https://developer.mozilla.org/En/Using_XMLHttpRequest
|
||||
- var success = request.status == 200 || request.status == 0;
|
||||
- if (success) {
|
||||
- text = request.responseText;
|
||||
- }
|
||||
- log("loaded: " + url);
|
||||
- callback(success, text);
|
||||
- }
|
||||
- };
|
||||
- request.send(null);
|
||||
- } catch (e) {
|
||||
- log("failed to load: " + url);
|
||||
- callback(false, '');
|
||||
+ request.open('GET', url, false);
|
||||
+ request.send(null);
|
||||
+ if (request.readyState != 4) {
|
||||
+ throw error;
|
||||
}
|
||||
+ return request.responseText;
|
||||
};
|
||||
|
||||
-var getFileList = function(url, callback) {
|
||||
+var getFileList = function(url) {
|
||||
var files = [];
|
||||
-
|
||||
- var getFileListImpl = function(url, callback) {
|
||||
- var files = [];
|
||||
- if (url.substr(url.length - 4) == '.txt') {
|
||||
- loadTextFileAsynchronous(url, function() {
|
||||
- return function(success, text) {
|
||||
- if (!success) {
|
||||
- callback(false, '');
|
||||
- return;
|
||||
- }
|
||||
- var lines = text.split('\n');
|
||||
- var prefix = '';
|
||||
- var lastSlash = url.lastIndexOf('/');
|
||||
- if (lastSlash >= 0) {
|
||||
- prefix = url.substr(0, lastSlash + 1);
|
||||
- }
|
||||
- var fail = false;
|
||||
- var count = 1;
|
||||
- var index = 0;
|
||||
- for (var ii = 0; ii < lines.length; ++ii) {
|
||||
- var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||
- if (str.length > 4 &&
|
||||
- str[0] != '#' &&
|
||||
- str[0] != ";" &&
|
||||
- str.substr(0, 2) != "//") {
|
||||
- new_url = prefix + str;
|
||||
- ++count;
|
||||
- getFileListImpl(new_url, function(index) {
|
||||
- return function(success, new_files) {
|
||||
- log("got files: " + new_files.length);
|
||||
- if (success) {
|
||||
- files[index] = new_files;
|
||||
- }
|
||||
- finish(success);
|
||||
- };
|
||||
- }(index++));
|
||||
- }
|
||||
- }
|
||||
- finish(true);
|
||||
-
|
||||
- function finish(success) {
|
||||
- if (!success) {
|
||||
- fail = true;
|
||||
- }
|
||||
- --count;
|
||||
- log("count: " + count);
|
||||
- if (!count) {
|
||||
- callback(!fail, files);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }());
|
||||
-
|
||||
- } else {
|
||||
- files.push(url);
|
||||
- callback(true, files);
|
||||
+ if (url.substr(url.length - 4) == '.txt') {
|
||||
+ var lines = loadTextFileSynchronous(url).split('\n');
|
||||
+ var prefix = '';
|
||||
+ var lastSlash = url.lastIndexOf('/');
|
||||
+ if (lastSlash >= 0) {
|
||||
+ prefix = url.substr(0, lastSlash + 1);
|
||||
}
|
||||
- };
|
||||
-
|
||||
- getFileListImpl(url, function(success, files) {
|
||||
- // flatten
|
||||
- var flat = [];
|
||||
- flatten(files);
|
||||
- function flatten(files) {
|
||||
- for (var ii = 0; ii < files.length; ++ii) {
|
||||
- var value = files[ii];
|
||||
- if (typeof(value) == "string") {
|
||||
- flat.push(value);
|
||||
- } else {
|
||||
- flatten(value);
|
||||
- }
|
||||
+ for (var ii = 0; ii < lines.length; ++ii) {
|
||||
+ var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||
+ if (str.length > 4 &&
|
||||
+ str[0] != '#' &&
|
||||
+ str[0] != ";" &&
|
||||
+ str.substr(0, 2) != "//") {
|
||||
+ new_url = prefix + str;
|
||||
+ files = files.concat(getFileList(new_url));
|
||||
}
|
||||
}
|
||||
- callback(success, flat);
|
||||
- });
|
||||
-};
|
||||
+ } else {
|
||||
+ files.push(url);
|
||||
+ }
|
||||
+ return files;
|
||||
+}
|
||||
|
||||
var TestFile = function(url) {
|
||||
this.url = url;
|
||||
};
|
||||
|
||||
var TestHarness = function(iframe, filelistUrl, reportFunc) {
|
||||
this.window = window;
|
||||
this.iframe = iframe;
|
||||
this.reportFunc = reportFunc;
|
||||
- this.timeoutDelay = 20000;
|
||||
- this.files = [];
|
||||
-
|
||||
- var that = this;
|
||||
- getFileList(filelistUrl, function() {
|
||||
- return function(success, files) {
|
||||
- that.addFiles_(success, files);
|
||||
- };
|
||||
- }());
|
||||
-
|
||||
-};
|
||||
-
|
||||
-TestHarness.reportType = {
|
||||
- ADD_PAGE: 1,
|
||||
- READY: 2,
|
||||
- START_PAGE: 3,
|
||||
- TEST_RESULT: 4,
|
||||
- FINISH_PAGE: 5,
|
||||
- FINISHED_ALL_TESTS: 6
|
||||
-};
|
||||
-
|
||||
-TestHarness.prototype.addFiles_ = function(success, files) {
|
||||
- if (!success) {
|
||||
+ try {
|
||||
+ var files = getFileList(filelistUrl);
|
||||
+ } catch (e) {
|
||||
this.reportFunc(
|
||||
TestHarness.reportType.FINISHED_ALL_TESTS,
|
||||
'Unable to load tests. Are you running locally?\n' +
|
||||
'You need to run from a server or configure your\n' +
|
||||
'browser to allow access to local files (not recommended).\n\n' +
|
||||
'Note: An easy way to run from a server:\n\n' +
|
||||
'\tcd path_to_tests\n' +
|
||||
'\tpython -m SimpleHTTPServer\n\n' +
|
||||
'then point your browser to ' +
|
||||
'<a href="http://localhost:8000/webgl-conformance-tests.html">' +
|
||||
'http://localhost:8000/webgl-conformance-tests.html</a>',
|
||||
false)
|
||||
return;
|
||||
}
|
||||
- log("total files: " + files.length);
|
||||
+ this.files = [];
|
||||
for (var ii = 0; ii < files.length; ++ii) {
|
||||
- log("" + ii + ": " + files[ii]);
|
||||
this.files.push(new TestFile(files[ii]));
|
||||
this.reportFunc(TestHarness.reportType.ADD_PAGE, files[ii], undefined);
|
||||
}
|
||||
- this.reportFunc(TestHarness.reportType.READY, undefined, undefined);
|
||||
this.nextFileIndex = files.length;
|
||||
this.lastFileIndex = files.length;
|
||||
+ this.timeoutDelay = 20000;
|
||||
}
|
||||
|
||||
+TestHarness.reportType = {
|
||||
+ ADD_PAGE: 1,
|
||||
+ START_PAGE: 2,
|
||||
+ TEST_RESULT: 3,
|
||||
+ FINISH_PAGE: 4,
|
||||
+ FINISHED_ALL_TESTS: 5
|
||||
+};
|
||||
+
|
||||
TestHarness.prototype.runTests = function(opt_start, opt_count) {
|
||||
var count = opt_count || this.files.length;
|
||||
this.nextFileIndex = opt_start || 0;
|
||||
this.lastFileIndex = this.nextFileIndex + count;
|
||||
this.startNextFile();
|
||||
};
|
||||
|
||||
TestHarness.prototype.setTimeout = function() {
|
@ -50,6 +50,10 @@ found in the LICENSE file.
|
||||
<script>
|
||||
var CONFORMANCE_TEST_VERSION = "1.0.1 (beta)";
|
||||
|
||||
var OPTIONS = {
|
||||
version: CONFORMANCE_TEST_VERSION
|
||||
};
|
||||
|
||||
function start() {
|
||||
|
||||
function log(msg) {
|
||||
@ -217,7 +221,7 @@ function start() {
|
||||
};
|
||||
|
||||
Folder.prototype.checked = function() {
|
||||
return this.check.checked &&
|
||||
return this.check.checked &&
|
||||
(this.folder ? this.folder.checked() : true);
|
||||
};
|
||||
|
||||
@ -247,7 +251,7 @@ function start() {
|
||||
this.subFolders[name] = subFolder;
|
||||
this.items.push(subFolder);
|
||||
this.childUL.appendChild(subFolder.elem);
|
||||
}
|
||||
}
|
||||
return subFolder;
|
||||
};
|
||||
|
||||
@ -363,7 +367,7 @@ function start() {
|
||||
// generate a text summary
|
||||
var tx = "";
|
||||
tx += "WebGL Conformance Test Results\n";
|
||||
tx += "Version " + CONFORMANCE_TEST_VERSION + "\n";
|
||||
tx += "Version " + OPTIONS.version + "\n";
|
||||
tx += "\n";
|
||||
tx += "-------------------\n\n";
|
||||
tx += "User Agent: " + (navigator.userAgent ? navigator.userAgent : "(navigator.userAgent is null)") + "\n";
|
||||
@ -432,7 +436,26 @@ function start() {
|
||||
};
|
||||
};
|
||||
|
||||
document.getElementById("testVersion").innerHTML = CONFORMANCE_TEST_VERSION;
|
||||
var getURLOptions = function(obj) {
|
||||
var s = window.location.href;
|
||||
var q = s.indexOf("?");
|
||||
var e = s.indexOf("#");
|
||||
if (e < 0) {
|
||||
e = s.length;
|
||||
}
|
||||
var query = s.substring(q + 1, e);
|
||||
var pairs = query.split("&");
|
||||
for (var ii = 0; ii < pairs.length; ++ii) {
|
||||
var keyValue = pairs[ii].split("=");
|
||||
var key = keyValue[0];
|
||||
var value = decodeURIComponent(keyValue[1]);
|
||||
obj[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
getURLOptions(OPTIONS);
|
||||
|
||||
document.getElementById("testVersion").innerHTML = OPTIONS.version;
|
||||
|
||||
var reporter = new Reporter();
|
||||
var iframe = document.getElementById("testframe");
|
||||
@ -441,7 +464,8 @@ function start() {
|
||||
'00_test_list.txt',
|
||||
function(type, msg, success) {
|
||||
return reporter.reportFunc(type, msg, success);
|
||||
});
|
||||
},
|
||||
OPTIONS);
|
||||
window.webglTestHarness = testHarness;
|
||||
var button = document.getElementById("runTestsButton");
|
||||
button.disabled = true;
|
||||
|
Loading…
Reference in New Issue
Block a user