How do I inspect a BroadcastChannel with Chrome DevTools?
Asked Answered
T

1

7

Is there a way, with Chrome DevTools, to see what’s going on in a BroadcastChannel other than attaching a message event listener to it, so that I could see who’s postMessage-ing what?

Tungsten answered 18/12, 2019 at 18:1 Comment(1)
No, there is none.Aultman
M
8

The best solution I found was extending the prototype of postMessage like this:

(function(postMessage) {
  BroadcastChannel.prototype.postMessage = function (message) {
    debugger;

    postMessage.call(this, message);
  };
}(BroadcastChannel.prototype.postMessage));

You can obviously replace the debugger statement by something else like console.trace(message) for example, than you get the callstack directly printed in the console.

I hopes this helps you.

Madelyn answered 12/5, 2020 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.