| Summary: | tabs.sendMessage not getting any response back if script wasn't injected | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Guilherme Rizzo <guivr2011> |
| Component: | WebKit Extensions | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | karlcow, mike, rz.rustyzone, timothy, webkit-bug-importer |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 16 | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 13 | ||
If you try to run: browser.tabs.sendMessage(tab.id, { text: "are_you_there_content_script?" }, function (msg) { msg = msg || {} if (msg.status !== 'yes') { chrome.scripting.executeScript({ ... }) } } ) In Chrome and Firefox, the function gets called no matter the response. In Safari, the function never runs because no script has been injected into the page so far. Always getting a response back, even if empty, undefined, or null, would make checking if scripts were injected much easier. This is useful to run executeScript only when asked for and only once, without managing a state with a variable by pushing and removing tabIds where it has run. Otherwise, people will add content scripts that always run - much heavier than executing scripts only when requested.