Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion source/braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):
):
return None

description = None
if config.conf["presentation"]["reportObjectDescriptions"]:
description = field.get("description", None)
states = field.get("states", set())
value=field.get('value',None)
current = field.get('current', controlTypes.IsCurrent.NO)
Expand All @@ -676,6 +679,8 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):

if presCat == field.PRESCAT_LAYOUT:
text = []
if description:
text.append(getPropertiesBraille(description=description))
if current:
text.append(getPropertiesBraille(current=current))
if role == controlTypes.ROLE_GRAPHIC and content:
Expand All @@ -694,6 +699,7 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):
"columnSpan": field.get("table-columnsspanned"),
"includeTableCellCoords": reportTableCellCoords,
"current": current,
"description": description,
}
if reportTableHeaders:
props["columnHeaderText"] = field.get("table-columnheadertext")
Expand All @@ -708,7 +714,8 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):
"value": value,
"current": current,
"placeholder": placeholder,
"roleText": roleText
"roleText": roleText,
"description": description,
}
if field.get('alwaysReportName', False):
# Ensure that the name of the field gets presented even if normally it wouldn't.
Expand Down
3 changes: 2 additions & 1 deletion source/compoundDocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _get_pointAtStart(self):
def _isObjectEditableText(self, obj):
return obj.role in (controlTypes.ROLE_PARAGRAPH, controlTypes.ROLE_EDITABLETEXT)

def _getControlFieldForObject(self, obj, ignoreEditableText=True):
def _getControlFieldForObject(self, obj: NVDAObject, ignoreEditableText=True):
if ignoreEditableText and self._isObjectEditableText(obj):
# This is basically just a text node.
return None
Expand All @@ -140,6 +140,7 @@ def _getControlFieldForObject(self, obj, ignoreEditableText=True):
field = textInfos.ControlField()
field["role"] = role
field['roleText'] = obj.roleText
field['description'] = obj.description
# The user doesn't care about certain states, as they are obvious.
states.discard(controlTypes.STATE_EDITABLE)
states.discard(controlTypes.STATE_MULTILINE)
Expand Down
7 changes: 3 additions & 4 deletions source/speech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,10 +1674,7 @@ def getControlFieldSpeech( # noqa: C901
isCurrent = attrs.get('current', controlTypes.IsCurrent.NO)
placeholderValue=attrs.get('placeholder', None)
value=attrs.get('value',"")
if reason == OutputReason.FOCUS or attrs.get('alwaysReportDescription', False):
description=attrs.get('description',"")
else:
description=""
description = attrs.get('description', "")
level=attrs.get('level',None)

if presCat != attrs.PRESCAT_LAYOUT:
Expand Down Expand Up @@ -1904,6 +1901,8 @@ def getControlFieldSpeech( # noqa: C901
out = []
if isCurrent != controlTypes.IsCurrent.NO:
out.extend(isCurrentSequence)
if descriptionSequence:
out.extend(descriptionSequence)
# Speak expanded / collapsed / level for treeview items (in ARIA treegrids)
if role == controlTypes.ROLE_TREEVIEWITEM:
if controlTypes.STATE_EXPANDED in states:
Expand Down
7 changes: 6 additions & 1 deletion tests/system/libraries/AssertsLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
class AssertsLib:
@staticmethod
def strings_match(actual, expected, ignore_case=False):
builtIn.log(
f"assert string matches (ignore case: {ignore_case}): '{expected}'",
level="INFO"
)
try:
builtIn.should_be_equal_as_strings(
actual,
Expand All @@ -26,6 +30,7 @@ def strings_match(actual, expected, ignore_case=False):
ignore_case,
repr(actual),
repr(expected)
)
),
level="DEBUG"
)
raise
127 changes: 127 additions & 0 deletions tests/system/robot/chromeTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,130 @@ def test_ariaCheckbox_browseMode():
actualSpeech,
"Sandwich Condiments grouping list with 4 items Lettuce check box not checked"
)


