1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/state/gl-enum-tests.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 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> 1.10 +<html> 1.11 +<head> 1.12 +<meta charset="utf-8"> 1.13 +<title>WebGL gl enums Conformance Tests</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 +</head> 1.19 +<body> 1.20 +<div id="description"></div> 1.21 +<div id="console"></div> 1.22 +<canvas id="canvas" width="2" height="2"> </canvas> 1.23 +<script> 1.24 +description("This test ensures various WebGL functions fail when passed non OpenGL ES 2.0 enums."); 1.25 + 1.26 +debug(""); 1.27 +debug("Canvas.getContext"); 1.28 + 1.29 +var gl = create3DContext(document.getElementById("canvas")); 1.30 +if (!gl) { 1.31 + testFailed("context does not exist"); 1.32 +} else { 1.33 + testPassed("context exists"); 1.34 + 1.35 + debug(""); 1.36 + debug("Checking gl enums."); 1.37 + 1.38 + var buffer = new ArrayBuffer(2); 1.39 + var buf = new Uint16Array(buffer); 1.40 + var tex = gl.createTexture(); 1.41 + gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); 1.42 + glErrorShouldBe(gl, gl.NO_ERROR); 1.43 + 1.44 + var tests = [ 1.45 + "gl.bindTexture(desktopGL['TEXTURE_3D'], tex)", 1.46 + "gl.blendEquation(desktopGL['MIN'])", 1.47 + "gl.blendEquation(desktopGL['MAX'])", 1.48 + "gl.blendEquationSeparate(desktopGL['MIN'], gl.FUNC_ADD)", 1.49 + "gl.blendEquationSeparate(desktopGL['MAX'], gl.FUNC_ADD)", 1.50 + "gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MIN'])", 1.51 + "gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MAX'])", 1.52 + "gl.bufferData(gl.ARRAY_BUFFER, 3, desktopGL['STATIC_READ'])", 1.53 + "gl.disable(desktopGL['CLIP_PLANE0'])", 1.54 + "gl.disable(desktopGL['POINT_SPRITE'])", 1.55 + "gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER'])", 1.56 + "gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST)", 1.57 + "gl.isEnabled(desktopGL['CLIP_PLANE0'])", 1.58 + "gl.isEnabled(desktopGL['POINT_SPRITE'])", 1.59 + "gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1)", 1.60 + ]; 1.61 + for (var ii = 0; ii < tests.length; ++ii) { 1.62 + eval(tests[ii]); 1.63 + glErrorShouldBe(gl, gl.INVALID_ENUM, 1.64 + tests[ii] + " should return INVALID_ENUM."); 1.65 + } 1.66 + 1.67 + gl.bindTexture(gl.TEXTURE_2D, tex); 1.68 + glErrorShouldBe(gl, gl.NO_ERROR); 1.69 + 1.70 + tests = [ 1.71 + "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])", 1.72 + "gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST)", 1.73 + "gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1)" 1.74 + ]; 1.75 + for (var ii = 0; ii < tests.length; ++ii) { 1.76 + eval(tests[ii]); 1.77 + glErrorShouldBe(gl, gl.INVALID_ENUM, 1.78 + tests[ii] + " should return INVALID_ENUM."); 1.79 + } 1.80 +} 1.81 + 1.82 +debug(""); 1.83 +successfullyParsed = true; 1.84 + 1.85 +</script> 1.86 +<script>finishTest();</script> 1.87 + 1.88 +</body> 1.89 +</html> 1.90 +