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

Target current tab from any iframe #72

Open
fregante opened this issue Apr 19, 2022 · 1 comment
Open

Target current tab from any iframe #72

fregante opened this issue Apr 19, 2022 · 1 comment

Comments

@fregante
Copy link
Collaborator

We have tabId: "this" for this purpose:

however it only works between extension pages because:

  • only extension pages can use chrome.tab without intermediary steps

  • the current logic only handles "this" by comparing the sender to the current context, but this could be trivially changed:

     on send:
     	if isContentScript && tabId === "this"
     		send to background
    
     on background receive:
     	if tabId === "this"
     		forward to this.trace[0].tab.id

    // Set "this" tab to the current tabId
    if (to.tabId === "this" && thisTarget.tabId === from.tab?.id) {
    to.tabId = thisTarget.tabId;
    }

@fregante
Copy link
Collaborator Author

fregante commented Jan 19, 2024

This is no longer used/necessary after the migration to sidePanel, but it can be added in these two places if it ever becomes useful again.

if (action === "forward") {
log.debug(type, seq, "🔀 forwarded", { sender, target });
handleMessage = async () => messenger(type, meta, target, ...args);

"↗️ sending message to tab",
tabId,

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

No branches or pull requests

1 participant