Closed Bug 877867 Opened 11 years ago Closed 7 years ago

browser/events does not work/emit until a new window is opened

Categories

(Add-on SDK Graveyard :: General, defect, P2)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: evold, Unassigned)

Details

Try:

require('sdk/event/core').on(require('sdk/browser/events').events, 'data', function() console.log('open'))

there should be a logged message but there is not, until you open a new window.
I want to work on sidebars, but I can't until this is done, unless I revert to using deprecated window-utils module..
I'm not sure why there would be a logged message since nothing changes. Can't you iterate over require("windows/utils").windows to get the currently open windows?
Assignee: nobody → evold
Hmm this looks intentional..

Past events are not track-able with the current interface.  One can only get future events.

With WindowTracker I could listen to all open windows and all future opened windows all in one line of code `WindowTracker({ onTrack: create })`

Now it appears I have to track all currently open & ready windows separately from future windows.. is this right?

I thought the new api was going to allow to to replace the above line with `on(browserEvents, 'load', create)`

but it seems I will have to add `windows().forEach(function(window) window.document.readyState == 'complete' && create(window))` beforehand..
Assignee: evold → nobody
Flags: needinfo?(rFobic)
(In reply to Erik Vold [:erikvold] [:ztatic] from comment #3)
> Hmm this looks intentional..
> 
> Past events are not track-able with the current interface.  One can only get
> future events.
> 
> With WindowTracker I could listen to all open windows and all future opened
> windows all in one line of code `WindowTracker({ onTrack: create })`
> 
> Now it appears I have to track all currently open & ready windows separately
> from future windows.. is this right?

This is correct, although note that while `open` event won't occur `load` event still may, depending on weather or not there are windows that are still loading.

> 
> I thought the new api was going to allow to to replace the above line with
> `on(browserEvents, 'load', create)`
> 
> but it seems I will have to add `windows().forEach(function(window)
> window.document.readyState == 'complete' && create(window))` beforehand..

Well note that while WindowTracker did gave you onTrack and onUntrack it had also negative side of not really knowing weather window was just loaded or it has being loaded for some time. Now you have to be little bit more explicit like here:
https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/content/events.js#L48-L55

That being said you're point is taken, we should probably have something that would give you track / untrack for cases when that's what you care about.

I'll submit a patch to do that.
Flags: needinfo?(rFobic)
No longer blocks: 787395
Assignee: nobody → rFobic
Hey Irakli, are you working on this one? if not could you please unassign yourself.
Flags: needinfo?(rFobic)
Assignee: rFobic → nobody
Flags: needinfo?(rFobic)
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.