diff --git a/CMakeLists.txt b/CMakeLists.txt index 116efa6b..b385b614 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(FetchContent) # -------------------------------------------------- FetchContent_Declare(AndroidExtensions GIT_REPOSITORY https://github.com/BabylonJS/AndroidExtensions.git - GIT_TAG 2d5af72259cc73e5f249d3c99bee2010be9cb042 + GIT_TAG 2e85a8d43b89246c460112c9e5546ad54b6e87b4 EXCLUDE_FROM_ALL) FetchContent_Declare(arcana.cpp GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git @@ -37,7 +37,7 @@ FetchContent_Declare(llhttp EXCLUDE_FROM_ALL) FetchContent_Declare(UrlLib GIT_REPOSITORY https://github.com/BabylonJS/UrlLib.git - GIT_TAG d53beb958b1cccafd5411260ace6d32b68b56a83 + GIT_TAG 880c2575e57ca0b59068ecc4860f185b9970e0ce EXCLUDE_FROM_ALL) # -------------------------------------------------- diff --git a/Tests/UnitTests/Scripts/tests.ts b/Tests/UnitTests/Scripts/tests.ts index ca9df835..cffe0060 100644 --- a/Tests/UnitTests/Scripts/tests.ts +++ b/Tests/UnitTests/Scripts/tests.ts @@ -1,4 +1,4 @@ -import * as Mocha from "mocha"; +import * as Mocha from "mocha"; import { expect } from "chai"; Mocha.setup('bdd'); @@ -407,6 +407,8 @@ if (hostPlatform !== "Unix") { it("should connect correctly with one websocket connection", function (done) { const ws = new WebSocket("wss://ws.postman-echo.com/raw"); const testMessage = "testMessage"; + let error: unknown; + ws.onopen = () => { try { expect(ws).to.have.property("readyState", 1); @@ -414,38 +416,42 @@ if (hostPlatform !== "Unix") { ws.send(testMessage); } catch (e) { - done(e); + error = e; + ws.close(); } }; ws.onmessage = (msg) => { try { expect(msg.data).to.equal(testMessage); - ws.close(); } catch (e) { - done(e); + error = e; } + ws.close(); }; ws.onclose = () => { - try { - expect(ws).to.have.property("readyState", 3); - done(); - } - catch (e) { - done(e); + if (!error) { + try { + expect(ws).to.have.property("readyState", 3); + } + catch (e) { + error = e; + } } + done(error); }; - ws.onerror = (ev) => { - done(new Error("WebSocket failed")); + ws.onerror = () => { + error = new Error("WebSocket failed"); }; }); it("should connect correctly with multiple websocket connections", function (done) { const testMessage1 = "testMessage1"; const testMessage2 = "testMessage2"; + let error: unknown; const ws1 = new WebSocket("wss://ws.postman-echo.com/raw"); ws1.onopen = () => { @@ -457,57 +463,66 @@ if (hostPlatform !== "Unix") { ws2.send(testMessage2); } catch (e) { - done(e); + error = e; + ws2.close(); } }; ws2.onmessage = (msg) => { try { expect(msg.data).to.equal(testMessage2); - ws2.close(); } catch (e) { - done(e); + error = e; } + ws2.close(); }; ws2.onclose = () => { - try { - expect(ws2).to.have.property("readyState", 3); - ws1.send(testMessage1); + if (!error) { + try { + expect(ws2).to.have.property("readyState", 3); + ws1.send(testMessage1); + } + catch (e) { + error = e; + ws1.close(); + } } - catch (e) { - done(e); + else { + ws1.close(); } }; - ws2.onerror = (ev) => { - done(new Error("Websocket failed")); + ws2.onerror = () => { + error = new Error("WebSocket failed"); }; } ws1.onmessage = (msg) => { try { expect(msg.data).to.equal(testMessage1); - ws1.close(); } catch (e) { - done(e); + error = e; } + ws1.close(); } ws1.onclose = () => { - try { - expect(ws1).to.have.property("readyState", 3); - done(); - } - catch (e) { - done(e); + if (!error) { + try { + expect(ws1).to.have.property("readyState", 3); + } + catch (e) { + error = e; + } } + done(error); } - ws1.onerror = (ev) => { - done(new Error("Websocket failed")); + ws1.onerror = () => { + error = new Error("WebSocket failed"); }; }); @@ -522,8 +537,18 @@ if (hostPlatform !== "Unix") { it("should trigger error callback with invalid domain", function (done) { this.timeout(10000); const ws = new WebSocket("wss://example"); + let errorFired = false; ws.onerror = () => { - done(); + errorFired = true; + }; + ws.onclose = () => { + try { + expect(errorFired).to.be.true; + done(); + } + catch (e) { + done(e); + } }; }); })