Only allow "about:" pages to have access to contentaccessible branding assets
Marking this as confidential, since I'm not sure how critical it is to keep nightly, alpha and release looking the same. But this was the aim of #42319 (closed), but there is a work-around.
Just add to a webpage
<link rel="stylesheet" href="chrome://branding/content/aboutDialog.css">
<div id="rightBox"></div>
<div id="trademark"></div>
and use computed style on #rightBox
and #trademark
to determine the difference. This works because the CSS is contentaccessible
, which means it can be used for anything that isn't a document, including as a stylesheet.
Note this only distinguishes between the stable release and nightly/alpha, because they have different rules for only these two elements.
Technically, alpha has another rule for #rightBox:-moz-locale-dir(rtl)
that nightly does not. However, I don't know of a way to access this rule. I think -moz-locale-dir
never matches for HTML (rather than XUL), and I don't think it is possible to read the cross-origin CSSStyleSheet.cssRules
. But maybe there is some other way.
I guess the solution would be to either:
- Use the same CSS for each platform.
- Make this CSS identical/empty on all platforms, but add the differences in some other non
contentaccessible
package. I.e. somewhere other thanchrome://branding/content/
. We can then do a similar thing withabout-wordmark.svg
to avoid the padding and right-to-left corrections. - Make all of
chrome://branding/content/
noncontentaccessible
. I asked in the firefox developer chat if there is a good reason not to do this.
And do the same for mullvad in mullvad-browser#312 (closed).