Skip to content
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

Add support for web_accessible_resources contexts #35

Open
martonlederer opened this issue Sep 11, 2022 · 1 comment
Open

Add support for web_accessible_resources contexts #35

martonlederer opened this issue Sep 11, 2022 · 1 comment

Comments

@martonlederer
Copy link

Usecase

You have an extension with html files added to web_accessible_resources in the manifest. These pages should be allowed to communicate with the background script and other pages, similarly to how for e.g. the popup page can communicate with the background script.

The problem

webext-bridge currently does not treat these pages from web_accessible_resources as different contexts, rather it detects them as background contexts. This prevents them to communicate with the background script, even through there is no security risk here, as the browser.runtime.sendMessage/browser.runtime.onMessage APIs are already exposed to them.

Potential solution

Create a new type of context (e.g.: web_accessible) that behaves similarly to how the content-script contexts work. There could be multiple pages added to web_accessible_resources, so this would allow you to send messages to specific pages as well, using their tabId.

Example

Send a message to a page with "web_accessible" context and the tabId 3412:

const returnData = await sendMessage('bar', { /* ... */ }, "web_accessible@3412");
@martonlederer
Copy link
Author

martonlederer commented Sep 11, 2022

I believe this would also solve #12 and is also referenced in the original repo, in issue #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant