From e4de02995c314a2b51fd6165cfa80adb1b62ad85 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 26 Nov 2017 00:04:19 +0300 Subject: [PATCH] fixup 978e5ca9: don't reuse the same object in async code! --- background/background.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/background/background.js b/background/background.js index e79ed593..c8530050 100644 --- a/background/background.js +++ b/background/background.js @@ -166,7 +166,6 @@ window.addEventListener('storageReady', function _() { updateIcon({id: undefined}, {}); const NTP = 'chrome://newtab/'; - const PING = {method: 'ping'}; const ALL_URLS = ''; const contentScripts = chrome.runtime.getManifest().content_scripts; // expand * as .*? @@ -189,12 +188,11 @@ window.addEventListener('storageReady', function _() { }; const pingCS = (cs, {id, url}) => { - const maybeInject = pong => !pong && injectCS(cs, PING.tabId); + const maybeInject = pong => !pong && injectCS(cs, id); cs.matches.some(match => { if ((match === ALL_URLS || url.match(match)) && (!url.startsWith('chrome') || url === NTP)) { - PING.tabId = id; - sendMessage(PING).then(maybeInject); + sendMessage({method: 'ping', tabId: id}, maybeInject); return true; } });