@@ -619,11 +619,13 @@ suite('include-fragment-element', function () {
619
619
620
620
suite ( 'CSP trusted types' , ( ) => {
621
621
teardown ( ( ) => {
622
+ // eslint-disable-next-line no-undef
622
623
setCSPTrustedTypesPolicy ( null )
623
624
} )
624
625
625
626
test ( 'can set a pass-through mock CSP trusted types policy' , async function ( ) {
626
627
let policyCalled = false
628
+ // eslint-disable-next-line no-undef
627
629
setCSPTrustedTypesPolicy ( {
628
630
createHTML : htmlText => {
629
631
policyCalled = true
@@ -641,8 +643,9 @@ suite('include-fragment-element', function () {
641
643
642
644
test ( 'can set and clear a mutating mock CSP trusted types policy' , async function ( ) {
643
645
let policyCalled = false
646
+ // eslint-disable-next-line no-undef
644
647
setCSPTrustedTypesPolicy ( {
645
- createHTML : htmlText => {
648
+ createHTML : ( ) => {
646
649
policyCalled = true
647
650
return '<b>replacement</b>'
648
651
}
@@ -654,6 +657,7 @@ suite('include-fragment-element', function () {
654
657
assert . equal ( '<b>replacement</b>' , data )
655
658
assert . ok ( policyCalled )
656
659
660
+ // eslint-disable-next-line no-undef
657
661
setCSPTrustedTypesPolicy ( null )
658
662
const el2 = document . createElement ( 'include-fragment' )
659
663
el2 . src = '/hello'
@@ -663,12 +667,14 @@ suite('include-fragment-element', function () {
663
667
664
668
test ( 'can set a real CSP trusted types policy in Chromium' , async function ( ) {
665
669
let policyCalled = false
670
+ // eslint-disable-next-line no-undef
666
671
const policy = globalThis . trustedTypes . createPolicy ( 'test1' , {
667
672
createHTML : htmlText => {
668
673
policyCalled = true
669
674
return htmlText
670
675
}
671
676
} )
677
+ // eslint-disable-next-line no-undef
672
678
setCSPTrustedTypesPolicy ( policy )
673
679
674
680
const el = document . createElement ( 'include-fragment' )
@@ -679,8 +685,9 @@ suite('include-fragment-element', function () {
679
685
} )
680
686
681
687
test ( 'can reject data using a mock CSP trusted types policy' , async function ( ) {
688
+ // eslint-disable-next-line no-undef
682
689
setCSPTrustedTypesPolicy ( {
683
- createHTML : htmlText => {
690
+ createHTML : ( ) => {
684
691
throw new Error ( 'Rejected data!' )
685
692
}
686
693
} )
@@ -696,13 +703,14 @@ suite('include-fragment-element', function () {
696
703
} )
697
704
698
705
test ( 'can access headers using a mock CSP trusted types policy' , async function ( ) {
706
+ // eslint-disable-next-line no-undef
699
707
setCSPTrustedTypesPolicy ( {
700
708
createHTML : ( htmlText , response ) => {
701
- if ( response . headers . get ( " X-Server-Sanitized" ) !== " sanitized=true" ) {
709
+ if ( response . headers . get ( ' X-Server-Sanitized' ) !== ' sanitized=true' ) {
702
710
// Note: this will reject the contents, but the error may be caught before it shows in the JS console.
703
- throw new Error ( " Rejecting HTML that was not marked by the server as sanitized." ) ;
711
+ throw new Error ( ' Rejecting HTML that was not marked by the server as sanitized.' )
704
712
}
705
- return htmlText ;
713
+ return htmlText
706
714
}
707
715
} )
708
716
0 commit comments