/*jshint multistr:true, quotmark:false */
-var fireNative,
- originaljQuery = this.jQuery || "jQuery",
- original$ = this.$ || "$",
+var fireNative, originaljQuery, original$,
+ supportjQuery = this.jQuery,
// see RFC 2606
externalHost = "example.com";
this.hasPHP = true;
this.isLocal = window.location.protocol === "file:";
-// For testing .noConflict()
-this.jQuery = originaljQuery;
-this.$ = original$;
+// Setup global variables before loading jQuery for testing .noConflict()
+supportjQuery.noConflict( true );
+originaljQuery = this.jQuery = undefined;
+original$ = this.$ = "replaced";
/**
* Returns an array of elements with the given IDs
).appendTo( "body" );
});
};
+this.iframeCallback = undefined;
-/**
- * Allow the test suite to run with other libs or jQuery's.
- */
-jQuery.noConflict();
+if ( typeof jQuery !== "undefined" ) {
+ /**
+ * Allow the test suite to run with other libs or jQuery's.
+ */
+ jQuery.noConflict();
+
+ // Expose Sizzle for Sizzle's selector tests
+ // We remove Sizzle's globalization in jQuery
+ this.Sizzle = this.Sizzle || jQuery.find;
+}
// For checking globals pollution despite auto-created globals in various environments
-jQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
+supportjQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
window[ name ] = window[ name ];
});
-// Expose Sizzle for Sizzle's selector tests
-// We remove Sizzle's globalization in jQuery
-var Sizzle = Sizzle || jQuery.find,
-
// Allow subprojects to test against their own fixtures
- qunitModule = QUnit.module,
+var qunitModule = QUnit.module,
qunitTest = QUnit.test;
/**
// Find test function and wrap to require subproject fixture
for ( ; i >= 0; i-- ) {
- if ( originaljQuery.isFunction( args[i] ) ) {
+ if ( supportjQuery.isFunction( args[i] ) ) {
args[i] = requireFixture( args[i] );
break;
}
// Load tests and fixture from subproject
// Test order matters, so we must be synchronous and throw an error on load failure
- originaljQuery.ajax( url, {
+ supportjQuery.ajax( url, {
async: false,
dataType: "html",
error: function( jqXHR, status ) {
},
success: function( data, status, jqXHR ) {
var sources = [],
- page = originaljQuery.parseHTML(
+ page = supportjQuery.parseHTML(
// replace html/head with dummy elements so they are represented in the DOM
( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ),
document,
if ( !page || !page.length ) {
this.error( jqXHR, "no data" );
}
- page = originaljQuery( page );
+ page = supportjQuery( page );
// Include subproject tests
page.filter("script[src]").add( page.find("script[src]") ).map(function() {
- var src = originaljQuery( this ).attr("src");
+ var src = supportjQuery( this ).attr("src");
if ( risTests.test( src ) ) {
sources.push( src );
}
}
// Replace the current fixture, including content outside of #qunit-fixture
- var oldFixture = originaljQuery("#qunit-fixture");
+ var oldFixture = supportjQuery("#qunit-fixture");
while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {
oldFixture = oldFixture.parent();
}
// WARNING: UNDOCUMENTED INTERFACE
QUnit.config.fixture = fixtureHTML;
QUnit.reset();
- if ( originaljQuery("#qunit-fixture").html() !== fixtureHTML ) {
+ if ( supportjQuery("#qunit-fixture").html() !== fixtureHTML ) {
ok( false, "Copied subproject fixture" );
return;
}
return {
register: function( name ) {
globals[ name ] = true;
- jQuery.globalEval( "var " + name + " = undefined;" );
+ supportjQuery.globalEval( "var " + name + " = undefined;" );
},
cleanup: function() {
var name,
current = globals;
globals = {};
for ( name in current ) {
- jQuery.globalEval( "try { " +
- "delete " + ( jQuery.support.deleteExpando ? "window['" + name + "']" : name ) +
+ supportjQuery.globalEval( "try { " +
+ "delete " + ( supportjQuery.support.deleteExpando ? "window['" + name + "']" : name ) +
"; } catch( x ) {}" );
}
}
QUnit.done(function() {
// Remove our own fixtures outside #qunit-fixture
- jQuery("#qunit ~ *").remove();
+ supportjQuery("#qunit ~ *").remove();
});
// jQuery-specific QUnit.reset
// Ensure jQuery events and data on the fixture are properly removed
jQuery("#qunit-fixture").empty();
+ // ...even if the jQuery under test has a broken .empty()
+ supportjQuery("#qunit-fixture").empty();
// Reset internal jQuery state
jQuery.event.global = {};
ok( pass, "Does not throw exceptions on host objects" );
// Objects from other windows should be matched
- window.iframeCallback = function( otherObject, detail ) {
- window.iframeCallback = undefined;
+ Globals.register("iframeDone");
+ window.iframeDone = function( otherObject, detail ) {
+ window.iframeDone = undefined;
iframe.parentNode.removeChild( iframe );
ok( jQuery.isPlainObject(new otherObject()), "new otherObject" + ( detail ? " - " + detail : "" ) );
start();
iframe = jQuery("#qunit-fixture")[0].appendChild( document.createElement("iframe") );
doc = iframe.contentDocument || iframe.contentWindow.document;
doc.open();
- doc.write("<body onload='window.parent.iframeCallback(Object);'>");
+ doc.write("<body onload='window.parent.iframeDone(Object);'>");
doc.close();
} catch(e) {
window.iframeDone( Object, "iframes not supported" );
equal( j.html(), "", "Check node,textnode,comment empty works" );
// Ensure oldIE empties selects (#12336)
- notEqual( $("#select1").find("option").length, 0, "Have some initial options" );
- $("#select1").empty();
- equal( $("#select1").find("option").length, 0, "No more option elements found" );
- equal( $("#select1")[0].options.length, 0, "options.length cleared as well" );
- });
+ notEqual( jQuery("#select1").find("option").length, 0, "Have some initial options" );
+ jQuery("#select1").empty();
+ equal( jQuery("#select1").find("option").length, 0, "No more option elements found" );
+ equal( jQuery("#select1")[0].options.length, 0, "options.length cleared as well" );
+});
test( "jQuery.cleanData", function() {