fixup 978e5ca9: don't reuse the same object in async code!
This commit is contained in:
parent
2495ded507
commit
e4de02995c
|
@ -166,7 +166,6 @@ window.addEventListener('storageReady', function _() {
|
||||||
updateIcon({id: undefined}, {});
|
updateIcon({id: undefined}, {});
|
||||||
|
|
||||||
const NTP = 'chrome://newtab/';
|
const NTP = 'chrome://newtab/';
|
||||||
const PING = {method: 'ping'};
|
|
||||||
const ALL_URLS = '<all_urls>';
|
const ALL_URLS = '<all_urls>';
|
||||||
const contentScripts = chrome.runtime.getManifest().content_scripts;
|
const contentScripts = chrome.runtime.getManifest().content_scripts;
|
||||||
// expand * as .*?
|
// expand * as .*?
|
||||||
|
@ -189,12 +188,11 @@ window.addEventListener('storageReady', function _() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const pingCS = (cs, {id, url}) => {
|
const pingCS = (cs, {id, url}) => {
|
||||||
const maybeInject = pong => !pong && injectCS(cs, PING.tabId);
|
const maybeInject = pong => !pong && injectCS(cs, id);
|
||||||
cs.matches.some(match => {
|
cs.matches.some(match => {
|
||||||
if ((match === ALL_URLS || url.match(match)) &&
|
if ((match === ALL_URLS || url.match(match)) &&
|
||||||
(!url.startsWith('chrome') || url === NTP)) {
|
(!url.startsWith('chrome') || url === NTP)) {
|
||||||
PING.tabId = id;
|
sendMessage({method: 'ping', tabId: id}, maybeInject);
|
||||||
sendMessage(PING).then(maybeInject);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user