xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/array_buffer.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1{{header}}
2{{object 1 0}} <<
3  /Type /Catalog
4  /Pages 2 0 R
5  /OpenAction 10 0 R
6>>
7endobj
8{{object 2 0}} <<
9  /Type /Pages
10  /Count 1
11  /Kids [
12    3 0 R
13  ]
14>>
15endobj
16% Page number 0.
17{{object 3 0}} <<
18  /Type /Page
19  /Parent 2 0 R
20  /Resources <<
21    /Font <</F1 15 0 R>>
22  >>
23  /Contents [21 0 R]
24  /MediaBox [0 0 612 792]
25>>
26endobj
27% OpenAction action
28{{object 10 0}} <<
29  /Type /Action
30  /S /JavaScript
31  /JS 11 0 R
32>>
33endobj
34% JS program to execute
35{{object 11 0}} <<
36  {{streamlen}}
37>>
38stream
39app.alert("This test attempts to make array buffers until exhausted");
40
41function test(size) {
42  var i, ab, ia;
43  app.alert("Trying size " + size);
44  ab = new ArrayBuffer(size);
45  ia = new Int32Array(ab);
46  for (i = 0; i < size / 4; ++i) {
47    ia[i] = i;
48  }
49  for (i = 0; i < size / 4; ++i) {
50    if (ia[i] != i) {
51      throw('aaaaaaah');
52    }
53  }
54}
55
56try {
57  test(1000);
58  test(2000000);
59  test(2147483647);
60} catch (e) {
61  app.alert("Caught error " + e);
62}
63endstream
64endobj
65{{xref}}
66{{trailer}}
67{{startxref}}
68%%EOF
69