joelpt / sidewise

Persistent sidebar extension for Chrome featuring tree style tabs and tab hibernation.
Creative Commons Zero v1.0 Universal
68 stars 13 forks source link

Consider killing onbeforeunload listeners in pages before closing/hibernating #4

Open joelpt opened 12 years ago

joelpt commented 12 years ago

Currently if multiple tabs are closed/hibernated from the sidebar at once, and one of those pages has an onbeforeunload handler which pops up an alert/prompt/confirm box, Chrome/Sidewise freaks out and starts focusing and blurring the popup box as fast as it can. The user must basically kill Chrome when this happens to gain control again.

One possible solution is, when closing/hibernating 2+ pages from the sidebar, first go into each of those pages and unset any onbeforeunload handlers in those pages, then perform the close operation. This would probably alleviate the problem.

However, since this can be considered to break some pages' expected functionality, it perhaps should be made into an advanced option that the user can disable if they need to. Even though disabling it would then allow the problem to manifest, some users may have a strong need for onbeforeunload to always fire, e.g. for web apps or intranet sites that really need to do some cleanup work or really need to detect unsaved changes.

Another possible solution is to check upon closing/hibernating a page whether that page has an onbeforeunload listener; if it does, close the page, then actually wait until the page is closed before continuing with the remaining close/hibernate operations. In this case we'd need to work out some way to detect when a user declines to close a page via such a prompt() and either abort or continue the remaining close operations.

A third/mixed solution is to work out some way to detect when such a prompt() is shown and wait for it to be disposed, then proceed with the remaining close/hibernate operations. Not sure if there is any way to do this.