Release 5.2.3

This commit is contained in:
dosse91 2021-02-24 08:19:11 +01:00
parent 44a48a6b4a
commit 64cdba6361
3 changed files with 13 additions and 12 deletions

View file

@ -14,7 +14,7 @@ A Go implementation is available in the [`speedtest-go`](https://github.com/libr
[Donate with PayPal](https://www.paypal.me/sineisochronic)
## License
Copyright (C) 2016-2020 Federico Dossena
Copyright (C) 2016-2021 Federico Dossena
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View file

@ -49,7 +49,7 @@ function Speedtest() {
this._settings = {}; //settings for the speedtest worker
this._state = 0; //0=adding settings, 1=adding servers, 2=server selection done, 3=test running, 4=done
console.log(
"LibreSpeed by Federico Dossena v5.2.2 - https://github.com/librespeed/speedtest"
"LibreSpeed by Federico Dossena v5.2.3 - https://github.com/librespeed/speedtest"
);
}
@ -69,8 +69,8 @@ Speedtest.prototype = {
* Invalid values or nonexistant parameters will be ignored by the speedtest worker.
*/
setParameter: function(parameter, value) {
if (this._state != 0)
throw "You cannot change the test settings after adding server or starting the test";
if (this._state == 3)
throw "You cannot change the test settings while running the test";
this._settings[parameter] = value;
if(parameter === "telemetry_extra"){
this._originalExtra=this._settings.telemetry_extra;
@ -191,9 +191,9 @@ Speedtest.prototype = {
throw "You can't select a server while the test is running";
}
if (this._selectServerCalled) throw "selectServer already called"; else this._selectServerCalled=true;
/*this function goes through a list of servers. For each server, the ping is measured, then the server with the function result is called with the best server, or null if all the servers were down.
/*this function goes through a list of servers. For each server, the ping is measured, then the server with the function selected is called with the best server, or null if all the servers were down.
*/
var select = function(serverList, result) {
var select = function(serverList, selected) {
//pings the specified URL, then calls the function result. Result will receive a parameter which is either the time it took to ping the URL, or -1 if something went wrong.
var PING_TIMEOUT = 2000;
var USE_PING_TIMEOUT = true; //will be disabled on unsupported browsers
@ -201,7 +201,7 @@ Speedtest.prototype = {
//IE11 doesn't support XHR timeout
USE_PING_TIMEOUT = false;
}
var ping = function(url, result) {
var ping = function(url, rtt) {
url += (url.match(/\?/) ? "&" : "?") + "cors=true";
var xhr = new XMLHttpRequest();
var t = new Date().getTime();
@ -217,11 +217,11 @@ Speedtest.prototype = {
if (d <= 0) d = p.duration;
if (d > 0 && d < instspd) instspd = d;
} catch (e) {}
result(instspd);
} else result(-1);
rtt(instspd);
} else rtt(-1);
}.bind(this);
xhr.onerror = function() {
result(-1);
rtt(-1);
}.bind(this);
xhr.open("GET", url);
if (USE_PING_TIMEOUT) {
@ -271,7 +271,7 @@ Speedtest.prototype = {
)
bestServer = serverList[i];
}
result(bestServer);
selected(bestServer);
}.bind(this);
var nextServer = function() {
if (i == serverList.length) {

View file

@ -64,7 +64,8 @@ var settings = {
useMebibits: false, //if set to true, speed will be reported in mebibits/s instead of megabits/s
telemetry_level: 0, // 0=disabled, 1=basic (results only), 2=full (results and timing) 3=debug (results+log)
url_telemetry: "results/telemetry.php", // path to the script that adds telemetry data to the database
telemetry_extra: "" //extra data that can be passed to the telemetry through the settings
telemetry_extra: "", //extra data that can be passed to the telemetry through the settings
forceIE11Workaround: false //when set to true, it will foce the IE11 upload test on all browsers. Debug only
};
var xhr = null; // array of currently active xhr requests