From cf99ed0ee006d0d1460e1c64c1dfc0adbd217803 Mon Sep 17 00:00:00 2001 From: Henry Su Date: Mon, 24 Aug 2026 22:10:01 -0500 Subject: [PATCH] fix(dock): handle nullish and missing parameters in resolveDockVisibility (#1817) --- src/helpers/dockPolicy.js | 3 ++- test/helpers/dockPolicy.test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/helpers/dockPolicy.js b/src/helpers/dockPolicy.js index 7a3702de61..af87417e49 100644 --- a/src/helpers/dockPolicy.js +++ b/src/helpers/dockPolicy.js @@ -10,7 +10,8 @@ // Whether the Dock icon should be visible right now. // Returns null off macOS, where there is no Dock to act on. -export function resolveDockVisibility({ platform, controlPanelVisible }) { +export function resolveDockVisibility(params = {}) { + const { platform, controlPanelVisible } = params || {}; if (platform !== "darwin") return null; return !!controlPanelVisible; } diff --git a/test/helpers/dockPolicy.test.js b/test/helpers/dockPolicy.test.js index 3b216f88c1..cccdf6ec46 100644 --- a/test/helpers/dockPolicy.test.js +++ b/test/helpers/dockPolicy.test.js @@ -27,3 +27,12 @@ test("there is no Dock to act on outside macOS", async () => { assert.equal(resolveDockVisibility({ platform, controlPanelVisible: true }), null); } }); + +test("handles nullish and missing parameter safely", async () => { + const { resolveDockVisibility } = await load(); + + assert.equal(resolveDockVisibility(), null); + assert.equal(resolveDockVisibility(null), null); + assert.equal(resolveDockVisibility(undefined), null); + assert.equal(resolveDockVisibility({}), null); +});