Bug 304996
| Summary: | WebTransportError constructor mishandles single options argument and treats it as message | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | ankshit <ankshit_jain> |
| Component: | New Bugs | Assignee: | Alex Christensen <achristensen> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | achristensen, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
ankshit
When WebTransportError is constructed with a single options object argument, the object is incorrectly interpreted as the message parameter and stringified to "[object Object]", rather than being recognized as the options dictionary.
```
// Fail
const e1 = new WebTransportError({ streamErrorCode: 42 });
console.log(e1.streamErrorCode); // null (expected: 42)
console.log(e1.message); // "[object Object]" (expected: "")
// Pass
const e2 = new WebTransportError('test error', { streamErrorCode: 42 });
console.log(e2.streamErrorCode); // 42 (expected: 42)
console.log(e2.message); // "test error" (expected: "test error")
```
The IDL interface correctly marks both arguments as optional:
```
interface WebTransportError : DOMException {
constructor(optional DOMString message = "", optional WebTransportErrorOptions options = {});
readonly attribute WebTransportErrorSource source;
readonly attribute unsigned long? streamErrorCode;
};
```
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alex Christensen
This seems to be an issue with the generated JSWebTransportErrorDOMConstructor::construct. I'm not sure if we have other functions with multiple optional arguments of different types, but it should try to line up the types.
Radar WebKit Bug Importer
<rdar://problem/167662230>
Alex Christensen
Pull request: https://github.com/WebKit/WebKit/pull/56176
EWS
Committed 305306@main (d6cbf74934a6): <https://commits.webkit.org/305306@main>
Reviewed commits have been landed. Closing PR #56176 and removing active labels.