fixes onend() (#358)

* fixes onend()

* Update speedtest.js
This commit is contained in:
Niels Peen 2020-09-17 18:13:35 +02:00 committed by GitHub
parent 3ccdd3d017
commit 5cef820749
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -330,13 +330,13 @@ Speedtest.prototype = {
console.error("Speedtest onupdate event threw exception: " + e); console.error("Speedtest onupdate event threw exception: " + e);
} }
if (data.testState >= 4) { if (data.testState >= 4) {
clearInterval(this.updater);
this._state = 4;
try { try {
if (this.onend) this.onend(data.testState == 5); if (this.onend) this.onend(data.testState == 5);
} catch (e) { } catch (e) {
console.error("Speedtest onend event threw exception: " + e); console.error("Speedtest onend event threw exception: " + e);
} }
clearInterval(this.updater);
this._state = 4;
} }
}.bind(this); }.bind(this);
this.updater = setInterval( this.updater = setInterval(