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