mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibWeb: Import detached ReadableStream buffer tests
This commit is contained in:
parent
cef714732e
commit
0c309d4660
Notes:
github-actions[bot]
2025-04-17 17:47:47 +00:00
Author: https://github.com/trflynn89
Commit: 0c309d4660
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4386
3 changed files with 42 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 1 tests
|
||||||
|
|
||||||
|
1 Fail
|
||||||
|
Fail enqueue after detaching byobRequest.view.buffer should throw
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
self.GLOBAL = {
|
||||||
|
isWindow: function() { return true; },
|
||||||
|
isWorker: function() { return false; },
|
||||||
|
isShadowRealm: function() { return false; },
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="../../resources/testharness.js"></script>
|
||||||
|
<script src="../../resources/testharnessreport.js"></script>
|
||||||
|
|
||||||
|
<div id=log></div>
|
||||||
|
<script src="../../streams/readable-byte-streams/enqueue-with-detached-buffer.any.js"></script>
|
|
@ -0,0 +1,21 @@
|
||||||
|
// META: global=window,worker,shadowrealm
|
||||||
|
|
||||||
|
promise_test(async t => {
|
||||||
|
const error = new Error('cannot proceed');
|
||||||
|
const rs = new ReadableStream({
|
||||||
|
type: 'bytes',
|
||||||
|
pull: t.step_func((controller) => {
|
||||||
|
const buffer = controller.byobRequest.view.buffer;
|
||||||
|
// Detach the buffer.
|
||||||
|
structuredClone(buffer, { transfer: [buffer] });
|
||||||
|
|
||||||
|
// Try to enqueue with a new buffer.
|
||||||
|
assert_throws_js(TypeError, () => controller.enqueue(new Uint8Array([42])));
|
||||||
|
|
||||||
|
// If we got here the test passed.
|
||||||
|
controller.error(error);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
const reader = rs.getReader({ mode: 'byob' });
|
||||||
|
await promise_rejects_exactly(t, error, reader.read(new Uint8Array(1)));
|
||||||
|
}, 'enqueue after detaching byobRequest.view.buffer should throw');
|
Loading…
Add table
Add a link
Reference in a new issue