[whatwg/xhr] Wrong algorithm + missing realm argument when creating ArrayBuffer (Issue #376)

In the [getter steps](https://xhr.spec.whatwg.org/#the-response-attribute) for the `response` attribute of the `XMLHTTPRequest` interface —

> 5. 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”](https://webidl.spec.whatwg.org/#new) 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”](https://webidl.spec.whatwg.org/#arraybuffer-create) instead.

Note that both of those algorithms also expect a realm argument, which is missing. Presumably it should be passing the [relevant realm](https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm) of [this](https://webidl.spec.whatwg.org/#this).

(Issue discovered by @twiss when [correcting ArrayBuffer usage in WebCrypto algorithms](https://github.com/w3c/webcrypto/pull/347#discussion_r1236440541).)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/issues/376
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/xhr/issues/376@github.com>

Received on Wednesday, 21 June 2023 08:32:13 UTC