feat: invoke page level JavaScript through a JS invoker - #25799
Draft
totally-not-ai[bot] wants to merge 3 commits into
Draft
totally-not-ai[bot] wants to merge 3 commits into
totally-not-ai[bot] wants to merge 3 commits into
Conversation
Page.getJsInvoker(Class) declares and runs page level JavaScript the way the element level entry point does, so a call made through it sends no expression either and needs no unsafe-eval. It schedules the way Page.executeJs does, so the two reach the client in the order they were made. A page invoker has no element to apply its function to, which the target of an invocation now says, and the client runs such a function with no `this` - page level JavaScript works on globals. Creating the invoker itself is shared by the two entry points, so a method may return the same things and an unusable interface is refused the same way wherever it came from.
Both paths build their invocation and hand it to one place that owns it with the root node, the way the element side funnels its two paths through one scheduler. The marker that ties the expression javadoc to its element counterpart sits with that method again, and the call type says it can come from either invoker. The combination the client's channel indexing depends on is covered too: a call with no element that is subscribed to, where the channels follow the arguments with nothing in between, and a page invoker method that answers with the execution.
|
Contributor
21 tasks
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.
Depends on #25749
Part of #10759
Part of #25734
missing API · flow-server, flow-client · applications that want a
strict content security policy for page level JavaScript
Background — JS invokers. #25749 adds interfaces that declare the
JavaScript the server can invoke as
@JsExpressionconstants, collectedinto the bundle by the build. An invocation then names the interface and
the method instead of carrying a script, so nothing is compiled in the
browser and the call works without
unsafe-eval.That covers the element level entry point. This adds the page level one,
so
Pagedeclares its JavaScript the same wayElementdoes.Risks:
Page.getJsInvoker(Class), andJsInvokersas thefactory both entry points hand out invokers through.
parameter after the arguments is the element to apply the function to.
Server and client change together.
this, wherePage.executeJsruns its expression against the context object. Thatkeeps the framework's plumbing out of declared JavaScript, which works
on globals instead.
performance.
Context. The types the declarations use are already neutral between
the two entry points; what was missing was the page level way in, and a
way for the client to know that a call has no element behind it.
Page.getJsInvoker(Class)schedules the wayPage.executeJsdoes, soan invoker call and an expression reach the client in the order they
were made.
that owns it with the root node.
JsInvokerscreates the invoker for both entry points, so what amethod may return and which interfaces are usable are the same
wherever an invoker came from.
function with no
thiswhen it does not.