This commit is contained in:
gorhill 2015-06-02 18:12:28 -04:00
parent 25070003bb
commit 8a73a093d9
1 changed files with 14 additions and 11 deletions

View File

@ -742,9 +742,12 @@ var tabWatcher = (function() {
if ( tabbrowser === browser ) { if ( tabbrowser === browser ) {
return 0; return 0;
} }
return vAPI.fennec ? // Fennec
tabbrowser.tabs.indexOf(browser) : // https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/BrowserApp
tabbrowser.browsers.indexOf(browser); if ( vAPI.fennec ) {
return tabbrowser.tabs.indexOf(tabbrowser.getTabForBrowser(browser));
}
return tabbrowser.browsers.indexOf(browser);
}; };
var indexFromTarget = function(target) { var indexFromTarget = function(target) {
@ -975,7 +978,7 @@ var tabWatcher = (function() {
return { return {
start: start, start: start,
browserFromTarget: browserFromTarget, browserFromTarget: browserFromTarget,
tabs: function() { return browserToTabIdMap.keys(); }, browsers: function() { return browserToTabIdMap.keys(); },
tabIdFromTarget: tabIdFromTarget, tabIdFromTarget: tabIdFromTarget,
browserFromTabId: browserFromTabId, browserFromTabId: browserFromTabId,
indexFromTarget: indexFromTarget, indexFromTarget: indexFromTarget,
@ -1573,8 +1576,8 @@ vAPI.net.registerListeners = function() {
// Popup candidate // Popup candidate
if ( details.openerURL ) { if ( details.openerURL ) {
for ( var tab of tabWatcher.tabs() ) { for ( var browser of tabWatcher.browsers() ) {
var URI = tab.currentURI; var URI = browser.currentURI;
// Probably isn't the best method to identify the source tab. // Probably isn't the best method to identify the source tab.
// Apparently URI can be undefined under some circumstances: I // Apparently URI can be undefined under some circumstances: I
@ -1585,7 +1588,7 @@ vAPI.net.registerListeners = function() {
continue; continue;
} }
sourceTabId = tabWatcher.tabIdFromTarget(tab); sourceTabId = tabWatcher.tabIdFromTarget(browser);
if ( sourceTabId === tabId ) { if ( sourceTabId === tabId ) {
sourceTabId = null; sourceTabId = null;
@ -2230,11 +2233,11 @@ vAPI.lastError = function() {
vAPI.onLoadAllCompleted = function() { vAPI.onLoadAllCompleted = function() {
var µb = µBlock; var µb = µBlock;
var tabId; var tabId;
for ( var tab of tabWatcher.tabs() ) { for ( var browser of tabWatcher.browsers() ) {
tabId = tabWatcher.tabIdFromTarget(tab); tabId = tabWatcher.tabIdFromTarget(browser);
µb.tabContextManager.commit(tabId, tab.currentURI.asciiSpec); µb.tabContextManager.commit(tabId, browser.currentURI.asciiSpec);
µb.bindTabToPageStats(tabId); µb.bindTabToPageStats(tabId);
tab.messageManager.sendAsyncMessage( browser.messageManager.sendAsyncMessage(
location.host + '-load-completed' location.host + '-load-completed'
); );
} }