Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: LayoutTests/accessibility/legend.html

Issue 876003003: Extract buildAccessibilityTree() from the individual layout test. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated some tests and added rolesToIgnore param to helper function. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script>
5
6 function buildAccessibilityTree(accessibilityObject, indent, targetObject, t argetString) {
7 var str = "";
8 for (var i = 0; i < indent; i++)
9 str += " ";
10 str += accessibilityObject.role;
11 str += " " + accessibilityObject.stringValue;
12 if (targetObject && accessibilityObject.isEqual(targetObject))
13 str += " " + targetString;
14 str += "\n";
15 document.getElementById("tree").innerText += str;
16
17 if (accessibilityObject.stringValue.indexOf('End of test') >= 0)
18 return false;
19
20 var count = accessibilityObject.childrenCount;
21 for (var i = 0; i < count; ++i) {
22 if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), ind ent + 1, targetObject, targetString))
23 return false;
24 }
25
26 return true;
27 }
28 </script>
29 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script src="../resources/accessibility-helper.js"></script>
30 </head> 6 </head>
31 <body id="body"> 7 <body id="body">
32 8
33 <fieldset> 9 <fieldset>
34 <legend>Choose a shipping method:</legend> 10 <legend>Choose a shipping method:</legend>
35 <input id="overnight" type="radio" name="shipping" value="overnight" />Overn ight 11 <input id="overnight" type="radio" name="shipping" value="overnight" />Overn ight
36 </fieldset> 12 </fieldset>
37 13
38 <div>End of test</div> 14 <div>End of test</div>
39 15
40 <p id="description"></p> 16 <p id="description"></p>
41 <pre id="tree"></pre>
42 <div id="console"></div> 17 <div id="console"></div>
43 18
44 <script> 19 <script>
45 20
46 description("This tests that a fieldset's title ui element is the legend."); 21 description("This tests that a fieldset's title ui element is the legend.");
47 22
48 if (window.accessibilityController) { 23 if (window.accessibilityController) {
49 document.body.focus(); 24 document.body.focus();
50 var body = accessibilityController.focusedElement; 25 var body = accessibilityController.focusedElement;
51 var fieldset = body.childAtIndex(0); 26 var fieldset = body.childAtIndex(0);
52 var titleUIElement = fieldset.titleUIElement(); 27 var titleUIElement = fieldset.titleUIElement();
53 28
54 // Print out the tree of accessible objects, indicating the titleUIEleme nt so 29 // Print out the tree of accessible objects, indicating the titleUIEleme nt so
55 // that each platform can verify their expected object has been found 30 // that each platform can verify their expected object has been found
56 buildAccessibilityTree(body, 0, titleUIElement, "<< fieldset's titleUIEl ement"); 31 buildAccessibilityTree(body, 0, 0, 0, titleUIElement, "<< fieldset's tit leUIElement");
57 32
58 // Verify that we have gotten the titleUIElement and it has the expected text, 33 // Verify that we have gotten the titleUIElement and it has the expected text,
59 // which should be in the last descendant regardless of platform. 34 // which should be in the last descendant regardless of platform.
60 shouldBeTrue("titleUIElement != null"); 35 shouldBeTrue("titleUIElement != null");
61 var titleUIElementText = titleUIElement; 36 var titleUIElementText = titleUIElement;
62 while (titleUIElementText && titleUIElementText.childrenCount) 37 while (titleUIElementText && titleUIElementText.childrenCount)
63 titleUIElementText = titleUIElementText.childAtIndex(0); 38 titleUIElementText = titleUIElementText.childAtIndex(0);
64 39
65 shouldBe("titleUIElementText.stringValue", "'AXValue: Choose a shipping method:'"); 40 shouldBe("titleUIElementText.stringValue", "'AXValue: Choose a shipping method:'");
66 } 41 }
67 </script> 42 </script>
68 43
69 </body> 44 </body>
70 </html> 45 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698