[wpt-sync] Sync PR 62762 - Apply CSP to inline event handler content attributes when set
Categories
(Core :: DOM: Core & HTML, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 62762 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/62762
Details from upstream follow.
Byungwoo Lee <blee@igalia.com> wrote:
Apply CSP to inline event handler content attributes when set
Per the HTML spec, the event handler content attribute change steps
run the CSP "Should element's inline behavior be blocked?" check when
the attribute is set [1][2]. But the violation was reported lazily,
when the handler was first accessed, rather than when the attribute
was set.To report a violation and skip setting the inline event listener as
per the spec, Element provides the following functions:
- SetElementAttributeEventListenerFromScriptBody()
- SetDocumentAttributeEventListenerFromScriptBody()
- SetWindowAttributeEventListenerFromScriptBody()
The functions check whether the modification is an inline handler
(kDirectly or kByParser) and, if so, whether it is blocked by CSP
(ContentSecurityPolicy::AllowInline()). When blocked, a violation is
reported and the listener is not set. The CSP check is guarded by
the stable runtime feature CheckCSPOnInlineScriptAttributeSet.Element's subclasses use these functions in ParseAttribute() when
they set an inline event handler (HTMLInputElement, HTMLBodyElement,
HTMLElement, HTMLFrameElementBase, HTMLFrameSetElement, MathMLElement,
SVGSMILElement, SVGElement, SVGScriptElement, SVGSVGElement).This CL updates two tests that do not match the spec:
- style-element-csp-nonce-allowed.html: Fix the unintended CSP
violation on the inline onerror attribute.- domdebugger-script-blocked-by-csp.js: Introduce CSP violation by
setAttribute() instead of click().[1] https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-content-attributes
[2] https://w3c.github.io/webappsec-csp/#should-block-inlineLow-Coverage-Reason: COVERAGE_UNDERREPORTED Tests exist (targeting-for-multiple-inline-handler-violations.html)
Bug: 559396684
Change-Id: I864b7456169307e78df8eab9d975d9d3ea863b21
Reviewed-on: https://chromium-review.googlesource.com/8365264
WPT-Export-Revision: ce9725bd0664542a3497602045bc87f5fccac9e5
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=93909
| Assignee | ||
Comment 2•2 months ago
|
||
CI Results
Ran 9 Firefox configurations based on mozilla-central, and Firefox, and Chrome on GitHub CI
Total 11 tests
Status Summary
Firefox
ERROR : 1[GitHub] 5[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
NOTRUN: 2[GitHub] 6[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
Chrome
OK : 1
PASS : 3
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
New Tests That Don't Pass
- /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-both-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-nonce-script-only.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-nonce-style-only.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-script-src-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-style-src-blocked-script-src-allowed.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-basic-import.html [wpt.fyi]:
ERROR - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-allowed.html [wpt.fyi]:
ERROR- Test securitypolicyviolation event doesn't fire on Declarative CSS Module when allowed via CSP:
NOTRUN - Test error event doesn't fire on Declarative CSS Module when allowed via CSP:
NOTRUN
- Test securitypolicyviolation event doesn't fire on Declarative CSS Module when allowed via CSP:
- /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-nonce-allowed.html [wpt.fyi]:
ERROR(Chrome:OK)- Test securitypolicyviolation event doesn't fire when nonce satisfies both CSPs:
NOTRUN(Chrome:PASS) - Test error event doesn't fire when nonce satisfies both CSPs:
NOTRUN(Chrome:PASS)
- Test securitypolicyviolation event doesn't fire when nonce satisfies both CSPs:
- /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-script-src-allowed.html [wpt.fyi]:
ERROR- Test securitypolicyviolation event doesn't fire when both CSPs allow:
NOTRUN - Test error event doesn't fire when both CSPs allow:
NOTRUN
- Test securitypolicyviolation event doesn't fire when both CSPs allow:
- /html/semantics/document-metadata/the-style-element/tentative/style-element-fixed.html [wpt.fyi]:
ERROR
Tests Disabled in Gecko Infrastructure
- /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-both-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-nonce-script-only.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-nonce-style-only.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-script-src-blocked.html [wpt.fyi]:
SKIP - /html/semantics/document-metadata/the-style-element/tentative/style-element-csp-style-src-blocked-script-src-allowed.html [wpt.fyi]:
SKIP
Comment 4•2 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/b76c63ac8ea7
https://hg.mozilla.org/mozilla-central/rev/ff718f9a48a7
Description
•