Use win.destroy to destroy Electron windows, log more events#5603
Use win.destroy to destroy Electron windows, log more events#5603brian-mann merged 7 commits intodevelopfrom
Conversation
|
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
jennifer-shehane
left a comment
There was a problem hiding this comment.
I've confirmed that this properly exits Electron when having a beforeunload handler (tried both types of listeners). It also adds extra logging, which I added screenshots of to the PR description.
brian-mann
left a comment
There was a problem hiding this comment.
let's add a few types of driver tests to confirm this works...
- setting
window.unbeforeunloadcallback - using
window.addEventListener('beforeunload', (evt) => evt.returnValue = '...) - do the same pattern above except do it with child windows by using
window.open()from the AUT - which will load in child windows that use the same listener patterns
@flotwig get with @jennifer-shehane - she put together a small sandbox confirming both ways are broken in electron.
|
The situations Brian is mentioning that require coverage in tests: window.onbeforeunload = function(){
return 'Are you sure you want to leave?';
};window.addEventListener('beforeunload', function(){
return 'Are you sure you want to leave?';
}; |
|
Ok, I think I added the appropriate tests in |
brian-mann
left a comment
There was a problem hiding this comment.
All this looks good except no reason to create all those separate e2e tests in the driver - we can use a single spec file and just cy.visit() the different fixtures... i will fix it now and merge.
User facing changelog
Fixed a long-standing bug where runs using Electron would sometimes hang at the end if there is an
onbeforeloaddialog blocking the window from closing.Additional details
win.close, which is just like clicking X on the window - if anonbeforeloadhandler is triggered, it will wait for that to be resolved beforeclosedis emitted and the window is really closedwin.destroyis used to kill the window, which is analogous to how wecp.killchrome's processwin.destroyd once the parent closesclose, responsive, session-end, unresponsiveeventsHow has the user experience changed?
Before
Logs would continue on forever after
After
PR Tasks