(source, message, options = {})
| 526 | } |
| 527 | |
| 528 | async function sendToContentScript(source, message, options = {}) { |
| 529 | throwIfStopped(); |
| 530 | const { responseTimeoutMs = getContentScriptResponseTimeoutMs(message) } = options; |
| 531 | const registry = await getTabRegistry(); |
| 532 | const entry = registry[source]; |
| 533 | |
| 534 | if (!entry || !entry.ready) { |
| 535 | throwIfStopped(); |
| 536 | return queueCommand(source, message); |
| 537 | } |
| 538 | |
| 539 | const alive = await isTabAlive(source); |
| 540 | throwIfStopped(); |
| 541 | if (!alive) { |
| 542 | return queueCommand(source, message); |
| 543 | } |
| 544 | |
| 545 | throwIfStopped(); |
| 546 | return sendTabMessageWithTimeout(entry.tabId, source, message, responseTimeoutMs); |
| 547 | } |
| 548 | |
| 549 | async function sendToContentScriptResilient(source, message, options = {}) { |
| 550 | const { timeoutMs = 30000, retryDelayMs = 600, logMessage = '' } = options; |
no test coverage detected