OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 6 <script src="../../js/resources/js-test-pre.js"></script> |
| 7 <script src="resources/webgl-test.js"></script> |
| 8 <script src="resources/typed-array-test-cases.js"></script> |
| 9 </head> |
| 10 <body> |
| 11 <div id="description"></div> |
| 12 <div id="console"></div> |
| 13 |
| 14 <script> |
| 15 description("Verifies allocation of large array buffers"); |
| 16 |
| 17 var currentlyRunning = ''; |
| 18 var allPassed = true; |
| 19 function running(str) { |
| 20 currentlyRunning = str; |
| 21 } |
| 22 |
| 23 function output(str) { |
| 24 debug(str); |
| 25 } |
| 26 |
| 27 function pass() { |
| 28 testPassed(currentlyRunning); |
| 29 } |
| 30 |
| 31 function fail(str) { |
| 32 allPassed = false; |
| 33 var exc; |
| 34 if (str) |
| 35 exc = currentlyRunning + ': ' + str; |
| 36 else |
| 37 exc = currentlyRunning; |
| 38 testFailed(exc); |
| 39 } |
| 40 |
| 41 function assertEq(prefix, expected, val) { |
| 42 if (expected != val) { |
| 43 var str = prefix + ': expected ' + expected + ', got ' + val; |
| 44 throw str; |
| 45 } |
| 46 } |
| 47 |
| 48 function assert(prefix, expected) { |
| 49 if (!expected) { |
| 50 var str = prefix + ': expected value / true'; |
| 51 throw str; |
| 52 } |
| 53 } |
| 54 |
| 55 function printSummary() { |
| 56 if (allPassed) { |
| 57 debug("Test passed."); |
| 58 } else { |
| 59 debug("TEST FAILED"); |
| 60 } |
| 61 } |
| 62 |
| 63 |
| 64 function testConstructionOfHugeArray(type, name, sz) { |
| 65 if (sz == 1) |
| 66 return; |
| 67 try { |
| 68 // Construction of huge arrays must fail because byteLength is |
| 69 // an unsigned long |
| 70 array = new type(3000000000); |
| 71 testFailed("Construction of huge " + name + " should throw exception"); |
| 72 } catch (e) { |
| 73 testPassed("Construction of huge " + name + " threw exception"); |
| 74 } |
| 75 } |
| 76 |
| 77 function runTests() { |
| 78 allPassed = true; |
| 79 |
| 80 for (var i = 0; i < testCases.length; i++) { |
| 81 var testCase = testCases[i]; |
| 82 running(testCase.name); |
| 83 if (!(testCase.name in window)) { |
| 84 fail("does not exist"); |
| 85 continue; |
| 86 } |
| 87 var type = window[testCase.name]; |
| 88 var name = testCase.name; |
| 89 testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes); |
| 90 } |
| 91 } |
| 92 |
| 93 runTests(); |
| 94 var successfullyParsed = true; |
| 95 |
| 96 </script> |
| 97 <script src="../../js/resources/js-test-post.js"></script> |
| 98 |
| 99 </body> |
| 100 </html> |
| 101 |
OLD | NEW |