Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* Any copyright is dedicated to the Public Domain.
"use strict";
const SERVER_ERROR_PAGE =
add_task(async function test_serverError() {
let browser;
let pageLoaded;
await BrowserTestUtils.openNewForegroundTab(
gBrowser,
() => {
gBrowser.selectedTab = BrowserTestUtils.addTab(
gBrowser,
SERVER_ERROR_PAGE
);
browser = gBrowser.selectedBrowser;
pageLoaded = BrowserTestUtils.waitForErrorPage(browser);
},
false
);
info("Loading and waiting for the net error");
await pageLoaded;
await SpecialPowers.spawn(browser, [], async function () {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
"Should be showing error page"
);
let titleEl;
let actualDataL10nID;
const netErrorCard = doc.querySelector("net-error-card");
if (netErrorCard) {
const card = netErrorCard.wrappedJSObject;
await card.getUpdateComplete();
titleEl = card.errorTitle;
} else {
titleEl = doc.querySelector(".title-text");
const responseStatusLabel = await ContentTaskUtils.waitForCondition(
() => doc.getElementById("response-status-label"),
"Waiting for response-status-label"
);
is(
responseStatusLabel.textContent,
"Error code: 500 Internal Server Error",
"Correct response status message is set"
);
}
actualDataL10nID = titleEl.getAttribute("data-l10n-id");
is(
actualDataL10nID,
"problem-with-this-site-title",
"Correct error page title is set"
);
});
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});