sdk/windows.browserWindows does not include pre-existing private browsing windows when addon enabled or installed



3 years ago
a year ago


(Reporter: u463073, Unassigned)


Firefox Tracking Flags

(Not tracked)




3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0
Build ID: 20150819004006

Steps to reproduce:

Create a boilerplate jpm addon.
In the package.json, make sure you include
"permissions": { 
    "private-browsing" : true

Include the following line:
var windows = require("sdk/windows");
Access the windows.browserWindows property in the main function.
jpm run --debug
Add a breakpoint on the line that you access browserWindows.
Open a Private Window and keep the existing window open.
Disable then enable the addon.
Check the browserWindow objects returned by windows.browserWindows

Actual results:

windows.browserWindows only contains normal browsing windows.

Expected results:

windows.browserWindows should contain normal browsing windows AND private browsing windows. Docs suggest this should be the case (

Comment 1

3 years ago
In case it helps, this seems to stem from an issue with windows() in sdk/windows/utils.js
I stumbled upon this earlier:

for (let domWindow of windows()) {
  let window = makeNewWindow(domWindow);
  if (window instanceof BrowserWindow)
    addListItem(browserWindows, window);
There doesn't seem to be anything at this level to handle whether an opted in addon should be given private browsing windows too.

I was honestly just trying to patch up an old/broken addon when I ran into this weirdness!


3 years ago
Summary: sdk/windows.browserWindows does not include private browsing windows → sdk/windows.browserWindows does not include pre-existing private browsing windows when addon enabled or installed

Comment 2

3 years ago
Narrowed it down to freshly installed or enabled extensions not having access to any private windows that had been opened beforehand.
I genuinely can't tell whether this is by design (to protect privacy, I guess?) or a bug.
Just providing a prebuilt xpi unfortunately won't work with the test I built.
Hope someone is willing to clone and fire off a jpm run --debug.

Comment 3

2 years ago
I can confirm that it is a bug.

Users have reported that my add-on is not working in the inital private window when Firefox starts in private mode.

Every other additional window (private & regular) is getting exposed by the API, just not the initial private one.

I have created a test case for it:

I consider this a major bug, would be nice if it gets fixed.

Comment 4

2 years ago
Congratulations, Firefox staff.

You completely ignored this bug report for two years (also bug 1248903) and somewhen recently fixed this by accident.

I can no longer reproduce this bug and it works as expected now.
Last Resolved: a year ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.