Repository navigation
Description
Use case
An unattended local client needs to determine whether a tab it previously owned was physically closed if the Playwright Extension connection ends during cleanup. The client must preserve unrelated tabs and cannot assume that a missing page in a new Playwright session means it was closed.
Reproduction
Verified on Windows with Playwright Extension 0.6.0 and both @playwright/mcp 0.0.83 and 0.0.86, using disposable Chromium profiles and only loopback pages.
- Put a control tab in a disposable profile and connect Playwright MCP with the extension token. Navigate the new token-created tab to a unique loopback URL. Record the original native tab ID using independent Chrome tab inventory as the test witness.
- In case A, disconnect the Playwright browser connection while that tab is still open. In case B, close the tab, verify that the original ID is absent using the same witness, and disconnect. The harness used the public Playwright
Browser.close()on the extension-backed connection to cause the disconnect. In A the oldPageemittedcloseandisClosed()became true while the native tab remained. - Start a fresh MCP connection with the same profile, client name, and token, then call
browser_tabswith{ "action": "list" }. - In both cases the new session sees one new blank tab and cannot see the original page. The independent inventory still sees the original ID in A and confirms it is absent in B. The control tab survives both.
The documented interactive group picker works in the open case: connect without auto-approval, select the old group, and click Allow. On 0.0.83 the reattached page was verified against the exact original native tab ID. This requires user interaction and does not provide a machine-readable result for both cases.
Requested capability
Could the extension offer a profile-scoped, read-only status lookup for an opaque handle issued while the tab was owned, or a durable browser-side acknowledgment for closing that exact handle? For a status lookup, distinguish open, closed, and unknown across transport reconnect. It should create no tabs and expose no unrelated tab information. Unknown handle, wrong profile, lost authorization, or ambiguous state should return unknown.
The two reconnect cases above are acceptance tests, along with wrong profile/handle and preservation of unrelated tabs. The request differs from #41874, which addresses establishing a connection again, and #41864, which concerns the new bootstrap tab.
Activity
carabinshely commentedon Nov 25, 2026
Runnable three-case reproduction
Save the script below as
repro.cjs. Pass four absolute paths: thenode_modulesfor@playwright/mcp@0.0.86, a Chromium executable that supports headless extensions, an unpacked copy of Playwright Extension 0.6.0, and a new output directory under a private temporary directory. Use a test shell with no Playwright MCP browser overrides. Example:node repro.cjs <node_modules> <chromium.exe> <unpacked-extension> <new-output-dir>. It generates its own token within each disposable profile and uses only loopback content.The three cases passed on Windows. The control tab survived each case and all disposable processes exited. In the disconnect-open case the old Page reports closed but the original native ID remains; the new token session has a different tab. Disconnect-after-close exposes the same new-session view but the original ID is absent. The extension worker is only the independent observer for this test.
For a regression test of a fix, assert browser-side status of the same scoped handle: ordinary close → closed, disconnect while open → open, disconnect after close → closed, wrong handle or profile → unknown. Querying the status should not create another tab. No enumeration of other tabs or new browser permissions are needed.
repro.cjs
microsoft-playwright-automation commentedon Nov 25, 2026
microsoft-playwright-automation commentedon Nov 25, 2026
Hi, I'm the Playwright bot. I checked the extension's ownership rules and tested both reconnect states.
The requested status lookup is not available today. On current main, a fresh connection cannot distinguish a previously owned tab that is still open from one that was closed. This matches the documented disconnect behavior: ownership ends on disconnect, and a token connection starts with a new blank tab. A missing page, or the old
Page.isClosed(), is not proof of physical tab closure.This needs a new cross-connection API, not a change to reconnect or tab listing. The current protocol has neither a retained, authorized handle nor a status-query connection that avoids opening a tab. I have not proposed a patch because defining access after ownership ends, revocation and retained close records changes the extension's API and lifetime rules.
Verification and existing coverage
Tested on Windows with Playwright
1.66.0-next, commitb9cff8a68a090c27d29d856747265732468acff0, the source-built extension0.6.0, and headless Chromium159.0.8154.33.I extended the existing
client leaves and its tabs stay open without the debuggertest locally. It connects directly to the real extension protocol, using the same profile, token and client name on each connection. Native tab IDs from the extension worker serve only as an independent test witness.The unrelated control tab kept its original ID. Giving the open tab back to the client restored access to that exact ID. Thus, loss of ownership and physical closure produce the same refusal; that refusal cannot serve as a closure result.
The extended test passed. The existing protocol tests for ordinary tab creation/removal and browser-wide command restrictions also passed. The existing full client-lifecycle test attempt timed out waiting for the connect page: its JavaScript browser launcher cannot be spawned directly on this Windows runner (
EFTYPE). The direct-protocol tests bypass that test launcher, not the extension's ownership checks.I did not rerun published MCP
0.0.83/0.0.86, headed mode, or wrong-profile/handle status queries: no such status operation exists. Firefox and WebKit do not run this Chromium extension suite.Existing coverage already checks token connections leaving the old group for user selection in
client-lifecycle.spec.ts. The implementation releases all ownership on disconnect and removes released tabs from the registry. It keeps no closed-handle history. The manage page's internalgetStatusreports current sessions, not historical tab state.This is distinct from #41874 and #41864. No pull request linked to this request was found.
Triaged on Windows by the Playwright bot - agent run
dgozman commentedon Nov 25, 2026
I can't say that I understood the request fully. Are you looking for a way to close all tabs upon disconnect? Something like
--close-tabs-on-disconnect? See alsodetach --close-tabsfor the cli.