Skip to content

Commit 92cff8b

Browse files
committed
Tests: Remove Sizzle intergration tests
Fixes #14818
1 parent a7c9fac commit 92cff8b

File tree

2 files changed

+27
-174
lines changed

2 files changed

+27
-174
lines changed

test/data/testinit.js

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ fireNative = document.createEvent ?
131131
* @result "data/test.php?foo=bar&10538358345554"
132132
*/
133133
function url( value ) {
134-
return baseURL + value + (/\?/.test(value) ? "&" : "?") +
135-
new Date().getTime() + "" + parseInt(Math.random() * 100000, 10);
134+
return baseURL + value + (/\?/.test( value ) ? "&" : "?") +
135+
new Date().getTime() + "" + parseInt( Math.random() * 100000, 10 );
136136
}
137137

138138
// Ajax testing helper
@@ -203,19 +203,17 @@ this.ajaxTest = function( title, expect, options ) {
203203

204204

205205
this.testIframe = function( fileName, name, fn ) {
206-
207-
test(name, function() {
208-
// pause execution for now
209-
stop();
206+
asyncTest(name, function() {
210207

211208
// load fixture in iframe
212209
var iframe = loadFixture(),
213210
win = iframe.contentWindow,
214-
interval = setInterval( function() {
211+
interval = setInterval(function() {
215212
if ( win && win.jQuery && win.jQuery.isReady ) {
216213
clearInterval( interval );
217-
// continue
214+
218215
start();
216+
219217
// call actual tests passing the correct jQuery instance to use
220218
fn.call( this, win.jQuery, win, win.document );
221219
document.body.removeChild( iframe );
@@ -225,9 +223,10 @@ this.testIframe = function( fileName, name, fn ) {
225223
});
226224

227225
function loadFixture() {
228-
var src = url("./data/" + fileName + ".html"),
229-
iframe = jQuery("<iframe />").appendTo("body")[0];
226+
var src = url( "./data/" + fileName + ".html" ),
227+
iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ];
230228
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
229+
231230
iframe.contentWindow.location = src;
232231
return iframe;
233232
}
@@ -265,11 +264,12 @@ QUnit.config.autostart = false;
265264
this.loadTests = function() {
266265
var loadSwarm,
267266
url = window.location.search;
268-
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) );
269-
loadSwarm = url && url.indexOf("http") === 0;
267+
268+
url = decodeURIComponent( url.slice( url.indexOf( "swarmURL=" ) + "swarmURL=".length ) );
269+
loadSwarm = url && url.indexOf( "http" ) === 0;
270270

271271
// Get testSubproject from testrunner first
272-
require([ "data/testrunner.js" ], function( testSubproject ) {
272+
require([ "data/testrunner.js" ], function() {
273273
var tests = [
274274
"unit/core.js",
275275
"unit/callbacks.js",
@@ -294,39 +294,26 @@ this.loadTests = function() {
294294
// Ensure load order (to preserve test numbers)
295295
(function loadDep() {
296296
var dep = tests.shift();
297+
297298
if ( dep ) {
298299
require( [ dep ], loadDep );
299-
} else {
300-
301300

302-
// Subproject tests must be last because they replace our test fixture
303-
testSubproject( "Sizzle", "../src/sizzle/test/", /^unit\/.*\.js$/, function() {
304-
// Call load to build module filter select element
305-
QUnit.load();
306-
307-
/**
308-
* Run in noConflict mode
309-
*/
310-
jQuery.noConflict();
311-
312-
// Expose Sizzle for Sizzle's selector tests
313-
// We remove Sizzle's globalization in jQuery
314-
window.Sizzle = window.Sizzle || jQuery.find;
301+
} else {
302+
QUnit.load();
315303

316-
// For checking globals pollution despite auto-created globals in various environments
317-
supportjQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
318-
window[ name ] = window[ name ];
319-
});
304+
/**
305+
* Run in noConflict mode
306+
*/
307+
jQuery.noConflict();
320308

321-
// Load the TestSwarm listener if swarmURL is in the address.
322-
if ( loadSwarm ) {
323-
require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
324-
QUnit.start();
325-
});
326-
} else {
309+
// Load the TestSwarm listener if swarmURL is in the address.
310+
if ( loadSwarm ) {
311+
require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
327312
QUnit.start();
328-
}
329-
});
313+
});
314+
} else {
315+
QUnit.start();
316+
}
330317
}
331318
})();
332319
});

test/data/testrunner.js

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -192,138 +192,4 @@ window.Globals = (function() {
192192
};
193193
})();
194194

195-
/**
196-
* Test a subproject with its own fixture
197-
* @param {String} label Project name
198-
* @param {String} url Test folder location
199-
* @param {RegExp} risTests To filter script sources
200-
*/
201-
function testSubproject( label, subProjectURL, risTests, complete ) {
202-
var sub, fixture, fixtureHTML,
203-
fixtureReplaced = false;
204-
205-
// Don't let subproject tests jump the gun
206-
QUnit.config.reorder = false;
207-
208-
// Create module
209-
module( label );
210-
211-
// Duckpunch QUnit
212-
// TODO restore parent fixture on teardown to support reordering
213-
module = QUnit.module = function( name ) {
214-
var args = arguments;
215-
216-
// Remember subproject-scoped module name
217-
sub = name;
218-
219-
// Override
220-
args[0] = label;
221-
return qunitModule.apply( this, args );
222-
};
223-
test = function( name ) {
224-
var args = arguments,
225-
i = args.length - 1;
226-
227-
// Prepend subproject-scoped module name to test name
228-
args[0] = sub + ": " + name;
229-
230-
// Find test function and wrap to require subproject fixture
231-
for ( ; i >= 0; i-- ) {
232-
if ( supportjQuery.isFunction( args[i] ) ) {
233-
args[i] = requireFixture( args[i] );
234-
break;
235-
}
236-
}
237-
238-
return qunitTest.apply( this, args );
239-
};
240-
241-
// Load tests and fixture from subproject
242-
// Test order matters, so we must be synchronous and throw an error on load failure
243-
supportjQuery.ajax( subProjectURL, {
244-
async: false,
245-
dataType: "html",
246-
error: function( jqXHR, status ) {
247-
throw new Error( "Could not load: " + subProjectURL + " (" + status + ")" );
248-
},
249-
success: function( data, status, jqXHR ) {
250-
var sources = [],
251-
page = supportjQuery.parseHTML(
252-
// replace html/head with dummy elements so they are represented in the DOM
253-
( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ),
254-
document,
255-
true
256-
);
257-
258-
if ( !page || !page.length ) {
259-
this.error( jqXHR, "no data" );
260-
}
261-
page = supportjQuery( page );
262-
263-
// Include subproject tests
264-
page.filter("script[src]").add( page.find("script[src]") ).map(function() {
265-
var src = supportjQuery( this ).attr("src");
266-
if ( risTests.test( src ) ) {
267-
sources.push( src );
268-
}
269-
});
270-
271-
// Ensure load order
272-
(function loadDep() {
273-
var dep = sources.shift();
274-
if ( dep ) {
275-
require( [ subProjectURL + dep ], loadDep );
276-
} else if ( complete ) {
277-
complete();
278-
}
279-
})();
280-
281-
// Get the fixture, including content outside of #qunit-fixture
282-
fixture = page.find("[id='qunit-fixture']");
283-
fixtureHTML = fixture.html();
284-
fixture.empty();
285-
while ( fixture.length && !fixture.prevAll("[id='qunit']").length ) {
286-
fixture = fixture.parent();
287-
}
288-
fixture = fixture.add( fixture.nextAll() );
289-
}
290-
});
291-
292-
function requireFixture( fn ) {
293-
return function() {
294-
if ( !fixtureReplaced ) {
295-
// Make sure that we retrieved a fixture for the subproject
296-
if ( !fixture.length ) {
297-
ok( false, "Found subproject fixture" );
298-
return;
299-
}
300-
301-
// Update helper function behavior
302-
baseURL = subProjectURL;
303-
304-
// Replace the current fixture, including content outside of #qunit-fixture
305-
var oldFixture = supportjQuery("#qunit-fixture");
306-
while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {
307-
oldFixture = oldFixture.parent();
308-
}
309-
oldFixture.nextAll().remove();
310-
oldFixture.replaceWith( fixture );
311-
312-
// WARNING: UNDOCUMENTED INTERFACE
313-
QUnit.config.fixture = fixtureHTML;
314-
reset();
315-
if ( supportjQuery("#qunit-fixture").html() !== fixtureHTML ) {
316-
ok( false, "Copied subproject fixture" );
317-
return;
318-
}
319-
fixtureReplaced = true;
320-
}
321-
322-
fn.apply( this, arguments );
323-
};
324-
}
325-
}
326-
327-
return testSubproject;
328-
329195
});

0 commit comments

Comments
 (0)