Tests: Support $.uiBackCompat = false via data-no-back-compat

Ref #10119
Ref gh-1528
This commit is contained in:
Scott González 2015-04-06 20:22:54 -04:00
parent 7d168ce630
commit 0714f55ad4

View File

@ -41,10 +41,10 @@ function requireModules( dependencies, callback, modules ) {
} }
// Load a set of test file along with the required test infrastructure // Load a set of test file along with the required test infrastructure
function requireTests( dependencies, callback ) { function requireTests( dependencies, noBackCompat ) {
dependencies = [ dependencies = [
"../../lib/qunit", "../../lib/qunit",
"jquery", noBackCompat ? "jquery-no-back-compat" : "jquery",
"jquery-simulate", "jquery-simulate",
"qunit-assert-classes", "qunit-assert-classes",
"../../lib/qunit-assert-domequal" "../../lib/qunit-assert-domequal"
@ -101,6 +101,7 @@ function swarmInject() {
// - data-widget: A widget to load test modules for // - data-widget: A widget to load test modules for
// - Automatically loads common, core, events, methods, and options // - Automatically loads common, core, events, methods, and options
// - data-deprecated: Loads the deprecated test modules for a widget // - data-deprecated: Loads the deprecated test modules for a widget
// - data-no-back-compat: Set $.uiBackCompat to false
(function() { (function() {
// Find the script element // Find the script element
@ -117,7 +118,9 @@ function swarmInject() {
modules = []; modules = [];
} }
var widget = script.getAttribute( "data-widget" ); var widget = script.getAttribute( "data-widget" );
var deprecated = script.getAttribute( "data-deprecated" ); var deprecated = !!script.getAttribute( "data-deprecated" );
var noBackCompat = !!script.getAttribute( "data-no-back-compat" );
if ( widget ) { if ( widget ) {
modules = modules.concat([ modules = modules.concat([
widget + ( deprecated ? "_common_deprecated" : "_common" ), widget + ( deprecated ? "_common_deprecated" : "_common" ),
@ -136,12 +139,19 @@ function swarmInject() {
script.src = "../../../external/requirejs/require.js"; script.src = "../../../external/requirejs/require.js";
script.onload = function() { script.onload = function() {
// 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 // Create a dummy bridge if we're not actually testing in PhantomJS
if ( !/PhantomJS/.test( navigator.userAgent ) ) { if ( !/PhantomJS/.test( navigator.userAgent ) ) {
define( "phantom-bridge", function() {} ); define( "phantom-bridge", function() {} );
} }
requireTests( modules ); requireTests( modules, noBackCompat );
}; };
document.documentElement.appendChild( script ); document.documentElement.appendChild( script );
} )(); } )();