Open Bug 1404425 Opened 7 years ago Updated 2 years ago

On error, XMLHttpRequest returns status !== 0 and response !== null

Categories

(Core :: DOM: Core & HTML, defect, P3)

56 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: CoolCmd, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0
Build ID: 20170926190823

Steps to reproduce:

Navigate to https://jsfiddle.net/CoolCmd/m4k92q9h/
Replace https://blablabla with URL to big HTTPS CORS file. I do not have such URL.

After 1 second, the "timeout" event handler (OnEvent) will be called.


Actual results:

Press F12 to open console.

xhr.status === 200
xhr.response ===  zero-length ArrayBuffer

I think, the "error" event also has these values.


Expected results:

according to specification,
xhr.status === 0
xhr.response ===  null
Version: 55 Branch → 56 Branch
My best interpretation of https://xhr.spec.whatwg.org/#request-error-steps is that response isn't null. Shawn, is my read right, mind confirming the expected results for status and response?
Flags: needinfo?(shuang)
Priority: -- → P3
Assignee: nobody → shuang
Flags: needinfo?(shuang)

I just tried the test-case with https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_30mb.mp4 as the file, and this was what it logged on today's nightly:

event=timeout, readyState=4, status=0, statusText="", response=ArrayBuffer { byteLength: 0 }

So I think the only issue here is that the response should be null, according to the XHR spec:

The request error steps for event event and optionally an exception exception are:
  3. Set response to a network error.

Where network errors are defined in the Fetch spec as:

A network error is a response whose status is always 0, status message is always the empty byte sequence,
header list is always empty, body is always null, and trailer is always empty. 

Chrome is indeed setting response=null, rather than an empty arraybuffer.

I wonder if the web platform tests are not covering these details yet...

Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.