haikuwebkit/LayoutTests/fast/dom/DOMURL
Alex Christensen 05c2dcb6ca Fix some whitespace handling issues in URL setters
https://bugs.webkit.org/show_bug.cgi?id=227806

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-08
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-setters-stripping.any-expected.txt:
* web-platform-tests/url/url-setters-stripping.any.worker-expected.txt:

Source/WebCore:

Covered by newly passing wpt tests.

* dom/Element.cpp:
(WebCore::Element::getURLAttribute const):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::href const):
Don't remove whitespace before giving to completeURL, which will do that for us if it's a valid URL.
If it's not a valid URL, we want the original string, not the trimmed string.
* html/URLDecomposition.cpp:
(WebCore::parsePort):
Parse ports more like the URLParser, which ignores tabs and newlines.

Source/WTF:

Setters should ignore tabs and newlines like the main parser does.
The protocol setter is problematic, which I reported in https://github.com/whatwg/url/issues/620

* wtf/URL.cpp:
(WTF::URL::setFragmentIdentifier):
* wtf/URLParser.cpp:
(WTF::URLParser::isSpecialScheme):
(WTF::URLParser::parse):
* wtf/URLParser.h:
The URL.hash setter should allow trailing C0 and control characters, which we would otherwise trim.
Rather than introduce a new parameter, use a sentinel value for when we need to do this.

LayoutTests:

Update some old tests that failed in Chrome and Firefox to pass in all browsers after this change.

* fast/dom/DOMURL/set-href-attribute-port-expected.txt:
* fast/dom/DOMURL/set-href-attribute-port.html:
* fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt:
* fast/dom/HTMLAnchorElement/set-href-attribute-port.html:

Canonical link: https://commits.webkit.org/239531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-08 22:59:59 +00:00
..
check-instanceof-domurl-functions-expected.txt
check-instanceof-domurl-functions.html
get-href-attribute-port-expected.txt
get-href-attribute-port.html
parsing-expected.txt
parsing.html
searchparams-expected.txt
searchparams-iterable-expected.txt
searchparams-iterable.html
searchparams.html
set-href-attribute-hash-expected.txt
set-href-attribute-hash.html
set-href-attribute-host-expected.txt
set-href-attribute-host.html
set-href-attribute-hostname-expected.txt
set-href-attribute-hostname.html
set-href-attribute-pathname-expected.txt
set-href-attribute-pathname.html
set-href-attribute-port-expected.txt Fix some whitespace handling issues in URL setters 2021-07-08 22:59:59 +00:00
set-href-attribute-port.html Fix some whitespace handling issues in URL setters 2021-07-08 22:59:59 +00:00
set-href-attribute-protocol-expected.txt
set-href-attribute-protocol.html
set-href-attribute-search-expected.txt
set-href-attribute-search.html
set-href-attribute-whitespace-expected.txt
set-href-attribute-whitespace.html
url-constructor-expected.txt
url-constructor.html
url-origin-expected.txt
url-origin.html
url-password-expected.txt
url-password.html
url-username-expected.txt
url-username.html