Comments (3)
extension pages should have the same permissions as the background page
Hmmm. I thought they might not have access to browser.tabs.sendMessage
but it looks like they do?
so there shouldn't be any need for the extension page to call a function in the background or vice versa
IIRC, there shouldn't be any need to. However in practice we do it for simplicity (e.g., reportError gets routed through the background page)
For example the sidebar can communicate directly with the content script (of any tab).
See response above. It looks they can given that they have browser.tabs.sendMessage
Likewise, is there any reason for a content script to communicate to the options page?
No. The only possible case I could think of is if we embedded a form or some other thing that set local state. (But at that point 1) the content script would be performing the action via the background page, and 2) the background page could choose to notify the options page or the options could listen for storage change events
can you list every messaging route and direction
I think the missing ones/directions are. I'll noodle on this a bit more though:
- background -> CS: the background page has webNavigation permission it uses to notify the content script of page navigation in SPAs
- background -> devtools: I think same as for background -> CS
- CS -> unsafe script (on any website): to execute bricks that read from the web application state (e.g.,
window
or the React application state)
but devtools.eval() should be used instead
I'd probably err on whatever has the easiest developer ergonomics for us
from webext-messenger.
I think this is not necessary for PixieBrix, but I may be wrong.
From what I understand, extension pages should have the same permissions as the background page, so there shouldn't be any need for the extension page to call a function in the background or vice versa.
Likewise, is there any reason for a content script to communicate to the options page?
We only have 3 limited contexts:
- content script
- dev tools
- unsafe script
Every other page, including the sidebar, are just extension pages with complete permissions. For example the sidebar can communicate directly with the content script (of any tab).
Maybe the only situation I can think of is the dev tools communicating directly to the sidebar, which would require this channel.
@twschiller can you list every messaging route and direction currently in PB? And also what you're seeing in the future?
I think we have:
- CS -> background
- dev tools -> background
- dev tools -> CS (through background)
- dev tools -> unsafe script (may be via CS and background, but
devtools.eval()
should be used instead) - app.pixiebrix -> background (
externally_connectable
, via CS only in Firefox) - any website -> CS (future API) (
externally_connectable
is not available onall_urls
)
Any route or direction missing? Are the sidebar and options page connecting anywhere?
It seems to me that all of them are mono-directional — that is, only ever one side starts the communication (excluding responses, which can follow the original message back)
from webext-messenger.
Also addressed by #8
from webext-messenger.
Related Issues (20)
- Remove branch protection from repo HOT 1
- Handle repeated injection gracefully HOT 6
- Drop `webextensions-polyfill` to avoid unnecessary abstraction
- Toggle WEBEXT_LOGGING at runtime
- Dispatch retries event and retry-exhaustion event
- Do not retry discarded tabs, return specific error
- Use `browser.runtime.getFrameId()` HOT 1
- Update Parcel
- Track timing HOT 2
- Immediately handle context invalidation, disabling further messaging
- Accept `Promise<Target>`
- Support `allFrames` as target
- Ensure sequence numbers are never reused HOT 2
- Error: Tabs cannot be edited right now (user may be dragging a tab).
- `retry: false` not respected when forwarding
- Add `extractTargetFromSender`
- Unwanted forwarding when targeting `allFrames` HOT 2
- Fail when trace.length > 2 HOT 2
- Meta: update parcel to 2.12+
- Preserve seq number when forwarding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webext-messenger.