summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/preferences/tests')
-rw-r--r--browser/components/preferences/tests/browser.toml4
-rw-r--r--browser/components/preferences/tests/browser_about_settings.js29
-rw-r--r--browser/components/preferences/tests/browser_basic_rebuild_fonts_test.js2
-rw-r--r--browser/components/preferences/tests/browser_browser_languages_subdialog.js20
-rw-r--r--browser/components/preferences/tests/browser_cert_export.js2
-rw-r--r--browser/components/preferences/tests/browser_connection.js2
-rw-r--r--browser/components/preferences/tests/browser_connection_bug388287.js2
-rw-r--r--browser/components/preferences/tests/browser_cookies_exceptions.js26
-rw-r--r--browser/components/preferences/tests/browser_dns_over_https_exceptions_subdialog.js185
-rw-r--r--browser/components/preferences/tests/browser_fluent.js4
-rw-r--r--browser/components/preferences/tests/browser_localSearchShortcuts.js4
-rw-r--r--browser/components/preferences/tests/browser_permissions_urlFieldHidden.js2
-rw-r--r--browser/components/preferences/tests/browser_proxy_backup.js2
-rw-r--r--browser/components/preferences/tests/browser_searchChangedEngine.js11
-rw-r--r--browser/components/preferences/tests/browser_search_within_preferences_2.js84
-rw-r--r--browser/components/preferences/tests/browser_sync_chooseWhatToSync.js2
-rw-r--r--browser/components/preferences/tests/browser_sync_pairing.js2
-rw-r--r--browser/components/preferences/tests/browser_trendingsuggestions.js17
-rw-r--r--browser/components/preferences/tests/head.js2
-rw-r--r--browser/components/preferences/tests/siteData/browser_clearSiteData.js2
-rw-r--r--browser/components/preferences/tests/siteData/head.js2
-rw-r--r--browser/components/preferences/tests/siteData/service_worker_test.html2
22 files changed, 369 insertions, 39 deletions
diff --git a/browser/components/preferences/tests/browser.toml b/browser/components/preferences/tests/browser.toml
index fe523bde94..9e619ce4be 100644
--- a/browser/components/preferences/tests/browser.toml
+++ b/browser/components/preferences/tests/browser.toml
@@ -11,6 +11,8 @@ support-files = [
"addons/set_newtab.xpi",
]
+["browser_about_settings.js"]
+
["browser_advanced_update.js"]
skip-if = ["!updater"]
@@ -82,6 +84,8 @@ skip-if = ["socketprocess_networking"]
["browser_defaultbrowser_alwayscheck.js"]
+["browser_dns_over_https_exceptions_subdialog.js"]
+
["browser_engines.js"]
fail-if = ["a11y_checks"] # Bug 1854636 clicked treechildren#engineChildren may not be focusable
diff --git a/browser/components/preferences/tests/browser_about_settings.js b/browser/components/preferences/tests/browser_about_settings.js
new file mode 100644
index 0000000000..3ffd75eeef
--- /dev/null
+++ b/browser/components/preferences/tests/browser_about_settings.js
@@ -0,0 +1,29 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_openPreferences_aboutSettings() {
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: "about:settings",
+ },
+ async () => {
+ is(
+ gBrowser.currentURI.spec,
+ "about:settings",
+ "about:settings should open normally"
+ );
+
+ // using `openPreferencesViaOpenPreferencesAPI` would introduce an extra about:blank tab we need to take care of
+ await openPreferences("paneGeneral");
+
+ is(
+ gBrowser.currentURI.spec,
+ "about:settings#general",
+ "openPreferences should keep about:settings"
+ );
+ }
+ );
+});
diff --git a/browser/components/preferences/tests/browser_basic_rebuild_fonts_test.js b/browser/components/preferences/tests/browser_basic_rebuild_fonts_test.js
index 51998db5a9..4491373c75 100644
--- a/browser/components/preferences/tests/browser_basic_rebuild_fonts_test.js
+++ b/browser/components/preferences/tests/browser_basic_rebuild_fonts_test.js
@@ -109,7 +109,7 @@ add_task(async function () {
win.FontBuilder._enumerator = {
_list: ["MockedFont1", "MockedFont2", "MockedFont3"],
_defaultFont: null,
- EnumerateFontsAsync(lang, type) {
+ EnumerateFontsAsync() {
return Promise.resolve(this._list);
},
EnumerateAllFontsAsync() {
diff --git a/browser/components/preferences/tests/browser_browser_languages_subdialog.js b/browser/components/preferences/tests/browser_browser_languages_subdialog.js
index 1941fb3502..9faa6d2969 100644
--- a/browser/components/preferences/tests/browser_browser_languages_subdialog.js
+++ b/browser/components/preferences/tests/browser_browser_languages_subdialog.js
@@ -194,7 +194,7 @@ function assertTelemetryRecorded(events) {
// Only look at the related events after stripping the timestamp and category.
let relatedEvents = snapshot.parent
- .filter(([timestamp, category]) => category == TELEMETRY_CATEGORY)
+ .filter(([, category]) => category == TELEMETRY_CATEGORY)
.map(relatedEvent => relatedEvent.slice(2, 6));
// Events are now an array of: method, object[, value[, extra]] as expected.
@@ -297,7 +297,7 @@ add_task(async function testDisabledBrowserLanguages() {
// Search for more languages.
available.menupopup.lastElementChild.doCommand();
available.menupopup.hidePopup();
- await waitForMutation(available.menupopup, { childList: true }, target =>
+ await waitForMutation(available.menupopup, { childList: true }, () =>
Array.from(available.menupopup.children).some(
locale => locale.value == "pl"
)
@@ -352,7 +352,7 @@ add_task(async function testReorderingBrowserLanguages() {
// Install all the available langpacks.
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
@@ -458,7 +458,7 @@ add_task(async function testAddAndRemoveSelectedLanguages() {
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
@@ -603,7 +603,7 @@ add_task(async function testInstallFromAMO() {
await waitForMutation(
available.menupopup,
{ childList: true },
- target => available.itemCount > 1
+ () => available.itemCount > 1
);
}
@@ -685,7 +685,7 @@ add_task(async function testInstallFromAMO() {
await waitForMutation(
available.menupopup,
{ childList: true },
- target => available.itemCount > 1
+ () => available.itemCount > 1
);
}
assertLocaleOrder(selected, "en-US");
@@ -793,7 +793,7 @@ add_task(async function testReorderMainPane() {
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
@@ -860,7 +860,7 @@ add_task(async function testLiveLanguageReloading() {
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
@@ -928,7 +928,7 @@ add_task(async function testLiveLanguageReloadingBidiOff() {
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
@@ -1006,7 +1006,7 @@ add_task(async function testLiveLanguageReloadingBidiOn() {
let langpacks = await createTestLangpacks();
let addons = await Promise.all(
- langpacks.map(async ([locale, file]) => {
+ langpacks.map(async ([, file]) => {
let install = await AddonTestUtils.promiseInstallFile(file);
return install.addon;
})
diff --git a/browser/components/preferences/tests/browser_cert_export.js b/browser/components/preferences/tests/browser_cert_export.js
index 48769f84e6..f37cdec767 100644
--- a/browser/components/preferences/tests/browser_cert_export.js
+++ b/browser/components/preferences/tests/browser_cert_export.js
@@ -78,7 +78,7 @@ async function checkCertExportWorks(
) {
MockFilePicker.displayDirectory = destDir;
var destFile = destDir.clone();
- MockFilePicker.init(window);
+ MockFilePicker.init(window.browsingContext);
MockFilePicker.filterIndex = exportType;
MockFilePicker.showCallback = function (fp) {
info("showCallback");
diff --git a/browser/components/preferences/tests/browser_connection.js b/browser/components/preferences/tests/browser_connection.js
index 01cdf571f2..896361b16b 100644
--- a/browser/components/preferences/tests/browser_connection.js
+++ b/browser/components/preferences/tests/browser_connection.js
@@ -26,7 +26,7 @@ function test() {
so it has to be opened as a sub dialog of the main pref tab.
Open the main tab here.
*/
- open_preferences(async function tabOpened(aContentWindow) {
+ open_preferences(async function tabOpened() {
is(
gBrowser.currentURI.spec,
"about:preferences",
diff --git a/browser/components/preferences/tests/browser_connection_bug388287.js b/browser/components/preferences/tests/browser_connection_bug388287.js
index d6f0c3c9d0..87d41a22c1 100644
--- a/browser/components/preferences/tests/browser_connection_bug388287.js
+++ b/browser/components/preferences/tests/browser_connection_bug388287.js
@@ -37,7 +37,7 @@ function test() {
so it has to be opened as a sub dialog of the main pref tab.
Open the main tab here.
*/
- open_preferences(async function tabOpened(aContentWindow) {
+ open_preferences(async function tabOpened() {
let dialog, dialogClosingPromise, dialogElement;
let proxyTypePref, sharePref, httpPref, httpPortPref;
diff --git a/browser/components/preferences/tests/browser_cookies_exceptions.js b/browser/components/preferences/tests/browser_cookies_exceptions.js
index d2d538a48a..03e29d0b4c 100644
--- a/browser/components/preferences/tests/browser_cookies_exceptions.js
+++ b/browser/components/preferences/tests/browser_cookies_exceptions.js
@@ -19,7 +19,7 @@ add_task(async function testAllow() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -52,7 +52,7 @@ add_task(async function testBlock() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -85,7 +85,7 @@ add_task(async function testAllowAgain() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -152,7 +152,7 @@ add_task(async function testAdd() {
PermissionTestUtils.remove(uri, "popup");
},
- params => {
+ () => {
return [
{
type: "popup",
@@ -178,7 +178,7 @@ add_task(async function testAllowHTTPSWithPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -204,7 +204,7 @@ add_task(async function testBlockHTTPSWithPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -230,7 +230,7 @@ add_task(async function testAllowAgainHTTPSWithPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -288,7 +288,7 @@ add_task(async function testAllowPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -321,7 +321,7 @@ add_task(async function testBlockPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -354,7 +354,7 @@ add_task(async function testAllowAgainPort() {
apply();
await observeAllPromise;
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -450,7 +450,7 @@ add_task(async function testSort() {
PermissionTestUtils.remove(uri, "cookie");
}
},
- params => {
+ () => {
return [
{
type: "cookie",
@@ -477,7 +477,7 @@ add_task(async function testSort() {
add_task(async function testPrivateBrowsingSessionPermissionsAreHidden() {
await runTest(
- async (params, observeAllPromise, apply) => {
+ async params => {
assertListContents(params, []);
let uri = Services.io.newURI("http://test.com");
@@ -498,7 +498,7 @@ add_task(async function testPrivateBrowsingSessionPermissionsAreHidden() {
PermissionTestUtils.remove(uri, "cookie");
},
- params => {
+ () => {
return [];
}
);
diff --git a/browser/components/preferences/tests/browser_dns_over_https_exceptions_subdialog.js b/browser/components/preferences/tests/browser_dns_over_https_exceptions_subdialog.js
new file mode 100644
index 0000000000..c24c13e9e8
--- /dev/null
+++ b/browser/components/preferences/tests/browser_dns_over_https_exceptions_subdialog.js
@@ -0,0 +1,185 @@
+async function dohExceptionsSubdialogOpened(dialogOverlay) {
+ const promiseSubDialogLoaded = promiseLoadSubDialog(
+ "chrome://browser/content/preferences/dialogs/dohExceptions.xhtml"
+ );
+ const contentDocument = gBrowser.contentDocument;
+ contentDocument.getElementById("dohExceptionsButton").click();
+ const win = await promiseSubDialogLoaded;
+ dialogOverlay = content.gSubDialog._topDialog._overlay;
+ ok(!BrowserTestUtils.isHidden(dialogOverlay), "The dialog is visible.");
+ return win;
+}
+
+function acceptDoHExceptionsSubdialog(win) {
+ const button = win.document.querySelector("dialog").getButton("accept");
+ button.doCommand();
+}
+
+function cancelDoHExceptionsSubdialog(win) {
+ const button = win.document.querySelector("dialog").getButton("cancel");
+ button.doCommand();
+}
+
+function addNewException(domain, dialog) {
+ let url = dialog.document.getElementById("url");
+ let addButton = dialog.document.getElementById("btnAddException");
+
+ ok(
+ addButton.disabled,
+ "The Add button is disabled when domain's input box is empty"
+ );
+
+ url.focus();
+ EventUtils.sendString(domain);
+
+ ok(
+ !addButton.disabled,
+ "The Add button is enabled when some text is on domain's input box"
+ );
+
+ addButton.click();
+
+ is(
+ url.value,
+ "",
+ "Domain input box is empty after adding a new domain to the list"
+ );
+ ok(
+ addButton.disabled,
+ "The Add button is disabled after exception has been added to the list"
+ );
+}
+
+add_task(async function () {
+ Services.prefs.lockPref("network.trr.excluded-domains");
+
+ await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
+ leaveOpen: true,
+ });
+ let dialogOverlay = content.gSubDialog._preloadDialog._overlay;
+ let win = await dohExceptionsSubdialogOpened(dialogOverlay);
+
+ ok(
+ win.document.getElementById("btnAddException").disabled,
+ "The Add button is disabled when preference is locked"
+ );
+ ok(
+ win.document.getElementById("url").disabled,
+ "The url input box is disabled when preference is locked"
+ );
+
+ cancelDoHExceptionsSubdialog(win);
+ Services.prefs.unlockPref("network.trr.excluded-domains");
+ win = await dohExceptionsSubdialogOpened(dialogOverlay);
+
+ ok(
+ win.document.getElementById("btnAddException").disabled,
+ "The Add button is disabled when preference is not locked"
+ );
+ ok(
+ !win.document.getElementById("url").disabled,
+ "The url input box is enabled when preference is not locked"
+ );
+
+ cancelDoHExceptionsSubdialog(win);
+ gBrowser.removeCurrentTab();
+});
+
+add_task(async function () {
+ await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
+ leaveOpen: true,
+ });
+ let dialogOverlay = content.gSubDialog._preloadDialog._overlay;
+
+ ok(BrowserTestUtils.isHidden(dialogOverlay), "The dialog is invisible.");
+ let win = await dohExceptionsSubdialogOpened(dialogOverlay);
+ acceptDoHExceptionsSubdialog(win);
+ ok(BrowserTestUtils.isHidden(dialogOverlay), "The dialog is invisible.");
+
+ win = await dohExceptionsSubdialogOpened(dialogOverlay);
+ Assert.equal(
+ win.document.getElementById("permissionsBox").itemCount,
+ 0,
+ "There are no exceptions set."
+ );
+ ok(
+ win.document.getElementById("removeException").disabled,
+ "The Remove button is disabled when there are no exceptions on the list"
+ );
+ ok(
+ win.document.getElementById("removeAllExceptions").disabled,
+ "The Remove All button is disabled when there are no exceptions on the list"
+ );
+ ok(
+ win.document.getElementById("btnAddException").disabled,
+ "The Add button is disabled when dialog box has just been opened"
+ );
+
+ addNewException("test1.com", win);
+ Assert.equal(
+ win.document.getElementById("permissionsBox").itemCount,
+ 1,
+ "List shows 1 new item"
+ );
+ let activeExceptions = win.document.getElementById("permissionsBox").children;
+ is(
+ activeExceptions[0].getAttribute("domain"),
+ "test1.com",
+ "test1.com added to the list"
+ );
+ ok(
+ !win.document.getElementById("removeAllExceptions").disabled,
+ "The Remove All button is enabled when there is one exception on the list"
+ );
+ addNewException("test2.com", win);
+ addNewException("test3.com", win);
+ Assert.equal(
+ win.document.getElementById("permissionsBox").itemCount,
+ 3,
+ "List shows 3 domain items"
+ );
+ ok(
+ win.document.getElementById("removeException").disabled,
+ "The Remove button is disabled when no exception has been selected"
+ );
+ win.document.getElementById("permissionsBox").selectedIndex = 1;
+ ok(
+ !win.document.getElementById("removeException").disabled,
+ "The Remove button is enabled when an exception has been selected"
+ );
+ win.document.getElementById("removeException").doCommand();
+ Assert.equal(
+ win.document.getElementById("permissionsBox").itemCount,
+ 2,
+ "List shows 2 domain items after removing one of the three"
+ );
+ activeExceptions = win.document.getElementById("permissionsBox").children;
+ ok(
+ win.document.getElementById("permissionsBox").itemCount == 2 &&
+ activeExceptions[0].getAttribute("domain") == "test1.com" &&
+ activeExceptions[1].getAttribute("domain") == "test3.com",
+ "test1.com and test3.com are the only items left on the list"
+ );
+ is(
+ win.document.getElementById("permissionsBox").selectedIndex,
+ -1,
+ "There is no selected item after removal"
+ );
+ addNewException("test2.com", win);
+ activeExceptions = win.document.getElementById("permissionsBox").children;
+ ok(
+ win.document.getElementById("permissionsBox").itemCount == 3 &&
+ activeExceptions[1].getAttribute("domain") == "test2.com",
+ "test2.com has been added as the second item"
+ );
+ win.document.getElementById("removeAllExceptions").doCommand();
+ is(
+ win.document.getElementById("permissionsBox").itemCount,
+ 0,
+ "There are no elements on the list after clicking Remove All"
+ );
+
+ acceptDoHExceptionsSubdialog(win);
+
+ gBrowser.removeCurrentTab();
+});
diff --git a/browser/components/preferences/tests/browser_fluent.js b/browser/components/preferences/tests/browser_fluent.js
index db2daecc4f..ae83abecf0 100644
--- a/browser/components/preferences/tests/browser_fluent.js
+++ b/browser/components/preferences/tests/browser_fluent.js
@@ -1,7 +1,7 @@
function whenMainPaneLoadedFinished() {
- return new Promise(function (resolve, reject) {
+ return new Promise(function (resolve) {
const topic = "main-pane-loaded";
- Services.obs.addObserver(function observer(aSubject) {
+ Services.obs.addObserver(function observer() {
Services.obs.removeObserver(observer, topic);
resolve();
}, topic);
diff --git a/browser/components/preferences/tests/browser_localSearchShortcuts.js b/browser/components/preferences/tests/browser_localSearchShortcuts.js
index 0b8e170cc1..7f0f4869b7 100644
--- a/browser/components/preferences/tests/browser_localSearchShortcuts.js
+++ b/browser/components/preferences/tests/browser_localSearchShortcuts.js
@@ -36,7 +36,7 @@ add_setup(async function () {
// The rows should be visible and checked by default.
add_task(async function visible() {
await checkRowVisibility(true);
- await forEachLocalShortcutRow(async (row, shortcut) => {
+ await forEachLocalShortcutRow(async row => {
Assert.equal(
gTree.view.getCellValue(row, gTree.columns.getNamedColumn("engineShown")),
"true",
@@ -136,7 +136,7 @@ add_task(async function syncToPrefs_click() {
// The keyword column should not be editable according to isEditable().
add_task(async function keywordNotEditable_isEditable() {
- await forEachLocalShortcutRow(async (row, shortcut) => {
+ await forEachLocalShortcutRow(async row => {
Assert.ok(
!gTree.view.isEditable(
row,
diff --git a/browser/components/preferences/tests/browser_permissions_urlFieldHidden.js b/browser/components/preferences/tests/browser_permissions_urlFieldHidden.js
index 537ee3db72..dea9762861 100644
--- a/browser/components/preferences/tests/browser_permissions_urlFieldHidden.js
+++ b/browser/components/preferences/tests/browser_permissions_urlFieldHidden.js
@@ -3,7 +3,7 @@
const PERMISSIONS_URL =
"chrome://browser/content/preferences/dialogs/permissions.xhtml";
-add_task(async function urlFieldVisibleForPopupPermissions(finish) {
+add_task(async function urlFieldVisibleForPopupPermissions() {
await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
leaveOpen: true,
});
diff --git a/browser/components/preferences/tests/browser_proxy_backup.js b/browser/components/preferences/tests/browser_proxy_backup.js
index fc05e19ada..e4ce5a99bd 100644
--- a/browser/components/preferences/tests/browser_proxy_backup.js
+++ b/browser/components/preferences/tests/browser_proxy_backup.js
@@ -47,7 +47,7 @@ function test() {
so it has to be opened as a sub dialog of the main pref tab.
Open the main tab here.
*/
- open_preferences(async function tabOpened(aContentWindow) {
+ open_preferences(async function tabOpened() {
is(
gBrowser.currentURI.spec,
"about:preferences",
diff --git a/browser/components/preferences/tests/browser_searchChangedEngine.js b/browser/components/preferences/tests/browser_searchChangedEngine.js
index 0882c9775e..22baba8dd6 100644
--- a/browser/components/preferences/tests/browser_searchChangedEngine.js
+++ b/browser/components/preferences/tests/browser_searchChangedEngine.js
@@ -46,6 +46,10 @@ add_task(async function test_change_engine() {
let row = findRow(tree, "Example");
Assert.notEqual(row, -1, "Should have found the entry");
+ await TestUtils.waitForCondition(
+ () => tree.view.getImageSrc(row, tree.columns.getNamedColumn("engineName")),
+ "Should have go an image URL"
+ );
Assert.ok(
tree.view
.getImageSrc(row, tree.columns.getNamedColumn("engineName"))
@@ -74,6 +78,13 @@ add_task(async function test_change_engine() {
row = findRow(tree, "Example 2");
Assert.notEqual(row, -1, "Should have found the updated entry");
+ await TestUtils.waitForCondition(
+ () =>
+ tree.view
+ .getImageSrc(row, tree.columns.getNamedColumn("engineName"))
+ ?.includes("img456.png"),
+ "Should have updated the image URL"
+ );
Assert.ok(
tree.view
.getImageSrc(row, tree.columns.getNamedColumn("engineName"))
diff --git a/browser/components/preferences/tests/browser_search_within_preferences_2.js b/browser/components/preferences/tests/browser_search_within_preferences_2.js
index 6de068fbe4..5fcb445adc 100644
--- a/browser/components/preferences/tests/browser_search_within_preferences_2.js
+++ b/browser/components/preferences/tests/browser_search_within_preferences_2.js
@@ -178,3 +178,87 @@ add_task(async function () {
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
+
+/**
+ * Test that search works as expected for custom elements that utilize both
+ * slots and shadow DOM. We should be able to find text the shadow DOM.
+ */
+add_task(async function testSearchShadowDOM() {
+ await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
+ leaveOpen: true,
+ });
+
+ // Create the toggle.
+ let { toggle, SHADOW_DOM_TEXT } = createToggle(gBrowser);
+
+ ok(
+ !BrowserTestUtils.isVisible(toggle),
+ "Toggle is not visible prior to search."
+ );
+
+ // Perform search with text found in moz-toggle's shadow DOM.
+ let query = SHADOW_DOM_TEXT;
+ let searchCompletedPromise = BrowserTestUtils.waitForEvent(
+ gBrowser.contentWindow,
+ "PreferencesSearchCompleted",
+ evt => evt.detail == query
+ );
+ EventUtils.sendString(query);
+ await searchCompletedPromise;
+ ok(
+ BrowserTestUtils.isVisible(toggle),
+ "Toggle is visible after searching for string in the shadow DOM."
+ );
+
+ BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+/**
+ * Test that search works as expected for custom elements that utilize both
+ * slots and shadow DOM. We should be able to find text the light DOM.
+ */
+add_task(async function testSearchLightDOM() {
+ await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
+ leaveOpen: true,
+ });
+
+ // Create the toggle.
+ let { toggle, LIGHT_DOM_TEXT } = createToggle(gBrowser);
+
+ // Perform search with text found in moz-toggle's slotted content.
+ let query = LIGHT_DOM_TEXT;
+ let searchCompletedPromise = BrowserTestUtils.waitForEvent(
+ gBrowser.contentWindow,
+ "PreferencesSearchCompleted",
+ evt => evt.detail == query
+ );
+ EventUtils.sendString(query);
+ await searchCompletedPromise;
+ ok(
+ BrowserTestUtils.isVisible(toggle),
+ "Toggle is visible again after searching for text found in slotted content."
+ );
+
+ BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+// Create a toggle with a slotted link element.
+function createToggle(gBrowser) {
+ const SHADOW_DOM_TEXT = "This text lives in the shadow DOM";
+ const LIGHT_DOM_TEXT = "This text lives in the light DOM";
+
+ let doc = gBrowser.contentDocument;
+ let toggle = doc.createElement("moz-toggle");
+ toggle.label = SHADOW_DOM_TEXT;
+
+ let link = doc.createElement("a");
+ link.href = "https://mozilla.org/";
+ link.textContent = LIGHT_DOM_TEXT;
+ toggle.append(link);
+ link.slot = "support-link";
+
+ let protectionsGroup = doc.getElementById("trackingGroup");
+ protectionsGroup.append(toggle);
+
+ return { SHADOW_DOM_TEXT, LIGHT_DOM_TEXT, toggle };
+}
diff --git a/browser/components/preferences/tests/browser_sync_chooseWhatToSync.js b/browser/components/preferences/tests/browser_sync_chooseWhatToSync.js
index b36d9ecea3..3ff65a0d93 100644
--- a/browser/components/preferences/tests/browser_sync_chooseWhatToSync.js
+++ b/browser/components/preferences/tests/browser_sync_chooseWhatToSync.js
@@ -167,7 +167,7 @@ add_task(async function testDialogLaunchFromURI() {
);
await BrowserTestUtils.withNewTab(
"about:preferences?action=choose-what-to-sync#sync",
- async browser => {
+ async () => {
let dialogEvent = await dialogEventPromise;
Assert.equal(
dialogEvent.detail.dialog._frame.contentWindow.location,
diff --git a/browser/components/preferences/tests/browser_sync_pairing.js b/browser/components/preferences/tests/browser_sync_pairing.js
index 6491007a38..39f7b547d8 100644
--- a/browser/components/preferences/tests/browser_sync_pairing.js
+++ b/browser/components/preferences/tests/browser_sync_pairing.js
@@ -29,7 +29,7 @@ add_setup(async function () {
};
const origStart = FxAccountsPairingFlow.start;
- FxAccountsPairingFlow.start = ({ emitter: e }) => {
+ FxAccountsPairingFlow.start = () => {
return `https://foo.bar/${flowCounter++}`;
};
diff --git a/browser/components/preferences/tests/browser_trendingsuggestions.js b/browser/components/preferences/tests/browser_trendingsuggestions.js
index 1cfae387cf..81285b7f6f 100644
--- a/browser/components/preferences/tests/browser_trendingsuggestions.js
+++ b/browser/components/preferences/tests/browser_trendingsuggestions.js
@@ -78,3 +78,20 @@ add_task(async function testNonTrendingEngine() {
);
gBrowser.removeCurrentTab();
});
+
+add_task(async function testEnabledTrendingEngine() {
+ const engine1 = Services.search.getEngineByName("Google");
+ Services.search.setDefault(
+ engine1,
+ Ci.nsISearchService.CHANGE_REASON_UNKNOWN
+ );
+ await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
+ let doc = gBrowser.selectedBrowser.contentDocument;
+ let trendingCheckbox = doc.getElementById(TRENDING_CHECKBOX_ID);
+
+ Assert.ok(
+ !trendingCheckbox.disabled,
+ "Checkbox should not be disabled when an engine that supports trending suggestions is default"
+ );
+ gBrowser.removeCurrentTab();
+});
diff --git a/browser/components/preferences/tests/head.js b/browser/components/preferences/tests/head.js
index 1861c040e5..f9e5b10c09 100644
--- a/browser/components/preferences/tests/head.js
+++ b/browser/components/preferences/tests/head.js
@@ -45,7 +45,7 @@ function openAndLoadSubDialog(
}
function promiseLoadSubDialog(aURL) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
content.gSubDialog._dialogStack.addEventListener(
"dialogopen",
function dialogopen(aEvent) {
diff --git a/browser/components/preferences/tests/siteData/browser_clearSiteData.js b/browser/components/preferences/tests/siteData/browser_clearSiteData.js
index ad1d27bfe2..7ae1fda453 100644
--- a/browser/components/preferences/tests/siteData/browser_clearSiteData.js
+++ b/browser/components/preferences/tests/siteData/browser_clearSiteData.js
@@ -137,7 +137,7 @@ async function testClearData(clearSiteData, clearCache) {
let clearButton = dialogWin.document
.querySelector("dialog")
.getButton("accept");
- if (!clearSiteData && !clearCache) {
+ if (!clearSiteData && !clearCache && useOldClearHistoryDialog) {
// Simulate user input on one of the checkboxes to trigger the event listener for
// disabling the clearButton.
clearCacheCheckbox.doCommand();
diff --git a/browser/components/preferences/tests/siteData/head.js b/browser/components/preferences/tests/siteData/head.js
index 2b8a9984a6..6385013a52 100644
--- a/browser/components/preferences/tests/siteData/head.js
+++ b/browser/components/preferences/tests/siteData/head.js
@@ -52,7 +52,7 @@ function is_element_hidden(aElement, aMsg) {
}
function promiseLoadSubDialog(aURL) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
content.gSubDialog._dialogStack.addEventListener(
"dialogopen",
function dialogopen(aEvent) {
diff --git a/browser/components/preferences/tests/siteData/service_worker_test.html b/browser/components/preferences/tests/siteData/service_worker_test.html
index 56f5173481..710b61090f 100644
--- a/browser/components/preferences/tests/siteData/service_worker_test.html
+++ b/browser/components/preferences/tests/siteData/service_worker_test.html
@@ -13,7 +13,7 @@
<h1>Service Worker Test</h1>
<script type="text/javascript">
navigator.serviceWorker.register("service_worker_test.js")
- .then(regis => document.body.setAttribute("data-test-service-worker-registered", "true"));
+ .then(() => document.body.setAttribute("data-test-service-worker-registered", "true"));
</script>
</body>
</html>