From 200059c23df4495a33f63c919eb47e90be1e2c46 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Wed, 10 Mar 2021 14:28:52 +0000 Subject: [PATCH] Bug 1697452 - [devtools] Access local tab from the toolbox descriptorFront instead of its target in RDM definition. r=ochameau. Accessing toolbox.target.localTab would throw if the target was already destroyed, which can happen if the access was happening while we where doing a target switch. We can fix that by retrieving the localTab through the toolbox descriptorFront instead, which will always be "alive" as long as the tab exists. Differential Revision: https://phabricator.services.mozilla.com/D107658 --- devtools/client/definitions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js index bbd71c229eed..9ffa5e26a4d0 100644 --- a/devtools/client/definitions.js +++ b/devtools/client/definitions.js @@ -525,15 +525,18 @@ exports.ToolboxButtons = [ ), isTargetSupported: target => target.isLocalTab, onClick(event, toolbox) { - const tab = toolbox.target.localTab; - const browserWindow = tab.ownerDocument.defaultView; - ResponsiveUIManager.toggle(browserWindow, tab, { trigger: "toolbox" }); + const { localTab } = toolbox.descriptorFront; + const browserWindow = localTab.ownerDocument.defaultView; + ResponsiveUIManager.toggle(browserWindow, localTab, { + trigger: "toolbox", + }); }, isChecked(toolbox) { - if (!toolbox.target.localTab) { + const { localTab } = toolbox.descriptorFront; + if (!localTab) { return false; } - return ResponsiveUIManager.isActiveForTab(toolbox.target.localTab); + return ResponsiveUIManager.isActiveForTab(localTab); }, setup(toolbox, onChange) { ResponsiveUIManager.on("on", onChange);