OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../resources/accessibility-helper.js"></script> |
5 </head> | 6 </head> |
6 <body> | 7 <body> |
7 | 8 |
8 <div id="textbox" contentEditable="true">First<p>Second</p></div> | 9 <div id="textbox" contentEditable="true">First<p>Second</p></div> |
9 | 10 |
10 <div id="console"></div> | 11 <div id="console"></div> |
11 <script> | 12 <script> |
12 description("This test ensures that moving the cursor in a contentEditable sends
a selected text change notification, and typing in a contentEditable sends both
a value changed and selected text changed notification - both on the root eleme
nt that's marked as contentEditable."); | 13 description("This test ensures that moving the cursor in a contentEditable sends
a selected text change notification, and typing in a contentEditable sends both
a value changed and selected text changed notification - both on the root eleme
nt that's marked as contentEditable."); |
13 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
14 | 15 |
15 if (window.testRunner && window.accessibilityController) { | 16 if (window.testRunner && window.accessibilityController) { |
16 testRunner.dumpAsText(); | 17 testRunner.dumpAsText(); |
17 | 18 |
| 19 // Ensure entire a11y tree has already been seen. |
| 20 traverseAccessibilityTree(accessibilityController.rootElement); |
| 21 |
18 // Focus the contenteditable text box and move the cursor to the end. | 22 // Focus the contenteditable text box and move the cursor to the end. |
19 var textbox = document.getElementById("textbox"); | 23 var textbox = document.getElementById("textbox"); |
20 textbox.focus(); | 24 textbox.focus(); |
21 eventSender.keyDown("ArrowDown", []); | 25 eventSender.keyDown("ArrowDown", []); |
22 eventSender.keyDown("ArrowDown", []); | 26 eventSender.keyDown("ArrowDown", []); |
23 | 27 |
24 var axTextBox = accessibilityController.focusedElement; | 28 var axTextBox = accessibilityController.focusedElement; |
25 | 29 |
26 var valueChangedCount = 0; | 30 var valueChangedCount = 0; |
27 var selectedTextChangedCount = 0; | 31 var selectedTextChangedCount = 0; |
28 | 32 |
29 // Defer the main part of the test so that the notification listener | 33 // Defer the main part of the test so that the notification listener |
30 // doesn't catch any notifications still in the queue from loading the | 34 // doesn't catch any notifications still in the queue from loading the |
31 // page and initially setting focus. | 35 // page and initially setting focus. |
32 window.setTimeout(function() { | 36 window.setTimeout(function() { |
33 axTextBox.addNotificationListener(function(notification) { | 37 axTextBox.addNotificationListener(function(notification) { |
34 testPassed("Got notification: " + notification); | 38 testPassed("Got notification: " + notification); |
35 | 39 |
36 if (notification == "ValueChanged") | 40 if (notification == "ValueChanged") |
37 valueChangedCount++; | 41 valueChangedCount++; |
38 else if (notification == "SelectedTextChanged") | 42 else if (notification == "SelectedTextChanged") |
39 selectedTextChangedCount++; | 43 selectedTextChangedCount++; |
40 | 44 |
41 if (valueChangedCount == 8 && selectedTextChangedCount == 6) { | 45 if (valueChangedCount >= 8 && selectedTextChangedCount >= 4) { |
42 textbox.style.display = "none"; | 46 textbox.style.display = "none"; |
43 finishJSTest(); | 47 finishJSTest(); |
44 } | 48 } |
45 }); | 49 }); |
46 | 50 |
47 eventSender.keyDown("ArrowLeft", []); | 51 eventSender.keyDown("ArrowLeft", []); |
48 eventSender.keyDown("ArrowLeft", []); | 52 eventSender.keyDown("ArrowLeft", []); |
49 eventSender.keyDown("w", []); | 53 eventSender.keyDown("w", []); |
50 eventSender.keyDown("x", []); | 54 eventSender.keyDown("x", []); |
51 eventSender.keyDown("y", []); | 55 eventSender.keyDown("y", []); |
52 eventSender.keyDown("z", []); | 56 eventSender.keyDown("z", []); |
53 | 57 |
54 }, 0); | 58 }, 0); |
55 } | 59 } |
56 | 60 |
57 </script> | 61 </script> |
58 | 62 |
59 </body> | 63 </body> |
60 </html> | 64 </html> |
OLD | NEW |