Closed Bug 2005963 Opened 3 months ago Closed 2 months ago

downloads.download() unnecessarily requires an active browser window

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(firefox149 fixed)

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

Attachments

(1 file)

As part of fixing bug 2005953, I created a xpcshell test to serve as a regression test. The test calls browser.downloads.download() with saveAs:true to open a file picker, but that API call failed because xpcshell tests do not have browser windows, but the ext-downloads.js implementation looks up one at https://searchfox.org/firefox-main/rev/d0cad31feab6676471f18793c8feff24b2434ab0/toolkit/components/extensions/parent/ext-downloads.js#931

That issue was hit before in bug 1623704, which relaxed the original implementation (strictly expecting a Firefox browser window) to the current one (expecting any platform-specific "browser" window).

This logic does not only fail in xpcshell tests, it would also fail if Firefox is running without a browser window.

I looked into the implementation, and the window (specifically its browsingContext) usage is as follows:

None of these uses depend on the input being a browser window. I think that we can safely fall back, or even only use, the (chrome privileged) window that owns the extension context (browser window for extension tabs/popups, or the headless window for background contexts).

A xpcshell test for this behavior will be added in bug 2005953.

Assignee: nobody → rob
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P3
Whiteboard: [addons-jira]
Pushed by rob@robwu.nl: https://github.com/mozilla-firefox/firefox/commit/3ffaf75cf1b9 https://hg.mozilla.org/integration/autoland/rev/77d20d8968e6 Do not require an active browser window in downloads.download() r=extension-reviewers,rpl
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch

This was not fixed yet, the patch was reverted in https://bugzilla.mozilla.org/show_bug.cgi?id=2005953#c8

This confusion caused be to reland the other patch without this patch, which resulted in another revert at https://bugzilla.mozilla.org/show_bug.cgi?id=2005953#c8

analysis: https://bugzilla.mozilla.org/show_bug.cgi?id=2005953#c10

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Pushed by rob@robwu.nl: https://github.com/mozilla-firefox/firefox/commit/c16604dceb7c https://hg.mozilla.org/integration/autoland/rev/aa9d1d3bb2bb Do not require an active browser window in downloads.download() r=extension-reviewers,rpl
Status: REOPENED → RESOLVED
Closed: 2 months ago2 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: