Build: Update QUnit to latest (1.17.1)

(cherry-picked from 2d5c5d213f)
Closes gh-2038
This commit is contained in:
Jörn Zaefferer 2015-01-26 19:24:59 +01:00 committed by Oleg Gaidarenko
parent f2ea60cfe8
commit db31206d36
4 changed files with 141 additions and 69 deletions

View File

@ -1,5 +1,4 @@
Copyright 2006, 2014 jQuery Foundation and other contributors, Copyright jQuery Foundation and other contributors, https://jquery.org/
https://jquery.org/
This software consists of voluntary contributions made by many This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history individuals. For exact contribution history, see the revision history

View File

@ -1,12 +1,12 @@
/*! /*!
* QUnit 1.16.0 * QUnit 1.17.1
* http://qunitjs.com/ * http://qunitjs.com/
* *
* Copyright 2006, 2014 jQuery Foundation and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-12-03T16:32Z * Date: 2015-01-20T19:39Z
*/ */
/** Font Family and Sizes */ /** Font Family and Sizes */
@ -77,6 +77,18 @@
#qunit-modulefilter-container { #qunit-modulefilter-container {
float: right; float: right;
padding: 0.2em;
}
.qunit-url-config {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
float: right;
margin-left: 1em;
} }
/** Tests: Pass/Fail */ /** Tests: Pass/Fail */
@ -95,11 +107,15 @@
display: none; display: none;
} }
#qunit-tests li.pass, #qunit-tests li.running, #qunit-tests li.fail { #qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item; display: list-item;
} }
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { #qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
display: none; display: none;
} }

View File

