Changeset 280855 in webkit
- Timestamp:
- Aug 10, 2021 10:51:30 AM (11 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 14 edited
- 1 moved
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/HTMLBaseElement/href-attribute-resolves-with-respect-to-document.html (deleted)
-
LayoutTests/http/tests/misc/href-attribute-resolves-with-respect-to-document-expected.txt (moved) (moved from trunk/LayoutTests/fast/dom/HTMLBaseElement/href-attribute-resolves-with-respect-to-document-expected.txt) (2 diffs)
-
LayoutTests/http/tests/misc/href-attribute-resolves-with-respect-to-document.html (added)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_about_blank-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_href_invalid-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_srcdoc-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Document.cpp (modified) (3 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/html/HTMLBaseElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLBaseElement.h (modified) (1 diff)
-
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (modified) (1 diff)
-
Source/WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/mac/DOM/DOMHTMLBaseElement.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r280846 r280855 1 2021-08-10 Chris Dumez <cdumez@apple.com> 2 3 Document.baseURI is inaccurate for iframe srcdoc documents 4 https://bugs.webkit.org/show_bug.cgi?id=228933 5 6 Reviewed by Alex Christensen. 7 8 Update existing layout test to reflect behavior change. 9 10 * fast/dom/HTMLBaseElement/href-attribute-resolves-with-respect-to-document.html: Removed. 11 * 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. 12 * http/tests/misc/href-attribute-resolves-with-respect-to-document.html: Added. 13 1 14 2021-08-10 Arcady Goldmints-Orlov <agoldmints@igalia.com> 2 15 -
trunk/LayoutTests/http/tests/misc/href-attribute-resolves-with-respect-to-document-expected.txt
r280854 r280855 1 Test for HTMLBaseElement's href attribute. 2 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 5 1 6 PASS endsWith(document.querySelector('base').href, 'foo/bar/') is true 2 7 PASS endsWith(document.querySelector('base').href, 'foo/bar/foo/bar/') is false … … 5 10 PASS document.querySelector('base').hasAttribute('href') is false 6 11 PASS endsWith(document.querySelector('base').href, '/href-attribute-resolves-with-respect-to-document.html') is true 7 PASS documentWithoutAView.querySelector('base').href is " "12 PASS documentWithoutAView.querySelector('base').href is "foo/bar/" 8 13 PASS documentWithoutAView.querySelector('base').href is "http://webkit.org/" 9 PASS iframe.contentDocument.querySelector('base').href is " "10 PASS newWindow.document.querySelector('base').href is " "14 PASS iframe.contentDocument.querySelector('base').href is "http://127.0.0.1:8000/misc/foo/bar/" 15 PASS newWindow.document.querySelector('base').href is "http://127.0.0.1:8000/misc/foo/bar/" 11 16 PASS successfullyParsed is true 12 17 -
trunk/LayoutTests/imported/w3c/ChangeLog
r280827 r280855 1 2021-08-10 Chris Dumez <cdumez@apple.com> 2 3 Document.baseURI is inaccurate for iframe srcdoc documents 4 https://bugs.webkit.org/show_bug.cgi?id=228933 5 6 Reviewed by Alex Christensen. 7 8 Rebaseline WPT tests now that more checks are passing. 9 10 * web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt: 11 * web-platform-tests/html/semantics/document-metadata/the-base-element/base_about_blank-expected.txt: 12 * web-platform-tests/html/semantics/document-metadata/the-base-element/base_href_invalid-expected.txt: 13 * web-platform-tests/html/semantics/document-metadata/the-base-element/base_srcdoc-expected.txt: 14 1 15 2021-08-10 Cathie Chen <cathiechen@igalia.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/terminology-0/document-base-url-expected.txt
r280491 r280855 3 3 PASS The fallback base URL of a document containing no base element is the document's address. 4 4 PASS The fallback base URL of a document whose address is about:blank is the document base URL of the creator document. 5 FAIL about:blank with a base element. assert_equals: img src should resolve correctly expected "http://localhost:8800/html/infrastructure/urls/terminology-0/sub/foo" but got "http://localhost:8800/html/infrastructure/urls/terminology-0/foo" 5 PASS about:blank with a base element. 6 6 PASS The fallback base URL of an iframe srcdoc document is the document base URL of the document's browsing context's browsing context container's document. 7 FAIL The base URL of an iframe srcdoc document with a <base> tag should be set by that tag. assert_equals: img src should resolve correctly expected "http://localhost:8800/html/infrastructure/urls/terminology-0/sub/foo" but got "http://localhost:8800/html/infrastructure/urls/terminology-0/foo" 7 PASS The base URL of an iframe srcdoc document with a <base> tag should be set by that tag. 8 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_about_blank-expected.txt
r203164 r280855 1 1 2 2 3 FAIL base element in about:blank document should resolve against its fallback base URI assert_equals: expected "http://localhost:8800/html/semantics/document-metadata/the-base-element/test" but got "" 3 PASS base element in about:blank document should resolve against its fallback base URI 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_href_invalid-expected.txt
r203164 r280855 1 1 2 FAIL base element with unparseable href should have .href getter return attr value assert_equals: expected "//test:test" but got "" 2 PASS base element with unparseable href should have .href getter return attr value 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base_srcdoc-expected.txt
r203164 r280855 1 1 2 2 3 FAIL base element in srcdoc document should resolve against its fallback base URI assert_equals: expected "http://localhost:8800/html/semantics/document-metadata/the-base-element/test" but got "" 3 PASS base element in srcdoc document should resolve against its fallback base URI 4 4 -
trunk/Source/WebCore/ChangeLog
r280854 r280855 1 2021-08-10 Chris Dumez <cdumez@apple.com> 2 3 Document.baseURI is inaccurate for iframe srcdoc documents 4 https://bugs.webkit.org/show_bug.cgi?id=228933 5 6 Reviewed by Alex Christensen. 7 8 Document.baseURI is inaccurate for iframe srcdoc documents: 9 - https://html.spec.whatwg.org/#fallback-base-url 10 11 This aligns our behavior with both Chrome and Firefox. 12 13 No new tests, rebaselined existing tests. 14 15 * dom/Document.cpp: 16 (WebCore::Document::fallbackBaseURL const): 17 (WebCore::Document::updateBaseURL): 18 Extract "fallback base URL" logic out of updateBaseURL() and into its own function so that 19 it can be called from other places. Add logic to deal with iframe srcdoc documents to 20 our "fallback base URL" logic, as per: 21 - https://html.spec.whatwg.org/#fallback-base-url 22 23 (WebCore::Document::processBaseElement): 24 As per https://html.spec.whatwg.org/#set-the-frozen-base-url, we should use the document's fallback base URL 25 as base URL when parsing the base element's href attribute. 26 27 * dom/Document.h: 28 29 * html/HTMLBaseElement.cpp: 30 (WebCore::HTMLBaseElement::href const): 31 Per https://html.spec.whatwg.org/#dom-base-href, we should use the document's fallback base URL when 32 parsing the base element's href attribute. Also we should return the attribute value if the URL fails 33 parsing, not a null URL. 34 35 * xml/parser/XMLDocumentParserLibxml2.cpp: 36 (WebCore::openFunc): 37 Keep in sync with HTMLBaseElement::href(), as per comment. 38 1 39 2021-08-10 Kimmo Kinnunen <kkinnunen@apple.com> 2 40 -
trunk/Source/WebCore/dom/Document.cpp
r280772 r280855 3407 3407 } 3408 3408 3409 // https://html.spec.whatwg.org/#fallback-base-url 3410 URL Document::fallbackBaseURL() const 3411 { 3412 // The documentURI attribute is read-only from JavaScript, but writable from Objective C, so we need to retain 3413 // this fallback behavior. We use a null base URL, since the documentURI attribute is an arbitrary string 3414 // and DOM 3 Core does not specify how it should be resolved. 3415 auto documentURL = URL({ }, documentURI()); 3416 3417 if (documentURL.isAboutSrcDoc()) { 3418 if (auto* parent = parentDocument()) 3419 return parent->baseURL(); 3420 } 3421 3422 if (documentURL.isAboutBlank()) { 3423 auto* creator = parentDocument(); 3424 if (!creator && frame() && frame()->loader().opener()) 3425 creator = frame()->loader().opener()->document(); 3426 if (creator) 3427 return creator->baseURL(); 3428 } 3429 3430 return documentURL; 3431 } 3432 3409 3433 void Document::updateBaseURL() 3410 3434 { … … 3416 3440 else if (!m_baseURLOverride.isEmpty()) 3417 3441 m_baseURL = m_baseURLOverride; 3418 else { 3419 // The documentURI attribute is read-only from JavaScript, but writable from Objective C, so we need to retain 3420 // this fallback behavior. We use a null base URL, since the documentURI attribute is an arbitrary string 3421 // and DOM 3 Core does not specify how it should be resolved. 3422 m_baseURL = URL({ }, documentURI()); 3423 3424 if (m_baseURL.isAboutBlank()) { 3425 auto* creator = parentDocument(); 3426 if (!creator && frame() && frame()->loader().opener()) 3427 creator = frame()->loader().opener()->document(); 3428 if (creator) 3429 m_baseURL = creator->baseURL(); 3430 } 3431 } 3442 else 3443 m_baseURL = fallbackBaseURL(); 3432 3444 3433 3445 clearSelectorQueryCache(); … … 3473 3485 String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href); 3474 3486 if (!strippedHref.isEmpty()) 3475 baseElementURL = URL( url(), strippedHref);3487 baseElementURL = URL(fallbackBaseURL(), strippedHref); 3476 3488 } 3477 3489 if (m_baseElementURL != baseElementURL && contentSecurityPolicy()->allowBaseURI(baseElementURL)) { -
trunk/Source/WebCore/dom/Document.h
r280772 r280855 1631 1631 String debugDescription() const; 1632 1632 1633 URL fallbackBaseURL() const; 1634 1633 1635 protected: 1634 1636 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 }; -
trunk/Source/WebCore/html/HTMLBaseElement.cpp
r261443 r280855 80 80 } 81 81 82 URL HTMLBaseElement::href() const 82 // https://html.spec.whatwg.org/#dom-base-href 83 String HTMLBaseElement::href() const 83 84 { 84 // This does not use the getURLAttribute function because that will resolve relative to the document's base URL; 85 // base elements like this one can be used to set that base URL. Thus we need to resolve relative to the document's 86 // URL and ignore the base URL. 87 88 const AtomString& attributeValue = attributeWithoutSynchronization(hrefAttr); 89 if (attributeValue.isNull()) 90 return document().url(); 85 AtomString url = attributeWithoutSynchronization(hrefAttr); 86 if (url.isNull()) 87 url = emptyAtom(); 91 88 92 89 // Same logic as openFunc() in XMLDocumentParserLibxml2.cpp. Keep them in sync. 93 90 auto* encoding = document().decoder() ? document().decoder()->encodingForURLParsing() : nullptr; 94 URL url(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue), encoding); 91 URL urlRecord(document().fallbackBaseURL(), stripLeadingAndTrailingHTMLSpaces(url), encoding); 92 if (!urlRecord.isValid()) 93 return url; 95 94 96 if (!url.isValid()) 97 return URL(); 98 99 return url; 95 return urlRecord.string(); 100 96 } 101 97 -
trunk/Source/WebCore/html/HTMLBaseElement.h
r246490 r280855 32 32 static Ref<HTMLBaseElement> create(const QualifiedName&, Document&); 33 33 34 WEBCORE_EXPORT URLhref() const;34 WEBCORE_EXPORT String href() const; 35 35 WEBCORE_EXPORT void setHref(const AtomString&); 36 36 -
trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
r279370 r280855 458 458 // Same logic as HTMLBaseElement::href(). Keep them in sync. 459 459 auto* encoding = (document && document->decoder()) ? document->decoder()->encodingForURLParsing() : nullptr; 460 URL url(document ? document-> url() : URL(), stripLeadingAndTrailingHTMLSpaces(uri), encoding);460 URL url(document ? document->fallbackBaseURL() : URL(), stripLeadingAndTrailingHTMLSpaces(uri), encoding); 461 461 462 462 if (!shouldAllowExternalLoad(url)) -
trunk/Source/WebKitLegacy/mac/ChangeLog
r280824 r280855 1 2021-08-10 Chris Dumez <cdumez@apple.com> 2 3 Document.baseURI is inaccurate for iframe srcdoc documents 4 https://bugs.webkit.org/show_bug.cgi?id=228933 5 6 Reviewed by Alex Christensen. 7 8 * DOM/DOMHTMLBaseElement.mm: 9 (-[DOMHTMLBaseElement href]): 10 1 11 2021-08-09 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLBaseElement.mm
r261968 r280855 43 43 { 44 44 WebCore::JSMainThreadNullState state; 45 return IMPL->href() .string();45 return IMPL->href(); 46 46 } 47 47
Note: See TracChangeset
for help on using the changeset viewer.