[dotnet] Added function to enable halting targets until runtime.runIfWaitingForDebugger is invoked #13330
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.
Description
This PR introduces
EnableWaitForDebuggerOnStart
function toDevToolsSession.cs
which enables halting new targets (tabs for instance) until theruntime.runIfWaitingForDebugger
command is invoked. For instance when wanting to capture the network traffic on a new target, the network domain should be instructed to do so before the target is doing any network traffic.In PR #13175 the datastructure for listening to the TargetAttached events was introduced.
In a follow up pull request I will introduce the ability to sent multiple DevTools commands in a single SendCommand function. This will allow proper handling of the TargetAttached event. The singular SendCommand function will get blocked because the commands running against that target will be blocked until
runtime.runIfWaitingForDebugger
is invoked. By bundling the commands we can get around that issue.Also see; #10603
Motivation and Context
When a new target (new tab for instance) is created DevTools continues execution based on the WaitForDebugger property set in the SetAutoAttach feature. When the WaitForDebugger property is set to false DevTools continues without waiting the consumer to properly enable all domains on the target. For instance when being interested in network events from the network domain we need to invoke Network.enable for that specific target. The current behavior causes some of the network events to be missing due to Selenium enabling the domains after the target already performed network requests.
By allowing consumers to enable the WaitForDebugger property we can enable all domains and tell DevTools whenever we are ready by using the Run.runIfWaitingForDebugger command.
Types of changes
Checklist