Tab open event fires before Tab is added to windows.browserWindows tab list.

RESOLVED INVALID

Status

RESOLVED INVALID
6 years ago
3 years ago

People

(Reporter: Gilgeson, Unassigned)

Tracking

Details

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5

Steps to reproduce:

Attach listener for tab's open event:

require('tabs').on('open', function(tab) {
  for each (var win in require('windows').browserWindows) {
    for (var i = 0; i < win.tabs.length; ++i) {
      if (tab == win.tabs[i]) {
        console.log('found window');
        return;
      }
    }
  }
  console.log('not found');
});

I need to be able to identify which window the new tab belongs to and use this approach to do so since the open event does not include this information.  The work around I found was to add require('timer').setTimeout and delay the handler for 1 millisecond.  Then I get the correct result.  I assume this works because the timer allows the JavaScript engine to continue processing and the function is called when flow is released by the Addon.


Actual results:

Prints "not found".


Expected results:

Prints "found window"
This is not a bug with addons.mozilla.org.  -> INVALID
Status: UNCONFIRMED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → INVALID
(Assignee)

Updated

3 years ago
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.