From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../preferences/tests/browser_spotlight.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 browser/components/preferences/tests/browser_spotlight.js (limited to 'browser/components/preferences/tests/browser_spotlight.js') diff --git a/browser/components/preferences/tests/browser_spotlight.js b/browser/components/preferences/tests/browser_spotlight.js new file mode 100644 index 0000000000..4a1aae7ec1 --- /dev/null +++ b/browser/components/preferences/tests/browser_spotlight.js @@ -0,0 +1,72 @@ +add_task(async function test_openPreferences_spotlight() { + for (let [arg, expectedPane, expectedHash, expectedSubcategory] of [ + ["privacy-reports", "panePrivacy", "#privacy", "reports"], + ["privacy-address-autofill", "panePrivacy", "#privacy", "address-autofill"], + [ + "privacy-credit-card-autofill", + "panePrivacy", + "#privacy", + "credit-card-autofill", + ], + ["privacy-form-autofill", "panePrivacy", "#privacy", "form-autofill"], + ["privacy-logins", "panePrivacy", "#privacy", "logins"], + [ + "privacy-trackingprotection", + "panePrivacy", + "#privacy", + "trackingprotection", + ], + [ + "privacy-permissions-block-popups", + "panePrivacy", + "#privacy", + "permissions-block-popups", + ], + ]) { + if ( + arg == "privacy-credit-card-autofill" && + Services.prefs.getCharPref( + "extensions.formautofill.creditCards.supported" + ) == "off" + ) { + continue; + } + if ( + arg == "privacy-address-autofill" && + Services.prefs.getCharPref( + "extensions.formautofill.addresses.supported" + ) == "off" + ) { + continue; + } + + let prefs = await openPreferencesViaOpenPreferencesAPI(arg, { + leaveOpen: true, + }); + is(prefs.selectedPane, expectedPane, "The right pane is selected"); + let doc = gBrowser.contentDocument; + is( + doc.location.hash, + expectedHash, + "The subcategory should be removed from the URI" + ); + await TestUtils.waitForCondition( + () => doc.querySelector(".spotlight"), + "Wait for the spotlight" + ); + is( + doc.querySelector(".spotlight").getAttribute("data-subcategory"), + expectedSubcategory, + "The right subcategory is spotlighted" + ); + + doc.defaultView.spotlight(null); + is( + doc.querySelector(".spotlight"), + null, + "The spotlighted section is cleared" + ); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); + } +}); -- cgit v1.2.3