Closed Bug 1919248 Opened 2 months ago Closed 16 days ago

Investigate why WPT <to-javascript-url-script-src.html> times out for Gecko (SecurityPolicyViolationEvent target is an iframe in other browsers)

Categories

(Core :: DOM: Security, task, P2)

task

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: mbrodesser-Igalia, Assigned: mbrodesser-Igalia)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [domsecurity-backlog], [wptsync upstream])

Attachments

(1 file)

No need to jump to a fix, but it would be nice to do an early investigation why this isn't passing

Flags: needinfo?(tschuster)
Severity: -- → S3
Priority: -- → P2
Whiteboard: [domsecurity-backlog]

It times out because e.target at [1] isn't the iframe element, but the outer document.

According to the spec [2] the violation's element is null. Later in the spec [3] in step 3.2 that results in a target of null. Which, in the same step is replaced by the global object, or, if the latter is a Window, by the windows' document.
Presumably the latter happens in Gecko.
The test passes in Chrome, so there the global object should be the iframe.

So it needs to be figured out which global is the correct one to use in step 3.1.1.3 of [2].

[1] https://searchfox.org/mozilla-central/rev/26a98a7ba56f315df146512c43449412f0592942/testing/web-platform/tests/content-security-policy/navigation/to-javascript-url-script-src.html#13
[2] https://w3c.github.io/webappsec-csp/#should-block-navigation-request
[3] https://w3c.github.io/webappsec-csp/#report-violation

Seems to be related to https://github.com/whatwg/html/issues/4651#issue-447334382:

so there is only one sane global to use around. But for location.href sets or modifications of the src attribute of <iframe>, it should be observable which global's CSP gets used here.

It would be good to get this properly specified and fixed. I think from an user's perspective using the iframe as the target makes sense?

Flags: needinfo?(tschuster)
Blocks: CSP
Summary: Investigate why WPT <to-javascript-url-script-src.html> times out for Gecko → Investigate why WPT <to-javascript-url-script-src.html> times out for Gecko (SecurityPolicyViolationEvent target is an iframe in other browsers)

(In reply to Tom Schuster (MoCo) from comment #5)

It would be good to get this properly specified and fixed. I think from an user's perspective using the iframe as the target makes sense?

Yes.

Currently trying to figure out how to get the iframe element in https://searchfox.org/mozilla-central/rev/1e8cec3727d6e09f4af41bb3d202b7a4c326ed84/dom/jsurl/nsJSProtocolHandler.cpp#171.

(In reply to Mirko Brodesser (:mbrodesser-Igalia) from comment #2)

It times out because e.target at [1] isn't the iframe element, but the outer document.

According to the spec [2] the violation's element is null. Later in the spec [3] in step 3.2 that results in a target of null. Which, in the same step is replaced by the global object, or, if the latter is a Window, by the windows' document.
Presumably the latter happens in Gecko.

Confirming the presumption.

Assignee: nobody → mbrodesser

Gecko doesn't set the securitypolicyevent violation's target element,
which prevented the async tests from passing with Gecko.
Setting the violation's target element isn't specified (
https://github.com/w3c/webappsec-csp/issues/687).

Promise-based tests allow removing checking the target element, because
the tests are run in sequence
(https://web-platform-tests.org/writing-tests/testharness-api.html#promise-tests).

Pushed by mbrodesser@igalia.com: https://hg.mozilla.org/integration/autoland/rev/b941985be923 transform WPT <to-javascript-url-script-src.html>'s async sub-tests to promise-tests and remove checking the securitypolicyevent's target element. r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/48884 for changes under testing/web-platform/tests
Whiteboard: [domsecurity-backlog] → [domsecurity-backlog], [wptsync upstream]
Status: NEW → RESOLVED
Closed: 16 days ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: