Skip to content

Commit 308e8b0

Browse files
jporter-devlissyx
authored andcommitted
Bug 2061552 - Add preference to hide the neterror illustrations. r=desktop-theme-reviewers,kcochrane
The pref defaults to true. When it is false, net-error-card omits the illustration container, and the card shrinks to its widest text line, so the text stays visually centered instead of sitting left of center. Differential Revision: https://phabricator.services.mozilla.com/D324950
1 parent aa8c8ab commit 308e8b0

5 files changed

Lines changed: 82 additions & 3 deletions

File tree

‎browser/app/profile/firefox.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,9 @@ pref("mousewheel.with_meta.action", 1);
14471447
pref("browser.xul.error_pages.expert_bad_cert", false);
14481448
pref("browser.xul.error_pages.show_safe_browsing_details_on_load", false);
14491449

1450+
// Deployments that do not want the artwork on error pages can turn this off
1451+
pref("browser.netError.illustration.enabled", true);
1452+
14501453
// Enable the one-click search call-to-action on the online dnsNotFound error
14511454
// page. On in Nightly, off elsewhere until a Nimbus rollout (bug 2055718).
14521455
#ifdef NIGHTLY_BUILD

‎browser/base/content/test/about/browser_aboutNetError_feltprivacy_illustrations.js‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,61 @@ add_task(async function test_securityError_illustration() {
113113

114114
BrowserTestUtils.removeTab(tab);
115115
});
116+
117+
add_task(async function test_illustrationPrefOff_securityError() {
118+
await SpecialPowers.pushPrefEnv({
119+
set: [["browser.netError.illustration.enabled", false]],
120+
});
121+
122+
const tab = await openErrorPage("https://expired.example.com/");
123+
const browser = tab.linkedBrowser;
124+
125+
await SpecialPowers.spawn(browser, [], async () => {
126+
const netErrorCard = content.document.querySelector("net-error-card");
127+
await netErrorCard.wrappedJSObject.getUpdateComplete();
128+
Assert.ok(
129+
!netErrorCard.shadowRoot.querySelector(".img-container"),
130+
"no illustration container when the pref is off"
131+
);
132+
Assert.ok(
133+
netErrorCard.shadowRoot.querySelector(".container"),
134+
"error content still renders without the illustration"
135+
);
136+
});
137+
138+
BrowserTestUtils.removeTab(tab);
139+
await SpecialPowers.popPrefEnv();
140+
});
141+
142+
add_task(async function test_illustrationPrefOff_noConnection() {
143+
await SpecialPowers.pushPrefEnv({
144+
set: [["browser.netError.illustration.enabled", false]],
145+
});
146+
147+
let browser, tab;
148+
await BrowserTestUtils.openNewForegroundTab(
149+
gBrowser,
150+
() => {
151+
gBrowser.selectedTab = BrowserTestUtils.addTab(
152+
gBrowser,
153+
SERVER_ERROR_PAGE
154+
);
155+
browser = gBrowser.selectedBrowser;
156+
tab = gBrowser.selectedTab;
157+
},
158+
false
159+
);
160+
await BrowserTestUtils.waitForErrorPage(browser);
161+
162+
await SpecialPowers.spawn(browser, [], async () => {
163+
const netErrorCard = content.document.querySelector("net-error-card");
164+
await netErrorCard.wrappedJSObject.getUpdateComplete();
165+
Assert.ok(
166+
!netErrorCard.shadowRoot.querySelector(".img-container"),
167+
"no illustration container when the pref is off"
168+
);
169+
});
170+
171+
BrowserTestUtils.removeTab(tab);
172+
await SpecialPowers.popPrefEnv();
173+
});

‎toolkit/content/net-error-card.mjs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const SEARCH_CTA_ENABLED = RPMGetBoolPref(
4545
"browser.netError.searchCTA.enabled",
4646
false
4747
);
48+
const ILLUSTRATION_ENABLED = RPMGetBoolPref(
49+
"browser.netError.illustration.enabled",
50+
true
51+
);
4852
// The only value of the parent's action vocabulary this page has to recognize,
4953
// meaning no CTA. It is duplicated rather than imported because the vocabulary
5054
// lives in URLKeywordAnalyzer, which is chrome-only, and this module runs in the
@@ -1421,9 +1425,11 @@ export class NetErrorCard extends MozLitElement {
14211425
aria-labelledby="error-title"
14221426
aria-describedby="error-intro whatCanYouDo"
14231427
>
1424-
<div class="img-container">
1425-
<img src=${src} class=${ifDefined(className)} alt=${alt} />
1426-
</div>
1428+
${ILLUSTRATION_ENABLED
1429+
? html`<div class="img-container">
1430+
<img src=${src} class=${ifDefined(className)} alt=${alt} />
1431+
</div>`
1432+
: null}
14271433
<div class="container">${this.containerContentTemplate(title)}</div>
14281434
</article>`;
14291435
}

‎toolkit/modules/RemotePageAccessManager.sys.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export let RemotePageAccessManager = {
5656
// CTA itself only ever renders on about:neterror. A denied read throws,
5757
// which would leave every cert error page blank.
5858
"browser.netError.searchCTA.enabled",
59+
"browser.netError.illustration.enabled",
5960
],
6061
RPMGetIntPref: [
6162
"security.dialog_enable_delay",
@@ -141,6 +142,7 @@ export let RemotePageAccessManager = {
141142
"browser.ipProtection.userEnabled",
142143
"network.sslkeylog_warning",
143144
"browser.netError.searchCTA.enabled",
145+
"browser.netError.illustration.enabled",
144146
],
145147
RPMGetHostForDisplay: ["*"],
146148
RPMGetInnermostAsciiHost: ["*"],

‎toolkit/themes/shared/aboutNetError.css‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ button:disabled {
271271
width: 100%;
272272
}
273273

274+
/* Without the illustration, shrink the text to its widest line and center
275+
it, so short messages do not sit left of center in the full-width card. */
276+
@media not -moz-pref("browser.netError.illustration.enabled") {
277+
justify-content: center;
278+
279+
> .container {
280+
width: fit-content;
281+
}
282+
}
283+
274284
/* Stack the illustration above the text, both left aligned. */
275285
@media (max-width: 640px) {
276286
flex-direction: column;

0 commit comments

Comments
 (0)