Bug 1930749 - Add option to Cu.Sandbox to specify CSP r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D228711
This commit is contained in:
Rob Wu
2024-11-14 03:28:09 +00:00
parent d6d56a46f2
commit cdef57f69d
7 changed files with 196 additions and 35 deletions

View File

@@ -497,9 +497,8 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(
// Get the CSP for addon sandboxes. If the principal is expanded and has a
// csp, we're probably in luck.
auto* basePrin = BasePrincipal::Cast(subjectPrincipal);
// ContentScriptAddonPolicy means it is also an expanded principal, thus
// this is in a sandbox used as a content script.
if (basePrin->ContentScriptAddonPolicy()) {
// TODO bug 1548468: Move CSP off ExpandedPrincipal.
if (basePrin->Is<ExpandedPrincipal>()) {
basePrin->As<ExpandedPrincipal>()->GetCsp(getter_AddRefs(csp));
}
// don't do anything unless there's a CSP