|
1 <!-- |
|
2 Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
3 Use of this source code is governed by a BSD-style license that can be |
|
4 found in the LICENSE file. |
|
5 --> |
|
6 <!DOCTYPE html> |
|
7 <html> |
|
8 <head> |
|
9 <meta charset="utf-8"> |
|
10 <title>WebGL gl enums Conformance Tests</title> |
|
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
|
12 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script> |
|
13 <script src="../../resources/js-test-pre.js"></script> |
|
14 <script src="../resources/webgl-test.js"></script> |
|
15 </head> |
|
16 <body> |
|
17 <div id="description"></div> |
|
18 <div id="console"></div> |
|
19 <canvas id="canvas" width="2" height="2"> </canvas> |
|
20 <script> |
|
21 description("This test ensures various WebGL functions fail when passed non OpenGL ES 2.0 enums."); |
|
22 |
|
23 debug(""); |
|
24 debug("Canvas.getContext"); |
|
25 |
|
26 var gl = create3DContext(document.getElementById("canvas")); |
|
27 if (!gl) { |
|
28 testFailed("context does not exist"); |
|
29 } else { |
|
30 testPassed("context exists"); |
|
31 |
|
32 debug(""); |
|
33 debug("Checking gl enums."); |
|
34 |
|
35 var buffer = new ArrayBuffer(2); |
|
36 var buf = new Uint16Array(buffer); |
|
37 var tex = gl.createTexture(); |
|
38 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); |
|
39 glErrorShouldBe(gl, gl.NO_ERROR); |
|
40 |
|
41 var tests = [ |
|
42 "gl.bindTexture(desktopGL['TEXTURE_3D'], tex)", |
|
43 "gl.blendEquation(desktopGL['MIN'])", |
|
44 "gl.blendEquation(desktopGL['MAX'])", |
|
45 "gl.blendEquationSeparate(desktopGL['MIN'], gl.FUNC_ADD)", |
|
46 "gl.blendEquationSeparate(desktopGL['MAX'], gl.FUNC_ADD)", |
|
47 "gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MIN'])", |
|
48 "gl.blendEquationSeparate(gl.FUNC_ADD, desktopGL['MAX'])", |
|
49 "gl.bufferData(gl.ARRAY_BUFFER, 3, desktopGL['STATIC_READ'])", |
|
50 "gl.disable(desktopGL['CLIP_PLANE0'])", |
|
51 "gl.disable(desktopGL['POINT_SPRITE'])", |
|
52 "gl.getBufferParameter(gl.ARRAY_BUFFER, desktopGL['PIXEL_PACK_BUFFER'])", |
|
53 "gl.hint(desktopGL['PERSPECTIVE_CORRECTION_HINT'], gl.FASTEST)", |
|
54 "gl.isEnabled(desktopGL['CLIP_PLANE0'])", |
|
55 "gl.isEnabled(desktopGL['POINT_SPRITE'])", |
|
56 "gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1)", |
|
57 ]; |
|
58 for (var ii = 0; ii < tests.length; ++ii) { |
|
59 eval(tests[ii]); |
|
60 glErrorShouldBe(gl, gl.INVALID_ENUM, |
|
61 tests[ii] + " should return INVALID_ENUM."); |
|
62 } |
|
63 |
|
64 gl.bindTexture(gl.TEXTURE_2D, tex); |
|
65 glErrorShouldBe(gl, gl.NO_ERROR); |
|
66 |
|
67 tests = [ |
|
68 "gl.getTexParameter(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'])", |
|
69 "gl.texParameteri(desktopGL['TEXTURE_3D'], gl.TEXTURE_MAG_FILTER, gl.NEAREST)", |
|
70 "gl.texParameteri(gl.TEXTURE_2D, desktopGL['GENERATE_MIPMAP'], 1)" |
|
71 ]; |
|
72 for (var ii = 0; ii < tests.length; ++ii) { |
|
73 eval(tests[ii]); |
|
74 glErrorShouldBe(gl, gl.INVALID_ENUM, |
|
75 tests[ii] + " should return INVALID_ENUM."); |
|
76 } |
|
77 } |
|
78 |
|
79 debug(""); |
|
80 successfullyParsed = true; |
|
81 |
|
82 </script> |
|
83 <script>finishTest();</script> |
|
84 |
|
85 </body> |
|
86 </html> |
|
87 |