ariaDescriptionSample = """
<div>
<div
contenteditable=""
spellcheck="false"
role="textbox"
aria-multiline="true"
><p>This is a line with no annotation</p>
<p><span
aria-description="User nearby, Boaty McBoatface"
>Here is a sentence that is being edited by someone else.</span>
<b>Multiple authors can edit this document at the same time.</b></p>
<p>An element with a role, follow <a
href="www.google.com"
aria-description="opens in a new tab"
>to google's</a
> website</p>
<p>Testing the title attribute, <a
href="www.google.com"
title="conduct a search"
>to google's</a
> website</p>
</div>
</div>
"""


def test_ariaDescription_focusMode():
""" Ensure aria description is read in focus mode.
"""
_chrome.prepareChrome(ariaDescriptionSample)
# Focus the contenteditable and automatically switch to focus mode (due to contenteditable)
actualSpeech = _chrome.getSpeechAfterKey("tab")
_asserts.strings_match(
actualSpeech,
"edit multi line This is a line with no annotation\nFocus mode"
)

annotation = "User nearby, Boaty Mc Boatface"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"{annotation} Here is a sentence that is being edited by someone else."
" Multiple authors can edit this document at the same time."
)
linkAnnotation = "opens in a new tab"
linkRole = "link"
linkName = "to google's"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"An element with a role, follow {linkRole} {linkAnnotation} {linkName} website"
)
linkTitle = "conduct a search"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"Testing the title attribute, {linkRole} {linkTitle} {linkName} website"
)


def test_ariaDescription_browseMode():
""" Ensure aria description is read in browse mode.
"""
_chrome.prepareChrome(ariaDescriptionSample)
actualSpeech = _chrome.getSpeechAfterKey("downArrow")
_asserts.strings_match(
actualSpeech,
"edit multi line This is a line with no annotation"
)

annotation = "User nearby, Boaty Mc Boatface"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"{annotation} Here is a sentence that is being edited by someone else."
" Multiple authors can edit this document at"
)
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
"the same time."
)
linkAnnotation = "opens in a new tab"
linkRole = "link"
linkName = "to google's"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"An element with a role, follow {linkRole} {linkAnnotation} {linkName} website"
)

linkTitle = "conduct a search"
actualSpeech = _chrome.getSpeechAfterKey('downArrow')
_asserts.strings_match(
actualSpeech,
f"Testing the title attribute, {linkRole} {linkTitle} {linkName} website"
)


def test_ariaDescription_sayAll():
""" Ensure aria description is read by say all.
"""
_chrome.prepareChrome(ariaDescriptionSample)
actualSpeech = _chrome.getSpeechAfterKey("NVDA+downArrow")

annotation = "User nearby, Boaty Mc Boatface"
linkAnnotation = "opens in a new tab"
linkRole = "link"
linkName = "to google's"
linkTitle = "conduct a search"
_asserts.strings_match(
actualSpeech,
"\n".join([
"Before Test Case Marker",
"edit multi line This is a line with no annotation",
f"{annotation} Here is a sentence that is being edited by someone else.",
"Multiple authors can edit this document at the same time.",
"An element with a role, " # no comma, concat these two long strings.
f"follow {linkRole} {linkAnnotation} {linkName} website",
f"Testing the title attribute, {linkRole} {linkTitle} {linkName} website"
" out of edit",
"After Test Case Marker"
])
)
9 changes: 9 additions & 0 deletions tests/system/robot/chromeTests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ ARIA checkbox
[Documentation] Navigate to an unchecked checkbox in reading mode.
[Tags] aria-at
test_ariaCheckbox_browseMode
ARIA description Focus Mode
[Documentation] Navigate to a span with aria-description in focus mode
test_ariaDescription_focusMode
ARIA description Browse Mode
[Documentation] Navigate to a span with aria-description in browse mode
test_ariaDescription_browseMode
ARIA description Say All
[Documentation] Say all, contents includes aria-description
test_ariaDescription_sayAll