[orca/gnome-3-14] Try to handle the destruction of the focused element in Gecko content



commit 93cbe9d40c6c54d8c57f5bc60b0a71706ff0aee2
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Sep 15 11:51:04 2014 -0400

    Try to handle the destruction of the focused element in Gecko content
    
    Certain Web Dev practices, such as a:focus{position:relative;}, cause
    Gecko to kill the accessible object that we just moved to and create
    a new object to replace it. If we don't catch this, navigation breaks
    because the proverbial rug has just been pulled out from under us. :(

 src/orca/script_utilities.py                       |   10 ++++
 src/orca/scripts/toolkits/Gecko/script.py          |    8 +++
 test/html/link-position-relative-on-focus.html     |   12 ++++
 ...line_nav_link_position_relative_on_focus.params |    1 +
 .../line_nav_link_position_relative_on_focus.py    |   51 ++++++++++++++++++
 test/keystrokes/firefox/line_nav_slash_test.py     |   54 ++++++--------------
 6 files changed, 98 insertions(+), 38 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 392daf8..a6b7382 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -883,6 +883,16 @@ class Utilities:
             if (obj1.name != obj2.name) or (obj1.getRole() != obj2.getRole()):
                 return False
             else:
+                # If one of the objects was destroyed, the last index may be -1.
+                # In addition, the extents likely will be zeroed out so the next
+                # tests will fail. But if the rest of the path is the same and
+                # the names are the same and the roles are the same, let's cross
+                # our fingers and call them the same.
+                path1 = pyatspi.utils.getPath(obj1)
+                path2 = pyatspi.utils.getPath(obj2)
+                if path1[0:-1] == path2[0:-1] and obj1.name == obj2.name != "":
+                    return True
+
                 # Comparing the extents of objects which claim to be different
                 # addresses both managed descendants and implementations which
                 # recreate accessibles for the same widget.
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 718e4d1..038b6b0 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -1082,6 +1082,14 @@ class Script(default.Script):
         if not event.type.startswith("object:children-changed:add"):
             return
 
+        # Certain Web Dev practices, such as a:focus{position:relative;}, cause
+        # Gecko to kill the accessible object that we just moved to and create
+        # a new object to replace it. If we don't catch this, navigation breaks
+        # because the proverbial rug has just been pulled out from under us. :(
+        obj, offset = self.getCaretContext()
+        if self.utilities.isSameObject(event.any_data, obj):
+            self.setCaretContext(event.any_data, offset)
+
         if self.handleAsLiveRegion(event):
             self.liveMngr.handleEvent(event)
             return
diff --git a/test/html/link-position-relative-on-focus.html b/test/html/link-position-relative-on-focus.html
new file mode 100644
index 0000000..013a792
--- /dev/null
+++ b/test/html/link-position-relative-on-focus.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<style>
+a:focus{position:relative;}
+</style>
+</head>
+<body>
+<p>Line 1</p>
+<a href="foo">Line 2</a>
+<p>Line 3</p>
+</body>
+</html>
diff --git a/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.params 
b/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.params
new file mode 100644
index 0000000..04dbfc3
--- /dev/null
+++ b/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.params
@@ -0,0 +1 @@
+PARAMS=$TEST_DIR/../../html/link-position-relative-on-focus.html
diff --git a/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.py 
b/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.py
new file mode 100644
index 0000000..76c3575
--- /dev/null
+++ b/test/keystrokes/firefox/line_nav_link_position_relative_on_focus.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+from macaroon.playback import *
+import utils
+
+sequence = MacroSequence()
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("<Control>Home"))
+sequence.append(utils.AssertPresentationAction(
+    "1. Top of file",
+    ["BRAILLE LINE:  'Line 1'",
+     "     VISIBLE:  'Line 1', cursor=1",
+     "SPEECH OUTPUT: 'Line 1'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "2. Line Down",
+    ["BRAILLE LINE:  'Line 2'",
+     "     VISIBLE:  'Line 2', cursor=1",
+     "SPEECH OUTPUT: 'Line 2'",
+     "SPEECH OUTPUT: 'link'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Down"))
+sequence.append(utils.AssertPresentationAction(
+    "3. Line Down",
+    ["BRAILLE LINE:  'Line 3'",
+     "     VISIBLE:  'Line 3', cursor=1",
+     "SPEECH OUTPUT: 'Line 3'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Up"))
+sequence.append(utils.AssertPresentationAction(
+    "4. Line Up",
+    ["BRAILLE LINE:  'Line 2'",
+     "     VISIBLE:  'Line 2', cursor=1",
+     "SPEECH OUTPUT: 'Line 2'",
+     "SPEECH OUTPUT: 'link'"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Up"))
+sequence.append(utils.AssertPresentationAction(
+    "5. Line Up",
+    ["BRAILLE LINE:  'Line 1'",
+     "     VISIBLE:  'Line 1', cursor=1",
+     "SPEECH OUTPUT: 'Line 1'"]))
+
+sequence.append(utils.AssertionSummaryAction())
+sequence.start()
diff --git a/test/keystrokes/firefox/line_nav_slash_test.py b/test/keystrokes/firefox/line_nav_slash_test.py
index ac63aaf..d897459 100644
--- a/test/keystrokes/firefox/line_nav_slash_test.py
+++ b/test/keystrokes/firefox/line_nav_slash_test.py
@@ -39,17 +39,6 @@ sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
     "4. Line Down",
-    ["KNOWN ISSUE: 'We are landing here twice",
-     "BRAILLE LINE:  'Science h4'",
-     "     VISIBLE:  'Science h4', cursor=1",
-     "SPEECH OUTPUT: 'Science'",
-     "SPEECH OUTPUT: 'link'",
-     "SPEECH OUTPUT: 'heading level 4'"]))
-
-sequence.append(utils.StartRecordingAction())
-sequence.append(KeyComboAction("Down"))
-sequence.append(utils.AssertPresentationAction(
-    "5. Line Down",
     ["BRAILLE LINE:  'Recent Tags h4'",
      "     VISIBLE:  'Recent Tags h4', cursor=1",
      "SPEECH OUTPUT: 'Recent Tags'",
@@ -59,18 +48,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "6. Line Down",
-    ["KNOWN ISSUE: 'We are landing here twice",
-     "BRAILLE LINE:  'Recent Tags h4'",
-     "     VISIBLE:  'Recent Tags h4', cursor=1",
-     "SPEECH OUTPUT: 'Recent Tags'",
-     "SPEECH OUTPUT: 'link'",
-     "SPEECH OUTPUT: 'heading level 4'"]))
-
-sequence.append(utils.StartRecordingAction())
-sequence.append(KeyComboAction("Down"))
-sequence.append(utils.AssertPresentationAction(
-    "7. Line Down",
+    "5. Line Down",
     ["BRAILLE LINE:  'Slashdot Login h4'",
      "     VISIBLE:  'Slashdot Login h4', cursor=1",
      "SPEECH OUTPUT: 'Slashdot Login heading level 4'"]))
@@ -78,7 +56,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "8. Line Down",
+    "6. Line Down",
     ["BRAILLE LINE:  'Nickname $l Password $l Log in push button'",
      "     VISIBLE:  'Nickname $l Password $l Log in p', cursor=1",
      "SPEECH OUTPUT: 'Nickname'",
@@ -90,7 +68,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "9. Line Down",
+    "7. Line Down",
     ["BRAILLE LINE:  'Some Poll h4'",
      "     VISIBLE:  'Some Poll h4', cursor=1",
      "SPEECH OUTPUT: 'Some Poll heading level 4'"]))
@@ -98,7 +76,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "10. Line Down",
+    "8. Line Down",
     ["BRAILLE LINE:  'What is your favorite poison?'",
      "     VISIBLE:  'What is your favorite poison?', cursor=1",
      "SPEECH OUTPUT: 'What is your favorite poison?"]))
@@ -106,7 +84,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "11. Line Down",
+    "9. Line Down",
     ["BRAILLE LINE:  '& y radio button Some polls'",
      "     VISIBLE:  '& y radio button Some polls', cursor=1",
      "SPEECH OUTPUT: 'not selected radio button'",
@@ -115,7 +93,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Down"))
 sequence.append(utils.AssertPresentationAction(
-    "12. Line Down",
+    "10. Line Down",
     ["BRAILLE LINE:  'Book Reviews h4'",
      "     VISIBLE:  'Book Reviews h4', cursor=1",
      "SPEECH OUTPUT: 'Book Reviews'",
@@ -125,7 +103,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "13. Line Up",
+    "11. Line Up",
     ["BRAILLE LINE:  '& y radio button Some polls'",
      "     VISIBLE:  '& y radio button Some polls', cursor=1",
      "SPEECH OUTPUT: 'not selected radio button'",
@@ -134,7 +112,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "14. Line Up",
+    "12. Line Up",
     ["BRAILLE LINE:  'What is your favorite poison?'",
      "     VISIBLE:  'What is your favorite poison?', cursor=1",
      "SPEECH OUTPUT: 'What is your favorite poison?"]))
@@ -142,7 +120,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "15. Line Up",
+    "13. Line Up",
     ["BRAILLE LINE:  'Some Poll h4'",
      "     VISIBLE:  'Some Poll h4', cursor=1",
      "SPEECH OUTPUT: 'Some Poll heading level 4'"]))
@@ -150,7 +128,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "16. Line Up",
+    "14. Line Up",
     ["BRAILLE LINE:  'Nickname $l Password $l Log in push button'",
      "     VISIBLE:  'Nickname $l Password $l Log in p', cursor=1",
      "SPEECH OUTPUT: 'Nickname'",
@@ -162,7 +140,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "17. Line Up",
+    "15. Line Up",
     ["BRAILLE LINE:  'Slashdot Login h4'",
      "     VISIBLE:  'Slashdot Login h4', cursor=1",
      "SPEECH OUTPUT: 'Slashdot Login heading level 4'"]))
@@ -170,7 +148,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "18. Line Up",
+    "16. Line Up",
     ["BRAILLE LINE:  'Recent Tags h4'",
      "     VISIBLE:  'Recent Tags h4', cursor=1",
      "SPEECH OUTPUT: 'Recent Tags'",
@@ -180,7 +158,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "19. Line Up",
+    "17. Line Up",
     ["BRAILLE LINE:  'Science h4'",
      "     VISIBLE:  'Science h4', cursor=1",
      "SPEECH OUTPUT: 'Science'",
@@ -190,7 +168,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "20. Line Up",
+    "18. Line Up",
     ["BRAILLE LINE:  'Services h4'",
      "     VISIBLE:  'Services h4', cursor=1",
      "SPEECH OUTPUT: 'Services heading level 4'"]))
@@ -198,7 +176,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "21. Line Up",
+    "19. Line Up",
     ["BRAILLE LINE:  'About h4'",
      "     VISIBLE:  'About h4', cursor=1",
      "SPEECH OUTPUT: 'About heading level 4'"]))
@@ -206,7 +184,7 @@ sequence.append(utils.AssertPresentationAction(
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("Up"))
 sequence.append(utils.AssertPresentationAction(
-    "22. Line Up",
+    "20. Line Up",
     ["BRAILLE LINE:  'Stories h4'",
      "     VISIBLE:  'Stories h4', cursor=1",
      "SPEECH OUTPUT: 'Stories heading level 4'"]))


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