Closed
Bug 389739
(flock9108)
Opened 18 years ago
Closed 13 years ago
XMLHttpRequest readyState does not define constants
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
DUPLICATE
of bug 649133
mozilla6
People
(Reporter: mattwillis, Unassigned)
Details
Attachments
(1 file, 4 obsolete files)
5.72 KB,
patch
|
Details | Diff | Splinter Review |
The readyState integers for XMLHttpRequest are not defined as constants but are instead listed in a comment in the IDL.
This leads to code like this:
this.req = CC[XMLHTTPREQUEST_CONTRACTID].
createInstance(CI.nsIXMLHttpRequest);
this.req.QueryInterface(CI.nsIJSXMLHttpRequest);
this.req.open("GET", aUrl, true);
var req = this.req;
this.req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
try {
We should move the values from the comments into constants for the readyStates. This makes the code more readable and gets rid of some "magic numbers".
Attachment #274057 -
Flags: review?(bzbarsky)
Reporter | ||
Updated•18 years ago
|
Alias: flock9018
Reporter | ||
Updated•18 years ago
|
Alias: flock9018 → flock9108
Status: NEW → ASSIGNED
![]() |
||
Comment 1•18 years ago
|
||
How does this align with the W3C spec for this stuff?
![]() |
||
Comment 2•18 years ago
|
||
In particular, I'd rather not introduce constants that would not interoperate with other UAs...
Reporter | ||
Comment 3•18 years ago
|
||
Good call. They're named differently than the original comment in the idl. I'll make a new patch using the W3C terms.
See http://www.w3.org/TR/XMLHttpRequest/#xmlhttprequest
Reporter | ||
Comment 4•18 years ago
|
||
Assignee: nobody → lilmatt
Attachment #274057 -
Attachment is obsolete: true
Attachment #274075 -
Flags: review?(bzbarsky)
Attachment #274057 -
Flags: review?(bzbarsky)
Reporter | ||
Comment 5•18 years ago
|
||
Shortens constant names since "XMLHTTPREQUEST" is included in CI.nsIXMLHttpRequest.
Also makes them unsigned shorts
Attachment #274075 -
Attachment is obsolete: true
Attachment #274079 -
Flags: review?(bzbarsky)
Attachment #274075 -
Flags: review?(bzbarsky)
Reporter | ||
Comment 6•18 years ago
|
||
Attachment #274079 -
Attachment is obsolete: true
Attachment #274082 -
Flags: review?(bzbarsky)
Attachment #274079 -
Flags: review?(bzbarsky)
![]() |
||
Comment 7•18 years ago
|
||
Comment on attachment 274082 [details] [diff] [review]
rev3 - Use exact terms from spec per bz
Thanks!
Attachment #274082 -
Flags: superreview+
Attachment #274082 -
Flags: review?(bzbarsky)
Attachment #274082 -
Flags: review+
Updated•18 years ago
|
Flags: in-testsuite?
Reporter | ||
Comment 8•18 years ago
|
||
Attachment #274082 -
Attachment is obsolete: true
Attachment #274109 -
Flags: review?(bzbarsky)
![]() |
||
Comment 9•18 years ago
|
||
Comment on attachment 274109 [details] [diff] [review]
rev4 - Includes missing implementation
Isn't "short" PRUint16? Check the generated header from this IDL?
Reporter | ||
Comment 10•18 years ago
|
||
Comment on attachment 274109 [details] [diff] [review]
rev4 - Includes missing implementation
Removing review request. I will try again after I get sleep.
Attachment #274109 -
Flags: review?(bzbarsky)
Comment 11•18 years ago
|
||
Please note that SENT has been renamed to HEADERS_RECEIVED in the editor's draft: http://dev.w3.org/cvsweb/~checkout~/2006/webapi/XMLHttpRequest/Overview.html?content-type=text/html;%20charset=utf-8
Comment 12•18 years ago
|
||
fantasai told me that OPEN clashed with open() because IDLs are not case-sensitive. I'm not really sure what a better name would be though. READY, maybe?
Reporter | ||
Comment 13•18 years ago
|
||
(In reply to comment #12)
Microsoft previously used "LOADING"
http://msdn2.microsoft.com/en-us/library/ms753800.aspx
however they appear to now follow the draft:
http://msdn2.microsoft.com/en-us/library/ms534361.aspx
Perhaps we could simply prepend "READYSTATE_" to the constants? IMO doing so makes them more readable in code as it explicity indicates these are readyState values.
(ex: "XMLHttpRequest::READYSTATE_OPEN" vs."XMLHttpRequest::OPEN")
Comment 14•18 years ago
|
||
I wouldn't trust Microsoft documentation. It is inaccurate. (Microsoft employees admitted as much which is part of the reason that SENT hsa been renamed to HEADERS_RECEIVED for instance.)
Prepending it with READYSTATE_ is not consistent with similar APIs (such as HTMLMediaElement from HTML 5 or various DOM features) so I would rather not do that. The names should be as concise and accurate as possible, imo.
Comment 15•18 years ago
|
||
Given that all the names except LOADING are past-tense, why not OPENED?
Comment 16•18 years ago
|
||
Cool, UNSENT, OPENED, HEADERS_RECEIVED, LOADING and DONE it is.
Comment 17•18 years ago
|
||
FWIW, the editor's draft mentioned in comment 11 has been updated to reflect this change.
Comment 18•13 years ago
|
||
Was fixed in bug 649133.
Assignee: mattwillis → nobody
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Component: XML → DOM: Mozilla Extensions
QA Contact: xml → general
Resolution: --- → DUPLICATE
Target Milestone: --- → mozilla6
Assignee | ||
Updated•12 years ago
|
Component: DOM: Mozilla Extensions → DOM
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•