Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / bindings / test / test_resizable_arraybufferview.html
blobf57ada5b680218d0002199257a4f2115e20c53b4
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1842773
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for resizable ArrayBufferViews</title>
9 <script src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1842773">Mozilla Bug 1842773</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 </pre>
20 <script type="application/javascript">
21 /* global TestFunctions */
23 SimpleTest.waitForExplicitFinish();
24 SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, go);
26 function checkThrowsResizable(f) {
27 let ex;
28 try{
29 f();
30 ok(false, "Should have thrown!");
31 } catch (e) {
32 ex = e;
34 ok(ex.toString().includes("resizable ArrayBuffer or ArrayBufferView"), "Got exception: " + ex);
37 function go() {
38 let test = new TestFunctions();
40 let ab = new ArrayBuffer(16, {maxByteLength: 16});
41 checkThrowsResizable(() => test.testNotAllowShared(ab));
42 checkThrowsResizable(() => test.testAllowShared(ab));
43 checkThrowsResizable(() => test.testDictWithAllowShared({arrayBuffer: ab}));
44 checkThrowsResizable(() => test.testUnionOfBuffferSource(ab));
45 checkThrowsResizable(() => { test.arrayBuffer = ab; });
46 checkThrowsResizable(() => { test.allowSharedArrayBuffer = ab; });
47 checkThrowsResizable(() => { test.sequenceOfArrayBuffer = [ab]; });
48 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBuffer = [ab]; });
50 let ta = new Int8Array(ab);
51 checkThrowsResizable(() => test.testNotAllowShared(ta));
52 checkThrowsResizable(() => test.testAllowShared(ta));
53 checkThrowsResizable(() => test.testDictWithAllowShared({arrayBufferView: ta}));
54 checkThrowsResizable(() => test.testUnionOfBuffferSource(ta));
55 checkThrowsResizable(() => { test.arrayBufferView = ta; });
56 checkThrowsResizable(() => { test.allowSharedArrayBufferView = ta; });
57 checkThrowsResizable(() => { test.sequenceOfArrayBufferView = [ta]; });
58 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [ta]; });
60 let dv = new DataView(ab);
61 checkThrowsResizable(() => test.testNotAllowShared(dv));
62 checkThrowsResizable(() => test.testAllowShared(dv));
63 checkThrowsResizable(() => test.testDictWithAllowShared({arrayBufferView: dv}));
64 checkThrowsResizable(() => test.testUnionOfBuffferSource(dv));
65 checkThrowsResizable(() => { test.arrayBufferView = dv; });
66 checkThrowsResizable(() => { test.allowSharedArrayBufferView = dv; });
67 checkThrowsResizable(() => { test.sequenceOfArrayBufferView = [dv]; });
68 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [dv]; });
70 if (this.SharedArrayBuffer) {
71 let sab = new SharedArrayBuffer(16, {maxByteLength: 16});
72 checkThrowsResizable(() => test.testAllowShared(sab));
73 checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBuffer: sab}));
74 checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sab));
75 checkThrowsResizable(() => { test.allowSharedArrayBuffer = sab; });
76 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBuffer = [sab]; });
78 let sta = new Int8Array(sab);
79 checkThrowsResizable(() => test.testAllowShared(sta));
80 checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBufferView: sta}));
81 checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sta));
82 checkThrowsResizable(() => { test.allowSharedArrayBufferView = sta; });
83 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [sta]; });
85 let sdv = new DataView(sab);
86 checkThrowsResizable(() => test.testAllowShared(sdv));
87 checkThrowsResizable(() => test.testDictWithAllowShared({allowSharedArrayBufferView: sdv}));
88 checkThrowsResizable(() => test.testUnionOfAllowSharedBuffferSource(sdv));
89 checkThrowsResizable(() => { test.allowSharedArrayBufferView = sdv; });
90 checkThrowsResizable(() => { test.sequenceOfAllowSharedArrayBufferView = [sdv]; });
93 SimpleTest.finish();
95 </script>
96 </body>
97 </html>