1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 // This tests the Privacy pane's Firefox QuickActions UI.
8 ChromeUtils.defineESModuleGetters(this, {
9 ActionsProviderQuickActions:
10 "resource:///modules/ActionsProviderQuickActions.sys.mjs",
11 UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs",
14 add_setup(async function setup() {
15 await SpecialPowers.pushPrefEnv({
17 ["browser.urlbar.secondaryActions.featureGate", true],
18 ["browser.urlbar.quickactions.enabled", true],
22 ActionsProviderQuickActions.addAction("testaction", {
23 commands: ["testaction"],
24 label: "quickactions-downloads2",
27 registerCleanupFunction(() => {
28 ActionsProviderQuickActions.removeAction("testaction");
32 async function isGroupHidden(tab) {
33 return SpecialPowers.spawn(
36 async () => content.document.getElementById("quickActionsBox").hidden
40 add_task(async function test_show_prefs() {
41 Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", false);
43 let tab = await BrowserTestUtils.openNewForegroundTab(
45 "about:preferences#search"
49 await isGroupHidden(tab),
50 "The preferences are hidden when pref disabled"
53 Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", true);
56 !(await isGroupHidden(tab)),
57 "The preferences are shown when pref enabled"
60 Services.prefs.clearUserPref("browser.urlbar.quickactions.showPrefs");
61 await BrowserTestUtils.removeTab(tab);
64 async function testActionIsShown(window, name) {
65 await UrlbarTestUtils.promiseAutocompleteResultPopup({
68 waitForFocus: SimpleTest.waitForFocus,
71 await BrowserTestUtils.waitForMutationCondition(
75 !!window.document.querySelector(
76 `.urlbarView-action-btn[data-action=${name}]`
79 Assert.ok(true, `We found action "${name}"`);
86 add_task(async function test_prefs() {
87 Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", true);
88 Services.prefs.setBoolPref("browser.urlbar.suggest.quickactions", false);
90 let tab = await BrowserTestUtils.openNewForegroundTab(
92 "about:preferences#search"
96 !(await testActionIsShown(window)),
97 "Actions are not shown while pref disabled"
100 await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
101 let checkbox = content.document.getElementById("enableQuickActions");
105 "Checkbox is not checked while feature is disabled"
111 await testActionIsShown(window, "testaction"),
112 "Actions are shown after user clicks checkbox"
115 Services.prefs.clearUserPref("browser.urlbar.quickactions.showPrefs");
116 Services.prefs.clearUserPref("browser.urlbar.suggest.quickactions");
117 await BrowserTestUtils.removeTab(tab);