Fix URL attributes

URL attributes should always use AttrValue::Url, and the input should be
resolved against the document's base URL at setting time always.
This commit is contained in:
Anthony Ramine 2017-10-10 16:14:40 +02:00
parent 826352ab4c
commit 605c679fee
11 changed files with 75 additions and 47 deletions

View file

@ -568,14 +568,10 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> Er
impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn Src(&self) -> DOMString {
self.upcast::<Element>().get_string_attribute(&local_name!("src"))
}
make_url_getter!(Src, "src");
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn SetSrc(&self, src: DOMString) {
self.upcast::<Element>().set_url_attribute(&local_name!("src"), src)
}
make_url_setter!(SetSrc, "src");
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
fn Sandbox(&self) -> DomRoot<DOMTokenList> {
@ -765,6 +761,7 @@ impl VirtualMethods for HTMLIFrameElement {
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
&local_name!("src") => AttrValue::from_url(document_from_node(self).base_url(), value.into()),
&local_name!("sandbox") => AttrValue::from_serialized_tokenlist(value.into()),
&local_name!("width") => AttrValue::from_dimension(value.into()),
&local_name!("height") => AttrValue::from_dimension(value.into()),