Closed Bug 1949092 Opened 5 months ago Closed 5 months ago

<input type="file"> is not functionable in an options page embedded in the add-ons manager (about:addons)

Categories

(WebExtensions :: Frontend, defect, P1)

defect

Tracking

(firefox-esr128 unaffected, firefox135 unaffected, firefox136 verified, firefox137 verified)

VERIFIED FIXED
137 Branch
Tracking Status
firefox-esr128 --- unaffected
firefox135 --- unaffected
firefox136 --- verified
firefox137 --- verified

People

(Reporter: yuki, Assigned: robwu)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [addons-jira])

Attachments

(3 files, 1 obsolete file)

Abstract

File type input field (<input type="file">) does not work in an options page embedded in the add-ons manager (about:addons) page.
This problem was originally reported at https://github.com/piroor/treestyletab/issues/3707

Steps to reproduce

  1. Download the attached testcase XPI.
  2. Go to about:debugging and load the testcase XPI as a temporary extension.
  3. Go to about:addons.
  4. Choose the addon "testcase".
  5. Choose the "Options" tab.
  6. Click the "Browse..." button in the options page.

Actual result

Nothing happens.

Expected result

A file chooser dialog appears.

Environment

  • Nightly 137.0a1 (build ID: 20250218205441) on Windows 11 24H2
  • Firefox 136.0b7 (build ID: 20250217120651) on Windows 11 24H2

Additional information

This does not happen on Firefox 135.0.

Flags: needinfo?(echen)

To see what is happening, between step 5 and 6 of the STR, run the following snippet from the devtools (in the about:addons tab). In comments, I wrote the current output:

setTimeout(() => {
  let browser = document.querySelector("browser#addon-inline-options");
  let bc = browser.browsingContext;
  let chromeDoc = bc.topChromeWindow.document; // the browser.xhtml, as expected
  console.log(
    bc.canOpenModalPicker, // = false, which causes this bug (bug 1949092)
    chromeDoc.activeElement, // = about:addons browser (tab browser)
    bc.topFrameElement // == browser, i.e. the browser#addon-inline-options
  );
}, 3000);

The above shows that the logic at https://searchfox.org/mozilla-central/rev/0d1f8ff61fe506646fe3898ef727817b4436ab32/docshell/base/CanonicalBrowsingContext.cpp#3271,3285,3294 does not account for the special situation in about:addons, where a <browser> is embedded in tab content (source of browser#addon-inline-options).

Since I have a good understanding of what is going on, I'm going to work on a patch.

Assignee: nobody → rob
Severity: -- → S3
Status: NEW → ASSIGNED
Flags: needinfo?(echen)
Priority: -- → P1
Whiteboard: [addons-jira]

This issue is not limited to the options page, by the way. It also affects the sidebar.
To see this, install the tree-style tabs add-on (which opens the sidebar), and run the snippet from comment 3 in the global Browser Console, with the second replaced with:

let browser = document.querySelector("browser#sidebar").contentDocument.querySelector("browser#webext-panels-browser");

then click inside the sidebar to focus it. The output is:

  • bc.canOpenModalPicker = false
  • chromeDoc.activeElement = browser#sidebar
  • bc.topFrameElement = browser, i.e. the browser#webext-panels-browser

This shows that the logic from the regressor does not account for non tab browsers.

P.S. For completeness, I also verified what happens with extension popup panels. Their <browser> are non-tab browsers, but still embedded in the top level. It works as expected. To test that, use the snippet with let browser = document.querySelector("browser.webextension-popup-browser"); and click on an extension button (e.g. uBlock Origin's button).

See Also: → 1949587
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/7f1aa02c220e Fix canOpenModalPicker for nested browsers + tests r=edgar
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch

The patch landed in nightly and beta is affected.
:robwu, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox136 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(rob)
Attachment #9467757 - Flags: approval-mozilla-beta?

beta Uplift Approval Request

  • User impact if declined: Fixes recent regression that has not reached release yet; File pickers and color pickers cannot be used from extension settings page and sidebars
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: See comment 0 of bug report
  • Risk associated with taking this patch: Low
  • Explanation of risk level: Issue well understood, fix is targeted in specific area where the logic was flawed before; includes unit tests for all relevant cases
  • String changes made/needed: No
  • Is Android affected?: no
Flags: needinfo?(rob)
Attachment #9467761 - Flags: approval-mozilla-beta?
Attachment #9467761 - Attachment is obsolete: true
Attachment #9467761 - Flags: approval-mozilla-beta?
Attachment #9467757 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+

Verified as Fixed. Tested on the latest Nightly (137.0a1/20250224170755) and Beta (136.0b10/20250223143918 from https://treeherder.mozilla.org/jobs?repo=mozilla-beta&revision=55180bee8d857d8bd454040efe47889ccd8fe93e) under Windows 10 and Ubuntu 24.04 LTS.

As per the STR from Comment 0, clicking the “Browse…” button on the attached extension options page will display a file chooser dialog, confirming the fix.

Moreover, running the snippets from Comment 3 and Comment 5 as specified, will now return bc.canOpenModalPicker = true in all three cases mentioned in the comments, further confirming the fix.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: