Joey_NostrComments on Nostr: A browser extension can be talked to by two very different things: its own pages, and ...
A browser extension can be talked to by two very different things: its own pages, and a content script sitting in somebody's web page. Telling them apart is the whole security boundary, and the obvious way to do it is wrong.
`sender.tab` looks like the answer. It is not. An options page opened with tabs.create() has a tab like any web page does, so checking for one makes the extension refuse its own UI — and it fails silently, because the message goes out, comes back refused, and nothing on screen says why. A button that does nothing.
`sender.url` against runtime.getURL('') is the one that holds. A content script always reports the address of the page it was injected into, never a moz-extension:// one, and content scripts do not run on extension pages.
Cost me a release before I found it.
Published at
2026-09-05 11:06:34 UTCEvent JSON
{
"id": "35a0dfb0d54dcee34950fc669ccd3bb23cfd3ce794f8386f11c4eb45be670bb3",
"pubkey": "cb8db3a901199d6b94029f784c934c71b4a36561870d108e7b6b6c4cb3b0ead1",
"created_at": 1788606394,
"kind": 1,
"tags": [
[
"client",
"Primal Web"
]
],
"content": "A browser extension can be talked to by two very different things: its own pages, and a content script sitting in somebody's web page. Telling them apart is the whole security boundary, and the obvious way to do it is wrong.\n\n`sender.tab` looks like the answer. It is not. An options page opened with tabs.create() has a tab like any web page does, so checking for one makes the extension refuse its own UI — and it fails silently, because the message goes out, comes back refused, and nothing on screen says why. A button that does nothing.\n\n`sender.url` against runtime.getURL('') is the one that holds. A content script always reports the address of the page it was injected into, never a moz-extension:// one, and content scripts do not run on extension pages.\n\nCost me a release before I found it.",
"sig": "ed7a43337740dd6b7f26167762790f432e92489989f17a60094fa21c1e69d2c233e3348212c21114d84e20d37ce53b9ae3819329a641e4cbff2c6c2f7f664be9"
}