Backed out 3 changesets (bug 1325876) for causing multiple bc failures.

Backed out changeset 10448d623bd4 (bug 1325876)
Backed out changeset 1092114b16b5 (bug 1325876)
Backed out changeset c0454be735a8 (bug 1325876)
This commit is contained in:
Goloman Adrian
2024-12-17 00:32:23 +02:00
parent e28e6b7180
commit 8d0f046600
16 changed files with 8 additions and 217 deletions

View File

@@ -1,38 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function decode(str) {
return decodeURIComponent(str.replace(/\+/g, encodeURIComponent(" ")));
}
function handleRequest(request, response) {
const queryString = request.queryString;
let params = queryString.split("&").reduce((memo, pair) => {
let [key, val] = pair.split("=");
if (!val) {
val = key;
key = "query";
}
try {
memo[decode(key)] = decode(val);
} catch (e) {
memo[key] = val;
}
return memo;
}, {});
const status = parseInt(params.status);
const message = params.message;
// Set default if missing parameters
if (!status || !message) {
response.setStatusLine(request.httpVersion, 400, "Bad Request");
response.setHeader("Content-Length", "0", false);
return;
}
response.setStatusLine(request.httpVersion, status, message);
response.setHeader("Content-Length", "0", false);
}

View File

@@ -45,11 +45,6 @@ skip-if = [
["browser_aboutNetError.js"]
["browser_aboutNetError_blank_page.js"]
support-files = [
"blank_page.sjs",
]
["browser_aboutNetError_csp_iframe.js"]
https_first_disabled = true
support-files = [

View File

@@ -1,72 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const BLANK_PAGE =
"https://example.com/browser/browser/base/content/test/about/blank_page.sjs";
async function test_blankPage(
page,
expectedL10nID,
responseStatus,
responseStatusText
) {
let browser;
let pageLoaded;
const uri = `${page}?status=${encodeURIComponent(
responseStatus
)}&message=${encodeURIComponent(responseStatusText)}`;
// Simulating loading the page
await BrowserTestUtils.openNewForegroundTab(
gBrowser,
() => {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri);
browser = gBrowser.selectedBrowser;
pageLoaded = BrowserTestUtils.waitForErrorPage(browser);
},
false
);
info("Loading and waiting for the net error");
await pageLoaded;
await SpecialPowers.spawn(
browser,
[expectedL10nID, responseStatus, responseStatusText],
function (l10nID, expectedStatus, expectedText) {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
"Should be showing error page"
);
const titleEl = doc.querySelector(".title-text");
const actualDataL10nID = titleEl.getAttribute("data-l10n-id");
is(actualDataL10nID, l10nID, "Correct error page title is set");
const expectedLabel =
"Error code: " + expectedStatus.toString() + " " + expectedText;
const actualLabel = doc.getElementById(
"response-status-label"
).textContent;
is(actualLabel, expectedLabel, "Correct response status message is set");
}
);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}
add_task(async function test_blankPage_4xx() {
await test_blankPage(BLANK_PAGE, "httpErrorPage-title", 400, "Bad Request");
});
add_task(async function test_blankPage_5xx() {
await test_blankPage(
BLANK_PAGE,
"serverError-title",
503,
"Service Unavailable"
);
});

View File

@@ -39,15 +39,6 @@ add_task(async function test_serverError() {
"serverError-title",
"Correct error page title is set"
);
const responseStatusLabel = doc.getElementById(
"response-status-label"
).textContent;
is(
responseStatusLabel,
"Error code: 500 Internal Server Error",
"Correct response status message is set"
);
});
BrowserTestUtils.removeTab(gBrowser.selectedTab);

View File

@@ -6,7 +6,6 @@ malformedURI2=Please check that the URL is correct and try again.
fileNotFound=Firefox cant find the file at %S.
fileAccessDenied=The file at %S is not readable.
# %S is replaced by the uri host
httpErrorPage=%S sent back an error.
serverError=%S might have a temporary problem or it could have moved.
dnsNotFound2=We cant connect to the server at %S.
unknownProtocolFound=Firefox doesnt know how to open this address, because one of the following protocols (%S) isnt associated with any program or is not allowed in this context.

View File

@@ -3353,9 +3353,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
nestedURI = do_QueryInterface(tempURI);
}
error = "unknownProtocolFound";
} else if (NS_ERROR_NET_EMPTY_RESPONSE == aError) {
NS_ENSURE_ARG_POINTER(aURI);
error = "httpErrorPage";
} else if (NS_ERROR_NET_ERROR_RESPONSE == aError) {
NS_ENSURE_ARG_POINTER(aURI);
error = "serverError";
@@ -6105,7 +6102,6 @@ nsresult nsDocShell::FilterStatusForErrorPage(
if (aStatus == NS_ERROR_NET_TIMEOUT ||
aStatus == NS_ERROR_NET_TIMEOUT_EXTERNAL ||
aStatus == NS_ERROR_NET_EMPTY_RESPONSE ||
aStatus == NS_ERROR_NET_ERROR_RESPONSE ||
aStatus == NS_ERROR_PROXY_GATEWAY_TIMEOUT ||
aStatus == NS_ERROR_REDIRECT_LOOP ||

View File

@@ -1661,36 +1661,22 @@ void GetErrorCodeStringFromNSResult(nsresult aResult,
}
void Document::GetNetErrorInfo(NetErrorInfo& aInfo, ErrorResult& aRv) {
nsresult rv = NS_OK;
if (NS_WARN_IF(!mFailedChannel)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
nsresult rv = NS_OK;
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mFailedChannel));
// We don't throw even if httpChannel is null, we just keep responseStatus and
// responseStatusText empty
if (httpChannel) {
uint32_t responseStatus;
nsAutoCString responseStatusText;
nsresult rv = httpChannel->GetResponseStatus(&responseStatus);
if (NS_SUCCEEDED(rv)) {
aInfo.mResponseStatus = responseStatus;
}
rv = httpChannel->GetResponseStatusText(responseStatusText);
if (NS_SUCCEEDED(rv)) {
aInfo.mResponseStatusText.AssignASCII(responseStatusText);
}
}
nsCOMPtr<nsITransportSecurityInfo> tsi;
rv = mFailedChannel->GetSecurityInfo(getter_AddRefs(tsi));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;
}
if (NS_WARN_IF(!tsi)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
nsresult channelStatus;
rv = mFailedChannel->GetStatus(&channelStatus);
@@ -1700,12 +1686,6 @@ void Document::GetNetErrorInfo(NetErrorInfo& aInfo, ErrorResult& aRv) {
}
aInfo.mChannelStatus = static_cast<uint32_t>(channelStatus);
// If nsITransportSecurityInfo is not set, simply keep the remaining fields
// empty (to make responseStatus and responseStatusText accessible).
if (!tsi) {
return;
}
// TransportSecurityInfo::GetErrorCodeString always returns NS_OK
(void)tsi->GetErrorCodeString(aInfo.mErrorCodeString);
if (aInfo.mErrorCodeString.IsEmpty()) {

View File

@@ -6,7 +6,6 @@ malformedURI2=Please check that the URL is correct and try again.
fileNotFound=The file %S cannot be found. Please check the location and try again.
fileAccessDenied=The file at %S is not readable.
# %S is replaced by the uri host
httpErrorPage=%S sent back an error.
serverError=%S might have a temporary problem or it could have moved.
dnsNotFound2=%S could not be found. Please check the name and try again.
unknownProtocolFound=One of the following (%S) is not a registered protocol or is not allowed in this context.

View File

@@ -12,6 +12,4 @@
dictionary NetErrorInfo {
DOMString errorCodeString = "";
unsigned long channelStatus = 0;
unsigned long responseStatus = 0;
DOMString responseStatusText = "";
};

View File

@@ -157,7 +157,6 @@ XPC_MSG_DEF(NS_ERROR_NET_TIMEOUT_EXTERNAL , "The request has been canc
XPC_MSG_DEF(NS_ERROR_OFFLINE , "The requested action could not be completed in the offline state")
XPC_MSG_DEF(NS_ERROR_PORT_ACCESS_NOT_ALLOWED , "Establishing a connection to an unsafe or otherwise banned port was prohibited")
XPC_MSG_DEF(NS_ERROR_NET_RESET , "The connection was established, but no data was ever received")
XPC_MSG_DEF(NS_ERROR_NET_EMPTY_RESPONSE , "The connection was established, but the browser received an empty page with an error response")
XPC_MSG_DEF(NS_ERROR_NET_ERROR_RESPONSE , "The connection was established, but the browser received an error response from the server")
XPC_MSG_DEF(NS_ERROR_NET_INTERRUPT , "The connection was established, but the data transfer was interrupted")
XPC_MSG_DEF(NS_ERROR_NET_PARTIAL_TRANSFER , "A transfer was only partially done when it completed")

View File

@@ -46,7 +46,6 @@ const KNOWN_ERROR_TITLE_IDS = new Set([
"unsafeContentType-title",
"netReset-title",
"netTimeout-title",
"httpErrorPage-title",
"serverError-title",
"unknownProtocolFound-title",
"proxyConnectFailure-title",
@@ -266,29 +265,6 @@ function recordTRREventTelemetry(
}
}
function setResponseStatus(shortDesc) {
let responseStatus;
let responseStatusText;
try {
const netErrorInfo = document.getNetErrorInfo();
responseStatus = netErrorInfo.responseStatus;
responseStatusText = netErrorInfo.responseStatusText;
} catch (ex) {
return;
}
if (responseStatus >= 400 && responseStatusText) {
let responseStatusLabel = document.createElement("p");
responseStatusLabel.id = "response-status-label"; // id for testing
document.l10n.setAttributes(
responseStatusLabel,
"neterror-response-status-code",
{ responsestatus: responseStatus, responsestatustext: responseStatusText }
);
shortDesc.appendChild(responseStatusLabel);
}
}
function initPage() {
// We show an offline support page in case of a system-wide error,
// when a user cannot connect to the internet and access the SUMO website.
@@ -619,7 +595,6 @@ function initPage() {
setNetErrorMessageFromParts(longDesc, parts);
}
setResponseStatus(shortDesc);
setNetErrorMessageFromCode();
}
@@ -742,7 +717,8 @@ function getNetErrorDescParts() {
case "connectionFailure":
case "netInterrupt":
case "netReset":
case "netTimeout": {
case "netTimeout":
case "serverError": {
let errorTags = [
["li", "neterror-load-error-try-again"],
["li", "neterror-load-error-connection"],
@@ -754,10 +730,6 @@ function getNetErrorDescParts() {
return errorTags;
}
case "httpErrorPage": // 4xx
return [["li", "neterror-http-error-page"]];
case "serverError": // 5xx
return [["li", "neterror-load-error-try-again"]];
case "blockedByPolicy":
case "deniedPortAccess":
case "malformedURI":
@@ -852,10 +824,7 @@ function setNetErrorMessageFromCode() {
try {
errorCode = document.getNetErrorInfo().errorCodeString;
} catch (ex) {
return;
}
if (!errorCode) {
// We don't have a securityInfo when this is for example a DNS error.
return;
}

View File

@@ -129,7 +129,6 @@ contentEncodingError-title = Content Encoding Error
unsafeContentType-title = Unsafe File Type
netReset-title = The connection was reset
netTimeout-title = The connection has timed out
httpErrorPage-title = Looks like theres a problem with this site
serverError-title = Looks like theres a problem with this site
unknownProtocolFound-title = The address wasnt understood
proxyConnectFailure-title = The proxy server is refusing connections

View File

@@ -44,8 +44,6 @@ neterror-load-error-firewall = If your computer or network is protected by a fir
# This warning is only shown on macOS Sequoia and later (see bug 1929377)
neterror-load-osx-permission = If you are trying to load a local network page, please check that { -brand-short-name } has been granted Local Network permissions in the macOS Privacy & Security settings.
neterror-http-error-page = Check to make sure youve typed the website address correctly.
neterror-captive-portal = You must log in to this network before you can access the internet.
# Variables:
@@ -180,8 +178,3 @@ certerror-mitm-what-can-you-do-about-it-attack-sts = If you are not familiar wit
certerror-what-should-i-do-bad-sts-cert-explanation = <b>{ $hostname }</b> has a security policy called HTTP Strict Transport Security (HSTS), which means that { -brand-short-name } can only connect to it securely. You cant add an exception to visit this site.
cert-error-trust-certificate-transparency-what-can-you-do-about-it = Probably nothing, since its likely theres a problem with the site itself.
# Variables:
# $responsestatus (string) - HTTP response status code (e.g., 500).
# $responsestatustext (string) - HTTP response status text (e.g., "Internal Server Error").
neterror-response-status-code = Error code: { $responsestatus } { $responsestatustext }

View File

@@ -63,7 +63,6 @@ ID01:
- unsafeContentType-title
- netReset-title
- netTimeout-title
- httpErrorPage-title
- serverError-title
- unknownProtocolFound-title
- proxyConnectFailure-title

View File

@@ -131,20 +131,6 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest* request) {
if (204 == responseCode || 205 == responseCode) {
return NS_BINDING_ABORTED;
}
// Bug 1325876: Show internal error page for HTTP responses with error
// codes (4xx, 5xx) and "Content-Length": 0 instead of blank page
int64_t contentLength = 0;
rv = httpChannel->GetContentLength(&contentLength);
if (NS_FAILED(rv) || contentLength <= 0) {
if (responseCode >= 500) {
return NS_ERROR_NET_ERROR_RESPONSE;
}
if (responseCode >= 400) {
return NS_ERROR_NET_EMPTY_RESPONSE;
}
}
}
//

View File

@@ -327,8 +327,6 @@ with modules["NETWORK"]:
errors["NS_ERROR_NET_RESET"] = FAILURE(20)
# The connection was established, but browser received an error response from the server
errors["NS_ERROR_NET_ERROR_RESPONSE"] = FAILURE(35)
# The connection was established, but browser received an empty page with 4xx, 5xx error response
errors["NS_ERROR_NET_EMPTY_RESPONSE"] = FAILURE(36)
# The connection was established, but the data transfer was interrupted.
errors["NS_ERROR_NET_INTERRUPT"] = FAILURE(71)
# The connection attempt to a proxy failed.