Use base_url instead of url when parsing href

spec: https://html.spec.whatwg.org/multipage/infrastructure.html#resolving-urls

This change makes more url parsing tests pass.
This commit is contained in:
Orvar Segerström 2016-06-06 13:19:49 +02:00
parent 1bc94c132e
commit e6b64f0e3c
3 changed files with 1 additions and 169 deletions

View file

@ -64,7 +64,7 @@ impl HTMLAnchorElement {
let attribute = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href")); let attribute = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href"));
*self.url.borrow_mut() = attribute.and_then(|attribute| { *self.url.borrow_mut() = attribute.and_then(|attribute| {
let document = document_from_node(self); let document = document_from_node(self);
document.url().join(&attribute.value()).ok() document.base_url().join(&attribute.value()).ok()
}); });
} }

View file

@ -246,39 +246,6 @@
[Parsing: <data:text/html,test#test> against <http://example.org/foo/bar>] [Parsing: <data:text/html,test#test> against <http://example.org/foo/bar>]
expected: FAIL expected: FAIL
[Parsing: <C|/foo/bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: </C|\\foo\\bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//C|/foo/bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//server/file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <\\\\server\\file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: </\\server/file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <///> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <///test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <file:test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <http://example.com/././foo> against <about:blank>] [Parsing: <http://example.com/././foo> against <about:blank>]
expected: FAIL expected: FAIL
@ -762,60 +729,9 @@
[Parsing: <sc::a@example.net> against <about:blank>] [Parsing: <sc::a@example.net> against <about:blank>]
expected: FAIL expected: FAIL
[Parsing: <http:/:@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:a:b@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/a:b@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http::@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:@:www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/@:www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <i> against <sc:sd>]
expected: FAIL
[Parsing: <i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <../i> against <sc:sd>]
expected: FAIL
[Parsing: <../i> against <sc:sd/sd>]
expected: FAIL
[Parsing: </i> against <sc:sd>]
expected: FAIL
[Parsing: </i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <?i> against <sc:sd>]
expected: FAIL
[Parsing: <?i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <http:> against <http://example.org/foo/bar>] [Parsing: <http:> against <http://example.org/foo/bar>]
expected: FAIL expected: FAIL
[Parsing: <http:> against <https://example.org/foo/bar>]
expected: FAIL
[Parsing: <sc:> against <https://example.org/foo/bar>] [Parsing: <sc:> against <https://example.org/foo/bar>]
expected: FAIL expected: FAIL

View file

@ -246,39 +246,6 @@
[Parsing: <data:text/html,test#test> against <http://example.org/foo/bar>] [Parsing: <data:text/html,test#test> against <http://example.org/foo/bar>]
expected: FAIL expected: FAIL
[Parsing: <C|/foo/bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: </C|\\foo\\bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//C|/foo/bar> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//server/file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <\\\\server\\file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: </\\server/file> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <//> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <///> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <///test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <file:test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <http://example.com/././foo> against <about:blank>] [Parsing: <http://example.com/././foo> against <about:blank>]
expected: FAIL expected: FAIL
@ -762,60 +729,9 @@
[Parsing: <sc::a@example.net> against <about:blank>] [Parsing: <sc::a@example.net> against <about:blank>]
expected: FAIL expected: FAIL
[Parsing: <http:/:@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:a:b@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/a:b@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http::@/www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:@:www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <http:/@:www.example.com> against <about:blank>]
expected: FAIL
[Parsing: <i> against <sc:sd>]
expected: FAIL
[Parsing: <i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <../i> against <sc:sd>]
expected: FAIL
[Parsing: <../i> against <sc:sd/sd>]
expected: FAIL
[Parsing: </i> against <sc:sd>]
expected: FAIL
[Parsing: </i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <?i> against <sc:sd>]
expected: FAIL
[Parsing: <?i> against <sc:sd/sd>]
expected: FAIL
[Parsing: <http:> against <http://example.org/foo/bar>] [Parsing: <http:> against <http://example.org/foo/bar>]
expected: FAIL expected: FAIL
[Parsing: <http:> against <https://example.org/foo/bar>]
expected: FAIL
[Parsing: <sc:> against <https://example.org/foo/bar>] [Parsing: <sc:> against <https://example.org/foo/bar>]
expected: FAIL expected: FAIL