有没有办法使用 Chrome DevTools 来查看BroadcastChannel
发生的事情,而不是将message
事件侦听器附加到它,以便我可以看到谁在postMessage
-ing 什么?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.