Auto merge of #8008 - nox:url, r=jdm

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.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8008)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-10-19 14:24:05 -06:00
commit f73cd40282
19 changed files with 395 additions and 254 deletions

View file

@ -4,7 +4,6 @@
use dom::bindings::codegen::Bindings::LocationBinding; use dom::bindings::codegen::Bindings::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
use dom::bindings::error::ErrorResult;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, Root}; use dom::bindings::js::{JS, Root};
use dom::bindings::str::USVString; use dom::bindings::str::USVString;
@ -48,11 +47,11 @@ impl Location {
impl LocationMethods for Location { impl LocationMethods for Location {
// https://html.spec.whatwg.org/multipage/#dom-location-assign // 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 // TODO: per spec, we should use the _API base URL_ specified by the
// _entry settings object_. // _entry settings object_.
let base_url = self.window.get_url(); 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); self.window.load_url(url);
} }
} }
@ -62,111 +61,90 @@ impl LocationMethods for Location {
self.window.load_url(self.get_url()); 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 { fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.get_url()) 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) { fn SetHash(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetHash); 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 { fn Host(&self) -> USVString {
UrlHelper::Host(&self.get_url()) 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) { fn SetHost(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetHost); 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 { fn Hostname(&self) -> USVString {
UrlHelper::Hostname(&self.get_url()) 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) { fn SetHostname(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetHostname); 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 { fn Href(&self) -> USVString {
UrlHelper::Href(&self.get_url()) UrlHelper::Href(&self.get_url())
} }
// https://url.spec.whatwg.org/#dom-urlutils-href // https://html.spec.whatwg.org/multipage/#dom-location-href
fn SetHref(&self, value: USVString) -> ErrorResult { fn SetHref(&self, value: USVString) {
if let Ok(url) = UrlParser::new().base_url(&self.window.get_url()).parse(&value.0) { if let Ok(url) = UrlParser::new().base_url(&self.window.get_url()).parse(&value.0) {
self.window.load_url(url); self.window.load_url(url);
}; }
Ok(())
} }
// https://url.spec.whatwg.org/#dom-urlutils-password // https://html.spec.whatwg.org/multipage/#dom-location-pathname
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
fn Pathname(&self) -> USVString { fn Pathname(&self) -> USVString {
UrlHelper::Pathname(&self.get_url()) 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) { fn SetPathname(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetPathname); 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 { fn Port(&self) -> USVString {
UrlHelper::Port(&self.get_url()) 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) { fn SetPort(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetPort); 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 { fn Protocol(&self) -> USVString {
UrlHelper::Protocol(&self.get_url()) 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) { fn SetProtocol(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetProtocol); 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 { fn Stringifier(&self) -> DOMString {
self.Href().0 self.Href().0
} }
// https://url.spec.whatwg.org/#dom-urlutils-search // https://html.spec.whatwg.org/multipage/#dom-location-search
fn Search(&self) -> USVString { fn Search(&self) -> USVString {
UrlHelper::Search(&self.get_url()) 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) { fn SetSearch(&self, value: USVString) {
self.set_url_component(value, UrlHelper::SetSearch); 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);
}
} }

View file

@ -88,42 +88,42 @@ impl URL {
} }
impl URLMethods for URL { impl URLMethods for URL {
// https://url.spec.whatwg.org/#dom-urlutils-hash // https://url.spec.whatwg.org/#dom-url-hash
fn Hash(&self) -> USVString { fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.url.borrow()) UrlHelper::Hash(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-hash // https://url.spec.whatwg.org/#dom-url-hash
fn SetHash(&self, value: USVString) { fn SetHash(&self, value: USVString) {
UrlHelper::SetHash(&mut self.url.borrow_mut(), value); UrlHelper::SetHash(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-host // https://url.spec.whatwg.org/#dom-url-host
fn Host(&self) -> USVString { fn Host(&self) -> USVString {
UrlHelper::Host(&self.url.borrow()) UrlHelper::Host(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-host // https://url.spec.whatwg.org/#dom-url-host
fn SetHost(&self, value: USVString) { fn SetHost(&self, value: USVString) {
UrlHelper::SetHost(&mut self.url.borrow_mut(), value); UrlHelper::SetHost(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-hostname // https://url.spec.whatwg.org/#dom-url-hostname
fn Hostname(&self) -> USVString { fn Hostname(&self) -> USVString {
UrlHelper::Hostname(&self.url.borrow()) UrlHelper::Hostname(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-hostname // https://url.spec.whatwg.org/#dom-url-hostname
fn SetHostname(&self, value: USVString) { fn SetHostname(&self, value: USVString) {
UrlHelper::SetHostname(&mut self.url.borrow_mut(), value); UrlHelper::SetHostname(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-href // https://url.spec.whatwg.org/#dom-url-href
fn Href(&self) -> USVString { fn Href(&self) -> USVString {
UrlHelper::Href(&self.url.borrow()) UrlHelper::Href(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-href // https://url.spec.whatwg.org/#dom-url-href
fn SetHref(&self, value: USVString) -> ErrorResult { fn SetHref(&self, value: USVString) -> ErrorResult {
match parse_with_base(value, self.base.as_ref()) { match parse_with_base(value, self.base.as_ref()) {
Ok(url) => { Ok(url) => {
@ -136,67 +136,67 @@ impl URLMethods for URL {
} }
} }
// https://url.spec.whatwg.org/#dom-urlutils-password // https://url.spec.whatwg.org/#dom-url-password
fn Password(&self) -> USVString { fn Password(&self) -> USVString {
UrlHelper::Password(&self.url.borrow()) UrlHelper::Password(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-password // https://url.spec.whatwg.org/#dom-url-password
fn SetPassword(&self, value: USVString) { fn SetPassword(&self, value: USVString) {
UrlHelper::SetPassword(&mut self.url.borrow_mut(), value); UrlHelper::SetPassword(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname // https://url.spec.whatwg.org/#dom-url-pathname
fn Pathname(&self) -> USVString { fn Pathname(&self) -> USVString {
UrlHelper::Pathname(&self.url.borrow()) UrlHelper::Pathname(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname // https://url.spec.whatwg.org/#dom-url-pathname
fn SetPathname(&self, value: USVString) { fn SetPathname(&self, value: USVString) {
UrlHelper::SetPathname(&mut self.url.borrow_mut(), value); UrlHelper::SetPathname(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-port // https://url.spec.whatwg.org/#dom-url-port
fn Port(&self) -> USVString { fn Port(&self) -> USVString {
UrlHelper::Port(&self.url.borrow()) UrlHelper::Port(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-port // https://url.spec.whatwg.org/#dom-url-port
fn SetPort(&self, value: USVString) { fn SetPort(&self, value: USVString) {
UrlHelper::SetPort(&mut self.url.borrow_mut(), value); UrlHelper::SetPort(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-protocol // https://url.spec.whatwg.org/#dom-url-protocol
fn Protocol(&self) -> USVString { fn Protocol(&self) -> USVString {
UrlHelper::Protocol(&self.url.borrow()) UrlHelper::Protocol(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-protocol // https://url.spec.whatwg.org/#dom-url-protocol
fn SetProtocol(&self, value: USVString) { fn SetProtocol(&self, value: USVString) {
UrlHelper::SetProtocol(&mut self.url.borrow_mut(), value); UrlHelper::SetProtocol(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#dom-urlutils-search // https://url.spec.whatwg.org/#dom-url-search
fn Search(&self) -> USVString { fn Search(&self) -> USVString {
UrlHelper::Search(&self.url.borrow()) UrlHelper::Search(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-search // https://url.spec.whatwg.org/#dom-url-search
fn SetSearch(&self, value: USVString) { fn SetSearch(&self, value: USVString) {
UrlHelper::SetSearch(&mut self.url.borrow_mut(), value); UrlHelper::SetSearch(&mut self.url.borrow_mut(), value);
} }
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior // https://url.spec.whatwg.org/#dom-url-href
fn Stringifier(&self) -> DOMString { fn Stringifier(&self) -> DOMString {
self.Href().0 self.Href().0
} }
// https://url.spec.whatwg.org/#dom-urlutils-username // https://url.spec.whatwg.org/#dom-url-username
fn Username(&self) -> USVString { fn Username(&self) -> USVString {
UrlHelper::Username(&self.url.borrow()) UrlHelper::Username(&self.url.borrow())
} }
// https://url.spec.whatwg.org/#dom-urlutils-username // https://url.spec.whatwg.org/#dom-url-username
fn SetUsername(&self, value: USVString) { fn SetUsername(&self, value: USVString) {
UrlHelper::SetUsername(&mut self.url.borrow_mut(), value); UrlHelper::SetUsername(&mut self.url.borrow_mut(), value);
} }

View file

@ -12,7 +12,6 @@ use url::{SchemeData, Url, UrlParser};
pub struct UrlHelper; pub struct UrlHelper;
impl UrlHelper { impl UrlHelper {
// https://url.spec.whatwg.org/#dom-urlutils-hash
pub fn Hash(url: &Url) -> USVString { pub fn Hash(url: &Url) -> USVString {
USVString(match url.fragment { USVString(match url.fragment {
None => "".to_owned(), None => "".to_owned(),
@ -21,13 +20,11 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-hash
pub fn SetHash(url: &mut Url, value: USVString) { pub fn SetHash(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_fragment(&value.0); let _ = wrapper.set_fragment(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-host
pub fn Host(url: &Url) -> USVString { pub fn Host(url: &Url) -> USVString {
USVString(match url.scheme_data { USVString(match url.scheme_data {
SchemeData::NonRelative(..) => "".to_owned(), SchemeData::NonRelative(..) => "".to_owned(),
@ -41,40 +38,33 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-host
pub fn SetHost(url: &mut Url, value: USVString) { pub fn SetHost(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_host(&value.0); let _ = wrapper.set_host(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-hostname
pub fn Hostname(url: &Url) -> USVString { pub fn Hostname(url: &Url) -> USVString {
USVString(url.serialize_host().unwrap_or_else(|| "".to_owned())) USVString(url.serialize_host().unwrap_or_else(|| "".to_owned()))
} }
// https://url.spec.whatwg.org/#dom-urlutils-hostname
pub fn SetHostname(url: &mut Url, value: USVString) { pub fn SetHostname(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_host_and_port(&value.0); let _ = wrapper.set_host_and_port(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-href
pub fn Href(url: &Url) -> USVString { pub fn Href(url: &Url) -> USVString {
USVString(url.serialize()) USVString(url.serialize())
} }
// https://url.spec.whatwg.org/#dom-urlutils-password
pub fn Password(url: &Url) -> USVString { pub fn Password(url: &Url) -> USVString {
USVString(url.password().unwrap_or("").to_owned()) USVString(url.password().unwrap_or("").to_owned())
} }
// https://url.spec.whatwg.org/#dom-urlutils-password
pub fn SetPassword(url: &mut Url, value: USVString) { pub fn SetPassword(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_password(&value.0); let _ = wrapper.set_password(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname
pub fn Pathname(url: &Url) -> USVString { pub fn Pathname(url: &Url) -> USVString {
USVString(match url.scheme_data { USVString(match url.scheme_data {
SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(), SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(),
@ -82,13 +72,11 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname
pub fn SetPathname(url: &mut Url, value: USVString) { pub fn SetPathname(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_path(&value.0); let _ = wrapper.set_path(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-port
pub fn Port(url: &Url) -> USVString { pub fn Port(url: &Url) -> USVString {
USVString(match url.port() { USVString(match url.port() {
None => "".to_owned(), None => "".to_owned(),
@ -96,18 +84,15 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-port
pub fn SetPort(url: &mut Url, value: USVString) { pub fn SetPort(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_port(&value.0); let _ = wrapper.set_port(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-protocol
pub fn Protocol(url: &Url) -> USVString { pub fn Protocol(url: &Url) -> USVString {
USVString(format!("{}:", url.scheme.clone())) USVString(format!("{}:", url.scheme.clone()))
} }
// https://url.spec.whatwg.org/#dom-urlutils-protocol
pub fn SetProtocol(url: &mut Url, value: USVString) { pub fn SetProtocol(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_scheme(&value.0); let _ = wrapper.set_scheme(&value.0);
@ -127,7 +112,6 @@ impl UrlHelper {
true true
} }
// https://url.spec.whatwg.org/#dom-urlutils-search
pub fn Search(url: &Url) -> USVString { pub fn Search(url: &Url) -> USVString {
USVString(match url.query { USVString(match url.query {
None => "".to_owned(), None => "".to_owned(),
@ -136,18 +120,15 @@ impl UrlHelper {
}) })
} }
// https://url.spec.whatwg.org/#dom-urlutils-search
pub fn SetSearch(url: &mut Url, value: USVString) { pub fn SetSearch(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_query(&value.0); let _ = wrapper.set_query(&value.0);
} }
// https://url.spec.whatwg.org/#dom-urlutils-username
pub fn Username(url: &Url) -> USVString { pub fn Username(url: &Url) -> USVString {
USVString(url.username().unwrap_or("").to_owned()) USVString(url.username().unwrap_or("").to_owned())
} }
// https://url.spec.whatwg.org/#dom-urlutils-username
pub fn SetUsername(url: &mut Url, value: USVString) { pub fn SetUsername(url: &mut Url, value: USVString) {
let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() };
let _ = wrapper.set_username(&value.0); let _ = wrapper.set_username(&value.0);

View file

@ -26,7 +26,7 @@ interface HTMLAnchorElement : HTMLElement {
// also has obsolete members // also has obsolete members
}; };
//HTMLAnchorElement implements URLUtils; //HTMLAnchorElement implements HTMLHyperlinkElementUtils;
// https://html.spec.whatwg.org/multipage/#HTMLAnchorElement-partial // https://html.spec.whatwg.org/multipage/#HTMLAnchorElement-partial
partial interface HTMLAnchorElement { partial interface HTMLAnchorElement {

View file

@ -13,12 +13,9 @@ interface HTMLAreaElement : HTMLElement {
//[PutForwards=value] attribute DOMSettableTokenList ping; //[PutForwards=value] attribute DOMSettableTokenList ping;
// attribute DOMString rel; // attribute DOMString rel;
readonly attribute DOMTokenList relList; readonly attribute DOMTokenList relList;
// attribute DOMString hreflang; // hreflang and type are not reflected
// attribute DOMString type;
// also has obsolete members
}; };
//HTMLAreaElement implements URLUtils; //HTMLAreaElement implements HTMLHyperlinkElementUtils;
// https://html.spec.whatwg.org/multipage/#HTMLAreaElement-partial // https://html.spec.whatwg.org/multipage/#HTMLAreaElement-partial
partial interface HTMLAreaElement { partial interface HTMLAreaElement {

View file

@ -0,0 +1,20 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#htmlhyperlinkelementutils
//[NoInterfaceObject/*, Exposed=Window*/]
//interface HTMLHyperlinkElementUtils {
// stringifier attribute USVString href;
// attribute USVString origin;
// attribute USVString protocol;
// attribute USVString username;
// attribute USVString password;
// attribute USVString host;
// attribute USVString hostname;
// attribute USVString port;
// attribute USVString pathname;
// attribute USVString search;
// attribute USVString hash;
//};

View file

@ -5,8 +5,24 @@
// https://html.spec.whatwg.org/multipage/#location // https://html.spec.whatwg.org/multipage/#location
/*[Unforgeable]*/ interface Location { /*[Unforgeable]*/ interface Location {
void assign(DOMString url); /*stringifier*/ attribute USVString href;
//void replace(DOMString url); // attribute USVString origin;
attribute USVString protocol;
attribute USVString host;
attribute USVString hostname;
attribute USVString port;
attribute USVString pathname;
attribute USVString search;
attribute USVString hash;
void assign(USVString url);
//void replace(USVString url);
void reload(); void reload();
//[SameObject] readonly attribute USVString[] ancestorOrigins;
// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
}; };
Location implements URLUtils;

View file

@ -8,5 +8,23 @@
interface URL { interface URL {
static USVString domainToASCII(USVString domain); static USVString domainToASCII(USVString domain);
// static USVString domainToUnicode(USVString domain); // static USVString domainToUnicode(USVString domain);
[SetterThrows]
/*stringifier*/ attribute USVString href;
// readonly attribute USVString origin;
attribute USVString protocol;
attribute USVString username;
attribute USVString password;
attribute USVString host;
attribute USVString hostname;
attribute USVString port;
attribute USVString pathname;
attribute USVString search;
// readonly attribute URLSearchParams searchParams;
attribute USVString hash;
// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
}; };
URL implements URLUtils;

View file

@ -7,7 +7,7 @@
* https://url.spec.whatwg.org/#interface-urlsearchparams * https://url.spec.whatwg.org/#interface-urlsearchparams
*/ */
[Constructor(optional (DOMString or URLSearchParams) init)] [Constructor(optional (DOMString or URLSearchParams) init/* = ""*/)]
interface URLSearchParams { interface URLSearchParams {
void append(DOMString name, DOMString value); void append(DOMString name, DOMString value);
void delete(DOMString name); void delete(DOMString name);
@ -15,5 +15,7 @@ interface URLSearchParams {
// sequence<DOMString> getAll(DOMString name); // sequence<DOMString> getAll(DOMString name);
boolean has(DOMString name); boolean has(DOMString name);
void set(DOMString name, DOMString value); void set(DOMString name, DOMString value);
// iterable<USVString, USVString>;
stringifier; stringifier;
}; };

View file

@ -1,28 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://url.spec.whatwg.org/#urlutils
[NoInterfaceObject]
interface URLUtils {
//stringifier attribute USVString href;
[SetterThrows]
attribute USVString href;
//readonly attribute USVString origin;
attribute USVString protocol;
attribute USVString username;
attribute USVString password;
attribute USVString host;
attribute USVString hostname;
attribute USVString port;
attribute USVString pathname;
attribute USVString search;
// attribute URLSearchParams searchParams;
attribute USVString hash;
// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
};

View file

@ -1,26 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://url.spec.whatwg.org/#urlutilsreadonly
[NoInterfaceObject/*,
Exposed=(Window,Worker)*/]
interface URLUtilsReadOnly {
//stringifier readonly attribute USVString href;
readonly attribute USVString href;
//readonly attribute USVString origin;
readonly attribute USVString protocol;
readonly attribute USVString host;
readonly attribute USVString hostname;
readonly attribute USVString port;
readonly attribute USVString pathname;
readonly attribute USVString search;
readonly attribute USVString hash;
// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
};

View file

@ -5,5 +5,19 @@
// https://html.spec.whatwg.org/multipage/#worker-locations // https://html.spec.whatwg.org/multipage/#worker-locations
//[Exposed=Worker] //[Exposed=Worker]
interface WorkerLocation { }; interface WorkerLocation {
WorkerLocation implements URLUtilsReadOnly; /*stringifier*/ readonly attribute USVString href;
// readonly attribute USVString origin;
readonly attribute USVString protocol;
readonly attribute USVString host;
readonly attribute USVString hostname;
readonly attribute USVString port;
readonly attribute USVString pathname;
readonly attribute USVString search;
readonly attribute USVString hash;
// This is only doing as well as gecko right now.
// https://github.com/servo/servo/issues/7590 is on file for
// adding attribute stringifier support.
stringifier;
};

View file

@ -36,47 +36,47 @@ impl WorkerLocation {
} }
impl WorkerLocationMethods for WorkerLocation { impl WorkerLocationMethods for WorkerLocation {
// https://url.spec.whatwg.org/#dom-urlutils-hash // https://html.spec.whatwg.org/multipage/#dom-workerlocation-hash
fn Hash(&self) -> USVString { fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.url) UrlHelper::Hash(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-host // https://html.spec.whatwg.org/multipage/#dom-workerlocation-host
fn Host(&self) -> USVString { fn Host(&self) -> USVString {
UrlHelper::Host(&self.url) UrlHelper::Host(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-hostname // https://html.spec.whatwg.org/multipage/#dom-workerlocation-hostname
fn Hostname(&self) -> USVString { fn Hostname(&self) -> USVString {
UrlHelper::Hostname(&self.url) UrlHelper::Hostname(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-href // https://html.spec.whatwg.org/multipage/#dom-workerlocation-href
fn Href(&self) -> USVString { fn Href(&self) -> USVString {
UrlHelper::Href(&self.url) UrlHelper::Href(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-pathname // https://html.spec.whatwg.org/multipage/#dom-workerlocation-pathname
fn Pathname(&self) -> USVString { fn Pathname(&self) -> USVString {
UrlHelper::Pathname(&self.url) UrlHelper::Pathname(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-port // https://html.spec.whatwg.org/multipage/#dom-workerlocation-port
fn Port(&self) -> USVString { fn Port(&self) -> USVString {
UrlHelper::Port(&self.url) UrlHelper::Port(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-protocol // https://html.spec.whatwg.org/multipage/#dom-workerlocation-protocol
fn Protocol(&self) -> USVString { fn Protocol(&self) -> USVString {
UrlHelper::Protocol(&self.url) UrlHelper::Protocol(&self.url)
} }
// https://url.spec.whatwg.org/#dom-urlutils-search // https://html.spec.whatwg.org/multipage/#dom-workerlocation-search
fn Search(&self) -> USVString { fn Search(&self) -> USVString {
UrlHelper::Search(&self.url) UrlHelper::Search(&self.url)
} }
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior // https://html.spec.whatwg.org/multipage/#dom-workerlocation-href
fn Stringifier(&self) -> DOMString { fn Stringifier(&self) -> DOMString {
self.Href().0 self.Href().0
} }

View file

@ -4395,12 +4395,6 @@
[HTMLAreaElement interface: attribute rel] [HTMLAreaElement interface: attribute rel]
expected: FAIL expected: FAIL
[HTMLAreaElement interface: attribute hreflang]
expected: FAIL
[HTMLAreaElement interface: attribute type]
expected: FAIL
[HTMLAreaElement interface: attribute noHref] [HTMLAreaElement interface: attribute noHref]
expected: FAIL expected: FAIL
@ -4425,12 +4419,6 @@
[HTMLAreaElement interface: document.createElement("area") must inherit property "rel" with the proper type (6)] [HTMLAreaElement interface: document.createElement("area") must inherit property "rel" with the proper type (6)]
expected: FAIL expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "hreflang" with the proper type (8)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "type" with the proper type (9)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "noHref" with the proper type (10)] [HTMLAreaElement interface: document.createElement("area") must inherit property "noHref" with the proper type (10)]
expected: FAIL expected: FAIL
@ -9363,3 +9351,177 @@
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onwaiting" with the proper type (156)] [Document interface: document.implementation.createDocument(null, "", null) must inherit property "onwaiting" with the proper type (156)]
expected: FAIL expected: FAIL
[HTMLAnchorElement interface: attribute href]
expected: FAIL
[HTMLAnchorElement interface: attribute origin]
expected: FAIL
[HTMLAnchorElement interface: attribute protocol]
expected: FAIL
[HTMLAnchorElement interface: attribute username]
expected: FAIL
[HTMLAnchorElement interface: attribute password]
expected: FAIL
[HTMLAnchorElement interface: attribute host]
expected: FAIL
[HTMLAnchorElement interface: attribute hostname]
expected: FAIL
[HTMLAnchorElement interface: attribute port]
expected: FAIL
[HTMLAnchorElement interface: attribute pathname]
expected: FAIL
[HTMLAnchorElement interface: attribute search]
expected: FAIL
[HTMLAnchorElement interface: attribute hash]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "href" with the proper type (13)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "origin" with the proper type (14)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "protocol" with the proper type (15)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "username" with the proper type (16)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "password" with the proper type (17)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "host" with the proper type (18)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "hostname" with the proper type (19)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "port" with the proper type (20)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "pathname" with the proper type (21)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "search" with the proper type (22)]
expected: FAIL
[HTMLAnchorElement interface: document.createElement("a") must inherit property "hash" with the proper type (23)]
expected: FAIL
[HTMLAreaElement interface: attribute href]
expected: FAIL
[HTMLAreaElement interface: attribute origin]
expected: FAIL
[HTMLAreaElement interface: attribute protocol]
expected: FAIL
[HTMLAreaElement interface: attribute username]
expected: FAIL
[HTMLAreaElement interface: attribute password]
expected: FAIL
[HTMLAreaElement interface: attribute host]
expected: FAIL
[HTMLAreaElement interface: attribute hostname]
expected: FAIL
[HTMLAreaElement interface: attribute port]
expected: FAIL
[HTMLAreaElement interface: attribute pathname]
expected: FAIL
[HTMLAreaElement interface: attribute search]
expected: FAIL
[HTMLAreaElement interface: attribute hash]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "noHref" with the proper type (8)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "href" with the proper type (9)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "origin" with the proper type (10)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "protocol" with the proper type (11)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "username" with the proper type (12)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "password" with the proper type (13)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "host" with the proper type (14)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "hostname" with the proper type (15)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "port" with the proper type (16)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "pathname" with the proper type (17)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "search" with the proper type (18)]
expected: FAIL
[HTMLAreaElement interface: document.createElement("area") must inherit property "hash" with the proper type (19)]
expected: FAIL
[Location interface: window.location must have own property "href"]
expected: FAIL
[Location interface: window.location must have own property "origin"]
expected: FAIL
[Location interface: window.location must have own property "protocol"]
expected: FAIL
[Location interface: window.location must have own property "host"]
expected: FAIL
[Location interface: window.location must have own property "hostname"]
expected: FAIL
[Location interface: window.location must have own property "port"]
expected: FAIL
[Location interface: window.location must have own property "pathname"]
expected: FAIL
[Location interface: window.location must have own property "search"]
expected: FAIL
[Location interface: window.location must have own property "hash"]
expected: FAIL
[Location interface: calling assign(USVString) on window.location with too few arguments must throw TypeError]
expected: FAIL
[Location interface: calling replace(USVString) on window.location with too few arguments must throw TypeError]
expected: FAIL
[Location interface: window.location must have own property "ancestorOrigins"]
expected: FAIL
[WorkerLocation interface: attribute origin]
expected: FAIL

View file

@ -15,9 +15,12 @@
[URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12)] [URL interface: new URL("http://foo") must inherit property "searchParams" with the proper type (12)]
expected: FAIL expected: FAIL
[URLSearchParams interface: existence and properties of interface object]
expected: FAIL
[URLSearchParams interface: operation getAll(ScalarValueString)] [URLSearchParams interface: operation getAll(ScalarValueString)]
expected: FAIL expected: FAIL
[URL interface: operation domainToUnicode(USVString)]
expected: FAIL
[URLSearchParams interface: operation getAll(USVString)]
expected: FAIL

View file

@ -141,7 +141,7 @@ var embeddedElements = {
hreflang: "string", hreflang: "string",
type: "string", type: "string",
//URLUtils // HTMLHyperlinkElementUtils
href: "url", href: "url",
// Obsolete // Obsolete

View file

@ -10,7 +10,7 @@ var textElements = {
hreflang: "string", hreflang: "string",
type: "string", type: "string",
// URLUtils // HTMLHyperlinkElementUtils
href: "url", href: "url",
// Obsolete // Obsolete

View file

@ -11,16 +11,6 @@
<h1>HTML IDL tests</h1> <h1>HTML IDL tests</h1>
<div id=log></div> <div id=log></div>
<!-- URLUtils* stubs -->
<script type=text/plain class=untested>
interface URLUtils {
stringifier;
};
interface URLUtilsReadOnly {
stringifier;
};
</script>
<!-- DOM IDLs -->
<script type=text/plain class=untested> <script type=text/plain class=untested>
[Constructor(DOMString type, optional EventInit eventInitDict)/*, [Constructor(DOMString type, optional EventInit eventInitDict)/*,
Exposed=(Window,Worker)*/] Exposed=(Window,Worker)*/]
@ -868,6 +858,21 @@ typedef (Int8Array or Uint8Array or Uint8ClampedArray or
Float32Array or Float64Array or Float32Array or Float64Array or
DataView) ArrayBufferView; DataView) ArrayBufferView;
[NoInterfaceObject, Exposed=Window]
interface HTMLHyperlinkElementUtils {
stringifier attribute USVString href;
attribute USVString origin;
attribute USVString protocol;
attribute USVString username;
attribute USVString password;
attribute USVString host;
attribute USVString hostname;
attribute USVString port;
attribute USVString pathname;
attribute USVString search;
attribute USVString hash;
};
interface HTMLAllCollection : HTMLCollection { interface HTMLAllCollection : HTMLCollection {
// inherits length and 'getter' // inherits length and 'getter'
Element? item(unsigned long index); Element? item(unsigned long index);
@ -1125,19 +1130,17 @@ interface HTMLDivElement : HTMLElement {
}; };
interface HTMLAnchorElement : HTMLElement { interface HTMLAnchorElement : HTMLElement {
attribute DOMString target; attribute DOMString target;
attribute DOMString download; attribute DOMString download;
[PutForwards=value] attribute DOMSettableTokenList ping; [PutForwards=value] readonly attribute DOMSettableTokenList ping;
attribute DOMString rel; attribute DOMString rel;
readonly attribute DOMTokenList relList; readonly attribute DOMTokenList relList;
attribute DOMString hreflang; attribute DOMString hreflang;
attribute DOMString type; attribute DOMString type;
attribute DOMString text; attribute DOMString text;
// also has obsolete members
}; };
HTMLAnchorElement implements URLUtils; HTMLAnchorElement implements HTMLHyperlinkElementUtils;
interface HTMLDataElement : HTMLElement { interface HTMLDataElement : HTMLElement {
attribute DOMString value; attribute DOMString value;
@ -1494,20 +1497,17 @@ interface HTMLMapElement : HTMLElement {
}; };
interface HTMLAreaElement : HTMLElement { interface HTMLAreaElement : HTMLElement {
attribute DOMString alt; attribute DOMString alt;
attribute DOMString coords; attribute DOMString coords;
attribute DOMString shape; attribute DOMString shape;
attribute DOMString target; attribute DOMString target;
attribute DOMString download; attribute DOMString download;
[PutForwards=value] attribute DOMSettableTokenList ping; [PutForwards=value] readonly attribute DOMSettableTokenList ping;
attribute DOMString rel; attribute DOMString rel;
readonly attribute DOMTokenList relList; readonly attribute DOMTokenList relList;
attribute DOMString hreflang; // hreflang and type are not reflected
attribute DOMString type;
// also has obsolete members
}; };
HTMLAreaElement implements URLUtils; HTMLAreaElement implements HTMLHyperlinkElementUtils;
interface HTMLTableElement : HTMLElement { interface HTMLTableElement : HTMLElement {
attribute HTMLTableCaptionElement? caption; attribute HTMLTableCaptionElement? caption;
@ -2320,11 +2320,22 @@ interface History {
}; };
[Unforgeable] interface Location { [Unforgeable] interface Location {
void assign(DOMString url); stringifier attribute USVString href;
void replace(DOMString url); attribute USVString origin;
attribute USVString protocol;
attribute USVString host;
attribute USVString hostname;
attribute USVString port;
attribute USVString pathname;
attribute USVString search;
attribute USVString hash;
void assign(USVString url);
void replace(USVString url);
void reload(); void reload();
[SameObject] readonly attribute USVString[] ancestorOrigins;
}; };
Location implements URLUtils;
[Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=Window,Worker] [Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=Window,Worker]
interface PopStateEvent : Event { interface PopStateEvent : Event {
@ -2816,8 +2827,17 @@ WorkerNavigator implements NavigatorLanguage;
WorkerNavigator implements NavigatorOnLine; WorkerNavigator implements NavigatorOnLine;
[Exposed=Worker] [Exposed=Worker]
interface WorkerLocation { }; interface WorkerLocation {
WorkerLocation implements URLUtilsReadOnly; stringifier readonly attribute USVString href;
readonly attribute USVString origin;
readonly attribute USVString protocol;
readonly attribute USVString host;
readonly attribute USVString hostname;
readonly attribute USVString port;
readonly attribute USVString pathname;
readonly attribute USVString search;
readonly attribute USVString hash;
};
interface Storage { interface Storage {
readonly attribute unsigned long length; readonly attribute unsigned long length;

View file

@ -9,54 +9,38 @@
<div id=log></div> <div id=log></div>
<script type=text/plain> <script type=text/plain>
[Constructor(DOMString url, optional DOMString base = "about:blank"), [Constructor(USVString url, optional USVString base),
Exposed=Window,Worker] Exposed=(Window,Worker)]
interface URL { interface URL {
static DOMString domainToASCII(ScalarValueString domain); static USVString domainToASCII(USVString domain);
static DOMString domainToUnicode(ScalarValueString domain); static USVString domainToUnicode(USVString domain);
};
URL implements URLUtils;
[NoInterfaceObject] stringifier attribute USVString href;
interface URLUtils { readonly attribute USVString origin;
stringifier attribute ScalarValueString href; attribute USVString protocol;
readonly attribute DOMString origin; attribute USVString username;
attribute USVString password;
attribute ScalarValueString protocol; attribute USVString host;
attribute ScalarValueString username; attribute USVString hostname;
attribute ScalarValueString password; attribute USVString port;
attribute ScalarValueString host; attribute USVString pathname;
attribute ScalarValueString hostname; attribute USVString search;
attribute ScalarValueString port; readonly attribute URLSearchParams searchParams;
attribute ScalarValueString pathname; attribute USVString hash;
attribute ScalarValueString search;
readonly attribute URLSearchParams searchParams;
attribute ScalarValueString hash;
}; };
[NoInterfaceObject] [Constructor(optional (USVString or URLSearchParams) init = ""),
interface URLUtilsReadOnly { Exposed=(Window,Worker)]
stringifier readonly attribute DOMString href;
readonly attribute DOMString origin;
readonly attribute DOMString protocol;
readonly attribute DOMString host;
readonly attribute DOMString hostname;
readonly attribute DOMString port;
readonly attribute DOMString pathname;
readonly attribute DOMString search;
readonly attribute DOMString hash;
};
interface URLSearchParams { interface URLSearchParams {
void append(ScalarValueString name, ScalarValueString value); void append(USVString name, USVString value);
void delete(ScalarValueString name); void delete(USVString name);
DOMString? get(ScalarValueString name); USVString? get(USVString name);
sequence<DOMString> getAll(ScalarValueString name); sequence<USVString> getAll(USVString name);
boolean has(ScalarValueString name); boolean has(USVString name);
void set(ScalarValueString name, ScalarValueString value); void set(USVString name, USVString value);
iterable<USVString, USVString>;
stringifier; stringifier;
}; };
typedef DOMString ScalarValueString;
</script> </script>
<script> <script>
"use strict"; "use strict";