Skip to content
Browse files
Merge branch 'domready' of
  • Loading branch information
dmethvin committed Apr 6, 2011
2 parents 1e85027 + de0c25b commit 0fbadbc
Showing 1 changed file with 79 additions and 13 deletions.
@@ -726,15 +726,15 @@ test("hover()", function() {

test("mouseover triggers mouseenter", function() {

var count = 0,
elem = jQuery("<a />");
elem.mouseenter(function () {
equals(count, 1, "make sure mouseover triggers a mouseenter" );


@@ -2023,8 +2023,8 @@ test("window resize", function() {

test("focusin bubbles", function() {
var input = jQuery( '<input type="text" />' ).prependTo( "body" ),

var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
order = 0;

jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
@@ -2037,12 +2037,12 @@ test("focusin bubbles", function() {

// DOM focus method

// To make the next focus test work, we need to take focus off the input.
// This will fire another focusin event, so set order to reflect that.
order = 1;

// jQuery trigger, which calls DOM focus
order = 0;
input.trigger( "focus" );
@@ -2051,15 +2051,81 @@ test("focusin bubbles", function() {
jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );

test("jQuery(function($) {})", function() {
jQuery(function($) {
equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see");

// This code must be run before DOM ready!
var notYetReady, noEarlyExecution,
order = [],
args = {};

notYetReady = !jQuery.isReady;

test("jQuery.isReady", function() {

equals(notYetReady, true, "jQuery.isReady should not be true before DOM ready");
equals(jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready");

// Create an event handler.
function makeHandler( testId ) {
// When returned function is executed, push testId onto `order` array
// to ensure execution order. Also, store event handler arg to ensure
// the correct arg is being passed into the event handler.
return function( arg ) {
args[testId] = arg;

// Bind to the ready event in every possible way.
jQuery(document).bind("ready.readytest", makeHandler("c"));

// Do it twice, just to be sure.
jQuery(document).bind("ready.readytest", makeHandler("f"));

noEarlyExecution = order.length == 0;

// This assumes that QUnit tests are run on DOM ready!
test("jQuery ready", function() {

ok(noEarlyExecution, "Handlers bound to DOM ready should not execute before DOM ready");

// Ensure execution order.
same(order, ["a", "b", "d", "e", "c", "f"], "Bound DOM ready handlers should execute in bind-order, but those bound with jQuery(document).bind( 'ready', fn ) will always execute last");

// Ensure handler argument is correct.
equals(args.a, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");
equals(args.b, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");
ok(args.c instanceof jQuery.Event, "Argument passed to fn in jQuery(document).bind( 'ready', fn ) should be an event object");

order = [];

// Now that the ready event has fired, again bind to the ready event
// in every possible way. These event handlers should execute immediately.
equals(order.pop(), "g", "Event handler should execute immediately");
equals(args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery");

equals(order.pop(), "h", "Event handler should execute immediately");
equals(args.h, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery");

jQuery(document).bind("ready.readytest", makeHandler("never"));
equals(order.length, 0, "Event handler should never execute since DOM ready has already passed");

// Cleanup.


test("event properties", function() {
jQuery("#simon1").click(function(event) {

0 comments on commit 0fbadbc

Please sign in to comment.