[orca] Prefer name over label when generating labelOrName for web content



commit 87abaf8c780fe3d399a1d1538caa5be7c977e647
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Sep 21 20:29:47 2015 -0400

    Prefer name over label when generating labelOrName for web content
    
    This makes us more compliant with the W3C name computation specification.

 src/orca/scripts/web/braille_generator.py          |    3 ++
 src/orca/scripts/web/speech_generator.py           |    3 ++
 test/html/radio-with-label-and-name.html           |   21 +++++++++++
 ...ocus_tracking_radios_with_label_and_name.params |    1 +
 .../focus_tracking_radios_with_label_and_name.py   |   38 ++++++++++++++++++++
 5 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/web/braille_generator.py b/src/orca/scripts/web/braille_generator.py
index 690d0a3..952e76d 100644
--- a/src/orca/scripts/web/braille_generator.py
+++ b/src/orca/scripts/web/braille_generator.py
@@ -105,6 +105,9 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
         if self._script.utilities.isTextBlockElement(obj):
             return []
 
+        if self._script.utilities.inDocumentContent(obj) and obj.name:
+            return self._generateName(obj, **args)
+
         return super()._generateLabelOrName(obj, **args)
 
     def _generateLabel(self, obj, **args):
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index e55d676..26645a5 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -142,6 +142,9 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         if self._script.utilities.isTextBlockElement(obj):
             return []
 
+        if self._script.utilities.inDocumentContent(obj) and obj.name:
+            return self._generateName(obj, **args)
+
         return super()._generateLabelOrName(obj, **args)
 
     def _generateLabel(self, obj, **args):
diff --git a/test/html/radio-with-label-and-name.html b/test/html/radio-with-label-and-name.html
new file mode 100644
index 0000000..29f6607
--- /dev/null
+++ b/test/html/radio-with-label-and-name.html
@@ -0,0 +1,21 @@
+<html>
+<head></head>
+<body>
+<div>Start</div>
+<div>
+    <label>
+        <span><input role="radio" aria-label="yes" type="radio"></span>
+        <span>yes</span>
+    </label>
+    <label>
+        <span><input role="radio" aria-label="well, maybe..." type="radio"></span>
+        <span>no</span>
+    </label>
+    <div>
+        <span id="yeap">Yes</span><input type="radio" aria-labelledby="yeap" aria-label="no way" id="r1">
+        <label for="r1">green</label>
+    </div>
+</div>
+<div>End</div>
+</body>
+</html>
diff --git a/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.params 
b/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.params
new file mode 100644
index 0000000..ca842fb
--- /dev/null
+++ b/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.params
@@ -0,0 +1 @@
+PARAMS=$TEST_DIR/../../html/radio-with-label-and-name.html
diff --git a/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.py 
b/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.py
new file mode 100644
index 0000000..56a8696
--- /dev/null
+++ b/test/keystrokes/firefox/focus_tracking_radios_with_label_and_name.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+from macaroon.playback import *
+import utils
+
+sequence = MacroSequence()
+
+sequence.append(KeyComboAction("<Control>Home"))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(utils.AssertPresentationAction(
+    "1. Tab to next radio button",
+    ["BRAILLE LINE:  '& y yes radio button'",
+     "     VISIBLE:  '& y yes radio button', cursor=1",
+     "SPEECH OUTPUT: 'yes.'",
+     "SPEECH OUTPUT: 'not selected radio button'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(utils.AssertPresentationAction(
+    "2. Tab to next radio button",
+    ["BRAILLE LINE:  '& y well, maybe... radio button'",
+     "     VISIBLE:  '& y well, maybe... radio button', cursor=1",
+     "SPEECH OUTPUT: 'well, maybe...'",
+     "SPEECH OUTPUT: 'not selected radio button'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(utils.AssertPresentationAction(
+    "3. Tab to next radio button",
+    ["BRAILLE LINE:  '& y Yes radio button'",
+     "     VISIBLE:  '& y Yes radio button', cursor=1",
+     "SPEECH OUTPUT: 'Yes.'",
+     "SPEECH OUTPUT: 'not selected radio button'"]))
+
+sequence.append(utils.AssertionSummaryAction())
+sequence.start()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]