-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use win.destroy to destroy Electron windows, log more events #5603
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a few types of driver tests to confirm this works...
- setting
window.unbeforeunload
callback - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
onbeforeload
dialog blocking the window from closing.Additional details
win.close
, which is just like clicking X on the window - if anonbeforeload
handler is triggered, it will wait for that to be resolved beforeclosed
is emitted and the window is really closedwin.destroy
is used to kill the window, which is analogous to how wecp.kill
chrome's processwin.destroy
d once the parent closesclose, responsive, session-end, unresponsive
eventsHow has the user experience changed?
Before
Logs would continue on forever after
After
PR Tasks