Implement Page.addScriptToEvaluateOnNewDocument CDP handler#57248
Closed
GijsWeterings wants to merge 1 commit into
Closed
Implement Page.addScriptToEvaluateOnNewDocument CDP handler#57248GijsWeterings wants to merge 1 commit into
GijsWeterings wants to merge 1 commit into
Conversation
Summary: Implement the CDP `Page.addScriptToEvaluateOnNewDocument` and `Page.removeScriptToEvaluateOnNewDocument` methods in the modern JS inspector (`jsinspector-modern`). `Page.addScriptToEvaluateOnNewDocument` registers a JavaScript snippet that is evaluated in every new JS runtime created for the Host (for example, after a reload), before the application's main bundle runs, matching the standard Chrome DevTools Protocol semantics. This is useful for debugger frontends and tooling that need to install instrumentation ahead of application code. The registered scripts are stored as session state (alongside `Runtime.addBinding` subscriptions in `SessionState`) and replayed onto each new runtime by `RuntimeAgent` via the runtime executor, so they run before any user code and survive reloads. Per CDP semantics the script does not run in the runtime that is current when it is registered; the client triggers `Page.reload` to apply it. `HostAgent` handles both methods, returning the generated script `identifier` from add and removing by `identifier` on remove. Changelog: [General][Added] - Implement the `Page.addScriptToEvaluateOnNewDocument` and `Page.removeScriptToEvaluateOnNewDocument` CDP methods in the modern inspector Reviewed By: hoxyq Differential Revision: D107084044
|
@GijsWeterings has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107084044. |
|
This pull request has been merged in bc20ec8. |
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.
Summary:
Implement the CDP
Page.addScriptToEvaluateOnNewDocumentandPage.removeScriptToEvaluateOnNewDocumentmethods in the modern JS inspector (jsinspector-modern).Page.addScriptToEvaluateOnNewDocumentregisters a JavaScript snippet that is evaluated in every new JS runtime created for the Host (for example, after a reload), before the application's main bundle runs, matching the standard Chrome DevTools Protocol semantics. This is useful for debugger frontends and tooling that need to install instrumentation ahead of application code.The registered scripts are stored as session state (alongside
Runtime.addBindingsubscriptions inSessionState) and replayed onto each new runtime byRuntimeAgentvia the runtime executor, so they run before any user code and survive reloads. Per CDP semantics the script does not run in the runtime that is current when it is registered; the client triggersPage.reloadto apply it.HostAgenthandles both methods, returning the generated scriptidentifierfrom add and removing byidentifieron remove.Changelog:
[General][Added] - Implement the
Page.addScriptToEvaluateOnNewDocumentandPage.removeScriptToEvaluateOnNewDocumentCDP methods in the modern inspectorReviewed By: hoxyq
Differential Revision: D107084044