summaryrefslogtreecommitdiffstats
path: root/uriloader
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /uriloader
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'uriloader')
-rw-r--r--uriloader/base/nsURILoader.cpp15
-rw-r--r--uriloader/exthandler/ExtHandlerService.sys.mjs4
-rw-r--r--uriloader/exthandler/nsExternalHelperAppService.h4
-rw-r--r--uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js10
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_auto_close_window.js2
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_auto_close_window_nodialog.js4
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_download_idn_blocklist.js5
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js2
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_download_spam_permissions.js4
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_download_urlescape.js2
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_extension_correction.js2
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_local_files_open_doesnt_duplicate.js4
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_open_internal_choice_persistence.js2
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_pdf_save_as.js14
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_save_filenames.js11
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js10
-rw-r--r--uriloader/exthandler/tests/mochitest/browser_txt_download_save_as.js12
-rw-r--r--uriloader/exthandler/unix/nsOSHelperAppService.cpp2
-rw-r--r--uriloader/preload/PreloadService.cpp50
-rw-r--r--uriloader/preload/PreloadService.h3
20 files changed, 78 insertions, 84 deletions
diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp
index 0acd451c9d..792f3ea893 100644
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -274,12 +274,19 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) {
// could happen because the Content-Disposition header is set so, or, in the
// future, because the user has specified external handling for the MIME
// type.
+ //
+ // If we're not going to be able to retarget to an external handler, ignore
+ // content-disposition, and unconditionally try to display the content.
+ // This is used for object/embed tags, which expect to display subresources
+ // marked with an attachment disposition.
bool forceExternalHandling = false;
- uint32_t disposition;
- rv = aChannel->GetContentDisposition(&disposition);
+ if (!(mFlags & nsIURILoader::DONT_RETARGET)) {
+ uint32_t disposition;
+ rv = aChannel->GetContentDisposition(&disposition);
- if (NS_SUCCEEDED(rv) && disposition == nsIChannel::DISPOSITION_ATTACHMENT) {
- forceExternalHandling = true;
+ if (NS_SUCCEEDED(rv) && disposition == nsIChannel::DISPOSITION_ATTACHMENT) {
+ forceExternalHandling = true;
+ }
}
LOG((" forceExternalHandling: %s", forceExternalHandling ? "yes" : "no"));
diff --git a/uriloader/exthandler/ExtHandlerService.sys.mjs b/uriloader/exthandler/ExtHandlerService.sys.mjs
index aad2c0b8d9..d7f3c9b9e0 100644
--- a/uriloader/exthandler/ExtHandlerService.sys.mjs
+++ b/uriloader/exthandler/ExtHandlerService.sys.mjs
@@ -324,7 +324,7 @@ HandlerService.prototype = {
},
// nsIObserver
- observe(subject, topic, data) {
+ observe(subject, topic) {
if (topic != "handlersvc-json-replace") {
return;
}
@@ -726,7 +726,7 @@ HandlerService.prototype = {
this._mockedProtocol = protocol;
this._mockedHandler = {
QueryInterface: ChromeUtils.generateQI([Ci.nsILocalHandlerApp]),
- launchWithURI(uri, context) {
+ launchWithURI(uri) {
Services.obs.notifyObservers(uri, "mocked-protocol-handler");
},
name: "Mocked handler",
diff --git a/uriloader/exthandler/nsExternalHelperAppService.h b/uriloader/exthandler/nsExternalHelperAppService.h
index 205f73cfa1..1f77e095db 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -544,8 +544,8 @@ class nsExternalAppHandler final : public nsIStreamListener,
const nsString& path);
/**
- * Set in HelperAppDlg.jsm. This is always null after the user has chosen an
- * action.
+ * Set in HelperAppDlg.sys.mjs. This is always null after the user has chosen
+ * an action.
*/
nsCOMPtr<nsIWebProgressListener2> mDialogProgressListener;
/**
diff --git a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js
index 4f66c99dc6..13084f92d6 100644
--- a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js
+++ b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js
@@ -34,7 +34,7 @@ Services.prefs.setCharPref("browser.download.dir", tmpDir.path);
const FAKE_CID = Services.uuid.generateUUID();
function HelperAppLauncherDialog() {}
HelperAppLauncherDialog.prototype = {
- show(aLauncher, aWindowContext, aReason) {
+ show(aLauncher) {
if (
Services.prefs.getBoolPref(
"browser.download.always_ask_before_handling_new_types"
@@ -49,13 +49,7 @@ HelperAppLauncherDialog.prototype = {
}
aLauncher.cancel(Cr.NS_BINDING_ABORTED);
},
- promptForSaveToFileAsync(
- appLauncher,
- parent,
- filename,
- extension,
- forceSave
- ) {
+ promptForSaveToFileAsync(appLauncher, parent, filename) {
if (
!Services.prefs.getBoolPref(
"browser.download.always_ask_before_handling_new_types"
diff --git a/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js b/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
index af60b59c4b..f5a08b854b 100644
--- a/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
+++ b/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
@@ -26,7 +26,7 @@ let curDialogResolve = null;
function HelperAppLauncherDialog() {}
HelperAppLauncherDialog.prototype = {
- show(aLauncher, aWindowContext, aReason) {
+ show(aLauncher, aWindowContext) {
ok(true, "Showing the helper app dialog");
curDialogResolve(aWindowContext);
executeSoon(() => {
diff --git a/uriloader/exthandler/tests/mochitest/browser_auto_close_window_nodialog.js b/uriloader/exthandler/tests/mochitest/browser_auto_close_window_nodialog.js
index 4f1e8ab18e..a80d8aa656 100644
--- a/uriloader/exthandler/tests/mochitest/browser_auto_close_window_nodialog.js
+++ b/uriloader/exthandler/tests/mochitest/browser_auto_close_window_nodialog.js
@@ -26,13 +26,13 @@ let curSaveResolve = null;
function HelperAppLauncherDialog() {}
HelperAppLauncherDialog.prototype = {
- show(aLauncher, aWindowContext, aReason) {
+ show(aLauncher) {
ok(false, "Shouldn't be showing the helper app dialog");
executeSoon(() => {
aLauncher.cancel(Cr.NS_ERROR_ABORT);
});
},
- promptForSaveToFileAsync(aLauncher, aWindowContext, aReason) {
+ promptForSaveToFileAsync(aLauncher, aWindowContext) {
ok(true, "Shouldn't be showing the helper app dialog");
curSaveResolve(aWindowContext);
executeSoon(() => {
diff --git a/uriloader/exthandler/tests/mochitest/browser_download_idn_blocklist.js b/uriloader/exthandler/tests/mochitest/browser_download_idn_blocklist.js
index 0d49a898a0..a5de2870af 100644
--- a/uriloader/exthandler/tests/mochitest/browser_download_idn_blocklist.js
+++ b/uriloader/exthandler/tests/mochitest/browser_download_idn_blocklist.js
@@ -24,7 +24,10 @@ server.registerFile(`/${encodeURIComponent(TEST_FILE)}`, file);
*/
add_task(async function test_idn_blocklisted_char_not_escaped() {
await SpecialPowers.pushPrefEnv({
- set: [["browser.download.always_ask_before_handling_new_types", false]],
+ set: [
+ ["browser.download.always_ask_before_handling_new_types", false],
+ ["dom.block_download_insecure", false],
+ ],
});
info("Testing with " + TEST_URL);
diff --git a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js
index c73538fe19..35d93703cd 100644
--- a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js
+++ b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js
@@ -23,7 +23,7 @@ const HandlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].getService(
);
let MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
function waitForAcceptButtonToGetEnabled(doc) {
let dialog = doc.querySelector("#unknownContentType");
diff --git a/uriloader/exthandler/tests/mochitest/browser_download_spam_permissions.js b/uriloader/exthandler/tests/mochitest/browser_download_spam_permissions.js
index 0f80af5ac5..082c278b69 100644
--- a/uriloader/exthandler/tests/mochitest/browser_download_spam_permissions.js
+++ b/uriloader/exthandler/tests/mochitest/browser_download_spam_permissions.js
@@ -18,7 +18,7 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
const AUTOMATIC_DOWNLOAD_TOPIC = "blocked-automatic-download";
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
registerCleanupFunction(() => MockFilePicker.cleanup());
let gTempDownloadDir;
@@ -140,7 +140,7 @@ async function savelink() {
await popupShown;
await new Promise(resolve => {
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
resolve();
let file = gTempDownloadDir.clone();
file.append("file_with__funny_name.png");
diff --git a/uriloader/exthandler/tests/mochitest/browser_download_urlescape.js b/uriloader/exthandler/tests/mochitest/browser_download_urlescape.js
index ababcc095c..e153b696bf 100644
--- a/uriloader/exthandler/tests/mochitest/browser_download_urlescape.js
+++ b/uriloader/exthandler/tests/mochitest/browser_download_urlescape.js
@@ -9,7 +9,7 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
);
var MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
registerCleanupFunction(() => MockFilePicker.cleanup());
/**
diff --git a/uriloader/exthandler/tests/mochitest/browser_extension_correction.js b/uriloader/exthandler/tests/mochitest/browser_extension_correction.js
index 9d67bf7213..955b8cec8c 100644
--- a/uriloader/exthandler/tests/mochitest/browser_extension_correction.js
+++ b/uriloader/exthandler/tests/mochitest/browser_extension_correction.js
@@ -172,7 +172,7 @@ async function checkDownloadWithExtensionState(
* we enforce a useful extension.
*/
add_task(async function test_enforce_useful_extension() {
- await BrowserTestUtils.withNewTab("data:text/html,", async browser => {
+ await BrowserTestUtils.withNewTab("data:text/html,", async () => {
await testLinkWithoutExtension("image/png", true);
await testLinkWithoutExtension("audio/ogg", true);
await testLinkWithoutExtension("video/webm", true);
diff --git a/uriloader/exthandler/tests/mochitest/browser_local_files_open_doesnt_duplicate.js b/uriloader/exthandler/tests/mochitest/browser_local_files_open_doesnt_duplicate.js
index d8e7c87c10..e708dd1acf 100644
--- a/uriloader/exthandler/tests/mochitest/browser_local_files_open_doesnt_duplicate.js
+++ b/uriloader/exthandler/tests/mochitest/browser_local_files_open_doesnt_duplicate.js
@@ -41,7 +41,7 @@ add_task(async function open_from_dialog() {
let openingPromise = TestUtils.topicObserved(
"test-only-opening-downloaded-file",
- (subject, data) => {
+ subject => {
subject.QueryInterface(Ci.nsISupportsPRBool);
// Block opening the file:
subject.data = false;
@@ -92,7 +92,7 @@ add_task(async function open_directly() {
let openingPromise = TestUtils.topicObserved(
"test-only-opening-downloaded-file",
- (subject, data) => {
+ subject => {
subject.QueryInterface(Ci.nsISupportsPRBool);
// Block opening the file:
subject.data = false;
diff --git a/uriloader/exthandler/tests/mochitest/browser_open_internal_choice_persistence.js b/uriloader/exthandler/tests/mochitest/browser_open_internal_choice_persistence.js
index 424fd424f9..a663fd3223 100644
--- a/uriloader/exthandler/tests/mochitest/browser_open_internal_choice_persistence.js
+++ b/uriloader/exthandler/tests/mochitest/browser_open_internal_choice_persistence.js
@@ -66,7 +66,7 @@ function ensureMIMEState({ preferredAction, alwaysAskBeforeHandling }) {
}
function waitDelay(delay) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
/* eslint-disable mozilla/no-arbitrary-setTimeout */
window.setTimeout(resolve, delay);
});
diff --git a/uriloader/exthandler/tests/mochitest/browser_pdf_save_as.js b/uriloader/exthandler/tests/mochitest/browser_pdf_save_as.js
index a08fe342cc..5d4a2080a7 100644
--- a/uriloader/exthandler/tests/mochitest/browser_pdf_save_as.js
+++ b/uriloader/exthandler/tests/mochitest/browser_pdf_save_as.js
@@ -16,9 +16,9 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
const { saveToDisk, alwaysAsk, handleInternally, useSystemDefault } =
Ci.nsIHandlerInfo;
const MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
-async function testPdfFilePicker(mimeInfo) {
+async function testPdfFilePicker() {
await BrowserTestUtils.withNewTab(
`data:text/html,<a id="test-link" href="${TEST_PATH}/file_pdf_application_pdf.pdf">Test PDF Link</a>`,
async browser => {
@@ -37,12 +37,14 @@ async function testPdfFilePicker(mimeInfo) {
let filePickerPromise = new Promise(resolve => {
MockFilePicker.showCallback = fp => {
ok(true, "filepicker should be visible");
- ok(
- fp.defaultExtension === "pdf",
+ Assert.strictEqual(
+ fp.defaultExtension,
+ "pdf",
"Default extension in filepicker should be pdf"
);
- ok(
- fp.defaultString === "file_pdf_application_pdf.pdf",
+ Assert.strictEqual(
+ fp.defaultString,
+ "file_pdf_application_pdf.pdf",
"Default string name in filepicker should have the correct pdf file name"
);
setTimeout(resolve, 0);
diff --git a/uriloader/exthandler/tests/mochitest/browser_save_filenames.js b/uriloader/exthandler/tests/mochitest/browser_save_filenames.js
index 46750d5c87..984d0dea21 100644
--- a/uriloader/exthandler/tests/mochitest/browser_save_filenames.js
+++ b/uriloader/exthandler/tests/mochitest/browser_save_filenames.js
@@ -55,7 +55,7 @@ const DEFAULT_FILENAME =
const PROMISE_FILENAME_TYPE = "application/x-moz-file-promise-dest-filename";
let MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
let expectedItems;
let sendAsAttachment = false;
@@ -240,7 +240,7 @@ add_task(async function save_document() {
tmpDir.append(baseFilename + "_document_files");
MockFilePicker.displayDirectory = tmpDir;
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
MockFilePicker.setFiles([tmpFile]);
MockFilePicker.filterIndex = 0; // kSaveAsType_Complete
};
@@ -280,8 +280,9 @@ add_task(async function save_document() {
fileIdx = filesSaved.indexOf(filename);
}
- ok(
- fileIdx >= 0,
+ Assert.greaterOrEqual(
+ fileIdx,
+ 0,
"file i" +
idx +
" " +
@@ -562,7 +563,7 @@ add_task(async function saveas_files_modified_in_filepicker() {
await new Promise(resolve => {
MockFilePicker.displayDirectory = savedFile;
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
MockFilePicker.filterIndex = 0; // kSaveAsType_Complete
savedFile.append(items[idx].pickedfilename);
MockFilePicker.setFiles([savedFile]);
diff --git a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js
index 6bf375dfff..38cca8530d 100644
--- a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js
+++ b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js
@@ -16,7 +16,7 @@ const { handleInternally, useHelperApp, useSystemDefault, saveToDisk } =
Ci.nsIHandlerInfo;
let MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
@@ -50,7 +50,7 @@ add_task(async function aDownloadSavedToDiskPromptsForFolder() {
await publicList.removeFinished();
});
let filePickerShownPromise = new Promise(resolve => {
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
setTimeout(resolve, 0);
return Ci.nsIFilePicker.returnCancel;
};
@@ -81,7 +81,7 @@ add_task(async function testFilesHandledInternally() {
);
let filePickerShown = false;
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
filePickerShown = true;
return Ci.nsIFilePicker.returnCancel;
};
@@ -120,7 +120,7 @@ add_task(async function testFilesHandledBySystemDefaultApp() {
ensureMIMEState({ preferredAction: useSystemDefault });
let filePickerShown = false;
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
filePickerShown = true;
return Ci.nsIFilePicker.returnCancel;
};
@@ -178,7 +178,7 @@ add_task(async function testFilesHandledByHelperApp() {
});
let filePickerShown = false;
- MockFilePicker.showCallback = function (fp) {
+ MockFilePicker.showCallback = function () {
filePickerShown = true;
return Ci.nsIFilePicker.returnCancel;
};
diff --git a/uriloader/exthandler/tests/mochitest/browser_txt_download_save_as.js b/uriloader/exthandler/tests/mochitest/browser_txt_download_save_as.js
index 7155c35fd9..9d0f8db41c 100644
--- a/uriloader/exthandler/tests/mochitest/browser_txt_download_save_as.js
+++ b/uriloader/exthandler/tests/mochitest/browser_txt_download_save_as.js
@@ -25,7 +25,7 @@ const {
} = Ci.nsIHandlerInfo;
const testDir = createTemporarySaveDirectory();
const MockFilePicker = SpecialPowers.MockFilePicker;
-MockFilePicker.init(window);
+MockFilePicker.init(window.browsingContext);
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
@@ -64,12 +64,14 @@ async function setupFilePicker() {
MockFilePicker.displayDirectory = testDir;
MockFilePicker.showCallback = fp => {
ok(true, "filepicker should be visible");
- ok(
- fp.defaultExtension === "txt",
+ Assert.strictEqual(
+ fp.defaultExtension,
+ "txt",
"Default extension in filepicker should be txt"
);
- ok(
- fp.defaultString === "file_txt_attachment_test.txt",
+ Assert.strictEqual(
+ fp.defaultString,
+ "file_txt_attachment_test.txt",
"Default string name in filepicker should have the correct file name"
);
const destFile = testDir.clone();
diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
index 7f6eaa46f2..fcc2e9f5ab 100644
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -176,7 +176,7 @@ struct FileLocationCache {
void Clear() { *this = {}; }
};
- EnumeratedArray<FileKind, FileKind::Count, Entry> mEntries;
+ EnumeratedArray<FileKind, Entry, size_t(FileKind::Count)> mEntries;
static const char* PrefFor(FileKind aKind) {
switch (aKind) {
diff --git a/uriloader/preload/PreloadService.cpp b/uriloader/preload/PreloadService.cpp
index 5fc59760f0..48cf9a364c 100644
--- a/uriloader/preload/PreloadService.cpp
+++ b/uriloader/preload/PreloadService.cpp
@@ -137,46 +137,28 @@ void PreloadService::PreloadLinkHeader(
}
// The mapping is specified as implementation-defined, see step 15 of
-// <https://fetch.spec.whatwg.org/#concept-fetch>. For web-compatibility,
-// Chromium's mapping described at
-// <https://web.dev/articles/fetch-priority#browser_priority_and_fetchpriority>
-// is chosen.
+// <https://fetch.spec.whatwg.org/#concept-fetch>.
+// See corresponding preferences in StaticPrefList.yaml for more context.
class SupportsPriorityValueFor {
public:
static int32_t LinkRelPreloadFont(const FetchPriority aFetchPriority) {
+ int32_t priorityValue = nsISupportsPriority::PRIORITY_HIGH;
if (!StaticPrefs::network_fetchpriority_enabled()) {
- return nsISupportsPriority::PRIORITY_HIGH;
+ return priorityValue;
}
- switch (aFetchPriority) {
- case FetchPriority::Auto:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::High:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::Low:
- return nsISupportsPriority::PRIORITY_LOW;
- }
-
- MOZ_ASSERT_UNREACHABLE();
- return nsISupportsPriority::PRIORITY_HIGH;
+ return priorityValue +
+ FETCH_PRIORITY_ADJUSTMENT_FOR(link_preload_font, aFetchPriority);
}
static int32_t LinkRelPreloadFetch(const FetchPriority aFetchPriority) {
+ int32_t priorityValue = nsISupportsPriority::PRIORITY_NORMAL;
if (!StaticPrefs::network_fetchpriority_enabled()) {
- return nsISupportsPriority::PRIORITY_NORMAL;
- }
-
- switch (aFetchPriority) {
- case FetchPriority::Auto:
- return nsISupportsPriority::PRIORITY_NORMAL;
- case FetchPriority::High:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::Low:
- return nsISupportsPriority::PRIORITY_LOW;
+ return priorityValue;
}
- MOZ_ASSERT_UNREACHABLE();
- return nsISupportsPriority::PRIORITY_NORMAL;
+ return priorityValue +
+ FETCH_PRIORITY_ADJUSTMENT_FOR(link_preload_fetch, aFetchPriority);
}
};
@@ -244,7 +226,8 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
break;
}
} else if (aAs.LowerCaseEqualsASCII("image")) {
- PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId);
+ PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId,
+ aFetchPriority);
} else if (aAs.LowerCaseEqualsASCII("font")) {
PreloadFont(uri, aCORS, aReferrerPolicy, aEarlyHintPreloaderId,
aFetchPriority);
@@ -276,10 +259,11 @@ void PreloadService::PreloadScript(
void PreloadService::PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aImageReferrerPolicy,
bool aIsImgSet,
- uint64_t aEarlyHintPreloaderId) {
- mDocument->PreLoadImage(aURI, aCrossOrigin,
- PreloadReferrerPolicy(aImageReferrerPolicy),
- aIsImgSet, true, aEarlyHintPreloaderId);
+ uint64_t aEarlyHintPreloaderId,
+ const nsAString& aFetchPriority) {
+ mDocument->PreLoadImage(
+ aURI, aCrossOrigin, PreloadReferrerPolicy(aImageReferrerPolicy),
+ aIsImgSet, true, aEarlyHintPreloaderId, aFetchPriority);
}
void PreloadService::PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
diff --git a/uriloader/preload/PreloadService.h b/uriloader/preload/PreloadService.h
index 5f6566ea34..79f5e7b6d1 100644
--- a/uriloader/preload/PreloadService.h
+++ b/uriloader/preload/PreloadService.h
@@ -90,7 +90,8 @@ class PreloadService {
void PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aImageReferrerPolicy, bool aIsImgSet,
- uint64_t aEarlyHintPreloaderId);
+ uint64_t aEarlyHintPreloaderId,
+ const nsAString& aFetchPriority);
void PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aReferrerPolicy,