Closed Bug 600111 Opened 14 years ago Closed 12 years ago

XMLHttpRequest.setRequestHeader() throws NS_ERROR_FAILURE inappropriately

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: zwol, Assigned: Ms2ger)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-needed)

Attachments

(1 file, 1 obsolete file)

The W3C spec for XMLHttpRequest (see URL) says that setRequestHeader() is supposed to distinguish two kinds of errors, and doesn't license it to produce any other kind of exception:

# Throws an INVALID_STATE_ERR exception if the state is not OPENED or
# if the send() flag is true.
#
# Throws a SYNTAX_ERR exception if header is not a valid HTTP header 
# field name or if value is not a valid HTTP header field value.

Our implementation uses NS_ERROR_FAILURE for conditions falling under both these heads, and also for some internal, should-never-happen conditions (IsPending() or IsCapabilityEnabled() fails - death to xpcom).  And it can throw NS_ERROR_IN_PROGRESS under conditions that are unclear to me but probably shouldn't be visible to JS.

Also, HttpBaseChannel::SetRequestHeader can throw NS_ERROR_INVALID_ARG for conditions that I think are supposed to be mapped to SYNTAX_ERR in this case, and NS_ERROR_NOT_AVAILABLE for another probably should-never-happen condition (nsHttp::ResolveAtom fails).  And several things can produce NS_ERROR_OUT_OF_MEMORY, but we probably don't need to worry about that.
Component: Networking: HTTP → DOM: Mozilla Extensions
QA Contact: networking.http → general
Hm, if this belongs in DOM:MozillaExtensions then so do a whole bunch of other XMLHttpRequest bugs.
Assignee: nobody → Ms2ger
Status: NEW → ASSIGNED
Attached patch WIP (obsolete) (deleted) — Splinter Review
This needs tests. I think I'll submit them to the official test suite first.
Whiteboard: [needs tests]
Blocks: 704787
Blocks: xhr
Attached patch Patch v1 (deleted) — Splinter Review
Attachment #516677 - Attachment is obsolete: true
Attachment #645527 - Flags: review?(bugs)
Whiteboard: [needs tests]
Attachment #645527 - Flags: review?(bugs) → review?(jonas)
https://hg.mozilla.org/mozilla-central/rev/8426cc6a7875
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Keywords: dev-doc-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
Backed out with the mass tree revert to get rid of the OS X M5 orange:
https://hg.mozilla.org/mozilla-central/rev/c801b99d726f
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
https://hg.mozilla.org/mozilla-central/rev/e5b07db1a574
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: