summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /browser/base/content/test/general
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/general')
-rw-r--r--browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js27
-rw-r--r--browser/base/content/test/general/browser_bug676619.js2
-rw-r--r--browser/base/content/test/general/browser_double_close_tab.js46
-rw-r--r--browser/base/content/test/general/browser_minimize.js43
-rw-r--r--browser/base/content/test/general/browser_save_link-perwindowpb.js8
-rw-r--r--browser/base/content/test/general/browser_save_link_when_window_navigates.js4
-rw-r--r--browser/base/content/test/general/browser_save_private_link_perwindowpb.js2
-rw-r--r--browser/base/content/test/general/browser_save_video.js4
-rw-r--r--browser/base/content/test/general/browser_save_video_frame.js2
-rw-r--r--browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js4
-rw-r--r--browser/base/content/test/general/navigating_window_with_download.html2
11 files changed, 59 insertions, 85 deletions
diff --git a/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js b/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
index 8a77f01ce4..8eb07a863a 100644
--- a/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
+++ b/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
@@ -1,36 +1,11 @@
const TEST_PAGE =
"http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html";
-const CONTENT_PROMPT_SUBDIALOG = Services.prefs.getBoolPref(
- "prompts.contentPromptSubDialog",
- false
-);
-
var expectingDialog = false;
var wantToClose = true;
var resolveDialogPromise;
-function onTabModalDialogLoaded(node) {
- ok(
- !CONTENT_PROMPT_SUBDIALOG,
- "Should not be using content prompt subdialogs."
- );
- ok(expectingDialog, "Should be expecting this dialog.");
- expectingDialog = false;
- if (wantToClose) {
- // This accepts the dialog, closing it
- node.querySelector(".tabmodalprompt-button0").click();
- } else {
- // This keeps the page open
- node.querySelector(".tabmodalprompt-button1").click();
- }
- if (resolveDialogPromise) {
- resolveDialogPromise();
- }
-}
-
function onCommonDialogLoaded(promptWindow) {
- ok(CONTENT_PROMPT_SUBDIALOG, "Should be using content prompt subdialogs.");
ok(expectingDialog, "Should be expecting this dialog.");
expectingDialog = false;
let dialog = promptWindow.Dialog;
@@ -51,11 +26,9 @@ SpecialPowers.pushPrefEnv({
});
// Listen for the dialog being created
-Services.obs.addObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded");
Services.obs.addObserver(onCommonDialogLoaded, "common-dialog-loaded");
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.tabs.warnOnClose");
- Services.obs.removeObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded");
Services.obs.removeObserver(onCommonDialogLoaded, "common-dialog-loaded");
});
diff --git a/browser/base/content/test/general/browser_bug676619.js b/browser/base/content/test/general/browser_bug676619.js
index 24d8d88447..80bbce8cb0 100644
--- a/browser/base/content/test/general/browser_bug676619.js
+++ b/browser/base/content/test/general/browser_bug676619.js
@@ -1,5 +1,5 @@
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
function waitForNewWindow() {
return new Promise(resolve => {
diff --git a/browser/base/content/test/general/browser_double_close_tab.js b/browser/base/content/test/general/browser_double_close_tab.js
index 554aeb8077..f5f2f1b6c7 100644
--- a/browser/base/content/test/general/browser_double_close_tab.js
+++ b/browser/base/content/test/general/browser_double_close_tab.js
@@ -4,24 +4,15 @@ const TEST_PAGE =
"http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html";
var testTab;
-const CONTENT_PROMPT_SUBDIALOG = Services.prefs.getBoolPref(
- "prompts.contentPromptSubDialog",
- false
-);
-
function waitForDialog(callback) {
function onDialogLoaded(nodeOrDialogWindow) {
- let node = CONTENT_PROMPT_SUBDIALOG
- ? nodeOrDialogWindow.document.querySelector("dialog")
- : nodeOrDialogWindow;
- Services.obs.removeObserver(onDialogLoaded, "tabmodal-dialog-loaded");
+ let node = nodeOrDialogWindow.document.querySelector("dialog");
Services.obs.removeObserver(onDialogLoaded, "common-dialog-loaded");
// Allow dialog's onLoad call to run to completion
Promise.resolve().then(() => callback(node));
}
// Listen for the dialog being created
- Services.obs.addObserver(onDialogLoaded, "tabmodal-dialog-loaded");
Services.obs.addObserver(onDialogLoaded, "common-dialog-loaded");
}
@@ -35,9 +26,7 @@ function waitForDialogDestroyed(node, callback) {
});
observer.observe(node.parentNode, { childList: true });
- if (CONTENT_PROMPT_SUBDIALOG) {
- node.ownerGlobal.addEventListener("unload", done);
- }
+ node.ownerGlobal.addEventListener("unload", done);
let failureTimeout = setTimeout(function () {
ok(false, "Dialog should have been destroyed");
@@ -49,12 +38,8 @@ function waitForDialogDestroyed(node, callback) {
observer.disconnect();
observer = null;
- if (CONTENT_PROMPT_SUBDIALOG) {
- node.ownerGlobal.removeEventListener("unload", done);
- SimpleTest.executeSoon(callback);
- } else {
- callback();
- }
+ node.ownerGlobal.removeEventListener("unload", done);
+ SimpleTest.executeSoon(callback);
}
}
@@ -76,23 +61,12 @@ add_task(async function () {
let doCompletion = () => setTimeout(resolveOuter, 0);
info("Now checking if dialog is destroyed");
- if (CONTENT_PROMPT_SUBDIALOG) {
- ok(
- !dialogNode.ownerGlobal || dialogNode.ownerGlobal.closed,
- "onbeforeunload dialog should be gone."
- );
- if (dialogNode.ownerGlobal && !dialogNode.ownerGlobal.closed) {
- dialogNode.acceptDialog();
- }
- } else {
- ok(!dialogNode.parentNode, "onbeforeunload dialog should be gone.");
- if (dialogNode.parentNode) {
- // Failed to remove onbeforeunload dialog, so do it ourselves:
- let leaveBtn = dialogNode.querySelector(".tabmodalprompt-button0");
- waitForDialogDestroyed(dialogNode, doCompletion);
- EventUtils.synthesizeMouseAtCenter(leaveBtn, {});
- return;
- }
+ ok(
+ !dialogNode.ownerGlobal || dialogNode.ownerGlobal.closed,
+ "onbeforeunload dialog should be gone."
+ );
+ if (dialogNode.ownerGlobal && !dialogNode.ownerGlobal.closed) {
+ dialogNode.acceptDialog();
}
doCompletion();
diff --git a/browser/base/content/test/general/browser_minimize.js b/browser/base/content/test/general/browser_minimize.js
index a57fea079c..3919cd7d77 100644
--- a/browser/base/content/test/general/browser_minimize.js
+++ b/browser/base/content/test/general/browser_minimize.js
@@ -12,26 +12,57 @@ add_task(async function () {
ok(isActive(), "Docshell should be active when starting the test");
ok(!document.hidden, "Top level window should be visible");
+ // When we show or hide the window (including by minimization),
+ // there are 2 signifiers that the process is complete: the
+ // sizemodechange event, and the browsing context becoming active
+ // or inactive. There is another signifier, the
+ // occlusionstatechange event, but whether or not that event
+ // is sent is platform-dependent, so it's not very useful. The
+ // safest way to check for stable state is to build promises
+ // around sizemodechange and browsing context active and then
+ // wait for them all to complete, and that's what we do here.
info("Calling window.minimize");
let promiseSizeModeChange = BrowserTestUtils.waitForEvent(
window,
"sizemodechange"
+ ).then(
+ () => ok(true, "Got sizemodechange."),
+ () => ok(false, "Rejected sizemodechange.")
+ );
+ let promiseBrowserInactive = BrowserTestUtils.waitForCondition(
+ () => !isActive(),
+ "Docshell should be inactive."
+ ).then(
+ () => ok(true, "Got inactive."),
+ () => ok(false, "Rejected inactive.")
);
window.minimize();
- await promiseSizeModeChange;
- ok(!isActive(), "Docshell should be Inactive");
+ await Promise.all([promiseSizeModeChange, promiseBrowserInactive]);
ok(document.hidden, "Top level window should be hidden");
+ // When we restore the window from minimization, we have the
+ // same concerns as above, so prepare our promises.
info("Calling window.restore");
promiseSizeModeChange = BrowserTestUtils.waitForEvent(
window,
"sizemodechange"
+ ).then(
+ () => ok(true, "Got sizemodechange."),
+ () => ok(false, "Rejected sizemodechange.")
+ );
+ let promiseBrowserActive = BrowserTestUtils.waitForCondition(
+ () => isActive(),
+ "Docshell should be active."
+ ).then(
+ () => ok(true, "Got active."),
+ () => ok(false, "Rejected active.")
);
window.restore();
+
// On Ubuntu `window.restore` doesn't seem to work, use a timer to make the
// test fail faster and more cleanly than with a test timeout.
await Promise.race([
- promiseSizeModeChange,
+ Promise.all([promiseSizeModeChange, promiseBrowserActive]),
new Promise((resolve, reject) =>
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(() => {
@@ -39,11 +70,5 @@ add_task(async function () {
}, 5000)
),
]);
- // The sizemodechange event can sometimes be fired before the
- // occlusionstatechange event, especially in chaos mode.
- if (window.isFullyOccluded) {
- await BrowserTestUtils.waitForEvent(window, "occlusionstatechange");
- }
- ok(isActive(), "Docshell should be active again");
ok(!document.hidden, "Top level window should be visible");
});
diff --git a/browser/base/content/test/general/browser_save_link-perwindowpb.js b/browser/base/content/test/general/browser_save_link-perwindowpb.js
index b018212280..234813ca2c 100644
--- a/browser/base/content/test/general/browser_save_link-perwindowpb.js
+++ b/browser/base/content/test/general/browser_save_link-perwindowpb.js
@@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
// Trigger a save of a link in public mode, then trigger an identical save
// in private mode and ensure that the second request is differentiated from
@@ -14,7 +14,7 @@ function triggerSave(aWindow, aCallback) {
let testBrowser = aWindow.gBrowser.selectedBrowser;
// This page sets a cookie if and only if a cookie does not exist yet
let testURI =
- "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517-2.html";
+ "https://example.com/browser/browser/base/content/test/general/bug792517-2.html";
BrowserTestUtils.startLoadingURIString(testBrowser, testURI);
BrowserTestUtils.browserLoaded(testBrowser, false, testURI).then(() => {
waitForFocus(function () {
@@ -132,7 +132,7 @@ function test() {
info("onExamineResponse with " + channel.URI.spec);
if (
channel.URI.spec !=
- "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517.sjs"
+ "https://example.com/browser/browser/base/content/test/general/bug792517.sjs"
) {
info("returning");
return;
@@ -158,7 +158,7 @@ function test() {
info("onModifyRequest with " + channel.URI.spec);
if (
channel.URI.spec !=
- "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517.sjs"
+ "https://example.com/browser/browser/base/content/test/general/bug792517.sjs"
) {
return;
}
diff --git a/browser/base/content/test/general/browser_save_link_when_window_navigates.js b/browser/base/content/test/general/browser_save_link_when_window_navigates.js
index e7507fcbb0..65daef5f1b 100644
--- a/browser/base/content/test/general/browser_save_link_when_window_navigates.js
+++ b/browser/base/content/test/general/browser_save_link_when_window_navigates.js
@@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
const SAVE_PER_SITE_PREF = "browser.download.lastDir.savePerSite";
const ALWAYS_DOWNLOAD_DIR_PREF = "browser.download.useDownloadDir";
@@ -36,7 +36,7 @@ function triggerSave(aWindow, aCallback) {
var fileName;
let testBrowser = aWindow.gBrowser.selectedBrowser;
let testURI =
- "http://mochi.test:8888/browser/browser/base/content/test/general/navigating_window_with_download.html";
+ "https://example.com/browser/browser/base/content/test/general/navigating_window_with_download.html";
// Only observe the UTC dialog if it's enabled by pref
if (Services.prefs.getBoolPref(ALWAYS_ASK_PREF)) {
diff --git a/browser/base/content/test/general/browser_save_private_link_perwindowpb.js b/browser/base/content/test/general/browser_save_private_link_perwindowpb.js
index 8ede97e640..42632bdc5a 100644
--- a/browser/base/content/test/general/browser_save_private_link_perwindowpb.js
+++ b/browser/base/content/test/general/browser_save_private_link_perwindowpb.js
@@ -43,7 +43,7 @@ function promiseImageDownloaded() {
return new Promise((resolve, reject) => {
let fileName;
let MockFilePicker = SpecialPowers.MockFilePicker;
- MockFilePicker.init(window);
+ MockFilePicker.init(window.browsingContext);
function onTransferComplete(downloadSuccess) {
ok(
diff --git a/browser/base/content/test/general/browser_save_video.js b/browser/base/content/test/general/browser_save_video.js
index 276088fbb1..e9701d7023 100644
--- a/browser/base/content/test/general/browser_save_video.js
+++ b/browser/base/content/test/general/browser_save_video.js
@@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
/**
* TestCase for bug 564387
@@ -14,7 +14,7 @@ add_task(async function () {
let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
BrowserTestUtils.startLoadingURIString(
gBrowser,
- "http://mochi.test:8888/browser/browser/base/content/test/general/web_video.html"
+ "https://example.com/browser/browser/base/content/test/general/web_video.html"
);
await loadPromise;
diff --git a/browser/base/content/test/general/browser_save_video_frame.js b/browser/base/content/test/general/browser_save_video_frame.js
index 877c33bcd3..11fe3ac80e 100644
--- a/browser/base/content/test/general/browser_save_video_frame.js
+++ b/browser/base/content/test/general/browser_save_video_frame.js
@@ -49,7 +49,7 @@ function waitForTransferComplete() {
*/
add_task(async function () {
let MockFilePicker = SpecialPowers.MockFilePicker;
- MockFilePicker.init(window);
+ MockFilePicker.init(window.browsingContext);
// Create the folder the video will be saved into.
let destDir = createTemporarySaveDirectory();
diff --git a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
index 2c0002fc44..2ec3b632f2 100644
--- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
+++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
@@ -15,7 +15,9 @@ function test() {
is(gBrowser.visibleTabs.length, 1, "Only one tab is visible");
- let uris = PlacesCommandHook.uniqueCurrentPages;
+ let uris = PlacesCommandHook.getUniquePages(
+ gBrowser.visibleTabs.filter(tab => !tab.pinned)
+ );
is(uris.length, 1, "Only one uri is returned");
is(
diff --git a/browser/base/content/test/general/navigating_window_with_download.html b/browser/base/content/test/general/navigating_window_with_download.html
index 6b0918941f..8649168cf5 100644
--- a/browser/base/content/test/general/navigating_window_with_download.html
+++ b/browser/base/content/test/general/navigating_window_with_download.html
@@ -2,6 +2,6 @@
<html>
<head><title>This window will navigate while you're downloading something</title></head>
<body>
- <iframe src="http://mochi.test:8888/browser/browser/base/content/test/general/unknownContentType_file.pif"></iframe>
+ <iframe src="https://example.com/browser/browser/base/content/test/general/unknownContentType_file.pif"></iframe>
</body>
</html>