aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/xmlhttprequest.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-17 02:44:54 -0600
committerGitHub <noreply@github.com>2016-11-17 02:44:54 -0600
commitf70fc6644ddb142627c188ebbde2cc0a0282f9b4 (patch)
tree35f3592908491db6c55cd55af8068c13086fedfe /components/script/dom/xmlhttprequest.rs
parentefae67ed18d11d599616f1515fe2ce3885491457 (diff)
parentb372e7c98f4148eda720faf343547404e4fd8d61 (diff)
downloadservo-f70fc6644ddb142627c188ebbde2cc0a0282f9b4.tar.gz
servo-f70fc6644ddb142627c188ebbde2cc0a0282f9b4.zip
Auto merge of #14096 - fflorent:11485-make-dom-methods-taking-mut-JSContent-unsafe, r=nox
11485 make dom methods taking mut js content unsafe This is a rebased version of PR #11595 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11485 <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because: no code logic was changed <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14096) <!-- Reviewable:end -->
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