-
Notifications
You must be signed in to change notification settings - Fork 901
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
Don't try to suspend tabs with the "window.onbeforeunload" event #272
Comments
+1 |
Here's an example of a page that recently stole focus from me when it got suspended: I checked the event listeners registered to the page using dev tools. It has a number of unload events registered: I'm actually happy to write a patch to fix this bug, but I'd like some suggestions on the best way to go about it. I'm guessing a lot of pages have unload event handlers, so simply not suspending such pages would probably result in many pages remaining unsuspended. Does anyone know if there's a way from an extension to unbind some event handlers from a page? This way, we could just unbind all the unload event handlers before suspending the tab. |
Going to call out @deanoemcke in case he has any suggestions... Thanks! |
Extensions have access to the same window object as the tab? Right? |
Ah, makes sense. I haven't done much extension development so I wasn't sure how it worked. However, I just tried reproducing the issue and was not able to. So I may be barking up the wrong tree here. I'm now not sure what causes these pages to steal focus when they suspend. Hopefully I will find a reproduction case some day and fix it. |
Tabs can sometimes steal focus on suspension. Presumably, this is happening due to onunload/unbeforeunload even handlers. This change removes the event handlers before suspending the tab. Let's hope it works!
@rodrigograca31 I'm testing this change: Unfortunately, it doesn't seem to work for your example page: |
This issue is from 2015... I don't remember the exact problem but: If you go to: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload That probably also happens if the extension trys to suspend it after X minutes... |
I agree this is annoying. But I could not find a way to turn these popups off either. |
is it possible to detect whether a page has any onunload listeners registered? If so, another idea would be to have an option to allow users to simply not suspend pages that have onunload/onbeforeunload listeners registered. |
Some pages have code like this one:
When "The Great Suspender" tries to suspend them it fires the event.... And focus the page.... (because it's like an alert)
More information: http://www.w3schools.com/jsref/event_onbeforeunload.asp
Example:
The text was updated successfully, but these errors were encountered: