Closed Bug 2074488 Opened 2 months ago Closed 2 months ago

[wpt-sync] Sync PR 62857 - Add tests for the javascript: URL pre-navigation check

Categories

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

task

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox159 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 62857 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/62857
Details from upstream follow.

Anne van Kesteren <annevk@annevk.nl> wrote:

Add tests for the javascript: URL pre-navigation check

The existing trusted-types/navigate-to-javascript-url-* tests all have a frame navigating itself, so they cannot distinguish the document that initiated the navigation from the one being navigated. These two add coverage for the cases where they differ, and for re-entrancy from the default policy.

navigate-to-javascript-url-009.html covers a javascript: URL in the src attribute of a freshly inserted iframe, where the default policy removes that iframe before the URL is evaluated. This is the one case where navigate to a javascript: URL runs the iframe load event steps when no Document is produced, and by then the navigable has no container. navigate-to-javascript-url-007-crash.html covers the same re-entrancy for a window.location navigation, where that branch is not reached. Passes in Chromium, Gecko, and WebKit.

navigate-to-javascript-url-010.html has one same-origin frame navigate another to a javascript: URL, with each document's default policy rewriting the script source to its own name, so the result says which document was consulted. Per the standard the synthetic request's policy container is snapshotted from the initiating document, so all three subtests expect the initiating document's require-trusted-types-for directive and default policy to apply.

This currently passes in Gecko only. Chromium and WebKit use the navigated document instead, for both the CSP list and the default policy. The second subtest is the notable one: a document that enforces require-trusted-types-for runs the original, un-vetted script source by aiming the javascript: URL at a same-origin frame that does not enforce, which is what the pre-navigation check is meant to prevent.

See also w3c/trusted-types#548 for which global the default policy is read from.

Component: web-platform-tests → DOM: Security
Product: Testing → Core

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 239 tests and 1 subtests

Status Summary

Firefox

OK : 2[GitHub] 237[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]
PASS: 1[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 4[GitHub] 3655[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 3656[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 3660[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]
FAIL: 21

Chrome

OK : 2
PASS: 1
FAIL: 3

Safari

OK : 2
PASS: 1
FAIL: 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

  • /trusted-types/trusted-types-from-literal.tentative.html [wpt.fyi]
    • TrustedHTML.fromLiteral is supported: FAIL
    • TrustedHTML.fromLiteral: Basic string literal works.: FAIL
    • TrustedHTML.fromLiteral: Empty string literal works.: FAIL
    • TrustedHTML.fromLiteral: A very important emoji works.: FAIL
    • TrustedHTML.fromLiteral: Multi-line string literal works.: FAIL
    • TrustedHTML.fromLiteral: Bound method works.: FAIL
    • TrustedScript.fromLiteral is supported: FAIL
    • TrustedScript.fromLiteral: Basic string literal works.: FAIL
    • TrustedScript.fromLiteral: Empty string literal works.: FAIL
    • TrustedScript.fromLiteral: A very important emoji works.: FAIL
    • TrustedScript.fromLiteral: Multi-line string literal works.: FAIL
    • TrustedScript.fromLiteral: Bound method works.: FAIL
    • TrustedScriptURL.fromLiteral is supported: FAIL
    • TrustedScriptURL.fromLiteral: Basic string literal works.: FAIL
    • TrustedScriptURL.fromLiteral: Empty string literal works.: FAIL
    • TrustedScriptURL.fromLiteral: A very important emoji works.: FAIL
    • TrustedScriptURL.fromLiteral: Multi-line string literal works.: FAIL
    • TrustedScriptURL.fromLiteral: Bound method works.: FAIL
    • TrustedHTML.fromLiteral: Normalization of value works.: FAIL
    • TrustedScript.fromLiteral: No normalization of value occurs.: FAIL
    • TrustedScriptURL.fromLiteral: No normalization of value occurs.: FAIL
Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/59918954edf7 https://hg.mozilla.org/integration/autoland/rev/707e2f706840 [wpt PR 62857] - Add tests for the javascript: URL pre-navigation check, a=testonly
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch
You need to log in before you can comment on or make changes to this bug.