Bug 12194 - Trying to access XMLHttpRequest.responseText or responseXML when they are not available should raise an exception
Summary: Trying to access XMLHttpRequest.responseText or responseXML when they are not...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P3 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-10 04:01 PST by Alexey Proskuryakov
Modified: 2007-11-19 04:31 PST (History)
1 user (show)

See Also:


Attachments
Patch + test cases (14.26 KB, patch)
2007-11-15 19:09 PST, Julien Chaffraix
darin: review+
Details | Formatted Diff | Diff
Patches updated with Darin's comments (14.40 KB, patch)
2007-11-17 18:48 PST, Julien Chaffraix
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2007-01-10 04:01:22 PST
From XMLHttpRequest spec draft:

------------------------
responseText of type DOMString, readonly
If the state is not receiving or loaded, the user agent must raise an INVALID_STATE_ERR exception. 
...
responseXML of type Document, readonly
If the state is not loaded, user agents must raise an INVALID_STATE_ERR exception.
------------------------
Comment 1 Julien Chaffraix 2007-11-15 19:09:34 PST
Created attachment 17309 [details]
Patch + test cases

Tested other browsers' behaviour :

IE 7:
raises an exception if readyState is not Loaded in both tests

Firefox:
does not raise any exception in both tests

Opera:
Fully implements the standard.

Judging from the results, I have sided with the specification (which is close to IE behaviour) and fully implemented it.

Patch tested on mac without any regression.
Comment 2 Darin Adler 2007-11-16 20:08:44 PST
Comment on attachment 17309 [details]
Patch + test cases

+            if (responseXML)
                 return toJS(exec, responseXML);
-            return jsNull();
+            else
+                return jsNull();

We normally do *not* do else after return in the WebKit project.

+    if (m_state < Receiving) {
+        ec = INVALID_STATE_ERR;
+    }

We do not put braces around single-line bodies of if statements.

+Should see "PASS" four times:
+
+PASSED
+PASSED
+PASSED
+PASSED

Probably should say "PASSED" or "PASS" consistently.

Change looks good, so I'll say r=me, but it would be nice to fix these minor style issues.
Comment 3 Julien Chaffraix 2007-11-17 18:48:39 PST
Created attachment 17333 [details]
Patches updated with Darin's comments
Comment 4 David Kilzer (:ddkilzer) 2007-11-17 21:21:12 PST
Comment on attachment 17333 [details]
Patches updated with Darin's comments

Please set the "review?" flag, not the "review+" flag.  Thanks!
Comment 5 Darin Adler 2007-11-17 22:50:35 PST
Comment on attachment 17333 [details]
Patches updated with Darin's comments

r=me
Comment 6 Mark Rowe (bdash) 2007-11-19 04:31:19 PST
Landed in r27898.