Files
owl/tools/devtools/src/content.js
T
Julien Carion (juca) fb013ccc72 [FIX] devtools: fix display and message passing for firefox
This commit fixes 2 issues specific to the firefox version of the
extension:
First issue concerns the computation the position of the
border between the subwindows of the components tab which could go
terribly wrong due to the fact that the innerwidth of the window is
implicitly set to 10 when the owl devtools window is hidden.
Second issue comes from changes in the runtime.onMessage method of
browser which now requires to directly return the response instead of
using the sendResponse method.
Also perform a little cleanup on usage of browserInstance and in the
manifest.
2023-10-18 15:15:12 +02:00

31 lines
1.1 KiB
JavaScript

import globalHook from "./page_scripts/owl_devtools_global_hook";
import { IS_FIREFOX, browserInstance } from "./utils";
// Relays the owlDevtools__... type top window messages to the background script so that it can relay it to the devtools app
window.addEventListener(
"message",
function (event) {
if (event.data.type && event.data.source === "owl-devtools") {
try {
browserInstance.runtime.sendMessage(
event.data.data
? { type: event.data.type, data: event.data.data, origin: event.data.origin }
: { type: event.data.type, origin: event.data.origin }
);
} catch (e) {
// Extension context invalidated, cannot be handled here since the whole communication system
// inside the extension is dead in this case.
}
}
},
false
);
// Load the devtools global hook this way when running on firefox
if (IS_FIREFOX) {
const script = document.createElement("script");
script.textContent = globalHook;
document.documentElement.appendChild(script);
script.parentNode.removeChild(script);
}