jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344743 )

Change subject: Ensure we use mw.now() instead of 'new Date' for relative 
measurement
......................................................................


Ensure we use mw.now() instead of 'new Date' for relative measurement

'new Date' is subject to clock drift etc.

mw.now() uses performance.now() when available, which will always
increase at a constant rate independent of the system clock.

Change-Id: Ib653103bf6116544f35c930fb33421f1bb362c7d
---
M resources/src/jquery/jquery.suggestions.js
M resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
2 files changed, 6 insertions(+), 6 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/resources/src/jquery/jquery.suggestions.js 
b/resources/src/jquery/jquery.suggestions.js
index fdc8a26..75f1ba6 100644
--- a/resources/src/jquery/jquery.suggestions.js
+++ b/resources/src/jquery/jquery.suggestions.js
@@ -96,7 +96,7 @@
  */
  // jscs:enable checkParamNames
 
-( function ( $ ) {
+( function ( $, mw ) {
 
        var hasOwn = Object.hasOwnProperty;
 
@@ -178,7 +178,7 @@
                                        context.data.prevText = val;
                                        // Try cache first
                                        if ( context.config.cache && 
hasOwn.call( cache, val ) ) {
-                                               if ( +new Date() - cache[ val 
].timestamp < context.config.cacheMaxAge ) {
+                                               if ( mw.now() - cache[ val 
].timestamp < context.config.cacheMaxAge ) {
                                                        
context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions );
                                                        if ( typeof 
context.config.update.after === 'function' ) {
                                                                
context.config.update.after.call( context.data.$textbox, cache[ val ].metadata 
);
@@ -203,7 +203,7 @@
                                                                        cache[ 
val ] = {
                                                                                
suggestions: suggestions,
                                                                                
metadata: metadata,
-                                                                               
timestamp: +new Date()
+                                                                               
timestamp: mw.now()
                                                                        };
                                                                }
                                                        },
@@ -786,4 +786,4 @@
         * @mixins jQuery.plugin.suggestions
         */
 
-}( jQuery ) );
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js 
b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
index 172cac2..2f90fe6 100644
--- a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
+++ b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
@@ -230,7 +230,7 @@
         */
        mw.Upload.BookletLayout.prototype.uploadFile = function () {
                var deferred = $.Deferred(),
-                       startTime = new Date(),
+                       startTime = mw.now(),
                        layout = this,
                        file = this.getFile();
 
@@ -265,7 +265,7 @@
                                deferred.reject( errorMessage );
                        } );
                }, function ( progress ) {
-                       var elapsedTime = new Date() - startTime,
+                       var elapsedTime = mw.now() - startTime,
                                estimatedTotalTime = ( 1 / progress ) * 
elapsedTime,
                                estimatedRemainingTime = moment.duration( 
estimatedTotalTime - elapsedTime );
                        layout.emit( 'fileUploadProgress', progress, 
estimatedRemainingTime );

-- 
To view, visit https://gerrit.wikimedia.org/r/344743
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib653103bf6116544f35c930fb33421f1bb362c7d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to