Repository: jquery/jquery
File: test/unit/core.js (JavaScript)

Code before:
	document.body.appendChild( script );

	jQuery.globalEval( "var strictEvalTest = " + Date.now() + ";" );
	assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
} );

QUnit.test( "jQuery.append with crossOrigin attribute", function( assert ) {
	var done = assert.async();
	assert.expect( 1 );

	var timeout = null;

	Globals.register( "corsCallback" );
	window.corsCallback = function( response ) {
		assert.ok( response === true, "Cors" );

		if ( timeout != null ) {
			window.clearTimeout( timeout );
		}

		done();
	};

	var src = baseURL + "mock.php?action=cors";
	src = src.replace( "localhost", "127.0.0.1" );
	var html = "<script type=\"text/javascript\" src=\"" + src + "\" crossOrigin=\"anonymous\"><\/script>";

	jQuery( document.body ).append( html );
	timeout = window.setTimeout( function() {
		assert.ok( false, "Cors" );
		done();
	}, 2000 );
} );

QUnit.test( "noConflict", function( assert ) {
	assert.expect( 7 );

	var $$ = jQuery;

	assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
	assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
	assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );

	jQuery = $ = $$;

	assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
	assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
	assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
	assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );

	window[ "jQuery" ] = jQuery = $$;

Review comment (security):
HTML is case-insensitive, so:
```suggestion
	var html = "<script type=\"text/javascript\" src=\"" + src + "\" crossorigin=\"anonymous\"><\/script>";
```

Code after:
	document.body.appendChild( script );

	jQuery.globalEval( "var strictEvalTest = " + Date.now() + ";" );
	assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
} );

testIframe(
	"globalEval with custom document context",
	"core/globaleval-context.html",
	function( assert, framejQuery, frameWindow, frameDocument ) {
		assert.expect( 2 );

		jQuery.globalEval( "window.scriptTest = true;", {}, frameDocument );
		assert.ok( !window.scriptTest, "script executed in iframe context" );
		assert.ok( frameWindow.scriptTest, "script executed in iframe context" );
	}
);


QUnit.test( "noConflict", function( assert ) {
	assert.expect( 7 );

	var $$ = jQuery;

	assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
	assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
	assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );

	jQuery = $ = $$;

	assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
	assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
	assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
	assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );

	window[ "jQuery" ] = jQuery = $$;
} );

QUnit.test( "isPlainObject", function( assert ) {
	var done = assert.async();

	assert.expect( 23 );

	var pass, iframe, doc, parentObj, childObj, deep,
		fn = function() {};

	// The use case that we want to match
	assert.ok( jQuery.isPlainObject( {} ), "{}" );
	assert.ok( jQuery.isPlainObject( new window.Object() ), "new Object" );
	assert.ok( jQuery.isPlainObject( { constructor: fn } ),
		"plain object with constructor property" );