diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /netwerk/test/mochitests/test_arraybufferinputstream_large.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
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.html | 45 |
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> |