mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Update URL-related interfaces and their tests up to spec
The URL spec recently changed and the variour "mixins" interfaces are gone, this commit updates our code and WPT accordingly. The new expected failures related to HTMLAnchorElement and HTMLAreaElement's attributes are due to their moving to the HTMLHyperLinkElementUtils interface, which is not anymore in a separate <script class=untested> element.
This commit is contained in:
parent
e0c8a88410
commit
57c423a931
19 changed files with 395 additions and 254 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::LocationBinding;
|
||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::str::USVString;
|
||||
|
@ -48,11 +47,11 @@ impl Location {
|
|||
|
||||
impl LocationMethods for Location {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
||||
fn Assign(&self, url: DOMString) {
|
||||
fn Assign(&self, url: USVString) {
|
||||
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||
// _entry settings object_.
|
||||
let base_url = self.window.get_url();
|
||||
if let Ok(url) = UrlParser::new().base_url(&base_url).parse(&url) {
|
||||
if let Ok(url) = UrlParser::new().base_url(&base_url).parse(&url.0) {
|
||||
self.window.load_url(url);
|
||||
}
|
||||
}
|
||||
|
@ -62,111 +61,90 @@ impl LocationMethods for Location {
|
|||
self.window.load_url(self.get_url());
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hash
|
||||
fn Hash(&self) -> USVString {
|
||||
UrlHelper::Hash(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hash
|
||||
fn SetHash(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetHash);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-host
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-host
|
||||
fn Host(&self) -> USVString {
|
||||
UrlHelper::Host(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-host
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-host
|
||||
fn SetHost(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetHost);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hostname
|
||||
fn Hostname(&self) -> USVString {
|
||||
UrlHelper::Hostname(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-hostname
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hostname
|
||||
fn SetHostname(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetHostname);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
fn Href(&self) -> USVString {
|
||||
UrlHelper::Href(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
||||
fn SetHref(&self, value: USVString) -> ErrorResult {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
fn SetHref(&self, value: USVString) {
|
||||
if let Ok(url) = UrlParser::new().base_url(&self.window.get_url()).parse(&value.0) {
|
||||
self.window.load_url(url);
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-password
|
||||
fn Password(&self) -> USVString {
|
||||
UrlHelper::Password(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-password
|
||||
fn SetPassword(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetPassword);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-pathname
|
||||
fn Pathname(&self) -> USVString {
|
||||
UrlHelper::Pathname(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-pathname
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-pathname
|
||||
fn SetPathname(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetPathname);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-port
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-port
|
||||
fn Port(&self) -> USVString {
|
||||
UrlHelper::Port(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-port
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-port
|
||||
fn SetPort(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetPort);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-protocol
|
||||
fn Protocol(&self) -> USVString {
|
||||
UrlHelper::Protocol(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-protocol
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-protocol
|
||||
fn SetProtocol(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetProtocol);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
fn Stringifier(&self) -> DOMString {
|
||||
self.Href().0
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-search
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-search
|
||||
fn Search(&self) -> USVString {
|
||||
UrlHelper::Search(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-search
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-search
|
||||
fn SetSearch(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetSearch);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-username
|
||||
fn Username(&self) -> USVString {
|
||||
UrlHelper::Username(&self.get_url())
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-username
|
||||
fn SetUsername(&self, value: USVString) {
|
||||
self.set_url_component(value, UrlHelper::SetUsername);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue