@@ -166,9 +166,9 @@ void MyApp::HandleDevToolsProtocalPTargets()
166166 })
167167 .Get(),
168168 &m_targetInfoChangedToken));
169- // Enable Runtime events to receive Runtime.consoleAPICalled events, which is fired when console.log is called.
169+ // Enable Runtime events for the default target of top page to receive Runtime.consoleAPICalled events, which is fired when console.log is called.
170170 m_webView->CallDevToolsProtocolMethod(L"Runtime.enable", L"{}", nullptr);
171- // Auto attach to iframe and dedicated worker targets created from this target.
171+ // Auto attach to iframe and dedicated worker targets created from the default target of top page .
172172 m_webView->CallDevToolsProtocolMethod(
173173 L"Target.setAutoAttach",
174174 LR"({"autoAttach": true ,"waitForDebuggerOnStart": false ,"flatten": true })", nullptr);
@@ -206,10 +206,11 @@ private void CoreWebView2_AttachedToTarget(CoreWebView2 sender, CoreWebView2DevT
206206 string url = GetJSONStringField (jsonMessage , L " url" );
207207 m_devToolsTargetDescriptionMap [targetId ] = type + L " ," + url ;
208208 // Auto attach to targets further created from this target.
209- _ = m_webview .CallDevToolsProtocolMethodAsync (sessionId , " Target.setAutoAttach" ,
210- @" {"" autoAttach"" :true,"" waitForDebuggerOnStart"" :false,"" flatten"" :true}" );
209+ _ = m_webview .CallDevToolsProtocolMethodAsync (" Target.setAutoAttach" ,
210+ @" {"" autoAttach"" :true,"" waitForDebuggerOnStart"" :false,"" flatten"" :true}" ,
211+ sessionId );
211212 // Enable Runtime events to receive Runtime.consoleAPICalled from the target, which is triggered by console.log calls.
212- m_webview .CallDevToolsProtocolMethodAsync (sessionId , " Runtime.enable" , " {}" );
213+ m_webview .CallDevToolsProtocolMethodAsync (" Runtime.enable" , " {}" , sessionId );
213214}
214215
215216private void CoreWebView2_DetachedFromTarget (CoreWebView2 sender , CoreWebView2DevToolsProtocolEventReceivedEventArgs args )
@@ -243,9 +244,9 @@ private void CoreWebView2_TargetInfoChanged(CoreWebView2 sender, CoreWebView2Dev
243244 m_webview .GetDevToolsProtocolEventReceiver (" Target.attachedToTarget" ).DevToolsProtocolEventReceived += CoreWebView2_AttachedToTarget ;
244245 m_webview .GetDevToolsProtocolEventReceiver (" Target.detachedFromTarget" ).DevToolsProtocolEventReceived += CoreWebView2_DetachedFromTarget ;
245246 m_webview .GetDevToolsProtocolEventReceiver (" Target.targetInfoChanged" ).DevToolsProtocolEventReceived += CoreWebView2_TargetInfoChanged ;
246- // Enable Runtime events to receive Runtime.consoleAPICalled events, which is fired when console.log is called.
247+ // Enable Runtime events for the default target of top page to receive Runtime.consoleAPICalled events, which is fired when console.log is called.
247248 _ = m_webview .CallDevToolsProtocolMethodAsync (" Runtime.enable" , " {}" );
248- // Auto attach to iframe and dedicated worker targets created from this target.
249+ // Auto attach to iframe and dedicated worker targets created from the default target of top page .
249250 _ = m_webview .CallDevToolsProtocolMethodAsync (" Target.setAutoAttach" ,
250251 @" {"" autoAttach"" :true,"" waitForDebuggerOnStart"" :false,"" flatten"" :true}" );
251252 }
@@ -310,7 +311,7 @@ namespace Microsoft.Web.WebView2.Core
310311 {
311312 // ICoreWebView2_10 members
312313 // This is an overload for: public async Task<string> CallDevToolsProtocolMethodAsync(string methodName, string parametersAsJson);
313- public async Task<string> CallDevToolsProtocolMethodAsync(string sessionId , string methodName , string parametersAsJson );
314+ public async Task<string> CallDevToolsProtocolMethodAsync(string methodName , string parametersAsJson , string sessionId );
314315 }
315316 }
316317
0 commit comments