OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../js/resources/js-test-pre.js"></script> | 3 <script src="../../js/resources/js-test-pre.js"></script> |
4 <script src="resources/webgl-test.js"></script> | 4 <script src="resources/webgl-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <div id="description"></div> | 7 <div id="description"></div> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 | 9 |
10 <script> | 10 <script> |
(...skipping 26 matching lines...) Expand all Loading... |
37 var buffer = new ArrayBuffer(4); | 37 var buffer = new ArrayBuffer(4); |
38 var array; | 38 var array; |
39 try { | 39 try { |
40 array = new type(buffer, 4, -2147483648); | 40 array = new type(buffer, 4, -2147483648); |
41 testFailed("Construction of " + name + " with negative out-of-range valu
es should throw exception"); | 41 testFailed("Construction of " + name + " with negative out-of-range valu
es should throw exception"); |
42 } catch (e) { | 42 } catch (e) { |
43 testPassed("Construction of " + name + " with negative out-of-range valu
es threw exception"); | 43 testPassed("Construction of " + name + " with negative out-of-range valu
es threw exception"); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 function testConstructionOfHugeArray(type, name, sz) { | |
48 if (sz == 1) | |
49 return; | |
50 try { | |
51 // Construction of huge arrays must fail because byteLength is | |
52 // an unsigned long | |
53 array = new type(3000000000); | |
54 testFailed("Construction of huge " + name + " should throw exception"); | |
55 } catch (e) { | |
56 testPassed("Construction of huge " + name + " threw exception"); | |
57 } | |
58 } | |
59 | |
60 // These need to be global for shouldBe to see them | 47 // These need to be global for shouldBe to see them |
61 var array; | 48 var array; |
62 var typeSize; | 49 var typeSize; |
63 | 50 |
64 function testSubarrayWithOutOfRangeValues(type, name, sz) { | 51 function testSubarrayWithOutOfRangeValues(type, name, sz) { |
65 debug("Testing subarray of " + name); | 52 debug("Testing subarray of " + name); |
66 try { | 53 try { |
67 var buffer = new ArrayBuffer(32); | 54 var buffer = new ArrayBuffer(32); |
68 array = new type(buffer); | 55 array = new type(buffer); |
69 typeSize = sz; | 56 typeSize = sz; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 118 |
132 for (var i = 0; i < typeNames.length; i++) { | 119 for (var i = 0; i < typeNames.length; i++) { |
133 var name = typeNames[i]; | 120 var name = typeNames[i]; |
134 var type = window[name]; | 121 var type = window[name]; |
135 if (!type) { | 122 if (!type) { |
136 testFailed("Could not find array type " + name); | 123 testFailed("Could not find array type " + name); |
137 } else { | 124 } else { |
138 testConstructionWithNullBuffer(type, name); | 125 testConstructionWithNullBuffer(type, name); |
139 testConstructionWithOutOfRangeValues(type, name); | 126 testConstructionWithOutOfRangeValues(type, name); |
140 testConstructionWithNegativeOutOfRangeValues(type, name); | 127 testConstructionWithNegativeOutOfRangeValues(type, name); |
141 testConstructionOfHugeArray(type, name, typeSizes[i]); | |
142 testSubarrayWithOutOfRangeValues(type, name, typeSizes[i]); | 128 testSubarrayWithOutOfRangeValues(type, name, typeSizes[i]); |
143 testSettingFromArrayWithOutOfRangeOffset(type, name); | 129 testSettingFromArrayWithOutOfRangeOffset(type, name); |
144 testSettingFromFakeArrayWithOutOfRangeLength(type, name); | 130 testSettingFromFakeArrayWithOutOfRangeLength(type, name); |
145 testSettingFromWebGLArrayWithOutOfRangeOffset(type, name); | 131 testSettingFromWebGLArrayWithOutOfRangeOffset(type, name); |
146 } | 132 } |
147 } | 133 } |
148 | 134 |
149 buffer = new ArrayBuffer(40); | 135 buffer = new ArrayBuffer(40); |
150 ints = new Int32Array(buffer, 0, 10); | 136 ints = new Int32Array(buffer, 0, 10); |
151 floats = new Float32Array(buffer, 0, 10); | 137 floats = new Float32Array(buffer, 0, 10); |
152 // Plant a NaN into the buffer | 138 // Plant a NaN into the buffer |
153 ints[0]=-0x7ffff; | 139 ints[0]=-0x7ffff; |
154 // Read the NaN out as a float | 140 // Read the NaN out as a float |
155 shouldBeTrue("isNaN(floats[0])"); | 141 shouldBeTrue("isNaN(floats[0])"); |
156 | 142 |
157 </script> | 143 </script> |
158 <script src="../../js/resources/js-test-post.js"></script> | 144 <script src="../../js/resources/js-test-post.js"></script> |
159 | 145 |
160 </body> | 146 </body> |
161 </html> | 147 </html> |
OLD | NEW |