blob: db18e5b6027aec726925da1bbe62ab55b91463f6 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Conformance Tests</title>
<script src="resources/desktop-gl-constants.js" type="text/javascript"></script>
<script src="../../../resources/js-test.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');
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)");
// Make sure different numbers of extensions doesn't result in
// different test output.
var exts = gl.getSupportedExtensions();
var allPassed = true;
for (i in exts) {
if (typeof i != "string") {
shouldReturnString("gl.getSupportedExtensions()[" + i + "]");
allPassed = false;
}
}
if (allPassed) {
testPassed('getSupportedExtensions() returns an array of strings');
}
shouldReturnString("gl.getParameter(gl.VENDOR)");
shouldReturnString("gl.getParameter(gl.RENDERER)");
shouldReturnString("gl.getParameter(gl.VERSION)");
shouldReturnString("gl.getParameter(gl.SHADING_LANGUAGE_VERSION)");
}
debug("");
</script>
</body>
</html>