diff --git a/content/base/public/nsIContentSecurityPolicy.idl b/content/base/public/nsIContentSecurityPolicy.idl index 1145b2d871d..0c4259e09b9 100644 --- a/content/base/public/nsIContentSecurityPolicy.idl +++ b/content/base/public/nsIContentSecurityPolicy.idl @@ -10,10 +10,12 @@ interface nsIDocShell; /** * nsIContentSecurityPolicy - * Describes an XPCOM component used to model an enforce CSPs. + * Describes an XPCOM component used to model and enforce CSPs. Instances of + * this class may have multiple policies within them, but there should only be + * one of these per document/principal. */ -[scriptable, uuid(230b126d-afc3-4588-9794-3e135594d626)] +[scriptable, uuid(e5020ec3-1437-46f5-b4eb-8b60766d02c0)] interface nsIContentSecurityPolicy : nsISupports { @@ -25,61 +27,87 @@ interface nsIContentSecurityPolicy : nsISupports attribute boolean isInitialized; /** - * When set to true, content load-blocking and fail-closed are disabled: CSP - * will ONLY send reports, and not modify behavior. + * Accessor method for a read-only string version of the policy at a given + * index. */ - attribute boolean reportOnlyMode; + AString getPolicy(in unsigned long index); /** - * A read-only string version of the policy for debugging. + * Returns the number of policies attached to this CSP instance. Useful with + * getPolicy(). */ - readonly attribute AString policy; + attribute long policyCount; + + /** + * Remove a policy associated with this CSP context. + * @throws NS_ERROR_FAILURE if the index is out of bounds or invalid. + */ + void removePolicy(in unsigned long index); + + /** + * Parse and install a CSP policy. + * @param aPolicy + * String representation of the policy (e.g., header value) + * @param selfURI + * the URI of the protected document/principal + * @param reportOnly + * Should this policy affect content, script and style processing or + * just send reports if it is violated? + * @param specCompliant + * Whether or not the policy conforms to the W3C specification. + * If this is false, that indicates this policy is from the older + * implementation with different semantics and directive names. + */ + void appendPolicy(in AString policyString, in nsIURI selfURI, + in boolean reportOnly, in boolean specCompliant); /** * Whether this policy allows in-page script. - * @param shouldReportViolation + * @param shouldReportViolations * Whether or not the use of inline script should be reported. * This function always returns "true" for report-only policies, but when - * the report-only policy is violated, shouldReportViolation is true as - * well. + * any policy (report-only or otherwise) is violated, + * shouldReportViolations is true as well. * @return * Whether or not the effects of the inline script should be allowed * (block the compilation if false). */ - boolean getAllowsInlineScript(out boolean shouldReportViolation); + boolean getAllowsInlineScript(out boolean shouldReportViolations); /** * whether this policy allows eval and eval-like functions * such as setTimeout("code string", time). - * @param shouldReportViolation + * @param shouldReportViolations * Whether or not the use of eval should be reported. - * This function always returns "true" for report-only policies, but when - * the report-only policy is violated, shouldReportViolation is true as - * well. + * This function returns "true" when violating report-only policies, but + * when any policy (report-only or otherwise) is violated, + * shouldReportViolations is true as well. * @return * Whether or not the effects of the eval call should be allowed * (block the call if false). */ - boolean getAllowsEval(out boolean shouldReportViolation); + boolean getAllowsEval(out boolean shouldReportViolations); /** * Whether this policy allows in-page styles. * This includes