I have been reading over the chrome extension message passing documentation, but I cannot seem to establish communication from within the inspected window.
For example,
chrome.devtools.inspectedWindow.eval('function() {
.
.
.
/* send message to dev-tools panel */
chrome.runtime.sendMessage({foo:"foo"});<-- Uncaught Error: Invalid arguments to connect. Why is the extensionId required within chrome.devtools.inspectedWindow.eval? This made me step back and ask the question.
}')
I have tried leveraging both background and content scripts to listen for these messages, but nothing seems to trigger. My actual implementation is listening for WebSocket traffic, I left that out for brevity. I am able to listen to each request/response, however I cannot seem to establish communication within inspectedWindow.eval. In the end, my goal is to simply communicate with my dev-tools panel so I can update the UI.
Update
I found an interesting repo from someone that faced a similar issue. They however did not seem to find a valid solution. Could it be that this sort of messaging is not allowed by design?
https://github.com/thomasboyt/injectedWindow.eval-communication-sadness