fix #3425 (regression from 6cdb20df)

This commit is contained in:
Raymond Hill 2018-01-10 17:59:07 -05:00
parent d706415890
commit 36b1eac88e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 16 additions and 12 deletions

View File

@ -390,14 +390,15 @@ vAPI.tabs.registerListeners = function() {
vAPI.tabs.get = function(tabId, callback) { vAPI.tabs.get = function(tabId, callback) {
if ( tabId === null ) { if ( tabId === null ) {
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { chrome.tabs.query(
if ( chrome.runtime.lastError ) { /* noop */ } { active: true, currentWindow: true },
var tab = tabs && tabs[0]; function(tabs) {
if ( tab ) { if ( chrome.runtime.lastError ) { /* noop */ }
tab.id = tab.id.toString(); callback(
Array.isArray(tabs) && tabs.length !== 0 ? tabs[0] : null
);
} }
callback(tab); );
});
return; return;
} }

View File

@ -1015,7 +1015,7 @@ var µb = µBlock,
/******************************************************************************/ /******************************************************************************/
var getLoggerData = function(ownerId, tab, callback) { var getLoggerData = function(ownerId, activeTabId, callback) {
var tabIds = {}; var tabIds = {};
for ( var tabId in µb.pageStores ) { for ( var tabId in µb.pageStores ) {
var pageStore = µb.pageStoreFromTabId(tabId); var pageStore = µb.pageStoreFromTabId(tabId);
@ -1023,9 +1023,8 @@ var getLoggerData = function(ownerId, tab, callback) {
if ( pageStore.rawURL.startsWith(extensionPageURL) ) { continue; } if ( pageStore.rawURL.startsWith(extensionPageURL) ) { continue; }
tabIds[tabId] = pageStore.title; tabIds[tabId] = pageStore.title;
} }
var activeTabId; if ( activeTabId && tabIds.hasOwnProperty(activeTabId) === false ) {
if ( tabIds.hasOwnProperty(tab.id) ) { activeTabId = undefined;
activeTabId = tab.id;
} }
callback({ callback({
colorBlind: µb.userSettings.colorBlindFriendly, colorBlind: µb.userSettings.colorBlindFriendly,
@ -1083,7 +1082,11 @@ var onMessage = function(request, sender, callback) {
return; return;
} }
vAPI.tabs.get(null, function(tab) { vAPI.tabs.get(null, function(tab) {
getLoggerData(request.ownerId, tab, callback); getLoggerData(
request.ownerId,
tab && tab.id.toString(),
callback
);
}); });
return; return;