sendToTab function ✓ 100.0%
Last updated: 2026-02-24T21:07:57.586Z
Metrics
LOC: 19
Complexity: 5
Params: 4
Coverage: 100.0% (6/6 lines, 7x executed)
Signature
sendToTab(
tabId: number,
tabUrl: string | undefined,
message: ExtensionMessage,
): : Promise<unknown>
Source Code
async function sendToTab(
tabId: number,
tabUrl: string | undefined,
message: ExtensionMessage,
): Promise<unknown> {
const url = tabUrl ?? "";
if (!url.startsWith("http://") && !url.startsWith("https://")) {
return { error: "Content script not available on this page" };
}
try {
return await chrome.tabs.sendMessage(tabId, message);
} catch (initialError) {
return {
error: "Content script not responding",
details: String(initialError),
};
}
}
No outgoing dependencies.
No incoming dependencies.