haikuwebkit/Source/WebCore/xml/parser
Chris Dumez 60bdcd698a Document.baseURI is inaccurate for iframe srcdoc documents
https://bugs.webkit.org/show_bug.cgi?id=228933

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt:
* web-platform-tests/html/semantics/document-metadata/the-base-element/base_about_blank-expected.txt:
* web-platform-tests/html/semantics/document-metadata/the-base-element/base_href_invalid-expected.txt:
* web-platform-tests/html/semantics/document-metadata/the-base-element/base_srcdoc-expected.txt:

Source/WebCore:

Document.baseURI is inaccurate for iframe srcdoc documents:
- https://html.spec.whatwg.org/#fallback-base-url

This aligns our behavior with both Chrome and Firefox.

No new tests, rebaselined existing tests.

* dom/Document.cpp:
(WebCore::Document::fallbackBaseURL const):
(WebCore::Document::updateBaseURL):
Extract "fallback base URL" logic out of updateBaseURL() and into its own function so that
it can be called from other places. Add logic to deal with iframe srcdoc documents to
our "fallback base URL" logic, as per:
- https://html.spec.whatwg.org/#fallback-base-url

(WebCore::Document::processBaseElement):
As per https://html.spec.whatwg.org/#set-the-frozen-base-url, we should use the document's fallback base URL
as base URL when parsing the base element's href attribute.

* dom/Document.h:

* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Per https://html.spec.whatwg.org/#dom-base-href, we should use the document's fallback base URL when
parsing the base element's href attribute. Also we should return the attribute value if the URL fails
parsing, not a null URL.

* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::openFunc):
Keep in sync with HTMLBaseElement::href(), as per comment.

Source/WebKitLegacy/mac:

* DOM/DOMHTMLBaseElement.mm:
(-[DOMHTMLBaseElement href]):

LayoutTests:

Update existing layout test to reflect behavior change.

* fast/dom/HTMLBaseElement/href-attribute-resolves-with-respect-to-document.html: Removed.
* http/tests/misc/href-attribute-resolves-with-respect-to-document-expected.txt: Renamed from LayoutTests/fast/dom/HTMLBaseElement/href-attribute-resolves-with-respect-to-document-expected.txt.
* http/tests/misc/href-attribute-resolves-with-respect-to-document.html: Added.


Canonical link: https://commits.webkit.org/240398@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280855 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-10 17:51:30 +00:00
..
CharacterReferenceParserInlines.h Rename Checked::unsafeGet() to Checked::value() 2021-06-02 05:21:13 +00:00
MarkupTokenizerInlines.h
XMLDocumentParser.cpp Use `const uint8_t*` type more consistently to store bytes in WebKit 2021-06-06 05:25:41 +00:00
XMLDocumentParser.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
XMLDocumentParserLibxml2.cpp Document.baseURI is inaccurate for iframe srcdoc documents 2021-08-10 17:51:30 +00:00
XMLDocumentParserScope.cpp
XMLDocumentParserScope.h