From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../contextMenu/browser_contextmenu_inspect.js | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 browser/base/content/test/contextMenu/browser_contextmenu_inspect.js (limited to 'browser/base/content/test/contextMenu/browser_contextmenu_inspect.js') diff --git a/browser/base/content/test/contextMenu/browser_contextmenu_inspect.js b/browser/base/content/test/contextMenu/browser_contextmenu_inspect.js new file mode 100644 index 0000000000..94241e9e1f --- /dev/null +++ b/browser/base/content/test/contextMenu/browser_contextmenu_inspect.js @@ -0,0 +1,61 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Check that we show the inspect item(s) as appropriate. + */ +add_task(async function test_contextmenu_inspect() { + await SpecialPowers.pushPrefEnv({ + set: [ + ["devtools.selfxss.count", 0], + ["devtools.everOpened", false], + ], + }); + let contextMenu = document.getElementById("contentAreaContextMenu"); + await BrowserTestUtils.withNewTab("about:blank", async browser => { + for (let [pref, value, expectation] of [ + ["devtools.selfxss.count", 10, true], + ["devtools.selfxss.count", 0, false], + ["devtools.everOpened", false, false], + ["devtools.everOpened", true, true], + ]) { + await SpecialPowers.pushPrefEnv({ + set: [["devtools.selfxss.count", value]], + }); + is(contextMenu.state, "closed", "checking if popup is closed"); + let promisePopupShown = BrowserTestUtils.waitForEvent( + contextMenu, + "popupshown" + ); + let promisePopupHidden = BrowserTestUtils.waitForEvent( + contextMenu, + "popuphidden" + ); + await BrowserTestUtils.synthesizeMouse( + "body", + 2, + 2, + { type: "contextmenu", button: 2 }, + browser + ); + await promisePopupShown; + let inspectItem = document.getElementById("context-inspect"); + ok( + !inspectItem.hidden, + `Inspect should be shown (pref ${pref} is ${value}).` + ); + let inspectA11y = document.getElementById("context-inspect-a11y"); + is( + inspectA11y.hidden, + !expectation, + `A11y should be ${ + expectation ? "visible" : "hidden" + } (pref ${pref} is ${value}).` + ); + contextMenu.hidePopup(); + await promisePopupHidden; + } + }); +}); -- cgit v1.2.3