My .on('open')
handlers are not getting called for windows spawned by links with a target=
attribute. Let me demonstrate.
I have this extension:
let tabs = require('sdk/tabs');
let windows = require('sdk/windows').browserWindows;
tabs.on('open', function(tab) {
console.log("tabs.open: " + tab);
});
windows.on('open', function(window) {
console.log("windows.open: " + window);
});
tabs.on('ready', function(tab) {
console.log("tabs.ready: " + tab);
});
windows.on('ready', function(window) {
console.log("windows.ready: " + window);
});
tabs.on('load', function(tab) {
console.log("tabs.load: " + tab);
});
windows.on('load', function(window) {
console.log("windows.load: " + window);
});
And this test page:
<html><body>
<h1>Firefox SDK target=_blank event listener bug</h1>
<p><code>windows.on('open')</code> doesn't catch new tabs/pages made with a target set.</p>
<p>Try opening <a href="https://developer.mozilla.org/en-US/developers/docs/policies/reviews#section-binary" target="_blank">this link</a> in a new tab, and then by clicking on it, and compare the output from the extension.</p>.
</html></body>
Here is what the extension prints by right clicking and saying “new tab” on the link in the demo page:
console.log: disabletabs: tabs.open: [object Object]
console.log: disabletabs: windows.open: [object Object]
console.log: disabletabs: tabs.ready: [object Object]
console.log: disabletabs: tabs.load: [object Object]
And here it is by just clicking:
console.log: disabletabs: tabs.ready: [object Object]
console.log: disabletabs: tabs.load: [object Object]
What gives? Is target=
special or is this a bug in the SDK?
Edit: I should mention that if I have “Open new windows in a new tab instead” on, aka browser.link.open_newwindow = 3
, target=_blank
links work like any other new window/tab.