From 33969e8b2e5a6d9c42ef06ba5d2bc0e37bca3e54 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 20 Nov 2014 23:18:33 -0200 Subject: [PATCH] more spurious warnings in console foiled --- meta/crx/vapi-background.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/meta/crx/vapi-background.js b/meta/crx/vapi-background.js index 875930c31..ccbe85d4a 100644 --- a/meta/crx/vapi-background.js +++ b/meta/crx/vapi-background.js @@ -69,11 +69,22 @@ vAPI.tabs.registerListeners = function() { /******************************************************************************/ vAPI.tabs.get = function(tabId, callback) { + var onTabReady = function(tab) { + // https://code.google.com/p/chromium/issues/detail?id=410868#c8 + if ( chrome.runtime.lastError ) { + return; + } + callback(tab); + } if ( tabId !== null ) { - chrome.tabs.get(tabId, callback); + chrome.tabs.get(tabId, onTabReady); return; } var onTabReceived = function(tabs) { + // https://code.google.com/p/chromium/issues/detail?id=410868#c8 + if ( chrome.runtime.lastError ) { + return; + } callback(tabs[0]); }; chrome.tabs.query({ active: true, currentWindow: true }, onTabReceived); @@ -181,8 +192,7 @@ vAPI.tabs.remove = function(tabId) { vAPI.tabs.injectScript = function(tabId, details, callback) { var onScriptExecuted = function() { - // Must check `lastError` or else this may happen in the console: - // Unchecked runtime.lastError while running tabs.executeScript: The tab was closed. + // https://code.google.com/p/chromium/issues/detail?id=410868#c8 if ( chrome.runtime.lastError ) { } if ( typeof callback === 'function' ) {