carlo icon indicating copy to clipboard operation
carlo copied to clipboard

Exit event isn't emitted

Open FranklinYu opened this issue 7 years ago • 3 comments

I tried the exact example in https://github.com/GoogleChromeLabs/carlo#usage. After I close the Chrome window, the node process did not exit, so I think the exit event is not emitted.

Node.js 10.14.2 Carlo 0.9.43 Windows 10, version 1803

Please advise if full package-lock.json is needed.

FranklinYu avatar Dec 22 '18 21:12 FranklinYu

I added this code, and chrome closes and node process exits, but I don't know why.

chrome side:

window.onbeforeunload = exit;

nodejs side:

await app.exposeFunction('exit', () => {
    app.exit();
    process.exit();
});

Node.js: 10.15.0 Carlo: 0.9.43 Windows 10 1809

shosatojp avatar Feb 01 '19 03:02 shosatojp

@shosatojp Thanks, that works. In addition, following doesn't work:

document.addEventListener('beforeunload', exit)

I have no idea why the event beforeunload doesn't work with addEventListener. Isn't addEventListener preferred?

FranklinYu avatar Feb 14 '19 20:02 FranklinYu

@FranklinYu I wrote this code, and checked preserve log option on chrome and pressed f5 to reflesh. I thought beforeunload event of window emits but document doesn't emit. addEventListener is not a cause.

document.addEventListener('beforeunload', function () {
    console.log('document beforeunload');
});
window.addEventListener('beforeunload', function () {
    console.log('window beforeunload');
});

log:

//F5
window beforeunload
//F5
window beforeunload

FYI, window.addEventListener('beforeunload', exit) works.

shosatojp avatar Feb 15 '19 01:02 shosatojp