fix(browser): host agent browser in workbench
This commit is contained in:
1 parent
9a1f182397
commit
efb44f9340
12 files changed
+136
-41
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
import {
|
||||
browserHostView,
|
||||
closeAgentBrowser,
|
||||
createAgentBrowser,
|
||||
publishBrowserHostOpened,
|
||||
setBrowserBounds,
|
||||
setBrowserHostEventSink
|
||||
} from '../src/main/browser-host'
|
||||
|
||||
async function main(): Promise<void> {
|
||||
await app.whenReady()
|
||||
const owner = new BrowserWindow({ show: false, width: 1335, height: 916 })
|
||||
const events: Array<{ type: string; id: string; sessionId?: string }> = []
|
||||
setBrowserHostEventSink(event => events.push({ type: event.type, id: event.view.id, sessionId: event.view.sessionId }))
|
||||
|
||||
const sessionId = 'browser-agent-regression'
|
||||
const agent = createAgentBrowser(owner, sessionId)
|
||||
await agent.contents.loadURL('data:text/html,<title>Agent Browser</title><h1>ready</h1>')
|
||||
|
||||
assert.equal(browserHostView(owner, agent.id, sessionId).visible, false)
|
||||
setBrowserBounds(owner, agent.id, { x: 20, y: 20, width: 800, height: 600 }, sessionId)
|
||||
assert.equal(browserHostView(owner, agent.id, sessionId).visible, true)
|
||||
publishBrowserHostOpened(owner, agent.id, sessionId)
|
||||
assert.deepEqual(events, [{ type: 'opened', id: agent.id, sessionId }])
|
||||
|
||||
closeAgentBrowser(owner, agent.id, sessionId)
|
||||
setBrowserHostEventSink(undefined)
|
||||
owner.destroy()
|
||||
console.log('Agent browser host lifecycle regression checks passed.')
|
||||
app.quit()
|
||||
}
|
||||
|
||||
void main().catch(error => {
|
||||
console.error(error)
|
||||
app.exit(1)
|
||||
})
|
||||
Reference in new issue
Block a user