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) {
if ( tabId === null ) {
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
if ( chrome.runtime.lastError ) { /* noop */ }
var tab = tabs && tabs[0];
if ( tab ) {
tab.id = tab.id.toString();
chrome.tabs.query(
{ active: true, currentWindow: true },
function(tabs) {
if ( chrome.runtime.lastError ) { /* noop */ }
callback(
Array.isArray(tabs) && tabs.length !== 0 ? tabs[0] : null
);
}
callback(tab);
});
);
return;
}

View File

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