mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-07-07 17:23:15 +03:00
Merge commit 'd32092c1f0
' as 'jquery-ui'
This commit is contained in:
commit
b23131fdc2
717 changed files with 518330 additions and 0 deletions
jquery-ui/tests/lib
151
jquery-ui/tests/lib/bootstrap.js
vendored
Normal file
151
jquery-ui/tests/lib/bootstrap.js
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
( function() {
|
||||
|
||||
requirejs.config( {
|
||||
paths: {
|
||||
"globalize": "../../../external/globalize/globalize",
|
||||
"globalize/ja-JP": "../../../external/globalize/globalize.culture.ja-JP",
|
||||
"jquery": jqueryUrl(),
|
||||
"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",
|
||||
"qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close",
|
||||
"qunit": "../../../external/qunit/qunit",
|
||||
"testswarm": "http://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime(),
|
||||
"ui": "../../../ui"
|
||||
},
|
||||
shim: {
|
||||
"globalize/ja-JP": [ "globalize" ],
|
||||
"jquery-simulate": [ "jquery" ],
|
||||
"qunit-assert-close": [ "qunit" ],
|
||||
"testswarm": [ "qunit" ]
|
||||
}
|
||||
} );
|
||||
|
||||
// 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() {} );
|
||||
}
|
||||
|
||||
// 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
|
||||
function requireTests( dependencies, noBackCompat ) {
|
||||
dependencies = [
|
||||
"lib/qunit",
|
||||
noBackCompat ? "jquery-no-back-compat" : "jquery",
|
||||
"jquery-simulate"
|
||||
].concat( dependencies );
|
||||
|
||||
// Load the TestSwarm injector, if necessary
|
||||
if ( parseUrl().swarmURL ) {
|
||||
dependencies.push( "testswarm" );
|
||||
}
|
||||
|
||||
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++ ) {
|
||||
current = parts[ i ].split( "=" );
|
||||
data[ current[ 0 ] ] = current[ 1 ];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function jqueryUrl() {
|
||||
var version = parseUrl().jquery;
|
||||
var url;
|
||||
|
||||
if ( version === "git" ) {
|
||||
url = "http://code.jquery.com/jquery-" + version;
|
||||
} else {
|
||||
url = "../../../external/jquery-" + ( version || "1.12.4" ) + "/jquery";
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
// 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
|
||||
// - data-no-back-compat: Set $.uiBackCompat to false
|
||||
( function() {
|
||||
|
||||
// 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" );
|
||||
var deprecated = !!script.getAttribute( "data-deprecated" );
|
||||
var noBackCompat = !!script.getAttribute( "data-no-back-compat" );
|
||||
|
||||
if ( widget ) {
|
||||
modules = modules.concat( [
|
||||
( deprecated ? "common-deprecated" : "common" ),
|
||||
"core",
|
||||
"events",
|
||||
"methods",
|
||||
"options"
|
||||
] );
|
||||
if ( deprecated ) {
|
||||
modules = modules.concat( "deprecated" );
|
||||
}
|
||||
}
|
||||
|
||||
// Load the jQuery 1.7 fixes, if necessary
|
||||
if ( parseFloat( parseUrl().jquery ) === 1.7 ) {
|
||||
modules.push( "ui/jquery-1-7" );
|
||||
}
|
||||
|
||||
requireTests( modules, noBackCompat );
|
||||
} )();
|
||||
|
||||
} )();
|
137
jquery-ui/tests/lib/common.js
vendored
Normal file
137
jquery-ui/tests/lib/common.js
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery" ],
|
||||
function( QUnit, $ ) {
|
||||
|
||||
var exports = {};
|
||||
|
||||
function testWidgetDefaults( widget, defaults ) {
|
||||
var pluginDefaults = $.ui[ widget ].prototype.options;
|
||||
|
||||
// Ensure that all defaults have the correct value
|
||||
QUnit.test( "defined defaults", function( assert ) {
|
||||
var count = 0;
|
||||
$.each( defaults, function( key, val ) {
|
||||
assert.expect( ++count );
|
||||
if ( $.isFunction( val ) ) {
|
||||
assert.ok( $.isFunction( pluginDefaults[ key ] ), key );
|
||||
return;
|
||||
}
|
||||
assert.deepEqual( pluginDefaults[ key ], val, key );
|
||||
} );
|
||||
} );
|
||||
|
||||
// Ensure that all defaults were tested
|
||||
QUnit.test( "tested defaults", function( assert ) {
|
||||
var count = 0;
|
||||
$.each( pluginDefaults, function( key ) {
|
||||
assert.expect( ++count );
|
||||
assert.ok( key in defaults, key );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
function testWidgetOverrides( widget ) {
|
||||
if ( $.uiBackCompat === false ) {
|
||||
QUnit.test( "$.widget overrides", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
$.each( [
|
||||
"_createWidget",
|
||||
"destroy",
|
||||
"option",
|
||||
"_trigger"
|
||||
], function( i, method ) {
|
||||
assert.strictEqual( $.ui[ widget ].prototype[ method ],
|
||||
$.Widget.prototype[ method ], "should not override " + method );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
function testBasicUsage( widget ) {
|
||||
QUnit.test( "basic usage", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var defaultElement = $.ui[ widget ].prototype.defaultElement;
|
||||
$( defaultElement ).appendTo( "body" )[ widget ]().remove();
|
||||
assert.ok( true, "initialized on element" );
|
||||
|
||||
$( defaultElement )[ widget ]().remove();
|
||||
assert.ok( true, "initialized on disconnected DOMElement - never connected" );
|
||||
|
||||
// Ensure manipulating removed elements works (#3664)
|
||||
$( defaultElement ).appendTo( "body" ).remove()[ widget ]().remove();
|
||||
assert.ok( true, "initialized on disconnected DOMElement - removed" );
|
||||
} );
|
||||
}
|
||||
|
||||
exports.testWidget = function( widget, settings ) {
|
||||
QUnit.module( widget + ": common widget" );
|
||||
|
||||
exports.testJshint( "/widgets/" + widget );
|
||||
testWidgetDefaults( widget, settings.defaults );
|
||||
testWidgetOverrides( widget );
|
||||
if ( !settings.noDefaultElement ) {
|
||||
testBasicUsage( widget );
|
||||
}
|
||||
QUnit.test( "version", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.ok( "version" in $.ui[ widget ].prototype, "version property exists" );
|
||||
} );
|
||||
};
|
||||
|
||||
exports.testJshint = function( module ) {
|
||||
|
||||
// Function.prototype.bind check is needed because JSHint doesn't work in ES3 browsers anymore
|
||||
// https://github.com/jshint/jshint/issues/1384
|
||||
if ( QUnit.urlParams.nojshint || !Function.prototype.bind ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUnit.test( "JSHint", function( assert ) {
|
||||
var ready = assert.async();
|
||||
require( [ "jshint" ], function() {
|
||||
assert.expect( 1 );
|
||||
|
||||
$.when(
|
||||
$.ajax( {
|
||||
url: "../../../ui/.jshintrc",
|
||||
dataType: "json"
|
||||
} ),
|
||||
$.ajax( {
|
||||
url: "../../../ui/" + module + ".js",
|
||||
dataType: "text"
|
||||
} )
|
||||
)
|
||||
.done( function( hintArgs, srcArgs ) {
|
||||
var globals, passed, errors,
|
||||
jshintrc = hintArgs[ 0 ],
|
||||
source = srcArgs[ 0 ];
|
||||
|
||||
globals = jshintrc.globals || {};
|
||||
delete jshintrc.globals;
|
||||
passed = JSHINT( source, jshintrc, globals );
|
||||
errors = $.map( JSHINT.errors, function( error ) {
|
||||
|
||||
// JSHINT may report null if there are too many errors
|
||||
if ( !error ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return "[L" + error.line + ":C" + error.character + "] " +
|
||||
error.reason + "\n" + error.evidence + "\n";
|
||||
} ).join( "\n" );
|
||||
assert.ok( passed, errors );
|
||||
ready();
|
||||
} )
|
||||
.fail( function( hintError, srcError ) {
|
||||
assert.ok( false, "error loading source: " + ( hintError || srcError ).statusText );
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
} );
|
23
jquery-ui/tests/lib/css.js
vendored
Normal file
23
jquery-ui/tests/lib/css.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
( function() {
|
||||
|
||||
function includeStyle( url ) {
|
||||
document.write( "<link rel='stylesheet' href='../../../" + url + "'>" );
|
||||
}
|
||||
|
||||
// Find the script element
|
||||
var scripts = document.getElementsByTagName( "script" );
|
||||
var script = scripts[ scripts.length - 1 ];
|
||||
|
||||
// Load the modules
|
||||
var modules = script.getAttribute( "data-modules" );
|
||||
if ( modules ) {
|
||||
modules = modules.split( /\s+/ );
|
||||
for ( var i = 0; i < modules.length; i++ ) {
|
||||
includeStyle( "themes/base/" + modules[ i ] + ".css" );
|
||||
}
|
||||
}
|
||||
|
||||
// Load the QUnit stylesheet
|
||||
includeStyle( "external/qunit/qunit.css" );
|
||||
|
||||
} )();
|
33
jquery-ui/tests/lib/helper.js
vendored
Normal file
33
jquery-ui/tests/lib/helper.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
define( [
|
||||
"jquery"
|
||||
], function( $ ) {
|
||||
|
||||
var exports = {};
|
||||
|
||||
exports.forceScrollableWindow = function( appendTo ) {
|
||||
|
||||
// The main testable area is 10000x10000 so to enforce scrolling,
|
||||
// this DIV must be greater than 10000 to work
|
||||
return $( "<div>" )
|
||||
.css( {
|
||||
height: "11000px",
|
||||
width: "11000px"
|
||||
} )
|
||||
.appendTo( appendTo || "#qunit-fixture" );
|
||||
};
|
||||
|
||||
exports.onFocus = function( element, onFocus ) {
|
||||
var fn = function( event ) {
|
||||
if ( !event.originalEvent ) {
|
||||
return;
|
||||
}
|
||||
element.off( "focus", fn );
|
||||
onFocus();
|
||||
};
|
||||
|
||||
element.on( "focus", fn )[ 0 ].focus();
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
} );
|
123
jquery-ui/tests/lib/qunit-assert-domequal.js
vendored
Normal file
123
jquery-ui/tests/lib/qunit-assert-domequal.js
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Experimental assertion for comparing DOM objects.
|
||||
*
|
||||
* Serializes an element and some properties and attributes and its children if any,
|
||||
* otherwise the text. Then compares the result using deepEqual().
|
||||
*/
|
||||
define( [
|
||||
"qunit",
|
||||
"jquery"
|
||||
], function( QUnit, $ ) {
|
||||
|
||||
var domEqual = QUnit.assert.domEqual = function( selector, modifier, message ) {
|
||||
|
||||
var assert = this;
|
||||
|
||||
// Get current state prior to modifier
|
||||
var expected = extract( selector, message );
|
||||
|
||||
function done() {
|
||||
var actual = extract( selector, message );
|
||||
assert.push( QUnit.equiv( actual, expected ), actual, expected, message );
|
||||
}
|
||||
|
||||
// Run modifier (async or sync), then compare state via done()
|
||||
if ( modifier.length ) {
|
||||
modifier( done );
|
||||
} else {
|
||||
modifier();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
domEqual.properties = [
|
||||
"disabled",
|
||||
"readOnly"
|
||||
];
|
||||
|
||||
domEqual.attributes = [
|
||||
"autocomplete",
|
||||
"aria-activedescendant",
|
||||
"aria-controls",
|
||||
"aria-describedby",
|
||||
"aria-disabled",
|
||||
"aria-expanded",
|
||||
"aria-haspopup",
|
||||
"aria-hidden",
|
||||
"aria-labelledby",
|
||||
"aria-pressed",
|
||||
"aria-selected",
|
||||
"aria-valuemax",
|
||||
"aria-valuemin",
|
||||
"aria-valuenow",
|
||||
"class",
|
||||
"href",
|
||||
"id",
|
||||
"nodeName",
|
||||
"role",
|
||||
"tabIndex",
|
||||
"title"
|
||||
];
|
||||
|
||||
function getElementStyles( elem ) {
|
||||
var styles = {};
|
||||
var style = elem.ownerDocument.defaultView ?
|
||||
elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
|
||||
elem.currentStyle;
|
||||
var key, len;
|
||||
|
||||
if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
|
||||
len = style.length;
|
||||
while ( len-- ) {
|
||||
key = style[ len ];
|
||||
if ( typeof style[ key ] === "string" ) {
|
||||
styles[ $.camelCase( key ) ] = style[ key ];
|
||||
}
|
||||
}
|
||||
|
||||
// Support: Opera, IE <9
|
||||
} else {
|
||||
for ( key in style ) {
|
||||
if ( typeof style[ key ] === "string" ) {
|
||||
styles[ key ] = style[ key ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
function extract( selector, message ) {
|
||||
var elem = $( selector );
|
||||
if ( !elem.length ) {
|
||||
QUnit.push( false, null, null,
|
||||
"domEqual failed, can't extract " + selector + ", message was: " + message );
|
||||
return;
|
||||
}
|
||||
|
||||
var result = {};
|
||||
var children;
|
||||
$.each( domEqual.properties, function( index, attr ) {
|
||||
var value = elem.prop( attr );
|
||||
result[ attr ] = value != null ? value : "";
|
||||
} );
|
||||
$.each( domEqual.attributes, function( index, attr ) {
|
||||
var value = elem.attr( attr );
|
||||
result[ attr ] = value != null ? value : "";
|
||||
} );
|
||||
result.style = getElementStyles( elem[ 0 ] );
|
||||
result.events = $._data( elem[ 0 ], "events" );
|
||||
result.data = $.extend( {}, elem.data() );
|
||||
delete result.data[ $.expando ];
|
||||
children = elem.children();
|
||||
if ( children.length ) {
|
||||
result.children = elem.children().map( function() {
|
||||
return extract( $( this ) );
|
||||
} ).get();
|
||||
} else {
|
||||
result.text = elem.text();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} );
|
52
jquery-ui/tests/lib/qunit.js
vendored
Normal file
52
jquery-ui/tests/lib/qunit.js
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"qunit-assert-classes",
|
||||
"qunit-assert-close",
|
||||
"lib/qunit-assert-domequal",
|
||||
"phantom-bridge"
|
||||
], function( QUnit, $ ) {
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.config.requireExpects = true;
|
||||
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "nojshint",
|
||||
label: "Skip JSHint",
|
||||
tooltip: "Skip running JSHint, e.g., within TestSwarm, where Jenkins runs it already"
|
||||
} );
|
||||
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "jquery",
|
||||
label: "jQuery version",
|
||||
value: [
|
||||
"1.7.0", "1.7.1", "1.7.2",
|
||||
"1.8.0", "1.8.1", "1.8.2", "1.8.3",
|
||||
"1.9.0", "1.9.1",
|
||||
"1.10.0", "1.10.1", "1.10.2",
|
||||
"1.11.0", "1.11.1", "1.11.2", "1.11.3",
|
||||
"1.12.0", "1.12.1", "1.12.2", "1.12.3", "1.12.4",
|
||||
"2.0.0", "2.0.1", "2.0.2", "2.0.3",
|
||||
"2.1.0", "2.1.1", "2.1.2", "2.1.3", "2.1.4",
|
||||
"2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4",
|
||||
"3.0.0",
|
||||
"3.1.0",
|
||||
"git", "custom"
|
||||
],
|
||||
tooltip: "Which jQuery Core version to test against"
|
||||
} );
|
||||
|
||||
QUnit.reset = ( function( reset ) {
|
||||
return function() {
|
||||
|
||||
// Ensure jQuery events and data on the fixture are properly removed
|
||||
$( "#qunit-fixture" ).empty();
|
||||
|
||||
// Let QUnit reset the fixture
|
||||
reset.apply( this, arguments );
|
||||
};
|
||||
} )( QUnit.reset );
|
||||
|
||||
return QUnit;
|
||||
|
||||
} );
|
Loading…
Add table
Add a link
Reference in a new issue