aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/xmlhttprequest.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/xmlhttprequest.rs')
-rw-r--r--components/script/dom/xmlhttprequest.rs70
1 files changed, 34 insertions, 36 deletions
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 57191d1d4e9..de3321451d4 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -760,47 +760,45 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
#[allow(unsafe_code)]
// https://xhr.spec.whatwg.org/#the-response-attribute
- fn Response(&self, cx: *mut JSContext) -> JSVal {
- unsafe {
- rooted!(in(cx) let mut rval = UndefinedValue());
- match self.response_type.get() {
- XMLHttpRequestResponseType::_empty | XMLHttpRequestResponseType::Text => {
- let ready_state = self.ready_state.get();
- // Step 2
- if ready_state == XMLHttpRequestState::Done || ready_state == XMLHttpRequestState::Loading {
- self.text_response().to_jsval(cx, rval.handle_mut());
- } else {
- // Step 1
- "".to_jsval(cx, rval.handle_mut());
- }
- },
+ unsafe fn Response(&self, cx: *mut JSContext) -> JSVal {
+ rooted!(in(cx) let mut rval = UndefinedValue());
+ match self.response_type.get() {
+ XMLHttpRequestResponseType::_empty | XMLHttpRequestResponseType::Text => {
+ let ready_state = self.ready_state.get();
+ // Step 2
+ if ready_state == XMLHttpRequestState::Done || ready_state == XMLHttpRequestState::Loading {
+ self.text_response().to_jsval(cx, rval.handle_mut());
+ } else {
// Step 1
- _ if self.ready_state.get() != XMLHttpRequestState::Done => {
+ "".to_jsval(cx, rval.handle_mut());
+ }
+ },
+ // Step 1
+ _ if self.ready_state.get() != XMLHttpRequestState::Done => {
+ return NullValue();
+ },
+ // Step 2
+ XMLHttpRequestResponseType::Document => {
+ let op_doc = self.document_response();
+ if let Some(doc) = op_doc {
+ doc.to_jsval(cx, rval.handle_mut());
+ } else {
+ // Substep 1
return NullValue();
- },
- // Step 2
- XMLHttpRequestResponseType::Document => {
- let op_doc = self.document_response();
- if let Some(doc) = op_doc {
- doc.to_jsval(cx, rval.handle_mut());
- } else {
- // Substep 1
- return NullValue();
- }
- },
- XMLHttpRequestResponseType::Json => {
- self.json_response(cx).to_jsval(cx, rval.handle_mut());
- },
- XMLHttpRequestResponseType::Blob => {
- self.blob_response().to_jsval(cx, rval.handle_mut());
- },
- _ => {
- // XXXManishearth handle other response types
- self.response.borrow().to_jsval(cx, rval.handle_mut());
}
+ },
+ XMLHttpRequestResponseType::Json => {
+ self.json_response(cx).to_jsval(cx, rval.handle_mut());
+ },
+ XMLHttpRequestResponseType::Blob => {
+ self.blob_response().to_jsval(cx, rval.handle_mut());
+ },
+ _ => {
+ // XXXManishearth handle other response types
+ self.response.borrow().to_jsval(cx, rval.handle_mut());
}
- rval.get()
}
+ rval.get()
}
// https://xhr.spec.whatwg.org/#the-responsetext-attribute