From ea80e6ab6de49541b95caf50c22db176339de989 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 14 May 2024 15:16:44 -0400 Subject: [PATCH] Retrieve VoiceOver version (via macOS version) --- lib/modules/macos/session.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/modules/macos/session.js b/lib/modules/macos/session.js index e761706..e94419a 100644 --- a/lib/modules/macos/session.js +++ b/lib/modules/macos/session.js @@ -2,18 +2,38 @@ 'use strict'; +const child_process = require('child_process'); + const { v4: uuid } = require('uuid'); +/** + * @returns {Promise} + */ +const getMacOSVersion = async () => { + return new Promise((resolve, reject) => { + child_process.exec('sw_vers -productVersion', (error, stdout, stderr) => { + if (error) { + reject(new Error(stderr)); + return; + } + resolve(stdout.trim()); + }); + }); +}; + const newSession = /** @type {ATDriverModules.SessionNewSession} */ ( - (websocket, params) => { + async (websocket, params) => { // TODO: match requested capabilities // const { capabilities } = params; websocket.sessionId = uuid(); + return { sessionId: websocket.sessionId, capabilities: { atName: 'Voiceover', - atVersion: 'TODO', + // The ARIA-AT Community Group considers the MacOS version identifier + // to be an accurate identifier for the VoiceOver screen reader. + atVersion: await getMacOSVersion(), platformName: 'macos', }, };