Title: [127367] trunk
Revision
127367
Author
[email protected]
Date
2012-09-01 01:43:04 -0700 (Sat, 01 Sep 2012)

Log Message

[Gtk] Incorrect/unexpected characters in the text of certain accessibles
https://bugs.webkit.org/show_bug.cgi?id=95180

Patch by Joanmarie Diggs <[email protected]> on 2012-09-01
Reviewed by Chris Fleizach.

Source/WebCore: 

The bug was caused by failing to properly handle anonymous block text
which had object replacement characters (multibyte) in it. Calculating
the string length based on the UTF-8 string meant that we were returning
more characters than were there and in danger of splitting a multibyte
character.

Tests: platform/gtk/accessibility/entry-and-password.html
       platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html

* accessibility/gtk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetText): Convert the text returned by textForObject()
to Unicode before calculating its length.

Source/WebKit/gtk: 

Corrected a unit test in which the expected accessible text was wrong as
a result of this bug. In particular, the AtkText inserted into an empty
text field is expected to be the same text atk_text_get_text() returns.
That was not happening -- and presumably not noticed as a result of the
hard to read textual representation of the multibyte password field
bullets.

* tests/testatk.c:
(testWebkitAtkTextChangedNotifications): Corrected the test and added a
comment so that one knows what the multibyte character is.

Tools: 

The bug that was fixed stood in the way of fully implementing stringValue().
Testing that the bug is fixed requires stringValue() to be fully implemented
and object replacement characters to be printable.

* DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
(replaceCharactersForResults): New method which turns object replacement
characters into "<obj>" so that the characters can be properly shown in
Layout Test results. Also turns "\n" into "<\\n>" so that printing the
accessible text of a single object in the accessible tree doesn't mess up
the readibility of the results.
(AccessibilityUIElement::stringValue): Remove the code that immediately
returned upon encountering an object of ATK_ROLE_PANEL and call the new
replaceCharactersForResults() prior to returning the accessible string
value.

LayoutTests: 

Two new layout tests, plus one updated one.

* platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt: Indicated replaced objects.
* platform/gtk/accessibility/entry-and-password-expected.txt: Added.
* platform/gtk/accessibility/entry-and-password.html: Added.
* platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt: Added.
* platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (127366 => 127367)


--- trunk/LayoutTests/ChangeLog	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/LayoutTests/ChangeLog	2012-09-01 08:43:04 UTC (rev 127367)
@@ -1,3 +1,18 @@
+2012-09-01  Joanmarie Diggs  <[email protected]>
+
+        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
+        https://bugs.webkit.org/show_bug.cgi?id=95180
+
+        Reviewed by Chris Fleizach.
+
+        Two new layout tests, plus one updated one.
+
+        * platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt: Indicated replaced objects.
+        * platform/gtk/accessibility/entry-and-password-expected.txt: Added.
+        * platform/gtk/accessibility/entry-and-password.html: Added.
+        * platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt: Added.
+        * platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html: Added.
+
 2012-09-01  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Add MediaStream management to RTCPeerConnection

Modified: trunk/LayoutTests/platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt (127366 => 127367)


--- trunk/LayoutTests/platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/LayoutTests/platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt	2012-09-01 08:43:04 UTC (rev 127367)
@@ -14,10 +14,10 @@
 AXRole: scroll pane 
     AXRole: document frame 
         AXRole: paragraph AXValue: Before
-        AXRole: panel 
+        AXRole: panel AXValue: <obj>
             AXRole: scroll pane 
                 AXRole: document frame 
-                    AXRole: panel 
+                    AXRole: panel AXValue: <obj>Click me
                         AXRole: push button 
         AXRole: paragraph AXValue: After
         AXRole: paragraph AXValue: End of test
@@ -26,7 +26,7 @@
 AXRole: scroll pane 
     AXRole: document frame 
         AXRole: paragraph AXValue: Before
-        AXRole: panel 
+        AXRole: panel AXValue: 
         AXRole: paragraph AXValue: After
         AXRole: paragraph AXValue: End of test
 

Added: trunk/LayoutTests/platform/gtk/accessibility/entry-and-password-expected.txt (0 => 127367)


--- trunk/LayoutTests/platform/gtk/accessibility/entry-and-password-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/accessibility/entry-and-password-expected.txt	2012-09-01 08:43:04 UTC (rev 127367)
@@ -0,0 +1,16 @@
+ 
+End of test
+AXRole: document frame 
+    AXRole: form AXValue: <obj> <obj>
+        AXRole: entry AXValue: 123
+        AXRole: password text AXValue: •••
+    AXRole: section AXValue: End of test
+This tests that the text associated with entry and password fields is correct.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/gtk/accessibility/entry-and-password.html (0 => 127367)


--- trunk/LayoutTests/platform/gtk/accessibility/entry-and-password.html	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/accessibility/entry-and-password.html	2012-09-01 08:43:04 UTC (rev 127367)
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 
+<html> 
+<head>
+<script> 
+
+    function buildAccessibilityTree(accessibilityObject, indent) {
+        var str = "";
+        for (var i = 0; i < indent; i++)
+            str += "    ";
+        str += accessibilityObject.role;
+        str += " " + accessibilityObject.stringValue;
+        str += "\n";
+        document.getElementById("tree").innerText += str;
+
+        if (accessibilityObject.stringValue.indexOf('End of test') >= 0)
+            return false;
+
+        var count = accessibilityObject.childrenCount;
+        for (var i = 0; i < count; ++i) {
+            if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), indent + 1))
+                return false;
+        }
+
+        return true;
+    }
+</script> 
+<script src="" 
+</head> 
+<body> 
+ 
+<form>
+<input type='text' name='entry' value='123' />
+<input type='password' name='passwordEntry' value='123' />
+</form>
+
+<div>End of test</div>
+
+<pre id="tree"></pre>
+ 
+<p id="description"></p> 
+<div id="console"></div> 
+ 
+<script>
+    description("This tests that the text associated with entry and password fields is correct.");
+
+    if (window.accessibilityController) {
+        // Build the accessibility tree up until 'End of test' is encountered.
+        document.body.focus();
+        buildAccessibilityTree(accessibilityController.focusedElement, 0);
+    }
+
+</script>
+<script src=""
+</body> 
+</html> 

Added: trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt (0 => 127367)


--- trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks-expected.txt	2012-09-01 08:43:04 UTC (rev 127367)
@@ -0,0 +1,40 @@
+Paragraph
+
+button
+
+
+Div
+button
+Heading
+button
+
+
+End of test
+AXRole: document frame 
+    AXRole: paragraph AXValue: Paragraph
+    AXRole: panel AXValue: <obj>button<\n>
+        AXRole: push button 
+    AXRole: panel AXValue: <obj>
+        AXRole: scroll pane 
+            AXRole: document frame 
+    AXRole: panel AXValue: <obj>text area<\n>
+        AXRole: entry AXValue: text area
+    AXRole: panel AXValue: Div<\n>
+    AXRole: panel AXValue: <obj>button<\n>
+        AXRole: push button 
+    AXRole: heading AXValue: Heading<\n><obj>button<\n><obj>
+        AXRole: panel AXValue: Heading<\n>
+        AXRole: panel AXValue: <obj>button<\n>
+            AXRole: push button 
+        AXRole: panel AXValue: <obj>
+            AXRole: image 
+    AXRole: section AXValue: End of test
+This tests that the text associated with replaced objects in an anonymous block is correct.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html (0 => 127367)


--- trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html	2012-09-01 08:43:04 UTC (rev 127367)
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 
+<html> 
+<head>
+<script> 
+
+    function buildAccessibilityTree(accessibilityObject, indent) {
+        var str = "";
+        for (var i = 0; i < indent; i++)
+            str += "    ";
+        str += accessibilityObject.role;
+        str += " " + accessibilityObject.stringValue;
+        str += "\n";
+        document.getElementById("tree").innerText += str;
+
+        if (accessibilityObject.stringValue.indexOf('End of test') >= 0)
+            return false;
+
+        var count = accessibilityObject.childrenCount;
+        for (var i = 0; i < count; ++i) {
+            if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), indent + 1))
+                return false;
+        }
+
+        return true;
+    }
+</script> 
+<script src="" 
+</head> 
+<body> 
+ 
+<p>Paragraph</p>
+<button>button</button>
+<p></p>
+<iframe src=""
+<p></p>
+<textarea>text area</textarea>
+<div>
+Div
+<p></p>
+<button>button</button>
+</div>
+<h3>
+Heading
+<p></p>
+<button>button</button>
+<p></p>
+<img src="" alt="I should be an image" />
+</h3>
+
+<div>End of test</div>
+
+<pre id="tree"></pre>
+ 
+<p id="description"></p> 
+<div id="console"></div> 
+ 
+<script>
+    description("This tests that the text associated with replaced objects in an anonymous block is correct.");
+
+    if (window.accessibilityController) {
+        // Build the accessibility tree up until 'End of test' is encountered.
+        document.body.focus();
+        buildAccessibilityTree(accessibilityController.focusedElement, 0);
+    }
+
+</script>
+<script src=""
+</body> 
+</html> 

