Runtime.addBinding to create a MessageChannel pairing?

8 views
Skip to first unread message

guest271314

unread,
Jan 29, 2023, 10:30:48 AM1/29/23
to v8-users
Is it possible to use DevTools Runtime.addBinding to create a MessageChannel pairing between MessagePort in extension ServerWorker and MessagePort created by the function in arbitrary Web page?

Ben Noordhuis

unread,
Jan 30, 2023, 8:31:55 AM1/30/23
to v8-u...@googlegroups.com
On Sun, Jan 29, 2023 at 4:30 PM guest271314 <guest...@gmail.com> wrote:
>
> Is it possible to use DevTools Runtime.addBinding to create a MessageChannel pairing between MessagePort in extension ServerWorker and MessagePort created by the function in arbitrary Web page?

No. addBinding adds a single-arg function to the execution context. It
sends a 'bindingCalled' event (plus the string argument) to the
inspector client when called. And that's all it does.

guest271314

unread,
Jan 30, 2023, 9:30:44 AM1/30/23
to v8-u...@googlegroups.com
Thanks. Three paths I have been thinking about are 1) some means to get a reference to arbitrary Window object in the ServiceWorker; 2) locating all Chromium ServiceWorker dependencies and extracting that code to create a standalone, dedicated MessageChannel between ServiceWorker and arbitrary Web pages; 3) locating all Chromium ServiceWorker dependencies and extracting that code to create a standalone ServiceWorker mapped to localhost to use as a local server.

Right now I am dynamically setting externally_connectable of an extension to arbitrary Web pages and using the JSON-based messaging system extensions use to stream from Native Messaging host to ServiceWorker then to Web page. Preferably we could use transferable objects or just the onfetch handler of the ServiceWorker. I imagine neither option is a simple task.

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to a topic in the Google Groups "v8-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-users/lWJml4bZh0k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAHQurc_UvZsrbAvnuowQ%2BrZyR5h8MjrgRTiYNCnyd17QXWZ00Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages