From 93464f15a2a13442eab33cea0608e9fde748567d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claudio=20S=C3=A1=20de=20Abreu?= Date: Sun, 5 Jul 2026 14:15:17 -0300 Subject: [PATCH] Fix operator precedence in reportCurrentSpeed time-delta calculation The intent of these lines is clearly "if this is the first sample, the time delta is 0": dtLoad = dtDiff = 0 ? 0 : dTime - dtDiff; but due to operator precedence it parses as dtLoad = (dtDiff = (0 ? 0 : dTime - dtDiff)); i.e. the ternary condition is the constant 0 (always false), so the first-sample case is never handled and dtDiff is transiently assigned the wrong value before being overwritten on the next line. The same pattern exists in the upload branch (utLoad/utDiff). Fixed to compare explicitly (dtDiff === 0 / utDiff === 0). In the minified file the original minifier had constant-folded the dead ternary away, so the correct comparison is reintroduced there as well. --- assets/js/app-2.5.4.js | 4 ++-- assets/js/app-2.5.4.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/app-2.5.4.js b/assets/js/app-2.5.4.js index f5b5b6e..0f3cc12 100644 --- a/assets/js/app-2.5.4.js +++ b/assets/js/app-2.5.4.js @@ -1081,7 +1081,7 @@ window.onload = function() { dLoad = dLoaded <= 0 ? 0 : dLoaded - dDiff; dDiff = dLoaded; dTotal += dLoad; - dtLoad = dtDiff = 0 ? 0 : dTime - dtDiff; + dtLoad = dtDiff === 0 ? 0 : dTime - dtDiff; dtDiff = dTime; dtTotal += dtLoad; if (dTotal > 0) { @@ -1105,7 +1105,7 @@ window.onload = function() { uLoad = uLoaded <= 0 ? 0 : uLoaded - uDiff; uDiff = uLoaded; uTotal += uLoad; - utLoad = utDiff = 0 ? 0 : Tym - utDiff; + utLoad = utDiff === 0 ? 0 : Tym - utDiff; utDiff = Tym; utTotal += utLoad; if (uTotal > 0) { diff --git a/assets/js/app-2.5.4.min.js b/assets/js/app-2.5.4.min.js index 0df99a1..1704080 100644 --- a/assets/js/app-2.5.4.min.js +++ b/assets/js/app-2.5.4.min.js @@ -35,7 +35,7 @@ m&&1===I&&(e.Symbol(1),m="initup",e.showStatus("Initializing.."),e.LiveSpeed(".. e.GaugeProgresstoZero(y,"SendR"),za=void 0,e.showStatus("All done"),e.Symbol(2),m="busy",I=0));if("Error"===m){e.showStatus("Check your network connection status.");e.ConnectionError();m="busy";clearInterval(l);g=document.createElement("div");g.innerHTML='';var u=g.querySelector("a");e.oDoLiveSpeed.el.textContent="Network Error";var C=document.getElementById("oDoLiveSpeed");u.innerHTML=C.innerHTML; C.innerHTML=g.innerHTML}"SendR"===m&&(e.showStatus("All done"),g=document.createElement("div"),g.innerHTML='',u=g.querySelector("a"),e.oDoLiveSpeed.el.textContent=fb,C=document.getElementById("oDoLiveSpeed"),u.innerHTML=C.innerHTML,C.innerHTML=g.innerHTML,location.hostname!=Ba.toLowerCase()+Sa?(ba="https://"+Ba.toLowerCase()+Sa+"/results/show.php?&d="+R.toFixed(3)+"&u="+U.toFixed(3)+"&p="+ Ca+"&j="+Da+"&dd="+(ia/1048576).toFixed(3)+"&ud="+(ja/1048576).toFixed(3)+"&ua="+Ta,ba=encodeURI(ba),g=document.getElementById("resultsData"),g.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",ba),g.setAttribute("target","_blank"),saveData&&Y(5)):Y(3),m="busy",clearInterval(l))},100)}function w(){for(var b=0;b1E3*Qa+ya/2*1E3&&0===Ua&&(Ua=1,ka*=.01,ca*=.01,la=l+1E4);l>=la&&la=S?0:S-Wa;Wa=S;ca+=Va;Xa=Ea=l-Ea;Ea=l;ka+=Xa;01E3*Ra+Aa/2*1E3&&0===Ya&&(Ya=1,ma*=.1,da*=.1,na=b+1E4),b>=na&&na=P?0:P-$a,$a=P,da+=Za,ab=Fa=b-Fa,Fa=b,ma+=ab,01E3*Ra+Aa/2*1E3&&0===Ya&&(Ya=1,ma*=.1,da*=.1,na=b+1E4),b>=na&&na=P?0:P-$a,$a=P,da+=Za,ab=0===Fa?0:b-Fa,Fa=b,ma+=ab,0=g.loaded?0:g.loaded-l;if(isNaN(u)||!isFinite(u)||0>u)return!1;S+=u;l=g.loaded};z[b].onload=function(g){0===l&&(S+=g.total);"initDown"==m&&(m="Downloading");z[b]&&(z[b].abort(),z[b]=null,z[b]=void 0,delete z[b]);0===I&&M(b)};z[b].onerror=function(g){0===I&&M(b)};z[b].responseType="arraybuffer";z[b].send()}function F(b){var l=0;v[b]=new XMLHttpRequest;v[b].open("POST",Ga.Upload+"?n="+Math.random(),!0); v[b].upload.onprogress=function(g){"initup"==m&&void 0===u&&(m="Uploading");if(T>=ulDuration)return v[b].abort(),v[b]=null,v[b]=void 0,delete v[b],!1;var u=0>=g.loaded?0:g.loaded-l;if(isNaN(u)||!isFinite(u)||0>u)return!1;P+=u;l=g.loaded};v[b].onload=function(){if(0===l&&(P+=1048576*ulDataSize,T>=ulDuration))return v[b].abort(),v[b]=null,v[b]=void 0,delete v[b],!1;if("initup"==m&&void 0===g){var g;m="Uploading"}v[b]&&(v[b].abort(),v[b]=null,v[b]=void 0,delete v[b]);1===I&&F(b)};v[b].onerror=function(g){T<= ulDuration&&F(b)};v[b].setRequestHeader("Content-Type","application/octet-stream");0=P||v[b].send(za)}function Q(){bb=openSpeedTestServerList.length;m="Ping";performance.clearResourceTimings();if(Ha