dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
qunit: Also clear $.timers when stopping unfinished animations
[lhc/web/wiklou.git]
/
tests
/
qunit
/
data
/
testrunner.js
diff --git
a/tests/qunit/data/testrunner.js
b/tests/qunit/data/testrunner.js
index
b0118af
..
a947484
100644
(file)
--- a/
tests/qunit/data/testrunner.js
+++ b/
tests/qunit/data/testrunner.js
@@
-131,9
+131,11
@@
liveMessages = mw.messages;
function suppressWarnings() {
liveMessages = mw.messages;
function suppressWarnings() {
- warn = mw.log.warn;
- error = mw.log.error;
- mw.log.warn = mw.log.error = $.noop;
+ if ( warn === undefined ) {
+ warn = mw.log.warn;
+ error = mw.log.error;
+ mw.log.warn = mw.log.error = $.noop;
+ }
}
function restoreWarnings() {
}
function restoreWarnings() {
@@
-215,6
+217,10
@@
// Stop tracking ajax requests
$( document ).off( 'ajaxSend', trackAjax );
// Stop tracking ajax requests
$( document ).off( 'ajaxSend', trackAjax );
+ // As a convenience feature, automatically restore warnings if they're
+ // still suppressed by the end of the test.
+ restoreWarnings();
+
// Farewell, mock environment!
mw.config = liveConfig;
mw.messages = liveMessages;
// Farewell, mock environment!
mw.config = liveConfig;
mw.messages = liveMessages;
@@
-223,10
+229,6
@@
messages: liveMessages
} );
messages: liveMessages
} );
- // As a convenience feature, automatically restore warnings if they're
- // still suppressed by the end of the test.
- restoreWarnings();
-
// Tests should use fake timers or wait for animations to complete
// Check for incomplete animations/requests/etc and throw if there are any.
if ( $.timers && $.timers.length !== 0 ) {
// Tests should use fake timers or wait for animations to complete
// Check for incomplete animations/requests/etc and throw if there are any.
if ( $.timers && $.timers.length !== 0 ) {
@@
-238,6
+240,7
@@
);
} );
// Force animations to stop to give the next test a clean start
);
} );
// Force animations to stop to give the next test a clean start
+ $.timers = [];
$.fx.stop();
throw new Error( 'Unfinished animations: ' + timers );
$.fx.stop();
throw new Error( 'Unfinished animations: ' + timers );
@@
-253,8
+256,11
@@
mw.log.warn( 'Pending requests does not match jQuery.active count' );
}
// Force requests to stop to give the next test a clean start
mw.log.warn( 'Pending requests does not match jQuery.active count' );
}
// Force requests to stop to give the next test a clean start
- $.each( pending, function ( i, ajax ) {
- mw.log.warn( 'Pending AJAX request #' + i, ajax.options );
+ $.each( ajaxRequests, function ( i, ajax ) {
+ mw.log.warn(
+ 'AJAX request #' + i + ' (state: ' + ajax.xhr.state() + ')',
+ ajax.options
+ );
ajax.xhr.abort();
} );
ajaxRequests = [];
ajax.xhr.abort();
} );
ajaxRequests = [];