2015-04-03 19:21:16 +00:00
|
|
|
( function() {
|
|
|
|
|
2016-12-04 20:57:28 +00:00
|
|
|
var DEFAULT_JQUERY_VERSION = "1.12.4";
|
|
|
|
|
2015-08-21 04:13:44 +00:00
|
|
|
requirejs.config( {
|
2015-04-03 19:21:16 +00:00
|
|
|
paths: {
|
2015-04-06 23:46:15 +00:00
|
|
|
"globalize": "../../../external/globalize/globalize",
|
|
|
|
"globalize/ja-JP": "../../../external/globalize/globalize.culture.ja-JP",
|
2015-04-03 19:21:16 +00:00
|
|
|
"jquery": jqueryUrl(),
|
2016-12-04 20:57:28 +00:00
|
|
|
"jquery-migrate": migrateUrl(),
|
2015-04-03 19:21:16 +00:00
|
|
|
"jquery-simulate": "../../../external/jquery-simulate/jquery.simulate",
|
|
|
|
"jshint": "../../../external/jshint/jshint",
|
|
|
|
"lib": "../../lib",
|
|
|
|
"phantom-bridge": "../../../node_modules/grunt-contrib-qunit/phantomjs/bridge",
|
|
|
|
"qunit-assert-classes": "../../../external/qunit-assert-classes/qunit-assert-classes",
|
2015-04-08 13:15:23 +00:00
|
|
|
"qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close",
|
2015-04-03 19:21:16 +00:00
|
|
|
"qunit": "../../../external/qunit/qunit",
|
2015-08-21 04:13:44 +00:00
|
|
|
"testswarm": "http://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime(),
|
2015-04-03 19:21:16 +00:00
|
|
|
"ui": "../../../ui"
|
|
|
|
},
|
|
|
|
shim: {
|
2015-04-06 23:46:15 +00:00
|
|
|
"globalize/ja-JP": [ "globalize" ],
|
2015-04-03 19:21:16 +00:00
|
|
|
"jquery-simulate": [ "jquery" ],
|
2015-04-17 14:47:23 +00:00
|
|
|
"qunit-assert-close": [ "qunit" ],
|
|
|
|
"testswarm": [ "qunit" ]
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
2015-08-21 04:13:44 +00:00
|
|
|
} );
|
2015-04-17 16:13:38 +00:00
|
|
|
|
|
|
|
// Create a module that disables back compat for UI modules
|
|
|
|
define( "jquery-no-back-compat", [ "jquery" ], function( $ ) {
|
|
|
|
$.uiBackCompat = false;
|
|
|
|
|
|
|
|
return $;
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Create a dummy bridge if we're not actually testing in PhantomJS
|
|
|
|
if ( !/PhantomJS/.test( navigator.userAgent ) ) {
|
|
|
|
define( "phantom-bridge", function() {} );
|
|
|
|
}
|
2015-04-03 19:21:16 +00:00
|
|
|
|
|
|
|
// Load all modules in series
|
|
|
|
function requireModules( dependencies, callback, modules ) {
|
|
|
|
if ( !dependencies.length ) {
|
|
|
|
if ( callback ) {
|
|
|
|
callback.apply( null, modules );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !modules ) {
|
|
|
|
modules = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
var dependency = dependencies.shift();
|
|
|
|
require( [ dependency ], function( module ) {
|
|
|
|
modules.push( module );
|
|
|
|
requireModules( dependencies, callback, modules );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load a set of test file along with the required test infrastructure
|
2015-04-07 00:22:54 +00:00
|
|
|
function requireTests( dependencies, noBackCompat ) {
|
2020-05-16 06:30:11 +00:00
|
|
|
var preDependencies = [
|
2015-04-08 13:15:23 +00:00
|
|
|
"lib/qunit",
|
2015-04-07 00:22:54 +00:00
|
|
|
noBackCompat ? "jquery-no-back-compat" : "jquery",
|
2015-04-08 13:15:23 +00:00
|
|
|
"jquery-simulate"
|
2020-05-16 06:30:11 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
// Load migrate before test files
|
|
|
|
if ( parseUrl().migrate ) {
|
|
|
|
preDependencies.push( "jquery-migrate" );
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies = preDependencies.concat( dependencies );
|
2015-04-03 19:21:16 +00:00
|
|
|
|
2015-04-17 14:47:23 +00:00
|
|
|
// Load the TestSwarm injector, if necessary
|
|
|
|
if ( parseUrl().swarmURL ) {
|
|
|
|
dependencies.push( "testswarm" );
|
|
|
|
}
|
|
|
|
|
2015-04-03 19:21:16 +00:00
|
|
|
requireModules( dependencies, function( QUnit ) {
|
|
|
|
QUnit.start();
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the URL into key/value pairs
|
|
|
|
function parseUrl() {
|
|
|
|
var data = {};
|
|
|
|
var parts = document.location.search.slice( 1 ).split( "&" );
|
|
|
|
var length = parts.length;
|
|
|
|
var i = 0;
|
|
|
|
var current;
|
|
|
|
|
|
|
|
for ( ; i < length; i++ ) {
|
2016-12-04 20:57:28 +00:00
|
|
|
if ( parts[ i ].match( "=" ) ) {
|
|
|
|
current = parts[ i ].split( "=" );
|
|
|
|
data[ current[ 0 ] ] = current[ 1 ];
|
|
|
|
} else {
|
2017-02-06 15:20:50 +00:00
|
|
|
data[ parts[ i ] ] = true;
|
2016-12-04 20:57:28 +00:00
|
|
|
}
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function jqueryUrl() {
|
2016-12-04 20:57:28 +00:00
|
|
|
var version = parseUrl().jquery || DEFAULT_JQUERY_VERSION;
|
2015-04-03 19:21:16 +00:00
|
|
|
var url;
|
|
|
|
|
2019-12-08 21:23:08 +00:00
|
|
|
if ( version === "git" || version === "3.x-git" ) {
|
|
|
|
url = "https://code.jquery.com/jquery-" + version;
|
2015-04-03 19:21:16 +00:00
|
|
|
} else {
|
2016-12-04 20:57:28 +00:00
|
|
|
url = "../../../external/jquery-" + version + "/jquery";
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrateUrl() {
|
|
|
|
var jqueryVersion = parseUrl().jquery || DEFAULT_JQUERY_VERSION;
|
|
|
|
var url;
|
|
|
|
|
|
|
|
if ( jqueryVersion === "git" ) {
|
2019-12-08 21:23:08 +00:00
|
|
|
url = "https://code.jquery.com/jquery-migrate-git";
|
2016-12-04 20:57:28 +00:00
|
|
|
} else if ( jqueryVersion[ 0 ] === "3" ) {
|
2020-07-27 19:03:48 +00:00
|
|
|
url = "../../../external/jquery-migrate-3.3.1/jquery-migrate";
|
2016-12-04 20:57:28 +00:00
|
|
|
} else if ( jqueryVersion[ 0 ] === "1" || jqueryVersion[ 0 ] === "2" ) {
|
|
|
|
url = "../../../external/jquery-migrate-1.4.1/jquery-migrate";
|
|
|
|
} else if ( jqueryVersion === "custom" ) {
|
|
|
|
if ( parseUrl().migrate ) {
|
|
|
|
throw new Error ( "Migrate not currently supported for custom build" );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
throw new Error( "No migrate version known for jQuery " + jqueryVersion );
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
2015-04-17 16:13:38 +00:00
|
|
|
}
|
2015-04-03 19:21:16 +00:00
|
|
|
|
|
|
|
// Load test modules based on data attributes
|
|
|
|
// - data-modules: list of test modules to load
|
|
|
|
// - data-widget: A widget to load test modules for
|
|
|
|
// - Automatically loads common, core, events, methods, and options
|
|
|
|
// - data-deprecated: Loads the deprecated test modules for a widget
|
2015-04-07 00:22:54 +00:00
|
|
|
// - data-no-back-compat: Set $.uiBackCompat to false
|
2015-08-21 04:13:44 +00:00
|
|
|
( function() {
|
2015-04-03 19:21:16 +00:00
|
|
|
|
|
|
|
// Find the script element
|
|
|
|
var scripts = document.getElementsByTagName( "script" );
|
|
|
|
var script = scripts[ scripts.length - 1 ];
|
|
|
|
|
|
|
|
// Read the modules
|
|
|
|
var modules = script.getAttribute( "data-modules" );
|
|
|
|
if ( modules ) {
|
|
|
|
modules = modules
|
|
|
|
.replace( /^\s+|\s+$/g, "" )
|
|
|
|
.split( /\s+/ );
|
|
|
|
} else {
|
|
|
|
modules = [];
|
|
|
|
}
|
|
|
|
var widget = script.getAttribute( "data-widget" );
|
2015-04-07 00:22:54 +00:00
|
|
|
var deprecated = !!script.getAttribute( "data-deprecated" );
|
|
|
|
var noBackCompat = !!script.getAttribute( "data-no-back-compat" );
|
|
|
|
|
2015-04-03 19:21:16 +00:00
|
|
|
if ( widget ) {
|
2015-08-21 04:13:44 +00:00
|
|
|
modules = modules.concat( [
|
2015-04-07 14:55:52 +00:00
|
|
|
( deprecated ? "common-deprecated" : "common" ),
|
|
|
|
"core",
|
|
|
|
"events",
|
|
|
|
"methods",
|
|
|
|
"options"
|
2015-08-21 04:13:44 +00:00
|
|
|
] );
|
2015-04-03 19:21:16 +00:00
|
|
|
if ( deprecated ) {
|
2015-04-07 14:55:52 +00:00
|
|
|
modules = modules.concat( "deprecated" );
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
var jQueryVersion = parseUrl().jquery;
|
|
|
|
|
2017-05-15 22:24:19 +00:00
|
|
|
// Load the jQuery fixes, if necessary
|
2020-01-22 15:44:34 +00:00
|
|
|
if ( !jQueryVersion ||
|
|
|
|
( jQueryVersion.indexOf( "git" ) === -1 && parseFloat( jQueryVersion ) < 4 ) ) {
|
2020-05-16 06:29:08 +00:00
|
|
|
modules.unshift( "ui/jquery-patch" );
|
2015-08-31 19:33:02 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 16:13:38 +00:00
|
|
|
requireTests( modules, noBackCompat );
|
2015-04-03 19:21:16 +00:00
|
|
|
} )();
|
|
|
|
|
|
|
|
} )();
|