浏览器通信

常说的浏览器通信是指跨文档通信(cross-document messaging)和通道通信(channel messaging)。 跨文档通信就是我们国内更为熟知的HTML5 window.postMessage()应用的那种通信;通道通信也被称为”MessageChannel”. 示例

  • port.postMessage(message,transferList);

    message 发送给service worker的消息内容。 transferList
    可转移的对象,这些对象有这些来自浏览器上下文的对象的所有权; Transferable objects to be transferred — these objects have their ownership transferred to the receiving browsing context, so are no longer usable by the sending browsing context