Skip to content

Commit dd596cc

Browse files
committed
Manipulation: improve test for data-URI
Some environments do not support data-uri in "src" attribute of script element. Mitigate it with equality assertion Ref a467f86
1 parent 4467ed6 commit dd596cc

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/unit/manipulation.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,9 +2437,25 @@ test( "Validate creation of multiple quantities of certain elements (#13818)", 4
24372437

24382438
asyncTest( "Insert script with data-URI (gh-1887)", 1, function() {
24392439
Globals.register( "testFoo" );
2440-
jQuery( "#qunit-fixture" ).append( "<script src=\"data:text/javascript,testFoo = 'foo';\"></script>" );
2440+
Globals.register( "testSrcFoo" );
2441+
2442+
var script = document.createElement( "script" ),
2443+
fixture = document.getElementById( "qunit-fixture" );
2444+
2445+
script.src = "data:text/javascript,testSrcFoo = 'foo';";
2446+
2447+
fixture.appendChild( script );
2448+
2449+
jQuery( fixture ).append( "<script src=\"data:text/javascript,testFoo = 'foo';\"></script>" );
2450+
24412451
setTimeout(function() {
2442-
strictEqual( window[ "testFoo" ], "foo", "data-URI script executed" );
2452+
if ( window[ "testSrcFoo" ] === "foo" ) {
2453+
strictEqual( window[ "testFoo" ], window[ "testSrcFoo" ], "data-URI script executed" );
2454+
2455+
} else {
2456+
ok( true, "data-URI script is not supported by this environment" );
2457+
}
2458+
24432459
start();
2444-
}, 100 );
2460+
});
24452461
});

0 commit comments

Comments
 (0)