mirror of
https://github.com/servo/servo.git
synced 2025-07-31 11:10:22 +01:00
auto merge of #4793 : KiChjang/servo/xhr-cred-check, r=Manishearth
Fixes #4665
This commit is contained in:
commit
755adf0dde
4 changed files with 16 additions and 15 deletions
|
@ -50,6 +50,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
void setRequestHeader(ByteString name, ByteString value);
|
void setRequestHeader(ByteString name, ByteString value);
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
attribute unsigned long timeout;
|
attribute unsigned long timeout;
|
||||||
|
[SetterThrows]
|
||||||
attribute boolean withCredentials;
|
attribute boolean withCredentials;
|
||||||
readonly attribute XMLHttpRequestUpload upload;
|
readonly attribute XMLHttpRequestUpload upload;
|
||||||
[Throws]
|
[Throws]
|
||||||
|
|
|
@ -489,8 +489,21 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
||||||
fn WithCredentials(self) -> bool {
|
fn WithCredentials(self) -> bool {
|
||||||
self.with_credentials.get()
|
self.with_credentials.get()
|
||||||
}
|
}
|
||||||
fn SetWithCredentials(self, with_credentials: bool) {
|
// Spec for SetWithCredentials: https://xhr.spec.whatwg.org/#dom-xmlhttprequest-withcredentials
|
||||||
self.with_credentials.set(with_credentials);
|
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> {
|
fn Upload(self) -> Temporary<XMLHttpRequestUpload> {
|
||||||
Temporary::new(self.upload)
|
Temporary::new(self.upload)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[XMLHttpRequest-withCredentials.html]
|
|
||||||
type: testharness
|
|
||||||
[setting on synchronous XHR]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[setting withCredentials when not in UNSENT, OPENED state]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[XMLHttpRequest-withCredentials.worker]
|
|
||||||
type: testharness
|
|
||||||
[setting withCredentials when not in UNSENT, OPENED state]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue