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

Messages from the dev tools have no reference about the tab #37

Open
fregante opened this issue Oct 8, 2021 · 0 comments
Open

Messages from the dev tools have no reference about the tab #37

fregante opened this issue Oct 8, 2021 · 0 comments

Comments

@fregante
Copy link
Contributor

fregante commented Oct 8, 2021

Since the editor is just a page running in a custom app (the dev tools), they don't have a "tab" and don't report which tab they're operating on. This is the sender information for a message coming from the dev tools (to the background page):

{
  id: "mpjjildhmpddojocokjkgmlkkkfjnepo",
  origin: "chrome-extension://mpjjildhmpddojocokjkgmlkkkfjnepo",
  url: "chrome-extension://mpjjildhmpddojocokjkgmlkkkfjnepo/devtoolsPanel.html"
}

This means that any context known to lack a sender.tab information will need to also provide a tabId. In this case, the browser.runtime.onMessage handler in background would be called with these arguments:

[
  { // Message, custom
    type: 'REPORT_ERROR',
    args: [],
    tab: 123
  },
  { // Sender, browser-provided
    id: "mpjjildhmpddojocokjkgmlkkkfjnepo",
    origin: "chrome-extension://mpjjildhmpddojocokjkgmlkkkfjnepo",
    url: "chrome-extension://mpjjildhmpddojocokjkgmlkkkfjnepo/devtoolsPanel.html"
  }
]

and then it would build the usual MessengerMeta object like this one before calling the handler:

{
	trace: [{
		tabId: 123,
		context: "devtools"
	}]
}

Related

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

No branches or pull requests

1 participant