Make step 3 of XHR's SetResponseType method match the specification

This commit is contained in:
Tim van der Meij 2016-02-05 23:22:45 +01:00
parent 289232ef61
commit 816c65aab0

View file

@ -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