Intent to Ship: window.prompt() will not activate parent page

431 views
Skip to first unread message

Avi Drissman

unread,
Nov 10, 2016, 3:20:40 PM11/10/16
to blink-dev

Contact emails

a...@chromium.org


Spec

The relevant spec here is https://html.spec.whatwg.org/#dom-prompt .


Summary

If a document in a background tab calls window.prompt(), currently that tab is brought to the front, and the user is presented with the prompt dialog. As part of phase 1 of Project OldSpice, this will no longer be the case; if a document in a background tab calls window.prompt() then the call to prompt() will return immediately, and no dialog will be shown to the user for that call to prompt(). If the tab is foremost (if it is the active tab in the front window), then the call will show a dialog. Specifically, this removes the ability to use window.prompt() to bring a tab to the front against the user’s will.


The ability for pages to bring themselves forward using the window alert API (alert/confirm/prompt) is user-hostile, as it interrupts what the user is doing in whatever tab they’re working in. It is also not required by the spec, which also gives us discretion to not show a dialog at all.


The usage metrics for window.prompt() is 0.0007%, which is well below the cutoff of 0.03% required for feature removal. This is not an intent to remove the feature, just to remove some power from it that isn’t required by the spec and that is user-hostile.


Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Android and desktop behaviors when it comes to dialogs are already different. In the future, some OldSpice interventions will come to mobile, but right now this is desktop only.


Interoperability and Compatibility Risk

Neither Firefox nor Safari nor Edge allows this activation, though they differ in details.


Firefox doesn’t allow pages to pull themselves to the front (via dialogs) by default, although permission can be granted by the user. Firefox labels the tab as needing attention. Firefox does not suppress the dialog, but preserves it until the user switches to the tab. That is accomplished by nesting event loops, which is troublesome for them and therefore something we do not want to do.


Safari doesn’t allow pages to pull themselves to the front (via dialogs) and doesn’t provide it as an option. It provides no visible indication that a page has put up a dialog. Safari does not suppress the dialog, but preserves it until the user switches to the tab. However, this causes any tabs that share a renderer with the alerting tab to hang, beachballing the user with no indication of why that is happening. This is also something we do not want to do.


Edge doesn’t allow pages to pull themselves to the front (via dialogs) by default, and it labels the tab as needing attention. Edge does not suppress the dialog, but preserves it until the user switches to the tab. It is unknown what mechanism it uses.


Given the downsides to trying to preserve dialogs and the need for simplicity and consistency, we are opting to entirely suppress prompt() dialogs from background tabs rather than attempt to preserve them.


Entry on the feature dashboard

https://www.chromestatus.com/feature/5637107137642496

Rick Byers

unread,
Nov 12, 2016, 3:02:00 PM11/12/16
to Avi Drissman, blink-dev
LGTM1

Prompt is so rare overall, that the chance of it ever being triggered in a background-tab scenario seems tiny, and almost certainly something the user wouldn't actually want.  Seems definitely like a reasonable tradeoff to me.  Note also that Avi added a console warning when this occurs, in case any developer is surprised by it.

Jochen Eisinger

unread,
Nov 12, 2016, 3:06:57 PM11/12/16
to Rick Byers, Avi Drissman, blink-dev
lgtm2

why are you doing prompt() only, and not alert/confirm as well?

Avi Drissman

unread,
Nov 12, 2016, 3:21:56 PM11/12/16
to Jochen Eisinger, Rick Byers, blink-dev
I'm doing prompt only for now because it has very low usage and I wanted to start with something that was low controversy. I do plan on extending it to cover alert and confirm, but I want to keep my focus on getting auto-dismissing dialogs out there.

Avi

Rick Byers

unread,
Nov 12, 2016, 3:28:04 PM11/12/16
to Avi Drissman, Jochen Eisinger, blink-dev
I agree this is a good idea, even just from a risk-mitigation strategy.  If we get feedback / regression reports from this change (seems highly unlikely) than that would obviously influence the strategy for prompt/alert.  It would be nice if all the APIs can behave exactly the same, but the pragmatic reality of web compat may not allow that :-(

Philip Jägenstedt

unread,
Nov 14, 2016, 4:29:57 AM11/14/16
to Rick Byers, Avi Drissman, Jochen Eisinger, blink-dev
LGTM3
Reply all
Reply to author
Forward
0 new messages