Closed Bug 1701686 Opened 3 years ago Closed 3 years ago

Inappropriate handling of tab modal dialogs from another tab

Categories

(Remote Protocol :: Marionette, defect, P3)

Default
defect

Tracking

(firefox90 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

(Blocks 2 open bugs)

Details

Attachments

(5 files)

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0 ID:20210322093509

Marionettes modal dialog handler uses callbacks to inform about opened and closed modal dialogs:

https://searchfox.org/mozilla-central/rev/d58860eb739af613774c942c3bb61754123e449b/testing/marionette/modal.js#138,156

While this works fine for modal dialogs of the attached window, which block every tab, it's inappropriate for tab modals. Consumers currently only check for the ChromeWindow and as such would handle a tab modal dialog that gets opened in a not currently selected tab (window handle).

https://searchfox.org/mozilla-central/rev/d58860eb739af613774c942c3bb61754123e449b/testing/marionette/actors/MarionetteCommandsParent.jsm#79
https://searchfox.org/mozilla-central/rev/d58860eb739af613774c942c3bb61754123e449b/testing/marionette/driver.js#232-234

Before we fix that we need a good set of modal dialog tests (global and tab only) that open in a background tab.

This bug blocks my work on bug 1686741.

The patch on https://phabricator.services.mozilla.com/D110270 for Remote Agent will help us to only care about dialogs of the currently selected tab.

It actually needs a change in Toolkit, which is part of the patch on bug 1686743.

Depends on: 1686743

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #2)

It actually needs a change in Toolkit, which is part of the patch on bug 1686743.

This landed and is marked fixed. Is this bug now fixed too?

Flags: needinfo?(hskupin)

No, we have to make use of the new toolkit code to filter out modals from other than the currently selected tab.

Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Flags: needinfo?(hskupin)

So over on bug 1686743 the filtering of newly opened tab modals is done via:

const dialogs = browser.tabDialogBox.getContentDialogManager().dialogs;
dialog = dialogs.find(dialog => dialog.frameContentWindow === dialogWindow);

This wont work for the old tab modals. So given that we would like to keep backward compatibility for Marionette there are two questions:

  1. Will we clearly ship with Firefox 89 with the new modal dialogs enabled by default?
  2. Will the pref prompts.contentPromptSubDialog continue to exist so that users could switch back to the old modals?

If 2) is true how could we best check if the dialog is part of the current browser? Would dialogWindow.previousSibling === browser be a good check?

Flags: needinfo?(mconley)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #5)

  1. Will we clearly ship with Firefox 89 with the new modal dialogs enabled by default?

Yes, that's currently the plan.

  1. Will the pref prompts.contentPromptSubDialog continue to exist so that users could switch back to the old modals?

I'm going to guess "no", but redirecting to Gijs who probably knows better.

Flags: needinfo?(mconley) → needinfo?(gijskruitbosch+bugs)

