"require": false,
"module": false,
"mediaWiki": false,
- "mwPerformance": false,
"OO": false
},
"rules": {
* @singleton
*/
+/* global mwNow */
/* eslint-disable no-use-before-define */
( function ( $ ) {
*
* @return {number} Current time
*/
- now: ( function () {
- var perf = window.performance,
- navStart = perf && perf.timing && perf.timing.navigationStart;
- return navStart && typeof perf.now === 'function' ?
- function () { return navStart + perf.now(); } :
- function () { return +new Date(); };
- }() ),
+ now: mwNow,
+ // mwNow is defined in startup.js
/**
* Format a string. Replace $1, $2 ... $N with positional arguments.
return $.when.apply( $, all );
} );
loading.then( function () {
+ /* global mwPerformance */
mwPerformance.mark( 'mwLoadEnd' );
mw.hook( 'resourceloader.loadEnd' ).fire();
} );
/* global mw, $VARS, $CODE */
-// eslint-disable-next-line no-unused-vars
-var mediaWikiLoadStart = ( new Date() ).getTime(),
- mwPerformance = ( window.performance && performance.mark ) ? performance : {
+var mwPerformance = ( window.performance && performance.mark ) ? performance : {
mark: function () {}
- };
+ },
+ // Define now() here to ensure valid comparison with mediaWikiLoadEnd (T153819).
+ mwNow = ( function () {
+ var perf = window.performance,
+ navStart = perf && perf.timing && perf.timing.navigationStart;
+ return navStart && typeof perf.now === 'function' ?
+ function () { return navStart + perf.now(); } :
+ function () { return +new Date(); };
+ }() ),
+ // eslint-disable-next-line no-unused-vars
+ mediaWikiLoadStart = mwNow();
mwPerformance.mark( 'mwLoadStart' );
);
} );
+ QUnit.test( 'mw.now', function ( assert ) {
+ assert.equal( typeof mw.now(), 'number', 'Return a number' );
+ assert.equal(
+ String( Math.round( mw.now() ) ).length,
+ String( +new Date() ).length,
+ 'Match size of current timestamp'
+ );
+ } );
+
QUnit.test( 'mw.Map', function ( assert ) {
var arry, conf, funky, globalConf, nummy, someValues;