mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Make step 3 of XHR's SetResponseType method match the specification
This commit is contained in:
parent
289232ef61
commit
816c65aab0
1 changed files with 7 additions and 5 deletions
|
@ -675,19 +675,21 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
// https://xhr.spec.whatwg.org/#the-responsetype-attribute
|
||||||
fn SetResponseType(&self, response_type: XMLHttpRequestResponseType) -> ErrorResult {
|
fn SetResponseType(&self, response_type: XMLHttpRequestResponseType) -> ErrorResult {
|
||||||
match self.global() {
|
match self.global() {
|
||||||
GlobalRoot::Worker(_) if response_type == XMLHttpRequestResponseType::Document
|
GlobalRoot::Worker(_) if response_type == XMLHttpRequestResponseType::Document => return Ok(()),
|
||||||
=> return Ok(()),
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => Err(Error::InvalidState),
|
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => Err(Error::InvalidState),
|
||||||
_ if self.sync.get() => Err(Error::InvalidAccess),
|
|
||||||
_ => {
|
_ => {
|
||||||
|
if let (GlobalRoot::Window(_), true) = (self.global(), self.sync.get()) {
|
||||||
|
Err(Error::InvalidAccess)
|
||||||
|
} else {
|
||||||
self.response_type.set(response_type);
|
self.response_type.set(response_type);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://xhr.spec.whatwg.org/#the-response-attribute
|
// https://xhr.spec.whatwg.org/#the-response-attribute
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue