blob: f57ada5b680218d0002199257a4f2115e20c53b4 (
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
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1842773
-->
<head>
<meta charset="utf-8">
<title>Test for resizable ArrayBufferViews</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1842773">Mozilla Bug 1842773</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script type="application/javascript">
/* global TestFunctions */
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, go);
function checkThrowsResizable(f) {
let ex;
try{
f();
ok(false, "Should have thrown!");
} catch (e) {
ex = e;
}
ok(ex.toString().includes("resizable ArrayBuffer or ArrayBufferView"), "Got exception: " + ex);
}
function go() {
let test = new TestFunctions();
let ab = new ArrayBuffer(16, {maxByteLength: 16});
checkThrowsResizable(() => test.testNotAllowShared(ab));
checkThrowsResizable(() => test.testAllowShared(ab));
checkThrowsResizable(() => test.testDictWithAllowShared({arrayBuffer: ab}));
checkThrowsResizable(() => test.testUnionOfBuffferSource(ab));
checkThrowsResizable(() => { test.arrayBuffer = ab; });
checkThrowsResizable(() => { test.allowSharedArrayBuffer = ab; });
checkThrowsResizable(() => { test.sequenceOfArrayBuffer = [ab]; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBuffer = [ab]; });
let ta = new Int8Array(ab);
checkThrowsResizable(() => test.testNotAllowShared(ta));
checkThrowsResizable(() => test.testAllowShared(ta));
checkThrowsResizable(() => test.testDictWithAllowShared({arrayBufferView: ta}));
checkThrowsResizable(() => test.testUnionOfBuffferSource(ta));
checkThrowsResizable(() => { test.arrayBufferView = ta; });
checkThrowsResizable(() => { test.allowSharedArrayBufferView = ta; });
checkThrowsResizable(() => { test.sequenceOfArrayBufferView = [ta]; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [ta]; });
let dv = new DataView(ab);
checkThrowsResizable(() => test.testNotAllowShared(dv));
checkThrowsResizable(() => test.testAllowShared(dv));
checkThrowsResizable(() => test.testDictWithAllowShared({arrayBufferView: dv}));
checkThrowsResizable(() => test.testUnionOfBuffferSource(dv));
checkThrowsResizable(() => { test.arrayBufferView = dv; });
checkThrowsResizable(() => { test.allowSharedArrayBufferView = dv; });
checkThrowsResizable(() => { test.sequenceOfArrayBufferView = [dv]; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [dv]; });
if (this.SharedArrayBuffer) {
let sab = new SharedArrayBuffer(16, {maxByteLength: 16});
checkThrowsResizable(() => test.testAllowShared(sab));
checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBuffer: sab}));
checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sab));
checkThrowsResizable(() => { test.allowSharedArrayBuffer = sab; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBuffer = [sab]; });
let sta = new Int8Array(sab);
checkThrowsResizable(() => test.testAllowShared(sta));
checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBufferView: sta}));
checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sta));
checkThrowsResizable(() => { test.allowSharedArrayBufferView = sta; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [sta]; });
let sdv = new DataView(sab);
checkThrowsResizable(() => test.testAllowShared(sdv));
checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBufferView: sdv}));
checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sdv));
checkThrowsResizable(() => { test.allowSharedArrayBufferView = sdv; });
checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [sdv]; });
}
SimpleTest.finish();
}
</script>
</body>
</html>
|