(In reply to Mike Conley (:mconley) (:⚙️) (Catching up on needinfos) from comment #6)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #5)

  1. Will we clearly ship with Firefox 89 with the new modal dialogs enabled by default?

Yes, that's currently the plan.

  1. Will the pref prompts.contentPromptSubDialog continue to exist so that users could switch back to the old modals?

I'm going to guess "no", but redirecting to Gijs who probably knows better.

Not long-term, though we probably don't have time to remove it for 89, I don't think that means we need to support it though.

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to :Gijs (he/him) from comment #7)

Not long-term, though we probably don't have time to remove it for 89, I don't think that means we need to support it though.

Ok, but do we see any risks so far in a possible disabling of the feature in a late beta? I know that this is impossible to say but if there are risks I would feel better to keep the support for the old modals in Marionette until all the old code gets removed. If we turn it off late in beta or even in a release this might have an affect for thousands of external CI systems. I would kinda like to avoid this situation.

It's fairly easy to keep support for it in Marionette right now, and file a follow-up to remove the old code once it's gone in Firefox. As such (just to ask again) would dialogWindow.previousSibling === browser be a good idea?

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #8)

(In reply to :Gijs (he/him) from comment #7)

Not long-term, though we probably don't have time to remove it for 89, I don't think that means we need to support it though.

Ok, but do we see any risks so far in a possible disabling of the feature in a late beta? I know that this is impossible to say

"never say never", but the number of things that depend on this shipping is pretty large at this point.

but if there are risks I would feel better to keep the support for the old modals in Marionette until all the old code gets removed. If we turn it off late in beta or even in a release this might have an affect for thousands of external CI systems. I would kinda like to avoid this situation.

Sure, up to you.

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #5)

So over on bug 1686743 the filtering of newly opened tab modals is done via:

const dialogs = browser.tabDialogBox.getContentDialogManager().dialogs;
dialog = dialogs.find(dialog => dialog.frameContentWindow === dialogWindow);

If 2) is true how could we best check if the dialog is part of the current browser? Would dialogWindow.previousSibling === browser be a good check?

I think for both cases it'd be better to find the container of the dialog in the parent document, and ensure it is a descendant of the same container as the current browser. This avoids depending a lot on the current DOM hierarchy and having to change the code every time specifics in nesting levels or whatever vary. In particular, given a browser, you can do:

let container = browser.closest(".browserSidebarContainer");

and given a dialog window with the new dialogs, you can get its framing element using let frame = win.docShell.chromeEventHandler. Then container.contains(frame) will tell you if it's for the current tab. For the old dialogs, you get some prompt element as the subject of the observer notification, and you can use that directly with container.contains(subject), I think.

Does that help?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(hskupin)

Most of the existing tests in that file are meanwhile covered
by Wdspec tests, and as such can be removed. Only the
HTTP authentication tests have to remain for now given that
those aren't part of the WebDriver specification yet.

To allow the handling of all different modal dialog types,
which are displayed as content, tab, or window alert appropriate
tests have been added.

Using the "waitForEvent" promise will cause an extra
"DOMModalDialogClosed" event to be logged, which is
confusing.

(In reply to :Gijs (he/him) from comment #9)

Does that help?

Not completely but lets move the discussion over to the following Phabricator revision given that it is better to see real code:
https://phabricator.services.mozilla.com/D112366

Flags: needinfo?(hskupin)
Blocks: 1707497
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/58330e039fb5
[marionette] Refactor modal dialog unit tests. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/03d581e59446
[marionette] Use GeckoDriver's dialog handler to inform MarionetteCommands parent actor about a new user prompt. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/895269c78868
[marionette] Use GeckoDriver's dialog observer when awaiting open dialog to be closed. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/04d5757d8706
[marionette] Switch To Window has to check for open user prompts. r=marionette-reviewers,jdescottes,webdriver-reviewers
https://hg.mozilla.org/integration/autoland/rev/9e157e8bf594
[marionette] Only handle user prompts from the currently selected tab. r=marionette-reviewers,webdriver-reviewers,Gijs,jdescottes
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/28683 for changes under testing/web-platform/tests

Backed out 5 changesets (Bug 1701686) for causing xpcshell failures in test_modal.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/775a656b6ded712269f8b87db0a0ed4185b5e8b8
Push with failures, failure log.

Flags: needinfo?(hskupin)
Upstream PR was closed without merging

(In reply to Alexandru Michis [:malexandru] from comment #18)

Backed out 5 changesets (Bug 1701686) for causing xpcshell failures in test_modal.js

With reverting an optional change the xpcshell test has been fixed. We will re-check via bug 1707497 how to remove the ownerGlobal checks and improve the test_modal.js test.

Flags: needinfo?(hskupin)
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ffdbe61355a
[marionette] Refactor modal dialog unit tests. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/6d2c8ff216fc
[marionette] Use GeckoDriver's dialog handler to inform MarionetteCommands parent actor about a new user prompt. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/e352f905ecf8
[marionette] Use GeckoDriver's dialog observer when awaiting open dialog to be closed. r=marionette-reviewers,jdescottes
https://hg.mozilla.org/integration/autoland/rev/1cddea72d353
[marionette] Switch To Window has to check for open user prompts. r=marionette-reviewers,jdescottes,webdriver-reviewers
https://hg.mozilla.org/integration/autoland/rev/15253a3168d2
[marionette] Only handle user prompts from the currently selected tab. r=marionette-reviewers,webdriver-reviewers,Gijs,jdescottes

(In reply to Web Platform Test Sync Bot (Matrix: #interop:mozilla.org) from comment #17)

Created web-platform-tests PR
https://github.com/web-platform-tests/wpt/pull/28683 for changes under
testing/web-platform/tests

James, can you please poke merging this PR?

Flags: needinfo?(james)
Upstream PR merged by moz-wptsync-bot
Flags: needinfo?(james)
Regressions: 1708191
Regressions: 1708494
No longer regressions: 1708494
Regressions: 1721982
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: