summaryrefslogtreecommitdiffstats
path: root/browser/components/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /browser/components/tests
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/tests')
-rw-r--r--browser/components/tests/browser/browser.toml6
-rw-r--r--browser/components/tests/browser/browser_default_webprotocol_handler_mailto.js117
-rw-r--r--browser/components/tests/browser/browser_system_notification_telemetry.js54
-rw-r--r--browser/components/tests/browser/whats_new_page/browser.toml2
-rw-r--r--browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js109
-rw-r--r--browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.toml6
6 files changed, 237 insertions, 57 deletions
diff --git a/browser/components/tests/browser/browser.toml b/browser/components/tests/browser/browser.toml
index ffb3012e72..c754191b8b 100644
--- a/browser/components/tests/browser/browser.toml
+++ b/browser/components/tests/browser/browser.toml
@@ -20,6 +20,9 @@ reason = "test depends on update channel"
["browser_default_browser_prompt.js"]
+["browser_default_webprotocol_handler_mailto.js"]
+run-if = ["os == 'win'"]
+
["browser_initial_tab_remoteType.js"]
https_first_disabled = true
@@ -33,8 +36,5 @@ skip-if = ["os == 'mac'"]
["browser_startup_homepage.js"]
-["browser_system_notification_telemetry.js"]
-run-if = ["os == 'win'"]
-
["browser_to_handle_telemetry.js"]
run-if = ["os == 'win'"]
diff --git a/browser/components/tests/browser/browser_default_webprotocol_handler_mailto.js b/browser/components/tests/browser/browser_default_webprotocol_handler_mailto.js
new file mode 100644
index 0000000000..d061d84b23
--- /dev/null
+++ b/browser/components/tests/browser/browser_default_webprotocol_handler_mailto.js
@@ -0,0 +1,117 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const WebProtocolHandlerRegistrar = ChromeUtils.importESModule(
+ "resource:///modules/WebProtocolHandlerRegistrar.sys.mjs"
+).WebProtocolHandlerRegistrar.prototype;
+
+add_setup(function add_setup() {
+ Services.prefs.setBoolPref("browser.mailto.dualPrompt", true);
+});
+
+// site specific settings
+const protocol = "mailto";
+const sss_domain = "test.example.com";
+const ss_setting = "system.under.test";
+
+add_task(async function check_null_value() {
+ Assert.equal(
+ null,
+ await WebProtocolHandlerRegistrar._getSiteSpecificSetting(
+ sss_domain,
+ ss_setting
+ ),
+ "site specific setting should initially not exist and return null."
+ );
+});
+
+add_task(async function check_default_value() {
+ Assert.equal(
+ true,
+ await WebProtocolHandlerRegistrar._getSiteSpecificSetting(
+ sss_domain,
+ ss_setting,
+ null,
+ true
+ ),
+ "site specific setting with a fallback/default value set to true."
+ );
+});
+
+add_task(async function check_save_value() {
+ WebProtocolHandlerRegistrar._saveSiteSpecificSetting(
+ sss_domain,
+ ss_setting,
+ ss_setting
+ );
+ Assert.equal(
+ ss_setting,
+ await WebProtocolHandlerRegistrar._getSiteSpecificSetting(
+ sss_domain,
+ ss_setting
+ ),
+ "site specific setting save and retrieve test."
+ );
+});
+
+add_task(async function check_installHash() {
+ Assert.notEqual(
+ null,
+ WebProtocolHandlerRegistrar._getInstallHash(),
+ "test to check the installHash"
+ );
+});
+
+add_task(async function check_addLocal() {
+ let currentHandler = WebProtocolHandlerRegistrar._addLocal(
+ protocol,
+ sss_domain,
+ sss_domain
+ );
+
+ Assert.equal(
+ sss_domain,
+ currentHandler.name,
+ "does the handler have the right name?"
+ );
+ Assert.equal(
+ sss_domain,
+ currentHandler.uriTemplate,
+ "does the handler have the right uri?"
+ );
+
+ WebProtocolHandlerRegistrar._setLocalDefault(currentHandler);
+
+ WebProtocolHandlerRegistrar.removeProtocolHandler(
+ protocol,
+ currentHandler.uriTemplate
+ );
+});
+
+add_task(async function check_bar_is_shown() {
+ let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ browserWindow.windowUtils.disableNonTestMouseEvents(true);
+ browserWindow.document
+ .getElementById("main-window")
+ .removeAttribute("remotecontrol");
+ let browser = browserWindow.gBrowser.selectedBrowser;
+
+ await WebProtocolHandlerRegistrar._askUserToSetMailtoHandler(
+ browser,
+ protocol,
+ Services.io.newURI("https://" + sss_domain),
+ sss_domain
+ );
+
+ let button_yes = browserWindow.document.querySelector(
+ "[data-l10n-id='protocolhandler-mailto-os-handler-yes-button']"
+ );
+ Assert.notEqual(null, button_yes, "is the yes-button there?");
+
+ let button_no = browserWindow.document.querySelector(
+ "[data-l10n-id='protocolhandler-mailto-os-handler-no-button']"
+ );
+ Assert.notEqual(null, button_no, "is the no-button there?");
+});
diff --git a/browser/components/tests/browser/browser_system_notification_telemetry.js b/browser/components/tests/browser/browser_system_notification_telemetry.js
deleted file mode 100644
index 6cc8d12165..0000000000
--- a/browser/components/tests/browser/browser_system_notification_telemetry.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-async function handleCommandLine(args, state) {
- let newWinPromise;
- let target = Services.urlFormatter.formatURLPref(
- "browser.shell.defaultBrowserAgent.thanksURL"
- );
-
- const EXISTING_FILE = Cc["@mozilla.org/file/local;1"].createInstance(
- Ci.nsIFile
- );
- EXISTING_FILE.initWithPath(getTestFilePath("dummy.pdf"));
-
- if (state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
- newWinPromise = BrowserTestUtils.waitForNewWindow({
- url: target, // N.b.: trailing slashes matter when matching.
- });
- }
-
- let cmdLineHandler = Cc["@mozilla.org/browser/final-clh;1"].getService(
- Ci.nsICommandLineHandler
- );
-
- let fakeCmdLine = Cu.createCommandLine(args, EXISTING_FILE.parent, state);
- cmdLineHandler.handle(fakeCmdLine);
-
- if (newWinPromise) {
- let newWin = await newWinPromise;
- await BrowserTestUtils.closeWindow(newWin);
- } else {
- BrowserTestUtils.removeTab(gBrowser.selectedTab);
- }
-}
-
-// Launching from the WDBA should open the "thanks" page and should send a
-// telemetry event.
-add_task(async function test_launched_to_handle_default_browser_agent() {
- await handleCommandLine(
- ["-to-handle-default-browser-agent"],
- Ci.nsICommandLine.STATE_INITIAL_LAUNCH
- );
-
- TelemetryTestUtils.assertEvents(
- [{ extra: { name: "default-browser-agent" } }],
- {
- category: "browser.launched_to_handle",
- method: "system_notification",
- object: "toast",
- }
- );
-});
diff --git a/browser/components/tests/browser/whats_new_page/browser.toml b/browser/components/tests/browser/whats_new_page/browser.toml
index b8b9b93d4a..51426ea851 100644
--- a/browser/components/tests/browser/whats_new_page/browser.toml
+++ b/browser/components/tests/browser/whats_new_page/browser.toml
@@ -19,3 +19,5 @@ prefs = [
]
["browser_whats_new_page.js"]
+
+["include:./browser_whats_new_page_nimbus.toml"]
diff --git a/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js
new file mode 100644
index 0000000000..a46e4fec34
--- /dev/null
+++ b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js
@@ -0,0 +1,109 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function nimbus_whats_new_page() {
+ // The test harness will use the current tab and remove the tab's history.
+ // Since the page that is tested is opened prior to the test harness taking
+ // over the current tab the active-update.xml specifies two pages to open by
+ // having 'https://example.com/|https://example.com/' for the value of openURL
+ // and then uses the first tab for the test.
+ gBrowser.selectedTab = gBrowser.tabs[0];
+ // The test harness also changes the page to about:blank so go back to the
+ // page that was originally opened.
+ gBrowser.goBack();
+ // Wait for the page to go back to the original page.
+ await TestUtils.waitForCondition(
+ () =>
+ gBrowser.selectedBrowser &&
+ gBrowser.selectedBrowser.currentURI &&
+ gBrowser.selectedBrowser.currentURI.spec ==
+ "https://www.mozilla.org/en-US/projects/firefox/whatsnew/",
+ `Waiting for the expected page to reopen, ${gBrowser.selectedBrowser.currentURI.spec}`
+ );
+ is(
+ gBrowser.selectedBrowser.currentURI.spec,
+ "https://www.mozilla.org/en-US/projects/firefox/whatsnew/",
+ "The what's new page's url should equal https://www.mozilla.org/en-US/projects/firefox/whatsnew/"
+ );
+ gBrowser.removeTab(gBrowser.selectedTab);
+
+ let um = Cc["@mozilla.org/updates/update-manager;1"].getService(
+ Ci.nsIUpdateManager
+ );
+ await TestUtils.waitForCondition(
+ () => !um.readyUpdate,
+ "Waiting for the ready update to be removed"
+ );
+ ok(!um.readyUpdate, "There should not be a ready update");
+ await TestUtils.waitForCondition(
+ () => !!um.getUpdateAt(0),
+ "Waiting for the ready update to be moved to the update history"
+ );
+ ok(!!um.getUpdateAt(0), "There should be an update in the update history");
+
+ // Leave no trace. Since this test modifies its support files put them back in
+ // their original state.
+ let alternatePath = Services.prefs.getCharPref("app.update.altUpdateDirPath");
+ let testRoot = Services.prefs.getCharPref("mochitest.testRoot");
+ let relativePath = alternatePath.substring("<test-root>".length);
+ if (AppConstants.platform == "win") {
+ relativePath = relativePath.replace(/\//g, "\\");
+ }
+ alternatePath = testRoot + relativePath;
+ let updateDir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+ updateDir.initWithPath(alternatePath);
+
+ let activeUpdateFile = updateDir.clone();
+ activeUpdateFile.append("active-update.xml");
+ await TestUtils.waitForCondition(
+ () => !activeUpdateFile.exists(),
+ "Waiting until the active-update.xml file does not exist"
+ );
+
+ let updatesFile = updateDir.clone();
+ updatesFile.append("updates.xml");
+ await TestUtils.waitForCondition(
+ () => updatesFile.exists(),
+ "Waiting until the updates.xml file exists"
+ );
+
+ let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
+ Ci.nsIFileOutputStream
+ );
+ let flags =
+ FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE;
+
+ let stateSucceeded = "succeeded\n";
+ let updateStatusFile = updateDir.clone();
+ updateStatusFile.append("updates");
+ updateStatusFile.append("0");
+ updateStatusFile.append("update.status");
+ updateStatusFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
+ fos.init(updateStatusFile, flags, FileUtils.PERMS_FILE, 0);
+ fos.write(stateSucceeded, stateSucceeded.length);
+ fos.close();
+
+ let xmlContents =
+ '<?xml version="1.0"?><updates xmlns="http://www.mozilla.org/2005/' +
+ 'app-update"><update xmlns="http://www.mozilla.org/2005/app-update" ' +
+ 'appVersion="99999999.0" buildID="20990101111111" channel="test" ' +
+ 'detailsURL="https://127.0.0.1/" displayVersion="1.0" installDate="' +
+ '1555716429454" isCompleteUpdate="true" name="What\'s New Page Test" ' +
+ 'previousAppVersion="60.0" serviceURL="https://127.0.0.1/update.xml" ' +
+ 'type="minor" platformVersion="99999999.0" actions="showURL" ' +
+ 'openURL="https://example.com/|https://example.com/"><patch size="1" ' +
+ 'type="complete" URL="https://127.0.0.1/complete.mar" ' +
+ 'selected="true" state="pending"/></update></updates>\n';
+ activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
+ fos.init(activeUpdateFile, flags, FileUtils.PERMS_FILE, 0);
+ fos.write(xmlContents, xmlContents.length);
+ fos.close();
+
+ updatesFile.remove(false);
+ Cc["@mozilla.org/updates/update-manager;1"]
+ .getService(Ci.nsIUpdateManager)
+ .QueryInterface(Ci.nsIObserver)
+ .observe(null, "um-reload-update-data", "");
+});
diff --git a/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.toml b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.toml
new file mode 100644
index 0000000000..fafe08af36
--- /dev/null
+++ b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.toml
@@ -0,0 +1,6 @@
+[DEFAULT]
+
+["browser_whats_new_page_nimbus.js"]
+# This is a pref set by nimbus to be used for What's new pages
+prefs = ["startup.homepage_override_url_nimbus='https://www.mozilla.org/en-US/projects/firefox/whatsnew/|https://www.mozilla.org/en-US/projects/firefox/whatsnew/'",
+"startup.homepage_override_nimbus_maxVersion='99999999.0'"]