Modified: trunk/Source/WebCore/ChangeLog (127366 => 127367)


--- trunk/Source/WebCore/ChangeLog	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Source/WebCore/ChangeLog	2012-09-01 08:43:04 UTC (rev 127367)
@@ -1,3 +1,23 @@
+2012-09-01  Joanmarie Diggs  <[email protected]>
+
+        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
+        https://bugs.webkit.org/show_bug.cgi?id=95180
+
+        Reviewed by Chris Fleizach.
+
+        The bug was caused by failing to properly handle anonymous block text
+        which had object replacement characters (multibyte) in it. Calculating
+        the string length based on the UTF-8 string meant that we were returning
+        more characters than were there and in danger of splitting a multibyte
+        character.
+
+        Tests: platform/gtk/accessibility/entry-and-password.html
+               platform/gtk/accessibility/replaced-objects-in-anonymous-blocks.html
+
+        * accessibility/gtk/WebKitAccessibleInterfaceText.cpp:
+        (webkitAccessibleTextGetText): Convert the text returned by textForObject()
+        to Unicode before calculating its length.
+
 2012-09-01  Adam Barth  <[email protected]>
 
         Remove all-but-one use of WTF::String::operator+= from WebCore

Modified: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceText.cpp (127366 => 127367)


--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceText.cpp	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceText.cpp	2012-09-01 08:43:04 UTC (rev 127367)
@@ -537,7 +537,9 @@
 
     if (!ret.length()) {
         // This can happen at least with anonymous RenderBlocks (e.g. body text amongst paragraphs)
-        ret = String(textForObject(coreObject));
+        // In such instances, there may also be embedded objects. The object replacement character
+        // is something ATs want included and we have to account for the fact that it is multibyte.
+        ret = String::fromUTF8(textForObject(coreObject));
         if (!end)
             end = ret.length();
     }

Modified: trunk/Source/WebKit/gtk/ChangeLog (127366 => 127367)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-09-01 08:43:04 UTC (rev 127367)
@@ -1,3 +1,21 @@
+2012-09-01  Joanmarie Diggs  <[email protected]>
+
+        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
+        https://bugs.webkit.org/show_bug.cgi?id=95180
+
+        Reviewed by Chris Fleizach.
+
+        Corrected a unit test in which the expected accessible text was wrong as
+        a result of this bug. In particular, the AtkText inserted into an empty
+        text field is expected to be the same text atk_text_get_text() returns.
+        That was not happening -- and presumably not noticed as a result of the
+        hard to read textual representation of the multibyte password field
+        bullets.
+
+        * tests/testatk.c:
+        (testWebkitAtkTextChangedNotifications): Corrected the test and added a
+        comment so that one knows what the multibyte character is.
+
 2012-08-31  José Dapena Paz  <[email protected]>
 
         [GTK] Assert on ChromeClientGtk::scroll with delta (0, -1).

Modified: trunk/Source/WebKit/gtk/tests/testatk.c (127366 => 127367)


--- trunk/Source/WebKit/gtk/tests/testatk.c	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Source/WebKit/gtk/tests/testatk.c	2012-09-01 08:43:04 UTC (rev 127367)
@@ -1867,17 +1867,18 @@
                      GINT_TO_POINTER(TEXT_CHANGE_REMOVE));
 
     pos = 0;
+    /* A single bullet character is '\342\200\242' */
     atk_editable_text_insert_text(ATK_EDITABLE_TEXT(passwordEntry), "foobar", 6, &pos);
     g_assert_cmpstr(textChangedResult, ==, "|1|0|6|'\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242'|");
     text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
