[e10s] Add API for iterating over all (content) windows

RESOLVED WONTFIX

Status

()

Firefox
Extension Compatibility
--
enhancement
RESOLVED WONTFIX
3 years ago
a year ago

People

(Reporter: Jeferson Hultmann, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(e10s+, firefox41 affected)

Details

(Reporter)

Description

3 years ago
Sometimes extension code running in the chrome process needs to know what content windows are opened.

It is a trivial task for non-e10s code, but currently for e10s it requires too much work.

For example, it is useful for network/TabSelect observers.

I suggest something like the following.

=======8<-------

var map = Components.utils.winMap;
var innerId;

innerId = channel.loadInfo.innerWindowID;
innerId = map.getCurrentInnerId(tab.linkedBrowser.outerWindowID);

map.getOuterId(innerId);
map.getUrl(innerId);        // "https://www.mozilla.org/"
map.getParent(innerId);     // 17
map.getTop(innerId);        // 11
map.getOpener(innerId);     // -1
map.getFrames(innerId);     // [21, 22, 23]
map.getTopContentWindows(); // [11, 12, 13, 14, 15] (i.e. 5 tabs)
map.isContent(innerId);     // true
map.getAllWindows();        // [11, 21, ...] // chrome windows too?


// observers, so I can keep the data in a worker thread:

var obs = {
  observe: function(subject, topic, data) {
    var innerId = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
    console.log("new window: " + Cu.winMap.getUrl(innerId));
  
    var outerId = map.getOuterId(map.getTop(innerId));
    var browser = tabbrowser.getBrowserForOuterWindowID(outerId);
  }
};

Services.obs.addObserver(obs, "inner-window-added", false);
// and "inner-window-removed"
(Reporter)

Comment 1

3 years ago
Adblock Plus has a use case for it.
> Something we really need is a way to go from window/parentWindowId to the corresponding URL

https://issues.adblockplus.org/ticket/2504#comment:8
Blocks: 905436

Comment 2

3 years ago
> It is a trivial task for non-e10s code
> but currently for e10s it requires too much work.

imo it would be better for everyone to have a solution that reduces the boilerplate code that's needed for asynchronously talking to content (and getting return values, not just 1-way messages) instead of adding specialized code for every specific use-case. outlined my thoughts in bug 1147592.
tracking-e10s: --- → +
It's been a year and no-one has picked this up. It sounds like it is possible, to do this right now, but could be simpler. Given the move to WebExtensions, I'm tempted to close as won't fix on this. Any objections?
(Reporter)

Comment 4

a year ago
I'm the reporter for this bug, and I have no objections.

Updated

a year ago
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.