Closed Bug 2005673 Opened 7 months ago Closed 7 months ago

"save file as" dialog does not open anymore in Firefox frontend tests

Categories

(Remote Protocol :: Agent, defect, P2)

defect
Points:
2

Tracking

(firefox-esr115 unaffected, firefox-esr140 unaffected, firefox146 unaffected, firefox147 fixed, firefox148 fixed)

RESOLVED FIXED
148 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox146 --- unaffected
firefox147 --- fixed
firefox148 --- fixed

People

(Reporter: aryx, Assigned: jdescottes)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [webdriver:m18])

Attachments

(3 files)

Affected: Firefox 147+

The "Save file as" dialog does not open anymore in Firefox frontend tests.
Example: https://github.com/mozilla/fx-desktop-qa-automation/blob/baeea19b5c9ba890ee628cd05b6b31dfb874ca96/tests/downloads/test_download_pdf.py

Steps to reproduce the issue by Ben Chatterton:
The following steps should reproduce the issues we’re seeing in automated sessions re: downloading.

  1. Have Python >3.11.0 installed.
  2. Have Selenium 4.23.1 installed via pip.
  3. Have the version of Firefox under test installed and get its location in the filesystem.
  4. Download and run the attached script with selenium in the python env:
    python wait_for_manual_download.py <location of Fx executable>
  5. An automation window should open to the USCIS page for the I-9 form. You could change the link in the script to point to any pdf. You have 100 seconds to do any actions you like. This can be changed in the script.
  6. Open the devtools console if you are checking for the error message.
  7. Click the download button in the pdf.js frame.
  8. You have reproduced the bug if a Save As alert/modal does NOT appear and the file is NOT saved.
  9. The previous behavior was that the Save As modal appeared, and when OK was pressed, the file was downloaded, as shown by the progress icon and by inspecting the Downloads from the Panel UI.
  10. You can exit the script by the normal keyboard interrupts or wait for it to time out.

When I try to save a file I see the following JavaScript error in the console:

console.error: [Exception... "JavaScript component does not have a method named: "appendFilter"'JavaScript component does not have a method named: "appendFilter"' when calling method: [nsIFilePicker::appendFilter]"  nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)"  location: "JS frame :: chrome://global/content/contentAreaUtils.js :: appendFiltersForContentType :: line 940"  data: no]

I assume this is because we setup a mock file picker which landed as:
https://github.com/mozilla-firefox/firefox/commit/75ac0fc100a3#diff-cc7fa355eaeaf461512254a5fa2a9ba122864b689ac65adb382771868efeb168

Flags: needinfo?(jdescottes)
Component: General → Agent
Product: Firefox → Remote Protocol

This is also easy to reproduce:

  1. Start Firefox with mach run --setpref="remote.log.level=Trace" --setpref="remote.log.truncate=false" --remote-debugging-port --remote-allow-origins=https://juliandescottes.github.io
  2. Load https://juliandescottes.github.io/bidi-web-client/web/ in your normal browser
  3. Click the Connect button
  4. Click the Send button for the session.new command
  5. Try to save the open web page

Commenting out the following line fixes it for me:
https://github.com/mozilla-firefox/firefox/blob/438a3ce10eb77fb50d968463b7741117aec5bb4a/remote/shared/webdriver/Session.sys.mjs#L292

Maybe as a quick workaround we could only setup the file picker mock for BiDi, but finally we should still discuss when the mock should be used. There are still cases when the real file picker needs to be shown to users. Maybe we have to let test frameworks decide if the mock needs to be used or not by eg. providing a preference.

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

Commenting out the following line fixes it for me:
https://github.com/mozilla-firefox/firefox/blob/438a3ce10eb77fb50d968463b7741117aec5bb4a/remote/shared/webdriver/Session.sys.mjs#L292

Maybe as a quick workaround we could only setup the file picker mock for BiDi, but finally we should still discuss when the mock should be used. There are still cases when the real file picker needs to be shown to users. Maybe we have to let test frameworks decide if the mock needs to be used or not by eg. providing a preference.

For the time being, let's both only setup the file picker for BiDi and add a preference.

Normally whether file pickers are allowed or dismissed automatically should fully be handled by the user prompt behavior, which is Bug 1999693, so this will make the preference redundant in the long run.

The other issue is that at the moment, the file picker handler intercepts any file picker, and we would only want to intercept the ones from content pages.

Flags: needinfo?(jdescottes)
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/94019fef135b https://hg.mozilla.org/integration/autoland/rev/1c7be8d51fad [bidi] Only dismiss file pickers for BiDi sessions with dismiss preference set r=whimboo
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch

firefox-beta Uplift Approval Request

  • User impact if declined: Prevents firefox frontend tests from running correctly due to automatically dismissed file pickers
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: low
  • Explanation of risk level: Only impacts webdriver / marionette, simple JS patch.
  • String changes made/needed: N/A
  • Is Android affected?: no
Attachment #9532854 - Flags: approval-mozilla-beta?

Adds a new hidden preference to enable dismissing file pickers: remote.bidi.dismiss_file_pickers.enabled , defaults to false.
Dismissing file pickers is now only ever possible for sessions handling bidi commands
The FilePickerHandler.allowFilePickers is now a no-op if there was no matching call for dismissFilePickers

Original Revision: https://phabricator.services.mozilla.com/D276167

Attachment #9532854 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Severity: -- → S3
Points: --- → 2
Priority: -- → P2
Whiteboard: [webdriver:m19]
Whiteboard: [webdriver:m19] → [webdriver:m18]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: