Skip to content

Commit

Permalink
auto merge of #4793 : KiChjang/servo/xhr-cred-check, r=Manishearth
Browse files Browse the repository at this point in the history
Fixes #4665
  • Loading branch information
bors-servo committed Feb 2, 2015
2 parents 3286d28 + 2093291 commit 755adf0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions components/script/dom/webidls/XMLHttpRequest.webidl
Expand Up @@ -50,6 +50,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
void setRequestHeader(ByteString name, ByteString value);
[SetterThrows]
attribute unsigned long timeout;
[SetterThrows]
attribute boolean withCredentials;
readonly attribute XMLHttpRequestUpload upload;
[Throws]
Expand Down
17 changes: 15 additions & 2 deletions components/script/dom/xmlhttprequest.rs
Expand Up @@ -489,8 +489,21 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
fn WithCredentials(self) -> bool {
self.with_credentials.get()
}
fn SetWithCredentials(self, with_credentials: bool) {
self.with_credentials.set(with_credentials);
// Spec for SetWithCredentials: https://xhr.spec.whatwg.org/#dom-xmlhttprequest-withcredentials
fn SetWithCredentials(self, with_credentials: bool) -> ErrorResult {
match self.ready_state.get() {
XMLHttpRequestState::HeadersReceived |
XMLHttpRequestState::Loading |
XMLHttpRequestState::XHRDone => Err(InvalidState),
_ if self.send_flag.get() => Err(InvalidState),
_ => match self.global.root() {
GlobalRoot::Window(_) if self.sync.get() => Err(InvalidAccess),
_ => {
self.with_credentials.set(with_credentials);
Ok(())
},
},
}
}
fn Upload(self) -> Temporary<XMLHttpRequestUpload> {
Temporary::new(self.upload)
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 755adf0

Please sign in to comment.