Class TrustedTypePolicyFactory
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The TrustedTypePolicyFactory interface of the {{domxref("Trusted Types API", "", "", "nocode")}} creates policies and allows the verification of Trusted Type objects against created policies.
[Value("TrustedTypePolicyFactory")]
public class TrustedTypePolicyFactory
- Inheritance
-
TrustedTypePolicyFactory
- Inherited Members
Remarks
Constructors
TrustedTypePolicyFactory()
public TrustedTypePolicyFactory()
Properties
DefaultPolicy
The defaultPolicy read-only property of the TrustedTypePolicyFactory interface returns the default TrustedTypePolicy or null if this is empty.
[Value("defaultPolicy")]
public TrustedTypePolicy? DefaultPolicy { get; }
Property Value
- TrustedTypePolicy
A TrustedTypePolicy or
null.
Remarks
See The default policy for more details.
EmptyHTML
The emptyHTML read-only property of the TrustedTypePolicyFactory interface returns a TrustedHTML object containing an empty string.
[Value("emptyHTML")]
public TrustedHTML EmptyHTML { get; }
Property Value
- TrustedHTML
A TrustedHTML object.
Remarks
This object can be used when the application requires an empty string to be inserted into an injection sink.
EmptyScript
The emptyScript read-only property of the TrustedTypePolicyFactory interface returns a TrustedScript object containing an empty string.
[Value("emptyScript")]
public TrustedScript EmptyScript { get; }
Property Value
- TrustedScript
A TrustedScript object.
Remarks
This object can be used when the application requires an empty string to be inserted into an injection sink which is expecting a TrustedScript object.
Methods
CreatePolicy(string, TrustedTypePolicyOptions)
The createPolicy() method of the TrustedTypePolicyFactory interface creates a TrustedTypePolicy object that implements the rules passed as policyOptions.
[Value("createPolicy")]
public TrustedTypePolicy CreatePolicy(string policyName, TrustedTypePolicyOptions policyOptions = null)
Parameters
policyNamestringpolicyOptionsTrustedTypePolicyOptions
Returns
- TrustedTypePolicy
A TrustedTypePolicy object.
Remarks
GetAttributeType(string, string, string?, string?)
The getAttributeType() method of the TrustedTypePolicyFactory interface allows web developers to check if a Trusted Type is required for an element, and if so which Trusted Type is used.
[Value("getAttributeType")]
public string? GetAttributeType(string tagName, string attribute, string? elementNs = null, string? attrNs = null)
Parameters
Returns
- string
A string with one of:Or, null.
Remarks
GetPropertyType(string, string, string?)
The getPropertyType() method of the TrustedTypePolicyFactory interface allows web developers to check if a Trusted Type is required for an element's property.
[Value("getPropertyType")]
public string? GetPropertyType(string tagName, string property, string? elementNs = null)
Parameters
Returns
- string
A string with one of:Or,
null.
Remarks
IsHTML(dynamic)
The isHTML() method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedHTML object.
[Value("isHTML")]
public bool IsHTML(dynamic value)
Parameters
valuedynamic
Returns
- bool
A {{jsxref("boolean")}} that is true if the object is a valid TrustedHTML object.
Remarks
NOTE
The purpose of the functions
isHTML(), IsScript(dynamic), and IsScriptURL(dynamic) is to check if the object is a valid TrustedType object, created by a configured policy.
IsScript(dynamic)
The isScript() method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedScript object.
[Value("isScript")]
public bool IsScript(dynamic value)
Parameters
valuedynamic
Returns
- bool
A {{jsxref("boolean")}} that is true if the object is a valid TrustedScript object.
Remarks
NOTE
The purpose of the functions
isScript(), IsHTML(dynamic), and IsScriptURL(dynamic) is to check if the object is a valid TrustedType object, created by a configured policy.
IsScriptURL(dynamic)
The isScriptURL() method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedScriptURL object.
[Value("isScriptURL")]
public bool IsScriptURL(dynamic value)
Parameters
valuedynamic
Returns
- bool
A {{jsxref("boolean")}} that is true if the object is a valid TrustedScriptURL object.
Remarks
NOTE
The purpose of the functions
isScriptURL(), IsHTML(dynamic), and IsScript(dynamic) is to check if the object is a valid TrustedType object, created by a configured policy.