最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I inspect a BroadcastChannel with Chrome DevTools? - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question edited Jan 29, 2021 at 9:04 Paolo 21.2k21 gold badges76 silver badges121 bronze badges asked Dec 18, 2019 at 18:01 Константин ВанКонстантин Ван 14.9k8 gold badges75 silver badges87 bronze badges 1
  • 2 No, there is none. – woxxom Commented Dec 19, 2019 at 4:31
Add a ment  | 

1 Answer 1

Reset to default 9

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.

发布评论

评论列表(0)

  1. 暂无评论