whatwg / xhr

XMLHttpRequest Standard
https://xhr.spec.whatwg.org/
Other
314 stars 129 forks source link

Wrong algorithm + missing realm argument when creating ArrayBuffer #376

Open bathos opened 1 year ago

bathos commented 1 year ago

In the getter steps for the response attribute of the XMLHTTPRequest interface —

  1. If this’s response type is "arraybuffer", then set this’s response object to a new ArrayBuffer object representing this’s received bytes. If this throws an exception, then set this’s response object to failure and return null.

— the word “new” links to “create a new object implementing the interface” in Web IDL. However ArrayBuffer isn’t an interface and that algorithm doesn’t make sense with it. It looks like it should be calling “create an ArrayBuffer” instead.

Note that both of those algorithms also expect a realm argument, which is missing. Presumably it should be passing the relevant realm of this.

(Issue discovered by @twiss when correcting ArrayBuffer usage in WebCrypto algorithms.)