The current browsing context's document loses focus when a download is triggered because the DownloadsPanel takes focus
Categories
(Remote Protocol :: Agent, defect, P2)
Tracking
(firefox155 fixed)
| Tracking | Status | |
|---|---|---|
| firefox155 | --- | fixed |
People
(Reporter: julienw, Assigned: Sasha)
References
Details
(Whiteboard: [webdriver:m21][wptsync upstream][webdriver:relnote])
Attachments
(3 files, 1 obsolete file)
STR:
- Clone https://github.com/julienw/bug-firefox-webdriver-focus-after-download
- Run
npm ithennpm test
=> Notice that all focus-related tests fail after initiating download.
From what I see after removing the headless arg, the problem is that the download manager is present. If I add some code to send the Escape to the chrome, with some timeouts before/after to account for races, then the tests are passing as expected.
I understand it's useful for a user, especially for accessibility, but it would be good to have a pref to avoid that, that we could use in tests.
Thanks
Comment 1•4 months ago
|
||
Julien, does it still happen with the latest Nightly build?
Comment 2•4 months ago
|
||
I tried on latest main it still happens.
We can modify one of our wdspec tests to check that:
diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browser/set_download_behavior/download_behavior_allowed.py b/testing/web-platform/tests/webdriver/tests/bidi/browser/set_download_behavior/download_behavior_allowed.py
index 1fa9a1a37803..7828c4f9393c 100644
--- a/testing/web-platform/tests/webdriver/tests/bidi/browser/set_download_behavior/download_behavior_allowed.py
+++ b/testing/web-platform/tests/webdriver/tests/bidi/browser/set_download_behavior/download_behavior_allowed.py
@@ -1,4 +1,6 @@
import pytest
+import time
+from webdriver.bidi.modules.script import ContextTarget
pytestmark = pytest.mark.asyncio
@@ -21,7 +23,29 @@ async def test_destination_folder(bidi_session, new_tab, temp_dir,
"type": "allowed",
"destinationFolder": temp_dir
})
+
+ async def assert_has_focus():
+ hasFocus = await bidi_session.script.call_function(
+ arguments=[],
+ function_declaration="() => document.hasFocus()",
+ target=ContextTarget(new_tab["context"]),
+ await_promise=True,
+ user_activation=True,
+ )
+ assert hasFocus["value"]
+
+ # OK
+ await assert_has_focus()
+
+ # trigger the download, the download list will be displayed
event = await trigger_download(new_tab)
+
+ # wait a bit, does not fail immediately
+ time.sleep(1)
+
+ # KO: fails because focus is kept by the download manager
+ await assert_has_focus()
+
# Assert download is allowed.
assert event["status"] == "complete"
# Assert `destinationFolder` is respected.
Comment 4•4 months ago
|
||
Ok, so we are speaking about the downloader popup which stays open when a download is initiated and finished? If that's the case we should probably enforce that the popup doesn't get opened.
Comment 5•4 months ago
|
||
so we are speaking about the downloader popup which stays open when a download is initiated and finished?
Correct.
Comment 6•4 months ago
|
||
So the problem seems to be here:
https://searchfox.org/firefox-main/rev/410a52656dd13aa2360a3e96788e41bf48e80c0f/browser/components/downloads/content/downloads.js#349
We probably need a preference to control the panel, and that we can force it to not show up by default for WebDriver.
Comment 7•4 months ago
|
||
Could be an issue with async events, let's tackle this next milestone.
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 8•1 month ago
|
||
| Assignee | ||
Comment 9•1 month ago
|
||
| Assignee | ||
Comment 10•1 month ago
|
||
| Assignee | ||
Comment 11•1 month ago
|
||
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Comment 12•1 month ago
|
||
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/61665 for changes under testing/web-platform/tests
Comment 14•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/0a81792cc553
https://hg.mozilla.org/mozilla-central/rev/1b5d8b766328
https://hg.mozilla.org/mozilla-central/rev/4ca09fa6b1e8
Upstream PR merged by moz-wptsync-bot
Updated•13 days ago
|
Description
•