8 <div id=
"qunit-fixture"></div>
9 <script src=
"../../dist/jquery.min.js"></script>
10 <script src=
"iframeTest.js"></script>
12 var i
, input
, elem
, tags
, policy
,
15 [ "<div></div>", "<div class='test'></div>", [ "div" ] ],
16 [ "<div></div>", "<div class='test'></div><span class='test'></span>",
18 [ "<table></table>", "<td class='test'></td>", [ "td" ] ],
19 [ "<select></select>", "<option class='test'></option>", [ "option" ] ]
22 function runTests( messagePrefix
, getHtmlWrapper
) {
23 for ( i
= 0; i
< inputs
.length
; i
++ ) {
25 elem
= jQuery( getHtmlWrapper( input
[ 0 ] ) );
26 elem
.append( getHtmlWrapper( input
[ 1 ] ) );
27 tags
= elem
.find( ".test" ).toArray().map( function( node
) {
28 return node
.nodeName
.toLowerCase();
33 message
: messagePrefix
+ ": " + input
[ 2 ].join( ", " )
37 elem
= jQuery( getHtmlWrapper( "<div></div>" ) );
38 elem
.append( getHtmlWrapper( "text content" ) );
41 expected
: "text content",
42 message
: messagePrefix
+ ": text content properly appended"
46 if ( typeof trustedTypes
!== "undefined" ) {
47 policy
= trustedTypes
.createPolicy( "jquery-test-policy", {
48 createHTML: function( html
) {
53 runTests( "TrustedHTML", function wrapInTrustedHtml( input
) {
54 return policy
.createHTML( input
);
58 // No TrustedHTML support so let's at least run tests with object wrappers
59 // with a proper `toString` function. This also shows that jQuery support
60 // of TrustedHTML is generic and would work with similar APIs out of the box
61 // as well. Ideally, we'd run these tests in browsers with TrustedHTML support
62 // as well but due to the CSP TrustedHTML enforcement these tests would fail.
63 runTests( "Object wrapper", function( input
) {
65 toString
: function toString() {
72 startIframeTest( results
);