Permalink
Browse files

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
  • Loading branch information...
markelog committed Dec 7, 2014
1 parent 4467ed6 commit dd596ccf729b2f39d44b73bc54b53bd41c880146
Showing with 19 additions and 3 deletions.
  1. +19 −3 test/unit/manipulation.js
View
@@ -2437,9 +2437,25 @@ test( "Validate creation of multiple quantities of certain elements (#13818)", 4
asyncTest( "Insert script with data-URI (gh-1887)", 1, function() {
Globals.register( "testFoo" );
jQuery( "#qunit-fixture" ).append( "<script src=\"data:text/javascript,testFoo = 'foo';\"></script>" );
Globals.register( "testSrcFoo" );
var script = document.createElement( "script" ),
fixture = document.getElementById( "qunit-fixture" );
script.src = "data:text/javascript,testSrcFoo = 'foo';";
fixture.appendChild( script );
jQuery( fixture ).append( "<script src=\"data:text/javascript,testFoo = 'foo';\"></script>" );
setTimeout(function() {
strictEqual( window[ "testFoo" ], "foo", "data-URI script executed" );
if ( window[ "testSrcFoo" ] === "foo" ) {
strictEqual( window[ "testFoo" ], window[ "testSrcFoo" ], "data-URI script executed" );
} else {
ok( true, "data-URI script is not supported by this environment" );
}
start();
}, 100 );
});
});

0 comments on commit dd596cc

Please sign in to comment.