From 04dd2f473339b0dc59dbb2a0459b11d962ecfee0 Mon Sep 17 00:00:00 2001 From: Mike Kaply Date: Tue, 15 Jun 2021 21:41:41 +0000 Subject: [PATCH] Bug 1716630 - Test for developer tools on app menu when developer tools are disabled is set. r=emalysz Differential Revision: https://phabricator.services.mozilla.com/D117933 --- .../browser_policy_disable_developer_tools.js | 16 ++++++++++++++++ devtools/client/framework/devtools-browser.js | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js b/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js index 02386f08cde9..335a2221f126 100644 --- a/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js +++ b/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js @@ -50,6 +50,22 @@ add_task(async function test_updates_post_policy() { "The Web Developer item of the hamburger menu should not be available." ); + let menuButton = document.getElementById("PanelUI-menu-button"); + menuButton.click(); + await BrowserTestUtils.waitForEvent(window.PanelUI.mainView, "ViewShown"); + let moreToolsButtonId = "appMenu-more-button2"; + document.getElementById(moreToolsButtonId).click(); + await BrowserTestUtils.waitForEvent( + document.getElementById("appmenu-moreTools"), + "ViewShown" + ); + is( + document.getElementById("appmenu-developer-tools-view").children.length, + 2, + "The developer tools are properly populated" + ); + window.PanelUI.hide(); + BrowserTestUtils.removeTab(tab); }); diff --git a/devtools/client/framework/devtools-browser.js b/devtools/client/framework/devtools-browser.js index 57843c4ecf18..2a3fec39e431 100644 --- a/devtools/client/framework/devtools-browser.js +++ b/devtools/client/framework/devtools-browser.js @@ -620,7 +620,9 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = { const menu = win.document.getElementById("menu_devToolbox"); // Hide the "Toggle Tools" menu item if we are on about:devtools-toolbox. - menu.hidden = gDevToolsBrowser._isAboutDevtoolsToolbox(win); + menu.hidden = + gDevToolsBrowser._isAboutDevtoolsToolbox(win) || + Services.prefs.getBoolPref("devtools.policy.disabled", false); // Add a checkmark for the "Toggle Tools" menu item if a toolbox is already opened. const hasToolbox = gDevToolsBrowser.hasToolboxOpened(win);