summaryrefslogtreecommitdiffstats
path: root/netwerk/test/mochitests/test_arraybufferinputstream_large.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /netwerk/test/mochitests/test_arraybufferinputstream_large.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/mochitests/test_arraybufferinputstream_large.html')
-rw-r--r--netwerk/test/mochitests/test_arraybufferinputstream_large.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/netwerk/test/mochitests/test_arraybufferinputstream_large.html b/netwerk/test/mochitests/test_arraybufferinputstream_large.html
new file mode 100644
index 0000000000..33922d6e37
--- /dev/null
+++ b/netwerk/test/mochitests/test_arraybufferinputstream_large.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>ArrayBuffer stream with large ArrayBuffer test</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<script type="text/javascript">
+add_task(async function testLargeArrayBuffer() {
+ let ab = new ArrayBuffer(4.5 * 1024 * 1024 * 1024); // 4.5 GB.
+ let ta = new Uint8Array(ab);
+
+ const { Cc, Ci } = SpecialPowers;
+ let abis = Cc["@mozilla.org/io/arraybuffer-input-stream;1"]
+ .createInstance(Ci.nsIArrayBufferInputStream);
+
+ let sis = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ sis.init(abis);
+
+ // The stream currently doesn't support more than UINT32_MAX bytes.
+ let ex;
+ try {
+ abis.setData(ab, 0, ab.byteLength);
+ } catch (e) {
+ ex = e;
+ }
+ is(ex.message.includes("NS_ERROR_ILLEGAL_VALUE"), true, "Expecting exception");
+
+ // Reading a small slice of the large ArrayBuffer is fine, even near the end.
+ ta[ta.length - 10] = "a".charCodeAt(0);
+ ta[ta.length - 9] = "b".charCodeAt(0);
+ ta[ta.length - 8] = "c".charCodeAt(0);
+ abis.setData(ab, ab.byteLength - 10, 2);
+ is(sis.read(1), "a", "should read 'a' after init");
+ is(sis.read(1), "b", "should read 'b' after 'a'");
+ is(sis.read(1), "", "Should be done reading data");
+});
+</script>
+
+</head>
+<body>
+</body>
+</html>