Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* Any copyright is dedicated to the Public Domain.
"use strict";
const DUMMY_SUPPORT_BASE_PATH = "/1/firefox/fxVersion/OSVersion/language/";
const DUMMY_SUPPORT_URL = BAD_CERT_PAGE + DUMMY_SUPPORT_BASE_PATH;
const OFFLINE_SUPPORT_PAGE =
"chrome://global/content/neterror/supportpages/time-errors.html";
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["test.wait300msAfterTabSwitch", true],
["security.certerrors.felt-privacy-v1", true],
],
});
});
add_task(async function testOfflineSupportPage() {
// Cache the original value of app.support.baseURL pref to reset later
let originalBaseURL = Services.prefs.getCharPref("app.support.baseURL");
Services.prefs.setCharPref("app.support.baseURL", DUMMY_SUPPORT_URL);
let errorTab = await openErrorPage(BAD_CERT_PAGE);
let offlineSupportPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
DUMMY_SUPPORT_URL + "time-errors"
);
await SpecialPowers.spawn(
errorTab.linkedBrowser,
[DUMMY_SUPPORT_URL],
async expectedURL => {
let doc = content.document;
const netErrorCard = doc.querySelector("net-error-card").wrappedJSObject;
await netErrorCard.getUpdateComplete();
netErrorCard.advancedButton.scrollIntoView();
EventUtils.synthesizeMouseAtCenter(
netErrorCard.advancedButton,
{},
content
);
await ContentTaskUtils.waitForCondition(
() => ContentTaskUtils.isVisible(netErrorCard.advancedContainer),
"Advanced container is visible"
);
Assert.ok(
netErrorCard.advancedShowing,
"Advanced showing attribute should be true"
);
Assert.ok(ContentTaskUtils.isVisible(netErrorCard.advancedContainer));
let learnMoreLink = netErrorCard.learnMoreLink;
Assert.ok(learnMoreLink, '"Learn More" link exists.');
let supportPageURL = learnMoreLink.getAttribute("href");
Assert.equal(
supportPageURL,
expectedURL + "time-errors",
"Correct support page URL has been set"
);
learnMoreLink.scrollIntoView();
Assert.ok(ContentTaskUtils.isVisible(learnMoreLink));
await EventUtils.synthesizeMouseAtCenter(learnMoreLink, {}, content);
}
);
let offlineSupportTab = await offlineSupportPromise;
await BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
OFFLINE_SUPPORT_PAGE
);
// Reset this pref instead of clearing it to maintain globally set
// custom value for testing purposes.
Services.prefs.setCharPref("app.support.baseURL", originalBaseURL);
await BrowserTestUtils.removeTab(offlineSupportTab);
await BrowserTestUtils.removeTab(errorTab);
});