fix(evaluate): reject exposeFunctions in the utility world - #42649
Closed
Ayaan Gazali (ayaangazali) wants to merge 1 commit into
Closed
Ayaan Gazali (ayaangazali) wants to merge 1 commit into
Ayaan Gazali (ayaangazali) wants to merge 1 commit into
Conversation
Bindings are installed by an init script, which only runs in the main world, so combining exposeFunctions with world: "utility" crashed inside the injected code with "Cannot read properties of undefined (reading 'callBinding')" instead of reporting the unsupported combination. Also drop the claim that exposed functions reach all worlds of the page.
Member
|
Please file an issue |
Author
|
Done, filed as #42686 with the reproducer and the root cause. Noted on the issue-first rule, that is on me for opening this cold. I will lead with an issue from now on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong today
exposeFunctionsand the newworldoption cannot be combined, but passing both crashes inside the injected code instead of saying so. Onaeebee1d2:Same error from
frame.evaluateandlocator.evaluate. Reproduced on chromium, firefox and webkit.Why
PageBinding.createInitScriptinstalls the bindings controller as an init script, and init scripts only run in the main world, soglobalThis[kBindingsControllerProperty]is undefined in the utility world.Runtime.addBindingis registered without a world, so the transport is there, but the controller that dispatches through it is not. That is also why the docs sentence saying an exposed function is "technically accessible from all frames and worlds of the page" does not hold:What this changes
Throws on the combination from
assertEvaluateOptions, which everyevaluateentry point already calls, and corrects the two doc sentences that promise all worlds. This matches the errorJSHandleDispatcher.evaluateExpressionalready throws for a world it cannot serve.If bindings are meant to work in the utility world, this guard is the wrong fix and I am happy to close it. The doc sentences would be the part worth keeping either way.
Verified with
npm run flintgreen andtests/page/page-evaluate-world.spec.tsplus the seven adjacent evaluate/expose-function specs (173 tests) passing; the new test fails with thecallBindingTypeError when the guard is reverted.I am a freshman in college trying my best to contribute for the greater good, so please tell me if I have read the intent backwards here.