add disconnectEverything function. add new test where playwright sees
existing page tab
This commit is contained in:
@@ -68,6 +68,30 @@ async function toggleExtensionForActiveTab(): Promise<{ isConnected: boolean; st
|
||||
return { isConnected, state }
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
globalThis.disconnectEverything = disconnectEverything
|
||||
|
||||
async function disconnectEverything() {
|
||||
const { connectedTabs, connection } = useExtensionStore.getState()
|
||||
|
||||
// Disconnect all tabs
|
||||
for (const tabId of connectedTabs.keys()) {
|
||||
await disconnectTab(tabId)
|
||||
}
|
||||
|
||||
// Force close connection if it still exists
|
||||
const state = useExtensionStore.getState()
|
||||
if (state.connection) {
|
||||
state.connection.close('Manual full disconnect')
|
||||
useExtensionStore.setState({
|
||||
connection: undefined,
|
||||
connectionState: 'disconnected',
|
||||
connectedTabs: new Map(),
|
||||
errorText: undefined
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
globalThis.getExtensionState = () => useExtensionStore.getState()
|
||||
|
||||
@@ -75,6 +99,7 @@ declare global {
|
||||
var state: typeof useExtensionStore
|
||||
var toggleExtensionForActiveTab: () => Promise<{ isConnected: boolean; state: ExtensionState }>
|
||||
var getExtensionState: () => ExtensionState
|
||||
var disconnectEverything: () => Promise<void>
|
||||
}
|
||||
|
||||
async function resetDebugger() {
|
||||
|
||||
Reference in New Issue
Block a user