Backed out 2 changesets (bug 1711622) for causing reftest failures on accept-image-catchall.html. CLOSED TREE

Backed out changeset 877d9c37605a (bug 1711622)
Backed out changeset c315e89b6e4b (bug 1711622)
This commit is contained in:
Iulian Moraru 2024-05-20 16:59:04 +03:00
parent a26386f006
commit 7af8c65261
5 changed files with 13 additions and 32 deletions

View file

@ -42,7 +42,7 @@ add_task(async function () {
`${method} ${SIMPLE_URL.split("example.com")[1]} ${httpVersion}`, `${method} ${SIMPLE_URL.split("example.com")[1]} ${httpVersion}`,
"Host: example.com", "Host: example.com",
"User-Agent: " + navigator.userAgent + "", "User-Agent: " + navigator.userAgent + "",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Language: " + navigator.languages.join(",") + ";q=0.5", "Accept-Language: " + navigator.languages.join(",") + ";q=0.5",
"Accept-Encoding: gzip, deflate", "Accept-Encoding: gzip, deflate",
"Connection: keep-alive", "Connection: keep-alive",

View file

@ -51,7 +51,7 @@ function expectedImageAcceptHeader() {
return ( return (
(Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") + (Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") +
(Services.prefs.getBoolPref("image.jxl.enabled") ? "image/jxl," : "") + (Services.prefs.getBoolPref("image.jxl.enabled") ? "image/jxl," : "") +
"image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5" "image/webp,*/*"
); );
} }

View file

@ -6,10 +6,7 @@ function handleRequest(request, response) {
file.append("test"); file.append("test");
file.append("mochitest"); file.append("mochitest");
if ( if (request.getHeader("Accept") == "image/avif,image/webp,*/*") {
request.getHeader("Accept") ==
"image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"
) {
file.append("blue.png"); file.append("blue.png");
} else { } else {
file.append("red.png"); file.append("red.png");

View file

@ -216,33 +216,17 @@ static nsCString ImageAcceptHeader() {
mimeTypes.Append("image/jxl,"); mimeTypes.Append("image/jxl,");
} }
mimeTypes.Append("image/webp,"); mimeTypes.Append("image/webp,*/*");
// Default value as specified by fetch standard
// https://fetch.spec.whatwg.org/commit-snapshots/8dd73dbecfefdbef8f432164fb3a5b9785f7f520/#ref-for-header-list-contains%E2%91%A7
mimeTypes.Append("image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5");
return mimeTypes; return mimeTypes;
} }
static nsCString DocumentAcceptHeader() { static nsCString DocumentAcceptHeader(const nsCString& aImageAcceptHeader) {
// https://fetch.spec.whatwg.org/#document-accept-header-value nsPrintfCString mimeTypes(
// The value specified by the fetch standard is "text/html,application/xhtml+xml,application/xml;q=0.9,%s;q=0.8",
// `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8` aImageAcceptHeader.get());
// but we also insert all of the image formats before */*
nsCString mimeTypes("text/html,application/xhtml+xml,application/xml;q=0.9,");
if (mozilla::StaticPrefs::image_avif_enabled()) { return std::move(mimeTypes);
mimeTypes.Append("image/avif,");
}
if (mozilla::StaticPrefs::image_jxl_enabled()) {
mimeTypes.Append("image/jxl,");
}
mimeTypes.Append("image/webp,image/png,image/svg+xml,*/*;q=0.8");
return mimeTypes;
} }
nsHttpHandler::nsHttpHandler() nsHttpHandler::nsHttpHandler()
@ -251,7 +235,7 @@ nsHttpHandler::nsHttpHandler()
PR_SecondsToInterval(StaticPrefs::network_http_http2_timeout())), PR_SecondsToInterval(StaticPrefs::network_http_http2_timeout())),
mResponseTimeout(PR_SecondsToInterval(300)), mResponseTimeout(PR_SecondsToInterval(300)),
mImageAcceptHeader(ImageAcceptHeader()), mImageAcceptHeader(ImageAcceptHeader()),
mDocumentAcceptHeader(DocumentAcceptHeader()), mDocumentAcceptHeader(DocumentAcceptHeader(ImageAcceptHeader())),
mLastUniqueID(NowInSeconds()), mLastUniqueID(NowInSeconds()),
mDebugObservations(false), mDebugObservations(false),
mEnableAltSvc(false), mEnableAltSvc(false),
@ -1763,7 +1747,7 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
} }
if (userSetDocumentAcceptHeader.IsEmpty()) { if (userSetDocumentAcceptHeader.IsEmpty()) {
mDocumentAcceptHeader.Assign(DocumentAcceptHeader()); mDocumentAcceptHeader.Assign(DocumentAcceptHeader(mImageAcceptHeader));
} else { } else {
mDocumentAcceptHeader.Assign(userSetDocumentAcceptHeader); mDocumentAcceptHeader.Assign(userSetDocumentAcceptHeader);
} }

View file

@ -26,7 +26,7 @@ function test_iframe() {
let ifr = document.createElement("iframe"); let ifr = document.createElement("iframe");
ifr.src = "test_accept_header.sjs?iframe"; ifr.src = "test_accept_header.sjs?iframe";
ifr.onload = () => { ifr.onload = () => {
test_last_request_and_continue("iframe", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8"); test_last_request_and_continue("iframe", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8");
}; };
document.body.appendChild(ifr); document.body.appendChild(ifr);
} }
@ -36,7 +36,7 @@ function test_image() {
i.src = "test_accept_header.sjs?image"; i.src = "test_accept_header.sjs?image";
i.onload = function() { i.onload = function() {
// Fetch spec says we should have: "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5" // Fetch spec says we should have: "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"
test_last_request_and_continue("image", "image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"); test_last_request_and_continue("image", "image/avif,image/webp,*/*");
} }
} }