diff --git a/speedtest.js b/speedtest.js index b2feca9..d664104 100755 --- a/speedtest.js +++ b/speedtest.js @@ -319,6 +319,11 @@ Speedtest.prototype = { */ start: function() { if (this._state == 3) throw "Test already running"; + // Terminate any existing worker from previous test + if (this.worker) { + this.worker.terminate(); + this.worker = null; + } this.worker = new Worker("speedtest_worker.js?r=" + Math.random()); this.worker.onmessage = function(e) { if (e.data === this._prevData) return; @@ -337,6 +342,11 @@ Speedtest.prototype = { } catch (e) { console.error("Speedtest onend event threw exception: " + e); } + // Terminate worker after test completes + if (this.worker) { + this.worker.terminate(); + this.worker = null; + } } }.bind(this); this.updater = setInterval( diff --git a/test_multiple_instances.html b/test_multiple_instances.html new file mode 100644 index 0000000..4254b27 --- /dev/null +++ b/test_multiple_instances.html @@ -0,0 +1,166 @@ + + + + + LibreSpeed - Multiple Instance Test + + + + +

LibreSpeed - Multiple Instance Test

+

This page tests running multiple Speedtest instances sequentially and simultaneously.

+ +
+

Test Instance 1

+ + +
+
Status: Not started
+
Download: - Mbit/s
+
Upload: - Mbit/s
+
Ping: - ms
+
Jitter: - ms
+
IP: -
+
+
+ +
+

Test Instance 2

+ + +
+
Status: Not started
+
Download: - Mbit/s
+
Upload: - Mbit/s
+
Ping: - ms
+
Jitter: - ms
+
IP: -
+
+
+ +
+

Instructions:

+
    +
  1. Click "Start Test 1" and wait for it to complete
  2. +
  3. Then click "Start Test 2" - it should work correctly without strange values
  4. +
  5. You can also run both tests simultaneously
  6. +
  7. You can run each test multiple times
  8. +
+
+ + + + LibreSpeed Source Code + +