Tabs can steal focus using alert/prompt/confirm popups
Reported by berendja...@gmail.com, Oct 17 2008
Chrome Version : Official Build 2200 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13 URLs (if applicable) : http://skypher.com/SkyLined/Repro/Chrome/tabs%20steal%20focus/repro.html Other browsers tested: Add OK or FAIL after other browsers where you have tested this issue: Safari 3: NOT APPLICABLE Firefox 3: FAIL IE 7: OK What steps will reproduce the problem? 1. Open a page in a new tab 2. Shift focus to another tab 3. Page in new tab executes an alert/confirm/prompt popup What is the expected result? Focus remains on current tab What happens instead? Focus shifts to tab that executes the alert/confirm/prompt popup
Oct 17 2008,
Filed with mozilla as 460434: https://bugzilla.mozilla.org/show_bug.cgi?id=460434
Jul 25 2009,
interesting... Opera is passing this test btw
May 19 2010,
this can be especially bad if the alert was actually important or there could be fallout from the wrong reply to a choice it gives. i was just typing a facebook message when an online banking-related tab stole my focus and my keystrokes did something to dismiss the alert before i even got to see it. not good.
Jun 1 2014,
Issue 159329 is similar and will probably be resolved by the same fix.
Jun 1 2014,
Issue 159329 has been merged into this issue.
Sep 5 2014,
There's a profound irony here. There's an API for web notifications: https://developer.mozilla.org/en-US/docs/Web/API/notification This requires permission from the page in question, which is denied by default. But it doesn't steal focus, and as far as I can tell, can't really do anything evil. Gmail does this for incoming emails, assuming it's granted permission. On the other hand, all webpages are allowed to alert() with impunity. This steals focus, not just from other tabs, but from whole other applications, unless the window manager implements some sort of focus-stealing protection.
Sep 6 2014,
The alert in the repro link still prevents me from switching or closing tabs as of Chrome 38.0.2125.44 (Official Build 291484) beta-m, 64-bit, Windows 7. Looks like Firefox fixed this in 2010; in v28 I can close or switch away from an alert-blocked tab: https://bugzilla.mozilla.org/show_bug.cgi?id=59314
Apr 17 2015,
This also steals focus from other Chromium windows, even if they belong to a different profile. This issue should be escalated to a security issue, as it provides a small denial-of-service vector on the client side towards the user without permission, breaking one of the basic security assumptions of web browsing: That each website should be isolated and self-contained and not be able to affect the user and system whatsoever, unless given explicit permission through some user action.
Apr 30 2015,
Current behavior in Firefox on Linux is: 1. Alerts activate a tab in the browser window switching away from any other tab. 2. Alerts do not activate a browser window (so work done in another window including another Firefox window is not interrupted) 3. It is possible to switch away from the alerting tab to another tab without dismissing the alert. 4. Input to other tabs is not blocked.
Aug 21 2015,
Nov 13 2015,
Oct 11 2017,
Bug isn't fixed, focus is still stolen (although alert closes on tab switch).
Oct 13 2017,
True. I'll be fixing this :)
Feb 11 2018,
Maybe it is now solved. But I miss this 'feature'. I have a webapp that gives alerts when it needs my attention. It needs my attention, even when I'm on another tab.. Now I see a blue dot on the webapp-tab. But I easily overlook that. Is there a way to turn this feature (steal focus) on or off?
Feb 11 2018,
maybe look at using Notifications instead: https://developer.mozilla.org/en-US/docs/Web/API/notification
Feb 13 2018,
Tabs don't seem to steal focus anymore, but at least in MacOS, if the tab is selected and you are using another application, Chrome will steal focus from it. This is pretty annoying, especially when doing something like running Selenium tests with chromedriver when the test involves alerts.
In Chrome 67.0.3396.62 on Windows 7 x64, alerts and the onbeforeunload confirmation still steal focus from other tabs and apps. This bug breaks the Livereload web development workflow: if the an open tab with the project being worked on has an active beforeunload handler, Chrome steals focus from the IDE on every save.
Sign in to add a comment