Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset="utf-8"> |
michael@0 | 5 | <title>texImage2D and texSubImage2D tests with invalid data</title> |
michael@0 | 6 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 7 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 8 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <div id="description"></div> |
michael@0 | 12 | <div id="console"></div> |
michael@0 | 13 | <canvas id="canvas" width="2" height="2"> </canvas> |
michael@0 | 14 | <script type="text/javascript"> |
michael@0 | 15 | description("texImage2D and texSubImage2D tests with invalid data"); |
michael@0 | 16 | |
michael@0 | 17 | var canvas = document.getElementById("canvas"); |
michael@0 | 18 | var gl = create3DContext(canvas); |
michael@0 | 19 | if (!gl) |
michael@0 | 20 | testFailed("Context created."); |
michael@0 | 21 | else |
michael@0 | 22 | testPassed("Context created."); |
michael@0 | 23 | |
michael@0 | 24 | var tex; |
michael@0 | 25 | |
michael@0 | 26 | function setup() { |
michael@0 | 27 | tex = gl.createTexture(); |
michael@0 | 28 | gl.bindTexture(gl.TEXTURE_2D, bug32619_tests.tex); |
michael@0 | 29 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function teardown() { |
michael@0 | 33 | gl.deleteTexture(tex); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function test(desc, func, expected) { |
michael@0 | 37 | debug(desc); |
michael@0 | 38 | |
michael@0 | 39 | var exc = null; |
michael@0 | 40 | try { |
michael@0 | 41 | func(); |
michael@0 | 42 | } catch (x) { |
michael@0 | 43 | exc = x; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | if (expected == gl.INVALID_OPERATION) { |
michael@0 | 47 | glErrorShouldBe(gl, expected); |
michael@0 | 48 | } else if (expected == "exception") { |
michael@0 | 49 | if (exc) { |
michael@0 | 50 | testPassed("threw exception"); |
michael@0 | 51 | } else { |
michael@0 | 52 | testFailed("did not throw exception"); |
michael@0 | 53 | } |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | test("Passing a buffer not large enough to texImage2D should generate an INVALID_OPERATION", |
michael@0 | 58 | function () { |
michael@0 | 59 | var tooSmall = new Uint8Array(64); |
michael@0 | 60 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, tooSmall); |
michael@0 | 61 | }, |
michael@0 | 62 | gl.INVALID_OPERATION); |
michael@0 | 63 | |
michael@0 | 64 | test("Passing texImage2D parameter data of Number type should throw an exception", |
michael@0 | 65 | function () { |
michael@0 | 66 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, 42); |
michael@0 | 67 | }, |
michael@0 | 68 | "exception"); |
michael@0 | 69 | |
michael@0 | 70 | test("Passing texImage2D parameter data of String type should throw a TypeError", |
michael@0 | 71 | function () { |
michael@0 | 72 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer"); |
michael@0 | 73 | }, |
michael@0 | 74 | "exception"); |
michael@0 | 75 | test("Passing a buffer not large enough to texSubImage2D should generate an INVALID_OPERATION", |
michael@0 | 76 | function () { |
michael@0 | 77 | var tooSmall = new Uint8Array(64); |
michael@0 | 78 | gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, tooSmall); |
michael@0 | 79 | }, |
michael@0 | 80 | gl.INVALID_OPERATION); |
michael@0 | 81 | |
michael@0 | 82 | test("Passing texSubImage2D parameter data of Number type should throw a TypeError", |
michael@0 | 83 | function () { |
michael@0 | 84 | gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, 42); |
michael@0 | 85 | }, |
michael@0 | 86 | "exception"); |
michael@0 | 87 | |
michael@0 | 88 | test("Passing texSubImage2D parameter data of String type should throw a TypeError", |
michael@0 | 89 | function () { |
michael@0 | 90 | gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, "not a buffer"); |
michael@0 | 91 | }, |
michael@0 | 92 | "exception"); |
michael@0 | 93 | |
michael@0 | 94 | debug(""); |
michael@0 | 95 | successfullyParsed = true; |
michael@0 | 96 | </script> |
michael@0 | 97 | <script>finishTest();</script> |
michael@0 | 98 | |
michael@0 | 99 | </body> |
michael@0 | 100 | </html> |
michael@0 | 101 |