-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buffer: extract Blob's .arrayBuffer() & webidl changes #53372
base: main
Are you sure you want to change the base?
Conversation
KhafraDev
commented
Jun 6, 2024
- Extracts Blob.prototype.arrayBuffer so it cannot be overridden in .text(), etc.
- Make .bytes() enumerable. I guess the WPT runner is not running the idlharness tests?
- Make .text() return a Promise, rather than being explicitly async. This is a non-documented part of the webidl spec. Refs: lib: make fetch sync and return a Promise #49936
- Extracts Blob.prototype.arrayBuffer so it cannot be overridden in .text(), etc. - Make .bytes() enumerable. I guess the WPT runner is not running the idlharness tests? - Make .text() return a Promise, rather than being explicitly async. This is a non-documented part of the webidl spec. Refs: nodejs#49936 - Have .text(), .arrayBuffer(), and .bytes() reject for an invalid this instead of throwing. Fix the tests regarding this.
@@ -436,6 +414,7 @@ ObjectDefineProperties(Blob.prototype, { | |||
stream: kEnumerableProperty, | |||
text: kEnumerableProperty, | |||
arrayBuffer: kEnumerableProperty, | |||
bytes: kEnumerableProperty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a separate commit marked as fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a webidl change
(async () => { | ||
const blob = new Blob(['hello']); | ||
const { arrayBuffer } = Blob.prototype; | ||
|
||
Blob.prototype.arrayBuffer = common.mustNotCall(); | ||
|
||
try { | ||
assert.strictEqual(await blob.text(), 'hello'); | ||
} finally { | ||
Blob.prototype.arrayBuffer = arrayBuffer; | ||
} | ||
})().then(common.mustCall()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it worth to explicitly add a test for this behavior?