[ATK] Test accessibility/insert-children-assert.html is crashing since added in r216980
[WebKit-https.git] / LayoutTests / accessibility / insert-children-assert.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="../resources/accessibility-helper.js"></script>
6 <script>
7 var successfullyParsed = false;
8 </script>
9 </head>
10 <style>
11 body {
12     font-family: ahem;
13     -webkit-font-smoothing: none;
14 }
15 </style>
16 <body id="body">
17 <div id="content" aria-label="test">
18 <summary>a<span>b<div>c</div>d</span>e</summary>
19 </div>
20
21 <p id="description"></p>
22 <div id="console"></div>
23
24 <script>
25     description("This tests that we only insert valid children when building ax tree.");
26     jsTestIsAsync = true;
27
28     if ("webkitRequestFullScreen" in Element.prototype) {
29         var content = accessibilityController.accessibleElementById("content");
30         var value;
31         if (accessibilityController.platformName == "atk")
32             value = "AXValue: ab<\\n>c<\\n>de<\\n>";
33         else
34             value = "AXValue: d";
35         document.body.offsetTop;
36         var span = document.getElementsByTagName('span')[0];
37
38         var fullscreenChangeEvent = function(event) {
39             if (document.webkitIsFullScreen) {
40                 setTimeout(function () {
41                     document.webkitCancelFullScreen();
42                 }, 0)
43             } else
44                 finishJSTest();
45             shouldBe("valueOccuranceInElementTree(content, value)", "1");
46         };
47
48         document.addEventListener('webkitfullscreenchange', fullscreenChangeEvent);
49
50         document.addEventListener('keydown', function () {
51             span.webkitRequestFullScreen();
52         });
53         
54         shouldBe("valueOccuranceInElementTree(content, value)", "1");
55         if (window.eventSender)
56             eventSender.keyDown('a');
57     
58         function valueOccuranceInElementTree(element, value) {
59             if (!element) {
60                 return 0;
61             }
62             var count = 0;
63             if (element.stringValue == value)
64                 count++;
65             var childrenCount = element.childrenCount;
66             for (var k = 0; k < childrenCount; k++)
67                 count += valueOccuranceInElementTree(element.childAtIndex(k), value);
68             return count;
69         }
70     }
71     successfullyParsed = true;
72 </script>
73 </body>
74 </html>