postMessage

postMessage

コード

Extension.prototype.postMessage = function(name, data, callback) {
    this.listeners[name] = callback || function() {}
    if (Extension.isSafari()) {
        safari.self.tab.dispatchMessage(name, data)
    }
    else if (Extension.isChrome()) {
        this.port.postMessage({ name: name, data: data })
    }
    else if (Extension.isFirefox()) {
        self.postMessage({ name: name, data: data })
    }
}