Closed Bug 707484 Opened 13 years ago Closed 9 years ago

[XHR2] Allow setting XHR responseType and withCredentials before open

Categories

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

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: emk, Assigned: Ms2ger)

References

()

Details

(Keywords: dev-doc-needed)

Attachments

(2 files, 1 obsolete file)

The latest XHR2 spec allows setting responseType and withCredentials in UNSENT or OPENED state.
Summary: Allow setting XHR responseType and withCredentials before send. → Allow setting XHR responseType and withCredentials before open.
Attachment #707601 - Flags: review?(jonas)
Comment on attachment 707601 [details] [diff] [review]
Allow setting XHR.responseType before open()

Review of attachment 707601 [details] [diff] [review]:
-----------------------------------------------------------------

r=me if you also add a test.
Attachment #707601 - Flags: review?(jonas) → review+
HRs were not asynchronous by default. I also added a test.
Attachment #707601 - Attachment is obsolete: true
Attachment #708091 - Flags: review?(jonas)
Comment on attachment 708091 [details] [diff] [review]
Allow setting XHR.responseType before open()

Review of attachment 708091 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with that fixed.

::: content/base/test/test_XHR.html
@@ +90,5 @@
>    try { xhr.responseXML } catch (e) { didthrow = true; }
>    ok(didthrow, "should have thrown when accessing responseXML");
>  }
> +function checkSetResponseTypeThrows(xhr, type, shouldThrow) {
> +  var shouldThrow = shouldThrow === undefined ? true : shouldThrow;

shouldThrow = !!shouldThrow;

@@ +101,3 @@
>  }
> +function checkOpenThrows(xhr, method, url, async, shouldThrow) {
> +  var shouldThrow = shouldThrow === undefined ? true : shouldThrow;

Same

@@ +118,5 @@
> +checkSetResponseTypeThrows(xhr, "moz-chunked-text", false);
> +checkSetResponseTypeThrows(xhr, "moz-chunked-arraybuffer", false);
> +checkOpenThrows(xhr, "GET", "file_XHR_pass2.txt", false, true);
> +checkSetResponseTypeThrows(xhr, "", false);
> +checkOpenThrows(xhr, "GET", "file_XHR_pass2.txt", false, false);

Also add a test that checks that setting the reponseType to something before calling .open() actually works. I.e. that it interprets the response according to the set responseType.
Attachment #708091 - Flags: review?(jonas) → review+
Is it safe to change .responseType in HEADER_RECEIVED state?
yup, that should already work fine.
Summary: Allow setting XHR responseType and withCredentials before open. → [XHR2] Allow setting XHR responseType and withCredentials before open
Tillmann, could you post a new patch with review comments resolved?
Flags: needinfo?(tilkax)
Assignee: nobody → Ms2ger
Status: NEW → ASSIGNED
This is Tillmann's patch rebased to trunk. I removed the 

> checkSetResponseTypeThrows(xhr, "", false);
> checkOpenThrows(xhr, "GET", "file_XHR_pass2.txt", false, false);

bit from the test; it's already covered by the wpt tests. I left the rest in because it also tests proprietary values that the wpt tests can't.
Flags: needinfo?(tilkax)
Attachment #8547725 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/b5bec86469c8
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Tillmann, thanks for the patch!
You need to log in before you can comment on or make changes to this bug.