-
Notifications
You must be signed in to change notification settings - Fork 28
Don't allow modal dialogs for background pages #52
Comments
@martinthomson suggests making the dialogs tab-modal rather than making them only work in focused tabs. |
Note that this isn't easy, it might also be extremely difficult. window.alert() and friends are synchronous and block script execution. Freeing the "main thread" for use by other windows - which can also synchronously call into the same window in some circumstances - isn't trivial. |
To be clear, Firefox implements such a thing. We do it by violating run-to-completion in some cases, effectively. |
Violating run-to-completion seems like a reasonable compromise. These are crappy APIs. |
Last I saw, you could get Firefox into deadlock through judicious use of alerts. Maybe those were just bugs that have been fixed though. I agree that violating run-to-completion is fine in principle in this case, but I think we can get away with something simpler. The specific thing we're working on is queuing up alerts done in background tabs but continuing JS execution as if the user had clicked OK on the alert. For confirm and prompt we're hoping to just not fire them as we think it's probably extremely rare to use confirm/prompt in background tabs. |
I am confused by the title and first comment to this bug. I see "Don't allow modal dialogs for background pages" and "Remove the power from JavaScript dialogs by making them not block tab switching" as two very different things. Chromium already implements the latter, not allowing dialogs to block tab switching, by auto-dismissing them when the user switches tabs. As for the former, changing To add precision to @ojanvafai's answer: For Chromium already ignores While the title is "don't allow modal dialogs for background pages", the real motivation here is to remove activation of pages. Page activation enables problems ranging from popunders to URL spoofs. While Chromium can remove activation for I am coming to this from the front end, so I'm not sure of the consequences of violating run-to-completion, and I certainly don't know enough to implement it. I believe my approaches to our dialog woes are spec compliant, user-friendly, and aren't that drastic. |
Just so we're clear, the goal of the Firefox behavior has little to do with dialogs from background tabs per se. The key part of the Firefox behavior is that a user should be able to completely ignore a dialog from any tab if they want to. If the foreground tab It sounds like Chrome is trying to solve a quite different problem. |
That's exactly the problem we're trying to solve, too. We've already removed the app-modality from the dialogs, and we're removing the activation too. |
In my scenario above, in Chrome dev, the prompt will get dismissed if the user switches to a different tab to look something up. You're trying to solve the "modal dialogs should not trap the user" problem, as far as I can tell, which is not the same as the problem Firefox was trying to solve with its design. (Which says nothing about which of those problems needs solving, from a user point of view.) |
We're revisiting the interventions repo in an attempt to move everything to the appropriate issue trackers (in this case the one for the HTML Standard). See #72. From what I can tell, the various participants here are discussing several possible behaviors:
The current spec for modals is somewhat-intentionally vague and is trying to allow all sorts of things here. It allows early returns for any reason, and the pause spec says that implementations are encouraged to experiment with things that are not pausing. That said, by the exact letter of the spec I don't think violating run to completion is allowed, or auto-dismissing modals when switching tabs, or queuing up modals in background tabs (in particular there's nothing that says you can show a non-blocking alert after the user switches back). In my opinion this isn't a big deal, as such "spec violations" aren't really web-observable (with the possible exception of RTC violations). And they seem unlikely to cause any significant interop issues where users get a broken experience in only one browser. But if anyone feels like we should flesh out the spec more in this area, or that the lack of interop around ways people are making modals less-terrible is causing issues in the wild, please raise an issue on whatwg/html and we'll definitely look into it. |
Remove the power from JavaScript dialogs by making them not block tab switching.
The text was updated successfully, but these errors were encountered: