()
| 12738 | } |
| 12739 | |
| 12740 | async function createPolicy() { |
| 12741 | if (!(unsafeWindow.trustedTypes && unsafeWindow.trustedTypes.createPolicy && isTrustedTypesEnforced())) { |
| 12742 | return; |
| 12743 | } |
| 12744 | |
| 12745 | const { names: allowedNames, allowDuplicates, ttDirectiveFound } = await getCspTrustedTypesInfo(); |
| 12746 | |
| 12747 | if (ttDirectiveFound && !allowDuplicates) { |
| 12748 | debug("CSP Trusted Types is enforced without 'allow-duplicates'. " + |
| 12749 | "Skipping policy creation to avoid conflicts with the page."); |
| 12750 | return; |
| 12751 | } |
| 12752 | |
| 12753 | const MY_POLICY_NAME = 'pvcep_default'; |
| 12754 | |
| 12755 | try { |
| 12756 | escapeHTMLPolicy = unsafeWindow.trustedTypes.createPolicy(MY_POLICY_NAME, { |
| 12757 | createHTML: (string, sink) => string, |
| 12758 | createScriptURL: string => string, |
| 12759 | createScript: string => string |
| 12760 | }); |
| 12761 | escapeHTMLCreator = escapeHTMLPolicy.createHTML; |
| 12762 | return; |
| 12763 | } catch (e) { |
| 12764 | } |
| 12765 | debug("Could not create any trusted types policy."); |
| 12766 | } |
| 12767 | |
| 12768 | let escapeHTMLPolicy = null; |
| 12769 | let escapeHTMLCreator = null; |
no test coverage detected