SecurityPolicyViolationEvent Class
The event fired when a content security policy is violated (https://w3c.github.io/webappsec-csp/#violation-events): at the element that caused the violation, else at the document or at the global object of the worker, when the violation is reported (https://w3c.github.io/webappsec-csp/#report-violation).
public sealed class SecurityPolicyViolationEvent : Event- Inheritance
EventSecurityPolicyViolationEvent
Constructors
| Name | Description |
|---|---|
| SecurityPolicyViolationEvent(string, SecurityPolicyViolationEventInit?) | Creates a security policy violation event with the given type and initialization dictionary. |
SecurityPolicyViolationEvent(string, SecurityPolicyViolationEventInit?)
SecurityPolicyViolationEvent.csCreates a security policy violation event with the given type and initialization dictionary.
public SecurityPolicyViolationEvent(string type, SecurityPolicyViolationEventInit? eventInitDict = null)Properties
| Name | Description |
|---|---|
| BlockedUri | Gets the URL of the blocked resource (the URL of the request, not the URL of a redirect), without its fragment and credentials (only the scheme for a URL whose scheme is not HTTP(S)), or a keyword: inline, eval, wasm-eval, trusted-types-policy or trusted-types-sink. |
| ColumnNumber | Gets the column (1-based) of the script that caused the violation, or 0. |
| Disposition | Gets the disposition of the violated policy. |
| DocumentUri | Gets the URL of the document or worker whose policy is violated, without its fragment and credentials. |
| EffectiveDirective | Gets the name of the directive whose enforcement caused the violation (e.g. img-src when default-src applies to an image). |
| LineNumber | Gets the line (1-based) of the script that caused the violation, or 0. |
| OriginalPolicy | Gets the serialization of the violated policy. |
| Referrer | Gets the referrer of the document whose policy is violated, without its fragment and credentials. |
| Sample | Gets the sample of the code or the value that caused the violation (e.g. the first 40 characters of an inline script), or the empty string. |
| SourceFile | Gets the URL of the script that caused the violation (stripped as SecurityPolicyViolationEvent.BlockedUri), or the empty string. |
| StatusCode | Gets the HTTP status code of the response of the document or worker whose policy is violated. |
| ViolatedDirective | Gets the name of the violated directive: a historical alias of SecurityPolicyViolationEvent.EffectiveDirective. |
BlockedUri
SecurityPolicyViolationEvent.csGets the URL of the blocked resource (the URL of the request, not the URL of a redirect), without its fragment and credentials (only the scheme for a URL whose scheme is not HTTP(S)), or a keyword: inline, eval, wasm-eval, trusted-types-policy or trusted-types-sink.
public string BlockedUri { get; }Property value
See also
ColumnNumber
SecurityPolicyViolationEvent.csGets the column (1-based) of the script that caused the violation, or 0.
public uint ColumnNumber { get; }Property value
See also
Disposition
SecurityPolicyViolationEvent.csGets the disposition of the violated policy.
public SecurityPolicyViolationEventDisposition Disposition { get; }DocumentUri
SecurityPolicyViolationEvent.csGets the URL of the document or worker whose policy is violated, without its fragment and credentials.
public string DocumentUri { get; }Property value
See also
EffectiveDirective
SecurityPolicyViolationEvent.csGets the name of the directive whose enforcement caused the violation (e.g. img-src when default-src applies to an image).
public string EffectiveDirective { get; }LineNumber
SecurityPolicyViolationEvent.csGets the line (1-based) of the script that caused the violation, or 0.
public uint LineNumber { get; }Property value
See also
OriginalPolicy
SecurityPolicyViolationEvent.csGets the serialization of the violated policy.
public string OriginalPolicy { get; }Referrer
SecurityPolicyViolationEvent.csGets the referrer of the document whose policy is violated, without its fragment and credentials.
public string Referrer { get; }Property value
See also
Gets the sample of the code or the value that caused the violation (e.g. the first 40 characters of an inline script), or the empty string.
public string Sample { get; }Property value
See also
SourceFile
SecurityPolicyViolationEvent.csGets the URL of the script that caused the violation (stripped as SecurityPolicyViolationEvent.BlockedUri), or the empty string.
public string SourceFile { get; }Property value
See also
StatusCode
SecurityPolicyViolationEvent.csGets the HTTP status code of the response of the document or worker whose policy is violated.
public ushort StatusCode { get; }Property value
See also
ViolatedDirective
SecurityPolicyViolationEvent.csGets the name of the violated directive: a historical alias of SecurityPolicyViolationEvent.EffectiveDirective.
public string ViolatedDirective { get; }