[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.
This commit is contained in:
Julien Carion (juca)
2023-10-18 13:31:57 +02:00
committed by Géry Debongnie
parent fee3eecd7f
commit fb013ccc72
8 changed files with 20 additions and 24 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
import { IS_FIREFOX } from "../utils";
import { IS_FIREFOX, browserInstance } from "../utils";
let created = false;
let browserInstance = IS_FIREFOX ? browser : chrome;
// Try to load the owl panel each 1000 ms in case it (re)appears on the page later on
const checkInterval = setInterval(createPanelsIfOwl, 1000);
@@ -70,6 +70,8 @@ export class ComponentsTab extends Component {
onWindowResize = () => {
const minWidth = (147 / window.innerWidth) * 100;
this.store.splitPosition = Math.max(this.store.splitPosition, minWidth);
if (minWidth <= 100) {
this.store.splitPosition = Math.max(this.store.splitPosition, minWidth);
}
};
}
@@ -1,11 +1,9 @@
/** @odoo-module **/
import { isElementInCenterViewport, minimizeKey, IS_FIREFOX } from "../../../../utils";
import { isElementInCenterViewport, minimizeKey, browserInstance } from "../../../../utils";
import { useStore } from "../../../store/store";
import { HighlightText } from "./highlight_text/highlight_text";
const browserInstance = IS_FIREFOX ? browser : chrome;
const { Component, useRef, useState, useEffect, onMounted } = owl;
export class TreeElement extends Component {
@@ -1,9 +1,7 @@
const { reactive, useState, toRaw } = owl;
import { fuzzySearch, IS_FIREFOX, getActiveTabURL } from "../../utils";
import { fuzzySearch, IS_FIREFOX, getActiveTabURL, browserInstance } from "../../utils";
import globalHook from "../../page_scripts/owl_devtools_global_hook";
const browserInstance = IS_FIREFOX ? browser : chrome;
// Main store which contains all states that needs to be maintained throughout all components in the devtools app
export const store = reactive({
devtoolsId: 0,
@@ -943,10 +941,9 @@ function arraysEqual(arr1, arr2) {
async function getTabURL() {
if (IS_FIREFOX) {
// This happens in firefox when the method is called inside devtools so we ask the background to execute it instead
browserInstance.runtime.sendMessage({ type: "getActiveTabURL" }).then((response) => {
return response.result;
});
// It is not possible to run getActiveTabURL inside the devtools when using firefox so we ask the background to execute it instead
const response = await browserInstance.runtime.sendMessage({ type: "getActiveTabURL" });
return response.result;
} else {
return await getActiveTabURL();
}