Skip to content

Conversation

@juliandescottes
Copy link
Contributor

This adds test cases for script commands bypassing CSP.
See w3c/webdriver-bidi#1024

""",
"window.inlineScriptEval()",
"window.preloadScriptEval()",
"window.document.body.onclick()",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this fail if the CSP disallows eval? In other words, if I am testing that my CSP works, I want this to fail, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deciding this is the goal of the discussion in w3c/webdriver-bidi#1024

This test covers all the scenarios I could think about regarding eval/new Function usage from BiDi. At the moment Firefox fails all of them, and Chrome passes all of them except for the async use cases.

But I agree with you and I think it would be better if scripts defined in the content page were not allowed to bypass CSP, even if they are called from a WebDriver BiDi evaluated script. So both window.inlineScriptEval and window.document.body.onclick should fail IMO.

Copy link
Contributor

@sadym-chromium sadym-chromium left a comment

Choose a reason for hiding this comment

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

Really good coverage, thanks!

@juliandescottes
Copy link
Contributor Author

Thanks for the feedback, I guess we can land as tentative while we discuss. Any objection on the mozilla side? cc @jgraham @whimboo @lutien ?

@juliandescottes juliandescottes force-pushed the wdspec-bidi-script-csp-tentative branch from 6f5235b to a50d5e9 Compare November 14, 2025 11:26
@juliandescottes
Copy link
Contributor Author

There was a lot of duplication between the two tests, so I extracted the common setup logic to a dedicated fixture and also moved the base expressions used for evaluation to a shared list.

@juliandescottes juliandescottes force-pushed the wdspec-bidi-script-csp-tentative branch from a86fcf2 to 0192419 Compare November 17, 2025 09:08
@juliandescottes juliandescottes force-pushed the wdspec-bidi-script-csp-tentative branch from 0192419 to b8d2bc4 Compare November 17, 2025 13:58
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me, and the two failing tests for Firefox tests are unrelated to this change.

@juliandescottes
Copy link
Contributor Author

Thanks for the reviews! @jgraham could you admin merge this?

@juliandescottes
Copy link
Contributor Author

Can someone from @web-platform-tests/admins help merge this? The flakes are unrelated to my patch here.

@jgraham jgraham merged commit 9a253c3 into web-platform-tests:master Nov 20, 2025
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants