Skip to content

Commit a314025

Browse files
kblokjnyrup
andauthored
fix: only wait for page and frame targets when connecting (#2731)
* fix: only wait for page and frame targets when connecting * Update lib/PuppeteerSharp/Cdp/ChromeTargetManager.cs Co-authored-by: Jonas Nyrup <[email protected]> --------- Co-authored-by: Jonas Nyrup <[email protected]>
1 parent 19460ad commit a314025

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/PuppeteerSharp/Cdp/ChromeTargetManager.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ private void StoreExistingTargetsForInit()
103103
null,
104104
_browser.ScreenshotTaskQueue);
105105

106-
// Targets from extensions and the browser that will not be
107-
// auto-attached. Therefore, we should not add them to
108-
// #targetsIdsForInit.
109-
var skipTarget = kv.Value.Type == TargetType.Browser || kv.Value.Url.StartsWith("chrome-extension://", StringComparison.OrdinalIgnoreCase);
110-
if (!skipTarget && (_targetFilterFunc == null || _targetFilterFunc(targetForFilter)))
106+
// Only wait for pages and frames (except those from extensions)
107+
// to auto-attach.
108+
var isPageOrFrame = kv.Value.Type is TargetType.Page or TargetType.IFrame;
109+
var isExtension = kv.Value.Url.StartsWith("chrome-extension://", StringComparison.OrdinalIgnoreCase);
110+
111+
if (isPageOrFrame && !isExtension && (_targetFilterFunc == null || _targetFilterFunc(targetForFilter)))
111112
{
112113
_targetsIdsForInit.Add(kv.Key);
113114
}

0 commit comments

Comments
 (0)