diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2016-01-13 11:33:43 -0500 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2016-01-16 08:51:34 -0500 |
commit | a64f832e572c67d6bee6b1e488508678fa64e059 (patch) | |
tree | 7645ef7b992cf897d7dbbc565368d71ae20b2050 | |
parent | c7e86411746d229b1f5d43ca55875f7ddda9145a (diff) | |
download | servo-a64f832e572c67d6bee6b1e488508678fa64e059.tar.gz servo-a64f832e572c67d6bee6b1e488508678fa64e059.zip |
Change all DOMStrings to USV strings for XHR
4 files changed, 28 insertions, 28 deletions
diff --git a/components/script/dom/webidls/XMLHttpRequest.webidl b/components/script/dom/webidls/XMLHttpRequest.webidl index 372627a0eca..4223a13543c 100644 --- a/components/script/dom/webidls/XMLHttpRequest.webidl +++ b/components/script/dom/webidls/XMLHttpRequest.webidl @@ -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; }; diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index f129095bdb4..9802538d5b5 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -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 }; diff --git a/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini b/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini deleted file mode 100644 index f1d83359558..00000000000 --- a/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[open-url-encoding.htm] - type: testharness - [XMLHttpRequest: open() - URL encoding] - expected: FAIL - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-encoding.htm b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-encoding.htm index a545d41b2a9..7acdac86ad6 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-encoding.htm +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-encoding.htm @@ -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> |