either"
},
generate = function( html ) {
return function() {
var el = jQuery( html );
equal( el.length, 1, html + " succeeded" );
equal( el.parent().length, 0, html + " generated new content" );
};
};
for ( w in nowarns ) {
expectNoWarning( w, generate( nowarns[w] ) );
}
for ( w in warns ) {
expectWarning( w, generate( warns[w] ) );
}
});
test( "jQuery( '#' )", function() {
expect( 2 );
expectWarning( "Selector, through the jQuery constructor, nothing but hash", function() {
var set = jQuery( "#" );
equal( set.length, 0, "empty set" );
});
});
test( "selector state", function() {
expect( 18 );
var test;
test = jQuery( undefined );
equal( test.selector, "", "Empty jQuery Selector" );
equal( test.context, undefined, "Empty jQuery Context" );
test = jQuery( document );
equal( test.selector, "", "Document Selector" );
equal( test.context, document, "Document Context" );
test = jQuery( document.body );
equal( test.selector, "", "Body Selector" );
equal( test.context, document.body, "Body Context" );
test = jQuery("#qunit-fixture");
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equal( test.context, document, "#qunit-fixture Context" );
test = jQuery("#notfoundnono");
equal( test.selector, "#notfoundnono", "#notfoundnono Selector" );
equal( test.context, document, "#notfoundnono Context" );
test = jQuery( "#qunit-fixture", document );
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equal( test.context, document, "#qunit-fixture Context" );
test = jQuery( "#qunit-fixture", document.body );
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equal( test.context, document.body, "#qunit-fixture Context" );
// Test cloning
test = jQuery( test );
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equal( test.context, document.body, "#qunit-fixture Context" );
test = jQuery( document.body ).find("#qunit-fixture");
equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
equal( test.context, document.body, "#qunit-fixture find Context" );
});
test( "XSS injection", function() {
expect( 10 );
// Bad HTML will throw on some supported versions
expectWarning( "leading hash", function() {
try {
jQuery("#yeah
RIGHT
");
} catch ( e ) {}
});
// Don't expect HTML if there's a leading hash char; this is
// more strict than the 1.7 version but closes an XSS hole.
expectWarning( "XSS via script tag", function() {
var threw = false;
window.XSS = false;
try {
jQuery( "#