Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/security/test/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
/*
* Tests the "Is origin potentially trustworthy?" logic from
*/
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
Services.prefs.setCharPref(
"dom.securecontext.allowlist",
"example.net,example.org"
);
Services.prefs.setBoolPref("dom.securecontext.allowlist_onions", false);
add_task(async function test_isOriginPotentiallyTrustworthy() {
for (let [uriSpec, expectedResult] of [
["moz-extension://", true],
["about:config", false],
]) {
let uri = NetUtil.newURI(uriSpec);
let principal = Services.scriptSecurityManager.createContentPrincipal(
uri,
{}
);
Assert.equal(principal.isOriginPotentiallyTrustworthy, expectedResult);
}
// And now let's test whether .onion sites are properly treated when
Services.prefs.setBoolPref("dom.securecontext.allowlist_onions", true);
let principal = Services.scriptSecurityManager.createContentPrincipal(
uri,
{}
);
Assert.equal(principal.isOriginPotentiallyTrustworthy, true);
});