1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

this hopefully fixes #955

This commit is contained in:
gorhill 2015-11-21 08:06:14 -05:00
parent 651c620226
commit cb1a176e21

View File

@ -2384,15 +2384,34 @@ vAPI.toolbarButton = {
}); });
}; };
// https://github.com/gorhill/uBlock/issues/955
// Defer until `NativeWindow` is available.
tbb.initOne = function(win, tryCount) {
if ( typeof tryCount !== 'number' ) {
tryCount = 0;
}
if ( !win.NativeWindow ) {
tryCount += 1;
if ( tryCount < 10 ) {
vAPI.setTimeout(
this.initOne.bind(this, win, tryCount),
200
);
}
return;
}
var label = this.getMenuItemLabel();
var id = win.NativeWindow.menu.add({
name: label,
callback: this.onClick
});
menuItemIds.set(win, id);
};
tbb.init = function() { tbb.init = function() {
// Only actually expecting one window under Fennec (note, not tabs, windows) // Only actually expecting one window under Fennec (note, not tabs, windows)
for ( var win of winWatcher.getWindows() ) { for ( var win of winWatcher.getWindows() ) {
var label = this.getMenuItemLabel(); this.initOne(win);
var id = win.NativeWindow.menu.add({
name: label,
callback: this.onClick
});
menuItemIds.set(win, id);
} }
cleanupTasks.push(shutdown); cleanupTasks.push(shutdown);