summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/typedarrays/array-large-array-tests.html
blob: 8af76136aa53f69e9b48c870d800610824db579d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/tests/typed-array-test-cases.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>

<script>
"use strict";

description("Verifies allocation of large array buffers");

var currentlyRunning = '';
var allPassed = true;
function running(str) {
  currentlyRunning = str;
}

function output(str) {
  debug(str);
}

function pass() {
  testPassed(currentlyRunning);
}

function fail(str) {
  allPassed = false;
  var exc;
  if (str)
    exc = currentlyRunning + ': ' + str;
  else
    exc = currentlyRunning;
  testFailed(exc);
}

function assertEq(prefix, expected, val) {
  if (expected != val) {
    var str = prefix + ': expected ' + expected + ', got ' + val;
    throw str;
  }
}

function assert(prefix, expected) {
  if (!expected) {
    var str = prefix + ': expected value / true';
    throw str;
  }
}

function printSummary() {
  if (allPassed) {
    debug("Test passed.");
  } else {
    debug("TEST FAILED");
  }
}


function testConstructionOfHugeArray(type, name, sz) {
    if (sz == 1)
        return;
    try {
        // Construction of huge arrays must fail because byteLength is
        // an unsigned long
        array = new type(3000000000);
        testFailed("Construction of huge " + name + " should throw exception");
    } catch (e) {
        testPassed("Construction of huge " + name + " threw exception");
    }
}

function runTests() {
  allPassed = true;

  for (var i = 0; i < testCases.length; i++) {
    var testCase = testCases[i];
    running(testCase.name);
    if (!(testCase.name in window)) {
        fail("does not exist");
        continue;
    }
    var type = window[testCase.name];
    var name = testCase.name;
    testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes);
  }
}

runTests();
var successfullyParsed = true;

</script>
<script src="../../js/js-test-post.js"></script>

</body>
</html>