Closed Bug 1835484 Opened 1 years ago Closed 1 year ago

browser.windows.create() fails when there are no windows

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(firefox119 fixed)

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

browser.windows.create() fails to open a window when there are no browser windows.

STR:

  1. Open the Browser Console.
  2. Close all browser windows.
  3. In the Browser Console, switch to Multiprocess and inspect any of the extensions (there are some built-ins ones, so even if you don't inspect any, there is one).
  4. Run: browser.windows.create({})
  5. Run: browser.windows.create({url: "https://example.com"})

Expected:

  • Step 4 should open a browser window.
  • Step 5 should open a browser window with example.com loaded.

Actual:

  • Step 4 does not open a window.
  • Step 5 works as expected.

Closing an re-opening the Browser Console shows the following error from step 4:

window is null ext-windows.js:163
getTriggeringPrincipalForUrl chrome://browser/content/parent/ext-windows.js:163
create chrome://browser/content/parent/ext-windows.js:346

The issue happens because when url is not set, then the implementation attempts to determine whether the "current window" is a private browsing window in order to choose the right origin attributes as needed. But when there are no windows (or similarly, if the extension is not allowed access to private windows and the only active window is a private window), then the failure happens because this window will be null: https://searchfox.org/mozilla-release/rev/c916c520d3573ff1935fba2af55bffc375ff7890/browser/components/extensions/parent/ext-windows.js#155

Severity: -- → S3
Priority: -- → P3
Whiteboard: [addons-jira]

I'm fixing this in another patch.

Assignee: nobody → rob
Depends on: CVE-2023-5725
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
You need to log in before you can comment on or make changes to this bug.