While converting an addon SDK extension, it needs to query the windowtype attribute at one place to ensure it equals 'navigator:browser' to ensure it isn't working with some other type of window (say the bookmark manager) and it uses the following function to apply its settings while configureWindow() does nothing but create dynamic entries for the tab context menu.
Code: Select all
function refreshWindows() {
let windows = require("sdk/windows").browserWindows;
for (let window of windows) {
for (let tab of window.tabs) {
for (let subtab of tab.window.tabs) {
let win = viewFor(subtab.window);
configureWindow(win);
highlightBrowser(viewFor(tab), win);
refreshButtonIcons(win);
}
}
}
}
If configuring the window, then why go down to the level of tabs?
I've got it working with this equivalent -
Code: Select all
refreshWindows : function(){
var windows = Services.wm.getEnumerator('navigator:browser');
var window;
while(windows.hasMoreElements()){
window = windows.getNext().QueryInterface(Ci.nsIDOMWindowInternal);
//window = windows.getNext();
configureWindow(window);
for(let tab of window.gBrowser.tabs){
highlightBrowser(tab,window);
}
}
},
Code: Select all
function highlightBrowser(aTab, aWindow) {
if (!isBrowser(aWindow)) {
return;
}
...
}
Code: Select all
highlightBrowser : function(aTab, aWindow) {
if (aWindow.windowtype != "navigator:browser") {
return;
}
...
}
Where am I going wrong with my version of refreshWindows()