jenkins-bot has submitted this change and it was merged.

Change subject: Fix some potential sources of bias for CORS logging
......................................................................


Fix some potential sources of bias for CORS logging

* randomize the order in which the <script> tags are added to head
* cache-bust the scripts

Bug: T507
Change-Id: Ib6b3a4410bf1702bc72294dba0167c3f70f85a4a
---
M resources/logger/CorsLogger.js
1 file changed, 19 insertions(+), 6 deletions(-)

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



diff --git a/resources/logger/CorsLogger.js b/resources/logger/CorsLogger.js
index a661c3e..d2e1568 100644
--- a/resources/logger/CorsLogger.js
+++ b/resources/logger/CorsLogger.js
@@ -44,12 +44,23 @@
         * @param {number} samplingFactor sampling factor
         */
        CorsLogger.install = function ( samplingFactor ) {
-               var logger = CorsLogger.create( samplingFactor );
+               var promise,
+                       logger = CorsLogger.create( samplingFactor );
 
-               $.when(
-                       logger.loadScript( 'cors-test.js', true),
-                       logger.loadScript( 'non-cors-test.js' )
-               ).done( $.proxy( logger, 'collect' ) );
+               // randomize which request is fired first
+               if ( Math.random() >= 0.5 ) {
+                       promise = $.when(
+                               logger.loadScript( 'cors-test.js', true),
+                               logger.loadScript( 'non-cors-test.js' )
+                       );
+               } else {
+                       promise = $.when(
+                               logger.loadScript( 'non-cors-test.js' ),
+                               logger.loadScript( 'cors-test.js', true)
+                       );
+               }
+
+               promise.done( $.proxy( logger, 'collect' ) );
        };
 
        /**
@@ -82,7 +93,9 @@
                                crossorigin: crossorigin ? 'anonymous' : 
undefined,
                                // this will not work if wgExtensionAssetsPath 
is a relative URL (which is the
                                // default) but there is no need for CORS 
loading of assets in that case anyway
-                               src: this.mwConfig.get( 'wgExtensionAssetsPath' 
) + '/ImageMetrics/resources/' + filename
+                               src: this.mwConfig.get( 'wgExtensionAssetsPath' 
) + '/ImageMetrics/resources/' + filename +
+                                       // add cache buster to avoid bias if 
CORS and normal requests are cached differently
+                                       '?_=' + Math.random()
                        } )
                        .get( 0 );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6b3a4410bf1702bc72294dba0167c3f70f85a4a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ImageMetrics
Gerrit-Branch: master
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to