forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Commit pull-into descriptors after filling from queue
This aligns us with the latest streams specification changes to accommodate for the security advisor GHSA-p5g2-876g-95h9. See relevant links: GHSA-p5g2-876g-95h9 web-platform-tests/wpt#48085 Previously we would crash when running the attached test since we have an assert in ReadableByteStreamControllerFillHeadPullIntoDescriptor verifying that controller controller.raw_byob_request() is null. These changes make sure that we postpone calls to ReadableByteStreamControllerCommitPullIntoDescriptor until after all pull-into descriptors have been filled up by ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue. The attached test verifies that a pachted then() will see a null byobRequest.
- Loading branch information
1 parent
8dd70db
commit 0ee6df5
Showing
4 changed files
with
127 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
Tests/LibWeb/Text/expected/Streams/ReadableByteStream-byob-commit-pull-into-descriptor.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PASSED | ||
false | ||
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66 | ||
false | ||
4774451407313060418 |
45 changes: 45 additions & 0 deletions
45
Tests/LibWeb/Text/input/Streams/ReadableByteStream-byob-commit-pull-into-descriptor.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<script src="../include.js"></script> | ||
<script> | ||
asyncTest(async (done) => { | ||
let controller; | ||
const rs = new ReadableStream({ | ||
type: 'bytes', | ||
start(c) { | ||
controller = c; | ||
} | ||
}); | ||
const reader = rs.getReader({mode: 'byob'}); | ||
|
||
const length = 0x4000; | ||
const buffer = new ArrayBuffer(length); | ||
const bigArray = new BigUint64Array(buffer, length - 8, 1); | ||
|
||
const read1 = reader.read(new Uint8Array(new ArrayBuffer(0x10))); | ||
const read2 = reader.read(bigArray); | ||
|
||
let flag = false; | ||
Object.defineProperty(Object.prototype, 'then', { | ||
get: () => { | ||
if (!flag) { | ||
flag = true; | ||
// byobRequest should be null after filling both views. | ||
println(controller.byobRequest == null ? "PASSED": "FAILED"); | ||
} | ||
}, | ||
configurable: true | ||
}); | ||
|
||
controller.enqueue(new Uint8Array(0x110).fill(0x42)); | ||
|
||
const result1 = await read1; | ||
println(result1.done); | ||
println(result1.value); | ||
|
||
const result2 = await read2; | ||
println(result2.done); | ||
println([...result2.value]); | ||
|
||
done(); | ||
}); | ||
</script> |