mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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 LOADING = 3;
|
||||
const unsigned short DONE = 4;
|
||||
|
||||
readonly attribute unsigned short readyState;
|
||||
|
||||
// request
|
||||
[Throws]
|
||||
void open(ByteString method, /* [EnsureUTF16] */ DOMString url);
|
||||
void open(ByteString method, USVString url);
|
||||
[Throws]
|
||||
void open(ByteString method, /* [EnsureUTF16] */ DOMString url, boolean async,
|
||||
optional /* [EnsureUTF16] */ DOMString? username = null,
|
||||
optional /* [EnsureUTF16] */ DOMString? password = null);
|
||||
void open(ByteString method, USVString url, boolean async,
|
||||
optional USVString? username = null,
|
||||
optional USVString? password = null);
|
||||
|
||||
[Throws]
|
||||
void setRequestHeader(ByteString name, ByteString value);
|
||||
|
@ -60,7 +59,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
void abort();
|
||||
|
||||
// response
|
||||
readonly attribute DOMString responseURL;
|
||||
readonly attribute USVString responseURL;
|
||||
readonly attribute unsigned short status;
|
||||
readonly attribute ByteString statusText;
|
||||
ByteString? getResponseHeader(ByteString name);
|
||||
|
@ -71,7 +70,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
attribute XMLHttpRequestResponseType responseType;
|
||||
readonly attribute any response;
|
||||
[Throws]
|
||||
readonly attribute DOMString responseText;
|
||||
readonly attribute USVString responseText;
|
||||
[Throws]
|
||||
/*[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::refcounted::Trusted;
|
||||
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::{Document, IsHTMLDocument};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
|
@ -118,7 +118,7 @@ pub struct XMLHttpRequest {
|
|||
timeout: Cell<u32>,
|
||||
with_credentials: Cell<bool>,
|
||||
upload: JS<XMLHttpRequestUpload>,
|
||||
response_url: DOMString,
|
||||
response_url: String,
|
||||
status: Cell<u16>,
|
||||
status_text: DOMRefCell<ByteString>,
|
||||
response: DOMRefCell<ByteString>,
|
||||
|
@ -155,7 +155,7 @@ impl XMLHttpRequest {
|
|||
timeout: Cell::new(0u32),
|
||||
with_credentials: Cell::new(false),
|
||||
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
|
||||
response_url: DOMString::new(),
|
||||
response_url: String::from(""),
|
||||
status: Cell::new(0),
|
||||
status_text: 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
|
||||
fn Open(&self, method: ByteString, url: DOMString) -> ErrorResult {
|
||||
fn Open(&self, method: ByteString, url: USVString) -> ErrorResult {
|
||||
//FIXME(seanmonstar): use a Trie instead?
|
||||
let maybe_method = method.as_str().and_then(|s| {
|
||||
// Note: hyper tests against the uppercase versions
|
||||
|
@ -324,7 +324,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
|
||||
// Step 6
|
||||
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,
|
||||
Err(_) => return Err(Error::Syntax) // Step 7
|
||||
};
|
||||
|
@ -358,8 +358,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-open()-method
|
||||
fn Open_(&self, method: ByteString, url: DOMString, async: bool,
|
||||
_username: Option<DOMString>, _password: Option<DOMString>) -> ErrorResult {
|
||||
fn Open_(&self, method: ByteString, url: USVString, async: bool,
|
||||
_username: Option<USVString>, _password: Option<USVString>) -> ErrorResult {
|
||||
self.sync.set(!async);
|
||||
self.Open(method, url)
|
||||
}
|
||||
|
@ -634,8 +634,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-responseurl-attribute
|
||||
fn ResponseURL(&self) -> DOMString {
|
||||
self.response_url.clone()
|
||||
fn ResponseURL(&self) -> USVString {
|
||||
USVString(self.response_url.clone())
|
||||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-status-attribute
|
||||
|
@ -745,13 +745,13 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-responsetext-attribute
|
||||
fn GetResponseText(&self) -> Fallible<DOMString> {
|
||||
fn GetResponseText(&self) -> Fallible<USVString> {
|
||||
match self.response_type.get() {
|
||||
_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(),
|
||||
_ => "".to_owned()
|
||||
}))
|
||||
})))
|
||||
},
|
||||
_ => Err(Error::InvalidState)
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ impl XMLHttpRequest {
|
|||
let doc = doc.r();
|
||||
let docloader = DocumentLoader::new(&*doc.loader());
|
||||
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),
|
||||
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>
|
||||
test(function() {
|
||||
var client = new XMLHttpRequest()
|
||||
client.open("GET", "resources/content.py?ß", false)
|
||||
client.send(null)
|
||||
client.open("GET", "resources/content.py?\u00DF", false) // This is the German "eszett" character
|
||||
client.send()
|
||||
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>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue