diff --git a/gluon.d.ts b/gluon.d.ts index 260ae62..9d8fad7 100644 --- a/gluon.d.ts +++ b/gluon.d.ts @@ -339,7 +339,10 @@ type Window = { controls: ControlsApi, /** Close the Gluon window. */ - close(): void + close(): void, + + /** If the window has been closed or not. */ + closed: Boolean }; diff --git a/src/launcher/inject.js b/src/launcher/inject.js index 4a01d15..a3717b3 100644 --- a/src/launcher/inject.js +++ b/src/launcher/inject.js @@ -134,12 +134,17 @@ export default async (CDP, proc, injectionType = 'browser', { dataPath, browserN }, close: () => { + if (Window.closed) return false; + for (const handler of closeHandlers) handler(); // extra api handlers which need to be closed CDP.sendMessage('Browser.close'); CDP.close(); proc.kill(); + + return Window.closed = true; }, + closed: false, versions };