summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests/browser_newtab_menu.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /browser/components/preferences/tests/browser_newtab_menu.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_newtab_menu.js')
-rw-r--r--browser/components/preferences/tests/browser_newtab_menu.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_newtab_menu.js b/browser/components/preferences/tests/browser_newtab_menu.js
new file mode 100644
index 0000000000..774c9dd756
--- /dev/null
+++ b/browser/components/preferences/tests/browser_newtab_menu.js
@@ -0,0 +1,38 @@
+add_task(async function newtabPreloaded() {
+ await openPreferencesViaOpenPreferencesAPI("paneHome", { leaveOpen: true });
+
+ const { contentDocument: doc, contentWindow } = gBrowser;
+ function dispatchMenuItemCommand(menuItem) {
+ const cmdEvent = doc.createEvent("xulcommandevent");
+ cmdEvent.initCommandEvent(
+ "command",
+ true,
+ true,
+ contentWindow,
+ 0,
+ false,
+ false,
+ false,
+ false,
+ 0,
+ null,
+ 0
+ );
+ menuItem.dispatchEvent(cmdEvent);
+ }
+
+ const menuHome = doc.querySelector(`#newTabMode menuitem[value="0"]`);
+ const menuBlank = doc.querySelector(`#newTabMode menuitem[value="1"]`);
+ ok(menuHome.selected, "The first item, Home (default), is selected.");
+ ok(NewTabPagePreloading.enabled, "Default Home allows preloading.");
+
+ dispatchMenuItemCommand(menuBlank);
+ ok(menuBlank.selected, "The second item, Blank, is selected.");
+ ok(!NewTabPagePreloading.enabled, "Non-Home prevents preloading.");
+
+ dispatchMenuItemCommand(menuHome);
+ ok(menuHome.selected, "The first item, Home, is selected again.");
+ ok(NewTabPagePreloading.enabled, "Default Home allows preloading again.");
+
+ BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});