mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Fix #12838: hook point for non-jQuery.ajax synchronous script fetch/execute in domManip. Close gh-1051.
(cherry picked from commit 03db1ada2c)
This commit is contained in:
@@ -2150,14 +2150,18 @@ test( "html() - script exceptions bubble (#11743)", function() {
|
||||
expect( 2 );
|
||||
|
||||
raises(function() {
|
||||
jQuery("#qunit-fixture").html("<script>undefined(); ok( false, 'error not thrown' );</script>");
|
||||
ok( false, "error ignored" );
|
||||
}, "exception bubbled from inline script" );
|
||||
jQuery("#qunit-fixture").html("<script>undefined(); ok( false, 'Exception not thrown' );</script>");
|
||||
ok( false, "Exception ignored" );
|
||||
}, "Exception bubbled from inline script" );
|
||||
|
||||
raises(function() {
|
||||
jQuery("#qunit-fixture").html("<script src='data/badcall.js'></script>");
|
||||
ok( false, "error ignored" );
|
||||
}, "exception bubbled from remote script" );
|
||||
if ( jQuery.ajax ) {
|
||||
raises(function() {
|
||||
jQuery("#qunit-fixture").html("<script src='data/badcall.js'></script>");
|
||||
ok( false, "Exception ignored" );
|
||||
}, "Exception thrown in remote script" );
|
||||
} else {
|
||||
ok( true, "No jQuery.ajax" );
|
||||
}
|
||||
});
|
||||
|
||||
test( "checked state is cloned with clone()", function() {
|
||||
@@ -2197,7 +2201,7 @@ testIframeWithCallback( "buildFragment works even if document[0] is iframe's win
|
||||
|
||||
test( "script evaluation (#11795)", function() {
|
||||
|
||||
expect( 11 );
|
||||
expect( 13 );
|
||||
|
||||
var scriptsIn, scriptsOut,
|
||||
fixture = jQuery("#qunit-fixture").empty(),
|
||||
@@ -2238,6 +2242,44 @@ test( "script evaluation (#11795)", function() {
|
||||
fixture.append( scriptsOut.detach() );
|
||||
deepEqual( fixture.children("script").get(), scriptsOut.get(), "Scripts detached without reevaluation" );
|
||||
objGlobal.ok = isOk;
|
||||
|
||||
if ( jQuery.ajax ) {
|
||||
Globals.register("testBar");
|
||||
jQuery("#qunit-fixture").append( "<script src='" + url("data/test.js") + "'/>" );
|
||||
strictEqual( window["testBar"], "bar", "Global script evaluation" );
|
||||
} else {
|
||||
ok( true, "No jQuery.ajax" );
|
||||
ok( true, "No jQuery.ajax" );
|
||||
}
|
||||
});
|
||||
|
||||
test( "jQuery._evalUrl (#12838)", function() {
|
||||
|
||||
expect( 5 );
|
||||
|
||||
var message, expectedArgument,
|
||||
ajax = jQuery.ajax,
|
||||
evalUrl = jQuery._evalUrl;
|
||||
|
||||
message = "jQuery.ajax implementation";
|
||||
expectedArgument = 1;
|
||||
jQuery.ajax = function( input ) {
|
||||
equal( ( input.url || input ).slice( -1 ), expectedArgument, message );
|
||||
expectedArgument++;
|
||||
};
|
||||
jQuery("#qunit-fixture").append("<script src='1'/><script src='2'/>");
|
||||
equal( expectedArgument, 3, "synchronous execution" );
|
||||
|
||||
message = "custom implementation";
|
||||
expectedArgument = 3;
|
||||
jQuery._evalUrl = jQuery.ajax;
|
||||
jQuery.ajax = function( options ) {
|
||||
strictEqual( options, {}, "Unexpected call to jQuery.ajax" );
|
||||
};
|
||||
jQuery("#qunit-fixture").append("<script src='3'/><script src='4'/>");
|
||||
|
||||
jQuery.ajax = ajax;
|
||||
jQuery._evalUrl = evalUrl;
|
||||
});
|
||||
|
||||
test( "wrapping scripts (#10470)", function() {
|
||||
|
||||
Reference in New Issue
Block a user