-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement content script - unsafe script communication #5
Comments
I think I'm going to implement the messaging primitive first, as a separate module that exports The implementation will probably be based on pixiebrix/pixiebrix-extension#1019 or what was discussed within it. This is because, as that PR shows, there's no straight-forward way to send messages to the other side, so it would be easier to "polyfill" the |
Thinking out loud here. Let's say we have a handler in a content script; How do we reach it?
I think
Here, the method exported by // From the background
setPageTitle({tab: 1, frame: 0}, 'New title');
// From dev tools
setPageTitle({}, 'New title');
// From the sidebar
setPageTitle({}, 'New title');
// From the unsafe context
setPageTitle({extensionId: "mlhlldlpep22445"}, 'New title'); The contexts 2 and 3 don't look great, but they're ok. For the background page, I think the extension ID can be specified while creating the method, only if it's meant to be accessible from the unsafe context. So this line:
Would just become, for example: export const sum = getMethod("sum", "mlhlldlpep22445"); And that would be the signal that the method can also be used from the unsafe context, without having to alter the method’s signature. |
I think that approach looks pretty good. Let's give it a try Other things we might consider for "unsafe"/external:
|
Just for context, some code for this now exists at https://github.com/pixiebrix/pixiebrix-extension/blob/7ee1e1292db066b074818089944020418ca18dee/src/utils/postMessage.ts#L1 |
externally_connectible
in Firefox) pixiebrix-extension#1015The text was updated successfully, but these errors were encountered: