From f05314ff0ec1fce69d51345a4253ea22e5561747 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 12 Aug 2023 14:05:59 +0200 Subject: [PATCH] test: improve tranferable objects test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/pools/thread/fixed.test.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index 849590a6..4fce0b9e 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -156,16 +156,29 @@ describe('Fixed thread pool test suite', () => { }) it('Verify that transferable objects are sent to the worker correctly', async () => { - const transferList = [new ArrayBuffer(16), new MessageChannel().port1] let error let result try { - result = await pool.execute(undefined, undefined, transferList) + result = await pool.execute(undefined, undefined, [ + new ArrayBuffer(16), + new MessageChannel().port1 + ]) } catch (e) { error = e } expect(result).toStrictEqual({ ok: 1 }) expect(error).toBeUndefined() + try { + result = await pool.execute(undefined, undefined, [ + new SharedArrayBuffer(16) + ]) + } catch (e) { + error = e + } + expect(result).toStrictEqual({ ok: 1 }) + expect(error).toStrictEqual( + new TypeError('Found invalid object in transferList') + ) }) it('Verify that error handling is working properly:sync', async () => { -- 2.34.1