activity-stream/data/content-bridge.js

25 строки
734 B
JavaScript
Исходник Обычный вид История

2016-02-01 22:02:30 +03:00
/* globals unsafeWindow, cloneInto */
"use strict";
2016-02-09 00:01:42 +03:00
window.addEventListener("content-to-addon", function(event) {
self.port.emit("content-to-addon", JSON.parse(event.detail));
2016-02-01 22:02:30 +03:00
}, false);
2016-02-09 00:01:42 +03:00
self.port.on("addon-to-content", function(data) {
2016-02-01 22:02:30 +03:00
const clonedData = cloneInto(data, document.defaultView);
window.dispatchEvent(
2016-02-09 00:01:42 +03:00
new CustomEvent("addon-to-content", {detail: clonedData})
2016-02-01 22:02:30 +03:00
);
});
2016-02-09 00:01:42 +03:00
window.addEventListener("pagehide", function() {
self.port.emit("content-to-addon", {type: "pagehide"});
2016-02-01 22:02:30 +03:00
}, false);
document.onreadystatechange = function() {
self.port.emit("content-to-addon", {type: "NOTIFY_PERFORMANCE", data: "DOC_READY_STATE=" + document.readyState});
};
unsafeWindow.navigator.activity_streams_addon = true;