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

Code before:
	var now,
		script = document.createElement( "script" );

	script.src = baseURL + "mock.php?action=wait&wait=2&script=1";

	now = Date.now();
	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 = $ = $$;


Review comment (suggestion):
We typically put all var declarations near the top of the function under one `var` keyword, one declaration per line if immediately assigned, unassigned vars all in one line (the first one). Please see other tests for comparison.

Here I'd expect `assert.expect( 1 );` to be the first line, then an empty line & then all vars declared with one var statement.

Code after:
	var now,
		script = document.createElement( "script" );

	script.src = baseURL + "mock.php?action=wait&wait=2&script=1";

	now = Date.now();
	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() {};