1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/state/gl-geterror.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +<!-- 1.5 +Copyright (c) 2009 The Chromium Authors. All rights reserved. 1.6 +Use of this source code is governed by a BSD-style license that can be 1.7 + found in the LICENSE file. 1.8 + --> 1.9 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 1.10 + "http://www.w3.org/TR/html4/loose.dtd"> 1.11 +<html> 1.12 +<head> 1.13 +<title>WebGL get error conformance test.</title> 1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 +<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script> 1.16 +<script src="../../resources/js-test-pre.js"></script> 1.17 +<script src="../resources/webgl-test.js"> </script> 1.18 +<script src="../resources/webgl-test-utils.js"> </script> 1.19 +</head> 1.20 +<body> 1.21 +<canvas id="example" width="1" height="1" style="width: 256px; height: 48px;"></canvas> 1.22 +<div id="description"></div><div id="console"></div> 1.23 +<script> 1.24 +description("Test getError."); 1.25 +var wtu = WebGLTestUtils; 1.26 +var gl = wtu.create3DContext("example"); 1.27 +var tex = gl.createTexture(); 1.28 +gl.bindTexture(gl.TEXTURE_2D, tex); 1.29 + 1.30 +gl.enable(desktopGL.ALPHA_TEST); 1.31 +glErrorShouldBe(gl, gl.INVALID_ENUM, "should generate INVALID_ENUM"); 1.32 +gl.viewport(-1, -1, -1, -1); 1.33 +glErrorShouldBe(gl, gl.INVALID_VALUE, "should generate INVALID_VALUE"); 1.34 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1.35 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "should generate INVALID_OPERATION"); 1.36 + 1.37 +// Generate 2 errors of each type for 6 total possible errors. 1.38 +// The OpenGL ES 2.0 spec section 2.5 says the implementation is allowed to 1.39 +// either return the first error or many errors in an unspecied order. 1.40 +gl.viewport(-1, -1, -1, -1); 1.41 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1.42 +gl.enable(desktopGL.ALPHA_TEST); 1.43 +gl.viewport(-1, -1, -1, -1); 1.44 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 1.45 +// Note: This error is specifically last because we know it will be synthasized 1.46 +// by WebGL at least when implemented on top of Desktop OpenGL 1.47 +gl.enable(desktopGL.ALPHA_TEST); 1.48 + 1.49 +var err1 = gl.getError(); 1.50 +var err2 = gl.getError(); 1.51 +var err3 = gl.getError(); 1.52 +var err4 = gl.getError(); 1.53 +var err5 = gl.getError(); 1.54 +var err6 = gl.getError(); 1.55 + 1.56 +debug(""); 1.57 +if (err2 == gl.NO_ERROR) { 1.58 + debug("This WebGL implementation looks like it uses the 'first error' method"); 1.59 + debug("There should be 1 error, the first one generated"); 1.60 + shouldBeTrue('err1 == gl.INVALID_VALUE && err2 == gl.NO_ERROR && err3 == gl.NO_ERROR'); 1.61 +} else { 1.62 + debug("This WebGL implementation looks like it uses the many error method"); 1.63 + debug("Check is that at least one of the errors is the first error"); 1.64 + shouldBeTrue('err1 == gl.INVALID_VALUE || ' + 1.65 + 'err2 == gl.INVALID_VALUE || ' + 1.66 + 'err3 == gl.INVALID_VALUE || ' + 1.67 + 'err4 == gl.INVALID_VALUE || ' + 1.68 + 'err5 == gl.INVALID_VALUE || ' + 1.69 + 'err6 == gl.INVALID_VALUE'); 1.70 + shouldBeTrue('gl.getError() == gl.NO_ERROR'); 1.71 +} 1.72 + 1.73 +debug(""); 1.74 +successfullyParsed = true; 1.75 +</script> 1.76 +<script>finishTest();</script> 1.77 +</body> 1.78 +</html> 1.79 +