Skip to content

Implement trusted types integrations with DOM attribute APIs.#26519

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ziransun:Bug270436
May 15, 2024
Merged

Implement trusted types integrations with DOM attribute APIs.#26519
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ziransun:Bug270436

Conversation

@ziransun

@ziransun ziransun commented Mar 27, 2024

Copy link
Copy Markdown
Contributor

9a38b69

Implement trusted types integrations with DOM attribute APIs.
https://bugs.webkit.org/show_bug.cgi?id=270436

Reviewed by Ryosuke Niwa.

Implement the spec updates at whatwg/dom#1247

It also removes some expectations in GTK as the results should be
in line with the general expectation file.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/Element-setAttribute-respects-Elements-node-documents-globals-CSP-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/GlobalEventHandlers-onclick-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-metadata.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttribute-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttributeNS-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-event-handlers-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-event-handlers.html:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-svg-script-set-href-expected.txt:
* LayoutTests/platform/gtk/TestExpectations:
* Source/WebCore/dom/Element.cpp:
(WebCore::trustedTypesCompliantAttributeValue):
(WebCore::Element::validateAttributeIndex const):
(WebCore::Element::toggleAttribute):
(WebCore::Element::setAttribute):
(WebCore::Element::setElementsArrayAttribute):
(WebCore::appendAttributes):
(WebCore::Element::setAttributeNode):
(WebCore::Element::setAttributeNodeNS):
(WebCore::Element::setAttributeNS):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/Element.idl:
* Source/WebCore/dom/TrustedScript.h:
* Source/WebCore/dom/TrustedScriptURL.h:
(WebCore::TrustedScriptURL::toString const): Deleted.
(WebCore::TrustedScriptURL::toJSON const): Deleted.
* Source/WebCore/dom/TrustedType.cpp:
(WebCore::stringToTrustedType):
(WebCore::trustedTypeForAttribute):
* Source/WebCore/dom/TrustedType.h:
* Source/WebCore/dom/TrustedTypePolicyFactory.cpp:
(WebCore::TrustedTypePolicyFactory::getAttributeType const):
* Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm:
(-[WKDOMElement setAttribute:value:]):
* Source/WebKitLegacy/mac/DOM/DOMElement.mm:
(-[DOMElement setAttribute:value:]):
(-[DOMElement setAttributeNS:qualifiedName:value:]):

Canonical link: https://commits.webkit.org/278817@main

04b9b37

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ⏳ 🛠 wpe-skia
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 tv-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 watch
✅ 🛠 watch-sim

@ziransun
ziransun requested review from cdumez and rniwa as code owners March 27, 2024 15:56
Comment thread Source/WebCore/dom/Element.h Outdated
Comment thread Source/WebCore/dom/TrustedType.cpp Outdated
Comment thread Source/WebCore/dom/TrustedType.h Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/TrustedType.cpp Outdated
Comment thread Source/WebCore/dom/TrustedType.h Outdated
Comment thread Source/WebCore/dom/TrustedTypePolicyFactory.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
@lukewarlow
lukewarlow marked this pull request as draft March 27, 2024 16:24
Comment thread Source/WebCore/dom/TrustedType.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/Element.cpp Outdated
Comment thread Source/WebCore/dom/Element.idl Outdated
Comment thread Source/WebCore/dom/Element.idl Outdated
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 27, 2024
@lukewarlow

Copy link
Copy Markdown
Member

I think we need to add WEBCORE_EXPORT to TrustedScript and TrustedScriptURL like we have for TrustedHTML, that should fix the build failure.

Comment thread Source/WebCore/dom/Element.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This index can be stale as getTrustedTypesCompliantAttributeValue can result in JS execution which may mutate the attributes of the element. We need to work out an interopable solution to this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we will look this at a later stage. The bug is filed at https://bugs.webkit.org/show_bug.cgi?id=272678

Comment thread Source/WebCore/dom/TrustedType.cpp Outdated
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 9, 2024
@rniwa

rniwa commented May 9, 2024

Copy link
Copy Markdown
Member

Perf A/B looks good!

@ziransun ziransun removed the merging-blocked Applied to prevent a change from being merged label May 10, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 10, 2024
@ziransun ziransun removed the merging-blocked Applied to prevent a change from being merged label May 13, 2024
Comment thread Source/WebCore/dom/Element.h Outdated

@lukewarlow lukewarlow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to try and get rid of the header imports in the Element.h file.

Edit: Done

@lukewarlow
lukewarlow dismissed their stale review May 14, 2024 13:32

outdated

@lukewarlow
lukewarlow marked this pull request as ready for review May 14, 2024 13:32
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 14, 2024
@lukewarlow lukewarlow removed the merging-blocked Applied to prevent a change from being merged label May 15, 2024
@lukewarlow
lukewarlow requested a review from rniwa May 15, 2024 10:42
@lukewarlow
lukewarlow marked this pull request as draft May 15, 2024 11:01
@lukewarlow lukewarlow changed the title Implement trusted types integrations with DOM setAttribute APIs. Implement trusted types integrations with DOM attribute APIs. May 15, 2024
https://bugs.webkit.org/show_bug.cgi?id=270436

Reviewed by Ryosuke Niwa.

Implement the spec updates at whatwg/dom#1247

It also removes some expectations in GTK as the results should be
in line with the general expectation file.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/Element-setAttribute-respects-Elements-node-documents-globals-CSP-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/GlobalEventHandlers-onclick-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-metadata.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttribute-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttributeNS-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-event-handlers-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-event-handlers.html:
* LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-svg-script-set-href-expected.txt:
* LayoutTests/platform/gtk/TestExpectations:
* Source/WebCore/dom/Element.cpp:
(WebCore::trustedTypesCompliantAttributeValue):
(WebCore::Element::validateAttributeIndex const):
(WebCore::Element::toggleAttribute):
(WebCore::Element::setAttribute):
(WebCore::Element::setElementsArrayAttribute):
(WebCore::appendAttributes):
(WebCore::Element::setAttributeNode):
(WebCore::Element::setAttributeNodeNS):
(WebCore::Element::setAttributeNS):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/Element.idl:
* Source/WebCore/dom/TrustedScript.h:
* Source/WebCore/dom/TrustedScriptURL.h:
(WebCore::TrustedScriptURL::toString const): Deleted.
(WebCore::TrustedScriptURL::toJSON const): Deleted.
* Source/WebCore/dom/TrustedType.cpp:
(WebCore::stringToTrustedType):
(WebCore::trustedTypeForAttribute):
* Source/WebCore/dom/TrustedType.h:
* Source/WebCore/dom/TrustedTypePolicyFactory.cpp:
(WebCore::TrustedTypePolicyFactory::getAttributeType const):
* Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm:
(-[WKDOMElement setAttribute:value:]):
* Source/WebKitLegacy/mac/DOM/DOMElement.mm:
(-[DOMElement setAttribute:value:]):
(-[DOMElement setAttributeNS:qualifiedName:value:]):

Canonical link: https://commits.webkit.org/278817@main
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 278817@main (9a38b69): https://commits.webkit.org/278817@main

Reviewed commits have been landed. Closing PR #26519 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DOM For bugs specific to XML/HTML DOM elements (including parsing).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants