diff --git a/headless/lib/browser/protocol/target_handler.cc b/headless/lib/browser/protocol/target_handler.cc index 548be825e526b..55f3054bc4a45 100644 --- a/headless/lib/browser/protocol/target_handler.cc +++ b/headless/lib/browser/protocol/target_handler.cc @@ -8,6 +8,9 @@ #include #include "build/build_config.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" #include "headless/lib/browser/headless_browser_context_impl.h" #include "headless/lib/browser/headless_browser_impl.h" #include "headless/lib/browser/headless_web_contents_impl.h" @@ -110,6 +113,19 @@ Response TargetHandler::CreateTarget( HeadlessWebContentsImpl* web_contents_impl = HeadlessWebContentsImpl::From( context->CreateWebContentsBuilder().SetInitialURL(gurl).Build()); + // The hidden target hosts a `window.cdp` binding wired to a trusted + // browser-level DevTools session. Its siteless about:blank navigation + // never reaches SetIsUsed(), so the process would otherwise be treated as + // a freely-reusable allows-any-site host and unrelated web content could + // be co-scheduled with it at the process limit. Mark the process used so + // IsSuitableHost() rejects it for sites that require a dedicated process. + // (Mirrors content::HiddenTargetManager, which the headless embedder layer + // bypasses by handling Target.createTarget itself.) + web_contents_impl->web_contents() + ->GetPrimaryMainFrame() + ->GetProcess() + ->SetIsUsed(); + *out_target_id = content::DevToolsAgentHost::GetOrCreateFor( web_contents_impl->web_contents()) ->GetId();