tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 8641808763bed9ae74a03772f1b21f8c654ddbe8
parent 288e11d8d249b65a0a2e1d953fd6f6b8281e80eb
Author: Eitan Isaacson <eitan@monotonous.org>
Date:   Wed, 22 Oct 2025 03:44:57 +0000

Bug 1994031 - P1: Intro basic action test for IA2. r=Jamie

Swapped description for localizedName, and mirrored localizedName into
description for backwards compat.

Differential Revision: https://phabricator.services.mozilla.com/D268735

Diffstat:
Maccessible/tests/browser/windows/ia2/browser.toml | 2++
Aaccessible/tests/browser/windows/ia2/browser_action.js | 30++++++++++++++++++++++++++++++
Maccessible/windows/ia2/ia2AccessibleAction.cpp | 28+++++++++++++---------------
3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/accessible/tests/browser/windows/ia2/browser.toml b/accessible/tests/browser/windows/ia2/browser.toml @@ -15,6 +15,8 @@ prefs = [ "security.allow_eval_with_system_principal=true", ] +["browser_action.js"] + ["browser_groupPosition.js"] ["browser_keyboard_shortcut.js"] diff --git a/accessible/tests/browser/windows/ia2/browser_action.js b/accessible/tests/browser/windows/ia2/browser_action.js @@ -0,0 +1,30 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * Test basic press action. + */ +addAccessibleTask( + ` +<button id="btn" onclick="this.textContent = 'Clicked'">Click me</button> + `, + async function testBasicPress() { + const actions = await runPython(` + global doc + doc = getDocIa2() + global btn + btn = findIa2ByDomId(doc, "btn").QueryInterface(IAccessibleAction) + return str([[btn.name(i), btn.localizedName(i), btn.description(i)] for i in range(btn.nActions())]) + `); + is(actions, "[['press', 'Press', 'Press']]", "btn has correct actions"); + + const nameChanged = waitForEvent(EVENT_NAME_CHANGE, "btn"); + await runPython(` + btn.doAction(0) + `); + await nameChanged; + } +); diff --git a/accessible/windows/ia2/ia2AccessibleAction.cpp b/accessible/windows/ia2/ia2AccessibleAction.cpp @@ -62,19 +62,7 @@ ia2AccessibleAction::doAction(long aActionIndex) { STDMETHODIMP ia2AccessibleAction::get_description(long aActionIndex, BSTR* aDescription) { - if (!aDescription) return E_INVALIDARG; - *aDescription = nullptr; - - Accessible* acc = Acc(); - if (!acc) return CO_E_OBJNOTCONNECTED; - - nsAutoString description; - uint8_t index = static_cast<uint8_t>(aActionIndex); - acc->ActionDescriptionAt(index, description); - if (description.IsEmpty()) return S_FALSE; - - *aDescription = ::SysAllocStringLen(description.get(), description.Length()); - return *aDescription ? S_OK : E_OUTOFMEMORY; + return get_localizedName(aActionIndex, aDescription); } STDMETHODIMP @@ -147,7 +135,17 @@ STDMETHODIMP ia2AccessibleAction::get_localizedName(long aActionIndex, BSTR* aLocalizedName) { if (!aLocalizedName) return E_INVALIDARG; - *aLocalizedName = nullptr; - return E_NOTIMPL; + + Accessible* acc = Acc(); + if (!acc) return CO_E_OBJNOTCONNECTED; + + nsAutoString description; + uint8_t index = static_cast<uint8_t>(aActionIndex); + acc->ActionDescriptionAt(index, description); + if (description.IsEmpty()) return S_FALSE; + + *aLocalizedName = + ::SysAllocStringLen(description.get(), description.Length()); + return *aLocalizedName ? S_OK : E_OUTOFMEMORY; }