@ -1,12 +1,12 @@
/*! /*!
* QUnit 1.16.0 * QUnit 1.17.1
* http://qunitjs.com/ * http://qunitjs.com/
* *
* Copyright 2006, 2014 jQuery Foundation and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-12-03T16:32Z * Date: 2015-01-20T19:39Z
*/ */
(function( window ) { (function( window ) {
@ -103,10 +103,6 @@ config = {
// block until document ready // block until document ready
blocking: true, blocking: true,
// when enabled, show only failing tests
// gets persisted through sessionStorage and can be changed in UI via checkbox
hidepassed: false,
// by default, run previously failed tests first // by default, run previously failed tests first
// very useful in combination with "Hide passed tests" checked // very useful in combination with "Hide passed tests" checked
reorder: true, reorder: true,
@ -180,6 +176,10 @@ config.modules.push( config.currentModule );
} }
} }
if ( urlParams.filter === true ) {
delete urlParams.filter;
}
QUnit.urlParams = urlParams; QUnit.urlParams = urlParams;
// String search anywhere in moduleName+testName // String search anywhere in moduleName+testName
@ -363,24 +363,6 @@ extend( QUnit, {
return undefined; return undefined;
}, },
url: function( params ) {
params = extend( extend( {}, QUnit.urlParams ), params );
var key,
querystring = "?";
for ( key in params ) {
if ( hasOwn.call( params, key ) ) {
querystring += encodeURIComponent( key );
if ( params[ key ] !== true ) {
querystring += "=" + encodeURIComponent( params[ key ] );
}
querystring += "&";
}
}
return location.protocol + "//" + location.host +
location.pathname + querystring.slice( 0, -1 );
},
extend: extend, extend: extend,
load: function() { load: function() {
@ -578,7 +560,7 @@ function process( last ) {
process( last ); process( last );
} }
var start = now(); var start = now();
config.depth = config.depth ? config.depth + 1 : 1; config.depth = ( config.depth || 0 ) + 1;
while ( config.queue.length && !config.blocking ) { while ( config.queue.length && !config.blocking ) {
if ( !defined.setTimeout || config.updateRate <= 0 || if ( !defined.setTimeout || config.updateRate <= 0 ||
@ -1141,7 +1123,7 @@ Test.prototype = {
valid: function() { valid: function() {
var include, var include,
filter = config.filter && config.filter.toLowerCase(), filter = config.filter,
module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(), module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(),
fullName = ( this.module.name + ": " + this.testName ).toLowerCase(); fullName = ( this.module.name + ": " + this.testName ).toLowerCase();
@ -1164,7 +1146,7 @@ Test.prototype = {
include = filter.charAt( 0 ) !== "!"; include = filter.charAt( 0 ) !== "!";
if ( !include ) { if ( !include ) {
filter = filter.slice( 1 ); filter = filter.toLowerCase().slice( 1 );
} }
// If the filter matches, we need to honour include // If the filter matches, we need to honour include
@ -1987,12 +1969,15 @@ if ( typeof window !== "undefined" ) {
} }
// For nodejs // For nodejs
if ( typeof module !== "undefined" && module.exports ) { if ( typeof module !== "undefined" && module && module.exports ) {
module.exports = QUnit; module.exports = QUnit;
// For consistency with CommonJS environments' exports
module.exports.QUnit = QUnit;
} }
// For CommonJS with exports, but without module.exports, like Rhino // For CommonJS with exports, but without module.exports, like Rhino
if ( typeof exports !== "undefined" ) { if ( typeof exports !== "undefined" && exports ) {
exports.QUnit = QUnit; exports.QUnit = QUnit;
} }
@ -2340,7 +2325,10 @@ function getUrlConfigHtml() {
escaped = escapeText( val.id ); escaped = escapeText( val.id );
escapedTooltip = escapeText( val.tooltip ); escapedTooltip = escapeText( val.tooltip );
config[ val.id ] = QUnit.urlParams[ val.id ]; if ( config[ val.id ] === undefined ) {
config[ val.id ] = QUnit.urlParams[ val.id ];
}
if ( !val.value || typeof val.value === "string" ) { if ( !val.value || typeof val.value === "string" ) {
urlConfigHtml += "<input id='qunit-urlconfig-" + escaped + urlConfigHtml += "<input id='qunit-urlconfig-" + escaped +
"' name='" + escaped + "' type='checkbox'" + "' name='" + escaped + "' type='checkbox'" +
@ -2399,7 +2387,7 @@ function toolbarChanged() {
} }
params[ field.name ] = value; params[ field.name ] = value;
updatedUrl = QUnit.url( params ); updatedUrl = setUrl( params );
if ( "hidepassed" === field.name && "replaceState" in window.history ) { if ( "hidepassed" === field.name && "replaceState" in window.history ) {
config[ field.name ] = value || false; config[ field.name ] = value || false;
@ -2416,10 +2404,47 @@ function toolbarChanged() {
} }
} }
function setUrl( params ) {
var key,
querystring = "?";
params = QUnit.extend( QUnit.extend( {}, QUnit.urlParams ), params );
for ( key in params ) {
if ( hasOwn.call( params, key ) ) {
if ( params[ key ] === undefined ) {
continue;
}
querystring += encodeURIComponent( key );
if ( params[ key ] !== true ) {
querystring += "=" + encodeURIComponent( params[ key ] );
}
querystring += "&";
}
}
return location.protocol + "//" + location.host +
location.pathname + querystring.slice( 0, -1 );
}
function applyUrlParams() {
var selectBox = id( "qunit-modulefilter" ),
selection = decodeURIComponent( selectBox.options[ selectBox.selectedIndex ].value ),
filter = id( "qunit-filter-input" ).value;
window.location = setUrl({
module: ( selection === "" ) ? undefined : selection,
filter: ( filter === "" ) ? undefined : filter,
// Remove testId filter
testId: undefined
});
}
function toolbarUrlConfigContainer() { function toolbarUrlConfigContainer() {
var urlConfigContainer = document.createElement( "span" ); var urlConfigContainer = document.createElement( "span" );
urlConfigContainer.innerHTML = getUrlConfigHtml(); urlConfigContainer.innerHTML = getUrlConfigHtml();
addClass( urlConfigContainer, "qunit-url-config" );
// For oldIE support: // For oldIE support:
// * Add handlers to the individual elements instead of the container // * Add handlers to the individual elements instead of the container
@ -2430,6 +2455,40 @@ function toolbarUrlConfigContainer() {
return urlConfigContainer; return urlConfigContainer;
} }
function toolbarLooseFilter() {
var filter = document.createElement( "form" ),
label = document.createElement( "label" ),
input = document.createElement( "input" ),
button = document.createElement( "button" );
addClass( filter, "qunit-filter" );
label.innerHTML = "Filter: ";
input.type = "text";
input.value = config.filter || "";
input.name = "filter";
input.id = "qunit-filter-input";
button.innerHTML = "Go";
label.appendChild( input );
filter.appendChild( label );
filter.appendChild( button );
addEvent( filter, "submit", function( ev ) {
applyUrlParams();
if ( ev && ev.preventDefault ) {
ev.preventDefault();
}
return false;
});
return filter;
}
function toolbarModuleFilterHtml() { function toolbarModuleFilterHtml() {
var i, var i,
moduleFilterHtml = ""; moduleFilterHtml = "";
@ -2463,25 +2522,14 @@ function toolbarModuleFilter() {
moduleFilter = document.createElement( "span" ), moduleFilter = document.createElement( "span" ),
moduleFilterHtml = toolbarModuleFilterHtml(); moduleFilterHtml = toolbarModuleFilterHtml();
if ( !moduleFilterHtml ) { if ( !toolbar || !moduleFilterHtml ) {
return false; return false;
} }
moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
moduleFilter.innerHTML = moduleFilterHtml; moduleFilter.innerHTML = moduleFilterHtml;
addEvent( moduleFilter.lastChild, "change", function() { addEvent( moduleFilter.lastChild, "change", applyUrlParams );
var selectBox = moduleFilter.getElementsByTagName( "select" )[ 0 ],
selection = decodeURIComponent( selectBox.options[ selectBox.selectedIndex ].value );
window.location = QUnit.url({
module: ( selection === "" ) ? undefined : selection,
// Remove any existing filters
filter: undefined,
testId: undefined
});
});
toolbar.appendChild( moduleFilter ); toolbar.appendChild( moduleFilter );
} }
@ -2491,6 +2539,17 @@ function appendToolbar() {
if ( toolbar ) { if ( toolbar ) {
toolbar.appendChild( toolbarUrlConfigContainer() ); toolbar.appendChild( toolbarUrlConfigContainer() );
toolbar.appendChild( toolbarLooseFilter() );
}
}
function appendHeader() {
var header = id( "qunit-header" );
if ( header ) {
header.innerHTML = "<a href='" +
setUrl({ filter: undefined, module: undefined, testId: undefined }) +
"'>" + header.innerHTML + "</a> ";
} }
} }
@ -2499,9 +2558,6 @@ function appendBanner() {
if ( banner ) { if ( banner ) {
banner.className = ""; banner.className = "";
banner.innerHTML = "<a href='" +
QUnit.url({ filter: undefined, module: undefined, testId: undefined }) +
"'>" + banner.innerHTML + "</a> ";
} }
} }
@ -2533,7 +2589,8 @@ function storeFixture() {
function appendUserAgent() { function appendUserAgent() {
var userAgent = id( "qunit-userAgent" ); var userAgent = id( "qunit-userAgent" );
if ( userAgent ) { if ( userAgent ) {
userAgent.innerHTML = navigator.userAgent; userAgent.innerHTML = "";
userAgent.appendChild( document.createTextNode( navigator.userAgent ) );
} }
} }
@ -2568,7 +2625,7 @@ function appendTest( name, testId, moduleName ) {
rerunTrigger = document.createElement( "a" ); rerunTrigger = document.createElement( "a" );
rerunTrigger.innerHTML = "Rerun"; rerunTrigger.innerHTML = "Rerun";
rerunTrigger.href = QUnit.url({ testId: testId }); rerunTrigger.href = setUrl({ testId: testId });
testBlock = document.createElement( "li" ); testBlock = document.createElement( "li" );
testBlock.appendChild( title ); testBlock.appendChild( title );
@ -2590,17 +2647,16 @@ QUnit.begin(function( details ) {
// Fixture is the only one necessary to run without the #qunit element // Fixture is the only one necessary to run without the #qunit element
storeFixture(); storeFixture();
if ( !qunit ) { if ( qunit ) {
return; qunit.innerHTML =
"<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
"<h2 id='qunit-banner'></h2>" +
"<div id='qunit-testrunner-toolbar'></div>" +
"<h2 id='qunit-userAgent'></h2>" +
"<ol id='qunit-tests'></ol>";
} }
qunit.innerHTML = appendHeader();
"<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
"<h2 id='qunit-banner'></h2>" +
"<div id='qunit-testrunner-toolbar'></div>" +
"<h2 id='qunit-userAgent'></h2>" +
"<ol id='qunit-tests'></ol>";
appendBanner(); appendBanner();
appendTestResults(); appendTestResults();
appendUserAgent(); appendUserAgent();
@ -2608,7 +2664,7 @@ QUnit.begin(function( details ) {
appendTestsList( details.modules ); appendTestsList( details.modules );
toolbarModuleFilter(); toolbarModuleFilter();
if ( config.hidepassed ) { if ( qunit && config.hidepassed ) {
addClass( qunit.lastChild, "hidepass" ); addClass( qunit.lastChild, "hidepass" );
} }
}); });
@ -2788,7 +2844,7 @@ QUnit.testDone(function( details ) {
details.assertions.length + ")</b>"; details.assertions.length + ")</b>";
if ( details.skipped ) { if ( details.skipped ) {
addClass( testItem, "skipped" ); testItem.className = "skipped";
skipped = document.createElement( "em" ); skipped = document.createElement( "em" );
skipped.className = "qunit-skipped-label"; skipped.className = "qunit-skipped-label";
skipped.innerHTML = "skipped"; skipped.innerHTML = "skipped";

View File

@ -43,7 +43,8 @@
"grunt-npmcopy": "0.1.0", "grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2", "gzip-js": "0.3.2",
"load-grunt-tasks": "1.0.0", "load-grunt-tasks": "1.0.0",
"qunitjs": "1.16.0", "npm": "2.1.12",
"qunitjs": "1.17.1",
"requirejs": "2.1.15", "requirejs": "2.1.15",
"sinon": "1.12.2", "sinon": "1.12.2",
"sizzle": "2.1.1", "sizzle": "2.1.1",