-    g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242\302\200\302\242");
+    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242");
     g_free(text);
 
     atk_editable_text_delete_text(ATK_EDITABLE_TEXT(passwordEntry), 2, 4);
     g_assert_cmpstr(textChangedResult, ==, "|2|2|2|'\342\200\242\342\200\242'|");
 
     text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
-    g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242");
+    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242");
     g_free(text);
 
     pos = 3;
@@ -1885,7 +1886,7 @@
     g_assert_cmpstr(textChangedResult, ==, "|1|3|3|'\342\200\242\342\200\242\342\200\242'|");
 
     text = atk_text_get_text(ATK_TEXT(passwordEntry), 0, -1);
-    g_assert_cmpstr(text, ==, "\303\242\302\200\302\242\303\242\302\200\302\242\303\242");
+    g_assert_cmpstr(text, ==, "\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242");
     g_free(text);
 
     g_free(textChangedResult);

Modified: trunk/Tools/ChangeLog (127366 => 127367)


--- trunk/Tools/ChangeLog	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Tools/ChangeLog	2012-09-01 08:43:04 UTC (rev 127367)
@@ -1,3 +1,25 @@
+2012-09-01  Joanmarie Diggs  <[email protected]>
+
+        [Gtk] Incorrect/unexpected characters in the text of certain accessibles
+        https://bugs.webkit.org/show_bug.cgi?id=95180
+
+        Reviewed by Chris Fleizach.
+
+        The bug that was fixed stood in the way of fully implementing stringValue().
+        Testing that the bug is fixed requires stringValue() to be fully implemented
+        and object replacement characters to be printable.
+
+        * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp:
+        (replaceCharactersForResults): New method which turns object replacement
+        characters into "<obj>" so that the characters can be properly shown in
+        Layout Test results. Also turns "\n" into "<\\n>" so that printing the
+        accessible text of a single object in the accessible tree doesn't mess up
+        the readibility of the results.
+        (AccessibilityUIElement::stringValue): Remove the code that immediately
+        returned upon encountering an object of ATK_ROLE_PANEL and call the new
+        replaceCharactersForResults() prior to returning the accessible string
+        value.
+
 2012-09-01  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Add MediaStream management to RTCPeerConnection

Modified: trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp (127366 => 127367)


--- trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp	2012-09-01 08:20:01 UTC (rev 127366)
+++ trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp	2012-09-01 08:43:04 UTC (rev 127367)
@@ -34,7 +34,25 @@
 #include <wtf/Assertions.h>
 #include <wtf/gobject/GOwnPtr.h>
 #include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/unicode/CharacterNames.h>
 
+static inline gchar* replaceCharactersForResults(gchar* str)
+{
+    String uString = String::fromUTF8(str);
+
+    // The object replacement character is passed along to ATs so we need to be
+    // able to test for their presence and do so without causing test failures.
+    uString.replace(objectReplacementCharacter, "<obj>");
+
+    // The presence of newline characters in accessible text of a single object
+    // is appropriate, but it makes test results (especially the accessible tree)
+    // harder to read.
+    uString.replace("\n", "<\\n>");
+
+    return g_strdup(uString.utf8().data());
+}
+
 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
     : m_element(element)
 {
@@ -274,15 +292,8 @@
     if (!m_element || !ATK_IS_TEXT(m_element))
         return JSStringCreateWithCharacters(0, 0);
 
-    // FIXME: implement properly for ATK_ROLE_PANEL. Prior to doing so, we need
-    // to fix bug 95180 as well as determine which panels we wish to keep in the
-    // accessible hierarchy. See, for instance, bug 72811.
-    AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
-    if (role == ATK_ROLE_PANEL)
-        return JSStringCreateWithCharacters(0, 0);
-
-    gchar* text =text = atk_text_get_text(ATK_TEXT(m_element), 0, -1);
-    GOwnPtr<gchar> axValue(g_strdup_printf("AXValue: %s", text));
+    gchar* text = atk_text_get_text(ATK_TEXT(m_element), 0, -1);
+    GOwnPtr<gchar> axValue(g_strdup_printf("AXValue: %s", replaceCharactersForResults(text)));
     g_free(text);
 
     return JSStringCreateWithUTF8CString(axValue.get());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to