summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/browser/browser_default_audio_filename.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/content/tests/browser/browser_default_audio_filename.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/tests/browser/browser_default_audio_filename.js')
-rw-r--r--toolkit/content/tests/browser/browser_default_audio_filename.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/toolkit/content/tests/browser/browser_default_audio_filename.js b/toolkit/content/tests/browser/browser_default_audio_filename.js
new file mode 100644
index 0000000000..c32dda6878
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_default_audio_filename.js
@@ -0,0 +1,98 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var MockFilePicker = SpecialPowers.MockFilePicker;
+MockFilePicker.init(window);
+registerCleanupFunction(function () {
+ MockFilePicker.cleanup();
+});
+
+/**
+ * TestCase for bug 789550
+ * <https://bugzilla.mozilla.org/show_bug.cgi?id=789550>
+ */
+add_task(async function () {
+ const DATA_AUDIO_URL = await fetch(
+ getRootDirectory(gTestPath) + "audio_file.txt"
+ ).then(async response => response.text());
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: DATA_AUDIO_URL,
+ },
+ async function (browser) {
+ let popupShownPromise = BrowserTestUtils.waitForEvent(
+ document,
+ "popupshown"
+ );
+
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "video",
+ {
+ type: "contextmenu",
+ button: 2,
+ },
+ browser
+ );
+
+ await popupShownPromise;
+
+ let showFilePickerPromise = new Promise(resolve => {
+ MockFilePicker.showCallback = function (fp) {
+ is(
+ fp.defaultString.startsWith("Untitled"),
+ true,
+ "File name should be Untitled"
+ );
+ resolve();
+ };
+ });
+
+ // Select "Save Audio As" option from context menu
+ var saveImageAsCommand = document.getElementById("context-saveaudio");
+ saveImageAsCommand.doCommand();
+
+ await showFilePickerPromise;
+
+ let contextMenu = document.getElementById("contentAreaContextMenu");
+ let popupHiddenPromise = BrowserTestUtils.waitForEvent(
+ contextMenu,
+ "popuphidden"
+ );
+ contextMenu.hidePopup();
+ await popupHiddenPromise;
+ }
+ );
+});
+
+/**
+ * TestCase for bug 789550
+ * <https://bugzilla.mozilla.org/show_bug.cgi?id=789550>
+ */
+add_task(async function () {
+ const DATA_AUDIO_URL = await fetch(
+ getRootDirectory(gTestPath) + "audio_file.txt"
+ ).then(async response => response.text());
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: DATA_AUDIO_URL,
+ },
+ async function (browser) {
+ let showFilePickerPromise = new Promise(resolve => {
+ MockFilePicker.showCallback = function (fp) {
+ is(
+ fp.defaultString.startsWith("Untitled"),
+ true,
+ "File name should be Untitled"
+ );
+ resolve();
+ };
+ });
+
+ saveBrowser(browser);
+
+ await showFilePickerPromise;
+ }
+ );
+});