mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #9294 - KiChjang:xhr-usvstring, r=nox
Change all DOMStrings to USV strings for XHR This is in compliance with the new spec [here](https://xhr.spec.whatwg.org/#xmlhttprequest). <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9294) <!-- Reviewable:end -->
This commit is contained in:
commit
7ae16c7ea3
4 changed files with 28 additions and 28 deletions
|
@ -37,16 +37,15 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
const unsigned short HEADERS_RECEIVED = 2;
|
const unsigned short HEADERS_RECEIVED = 2;
|
||||||
const unsigned short LOADING = 3;
|
const unsigned short LOADING = 3;
|
||||||
const unsigned short DONE = 4;
|
const unsigned short DONE = 4;
|
||||||
|
|
||||||
readonly attribute unsigned short readyState;
|
readonly attribute unsigned short readyState;
|
||||||
|
|
||||||
// request
|
// request
|
||||||
[Throws]
|
[Throws]
|
||||||
void open(ByteString method, /* [EnsureUTF16] */ DOMString url);
|
void open(ByteString method, USVString url);
|
||||||
[Throws]
|
[Throws]
|
||||||
void open(ByteString method, /* [EnsureUTF16] */ DOMString url, boolean async,
|
void open(ByteString method, USVString url, boolean async,
|
||||||
optional /* [EnsureUTF16] */ DOMString? username = null,
|
optional USVString? username = null,
|
||||||
optional /* [EnsureUTF16] */ DOMString? password = null);
|
optional USVString? password = null);
|
||||||
|
|
||||||
[Throws]
|
[Throws]
|
||||||
void setRequestHeader(ByteString name, ByteString value);
|
void setRequestHeader(ByteString name, ByteString value);
|
||||||
|
@ -60,7 +59,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
// response
|
// response
|
||||||
readonly attribute DOMString responseURL;
|
readonly attribute USVString responseURL;
|
||||||
readonly attribute unsigned short status;
|
readonly attribute unsigned short status;
|
||||||
readonly attribute ByteString statusText;
|
readonly attribute ByteString statusText;
|
||||||
ByteString? getResponseHeader(ByteString name);
|
ByteString? getResponseHeader(ByteString name);
|
||||||
|
@ -71,7 +70,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
attribute XMLHttpRequestResponseType responseType;
|
attribute XMLHttpRequestResponseType responseType;
|
||||||
readonly attribute any response;
|
readonly attribute any response;
|
||||||
[Throws]
|
[Throws]
|
||||||
readonly attribute DOMString responseText;
|
readonly attribute USVString responseText;
|
||||||
[Throws]
|
[Throws]
|
||||||
/*[Exposed=Window]*/ readonly attribute Document? responseXML;
|
/*[Exposed=Window]*/ readonly attribute Document? responseXML;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ use dom::bindings::js::{JS, MutNullableHeap};
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::str::ByteString;
|
use dom::bindings::str::{ByteString, USVString};
|
||||||
use dom::document::DocumentSource;
|
use dom::document::DocumentSource;
|
||||||
use dom::document::{Document, IsHTMLDocument};
|
use dom::document::{Document, IsHTMLDocument};
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
@ -118,7 +118,7 @@ pub struct XMLHttpRequest {
|
||||||
timeout: Cell<u32>,
|
timeout: Cell<u32>,
|
||||||
with_credentials: Cell<bool>,
|
with_credentials: Cell<bool>,
|
||||||
upload: JS<XMLHttpRequestUpload>,
|
upload: JS<XMLHttpRequestUpload>,
|
||||||
response_url: DOMString,
|
response_url: String,
|
||||||
status: Cell<u16>,
|
status: Cell<u16>,
|
||||||
status_text: DOMRefCell<ByteString>,
|
status_text: DOMRefCell<ByteString>,
|
||||||
response: DOMRefCell<ByteString>,
|
response: DOMRefCell<ByteString>,
|
||||||
|
@ -155,7 +155,7 @@ impl XMLHttpRequest {
|
||||||
timeout: Cell::new(0u32),
|
timeout: Cell::new(0u32),
|
||||||
with_credentials: Cell::new(false),
|
with_credentials: Cell::new(false),
|
||||||
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
|
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
|
||||||
response_url: DOMString::new(),
|
response_url: String::from(""),
|
||||||
status: Cell::new(0),
|
status: Cell::new(0),
|
||||||
status_text: DOMRefCell::new(ByteString::new(vec!())),
|
status_text: DOMRefCell::new(ByteString::new(vec!())),
|
||||||
response: DOMRefCell::new(ByteString::new(vec!())),
|
response: DOMRefCell::new(ByteString::new(vec!())),
|
||||||
|
@ -293,7 +293,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-open()-method
|
// https://xhr.spec.whatwg.org/#the-open()-method
|
||||||
fn Open(&self, method: ByteString, url: DOMString) -> ErrorResult {
|
fn Open(&self, method: ByteString, url: USVString) -> ErrorResult {
|
||||||
//FIXME(seanmonstar): use a Trie instead?
|
//FIXME(seanmonstar): use a Trie instead?
|
||||||
let maybe_method = method.as_str().and_then(|s| {
|
let maybe_method = method.as_str().and_then(|s| {
|
||||||
// Note: hyper tests against the uppercase versions
|
// Note: hyper tests against the uppercase versions
|
||||||
|
@ -324,7 +324,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
|
|
||||||
// Step 6
|
// Step 6
|
||||||
let base = self.global().r().get_url();
|
let base = self.global().r().get_url();
|
||||||
let parsed_url = match base.join(&url) {
|
let parsed_url = match base.join(&url.0) {
|
||||||
Ok(parsed) => parsed,
|
Ok(parsed) => parsed,
|
||||||
Err(_) => return Err(Error::Syntax) // Step 7
|
Err(_) => return Err(Error::Syntax) // Step 7
|
||||||
};
|
};
|
||||||
|
@ -358,8 +358,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-open()-method
|
// https://xhr.spec.whatwg.org/#the-open()-method
|
||||||
fn Open_(&self, method: ByteString, url: DOMString, async: bool,
|
fn Open_(&self, method: ByteString, url: USVString, async: bool,
|
||||||
_username: Option<DOMString>, _password: Option<DOMString>) -> ErrorResult {
|
_username: Option<USVString>, _password: Option<USVString>) -> ErrorResult {
|
||||||
self.sync.set(!async);
|
self.sync.set(!async);
|
||||||
self.Open(method, url)
|
self.Open(method, url)
|
||||||
}
|
}
|
||||||
|
@ -634,8 +634,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
||||||
fn ResponseURL(&self) -> DOMString {
|
fn ResponseURL(&self) -> USVString {
|
||||||
self.response_url.clone()
|
USVString(self.response_url.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-status-attribute
|
// https://xhr.spec.whatwg.org/#the-status-attribute
|
||||||
|
@ -745,13 +745,13 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#the-responsetext-attribute
|
// https://xhr.spec.whatwg.org/#the-responsetext-attribute
|
||||||
fn GetResponseText(&self) -> Fallible<DOMString> {
|
fn GetResponseText(&self) -> Fallible<USVString> {
|
||||||
match self.response_type.get() {
|
match self.response_type.get() {
|
||||||
_empty | Text => {
|
_empty | Text => {
|
||||||
Ok(DOMString::from(match self.ready_state.get() {
|
Ok(USVString(String::from(match self.ready_state.get() {
|
||||||
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => self.text_response(),
|
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => self.text_response(),
|
||||||
_ => "".to_owned()
|
_ => "".to_owned()
|
||||||
}))
|
})))
|
||||||
},
|
},
|
||||||
_ => Err(Error::InvalidState)
|
_ => Err(Error::InvalidState)
|
||||||
}
|
}
|
||||||
|
@ -1110,7 +1110,7 @@ impl XMLHttpRequest {
|
||||||
let doc = doc.r();
|
let doc = doc.r();
|
||||||
let docloader = DocumentLoader::new(&*doc.loader());
|
let docloader = DocumentLoader::new(&*doc.loader());
|
||||||
let base = self.global().r().get_url();
|
let base = self.global().r().get_url();
|
||||||
let parsed_url = match base.join(&self.ResponseURL()) {
|
let parsed_url = match base.join(&self.ResponseURL().0) {
|
||||||
Ok(parsed) => Some(parsed),
|
Ok(parsed) => Some(parsed),
|
||||||
Err(_) => None // Step 7
|
Err(_) => None // Step 7
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[open-url-encoding.htm]
|
|
||||||
type: testharness
|
|
||||||
[XMLHttpRequest: open() - URL encoding]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -12,10 +12,16 @@
|
||||||
<script>
|
<script>
|
||||||
test(function() {
|
test(function() {
|
||||||
var client = new XMLHttpRequest()
|
var client = new XMLHttpRequest()
|
||||||
client.open("GET", "resources/content.py?ß", false)
|
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
||||||
client.send(null)
|
client.send()
|
||||||
assert_equals(client.getResponseHeader("x-request-query"), "%C3%9F")
|
assert_equals(client.getResponseHeader("x-request-query"), "%C3%9F")
|
||||||
})
|
}, "percent encode characters");
|
||||||
|
test(function() {
|
||||||
|
var client = new XMLHttpRequest()
|
||||||
|
client.open("GET", "resources/content.py?\uD83D", false)
|
||||||
|
client.send()
|
||||||
|
assert_equals(client.getResponseHeader("x-request-query"), "%EF%BF%BD")
|
||||||
|
}, "lone surrogate should return U+FFFD");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue