[Modern Media Controls] Controls bar may disappear while captions menu is visible
[WebKit-https.git] / LayoutTests / media / modern-media-controls / layout-node / children.html
1 <script src="../../../resources/js-test-pre.js"></script>
2 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/scheduler.js" type="text/javascript"></script>
3 <script src="../../../../Source/WebCore/Modules/modern-media-controls/controls/layout-node.js" type="text/javascript"></script>
4 <script src="../resources/media-controls-utils.js" type="text/javascript"></script>
5 <script type="text/javascript">
6
7 description("Testing the <code>LayoutNode.children</code> property.");
8
9 window.jsTestIsAsync = true;
10
11 const node = new LayoutNode;
12
13 debug("Check default state");
14 shouldBeTrue("Array.isArray(node.children)");
15 shouldBeTrue("node.children.length === 0");
16
17 const a = new LayoutNode;
18 const b = new LayoutNode;
19 const c = new LayoutNode;
20
21 const children = [a, b, c];
22 node.children = children;
23
24 debug("");
25 debug("Set children to [a, b, c]");
26 shouldBeTrue("node.children.length === 3");
27 shouldBeTrue("node.children[0] === a");
28 shouldBeTrue("node.children[1] === b");
29 shouldBeTrue("node.children[2] === c");
30 shouldBeTrue("node.children !== children");
31
32 let numberOfFrames = 0;
33 scheduler.frameDidFire = function()
34 {
35     debug("");
36     debug("Layout was performed");
37
38     switch (++numberOfFrames) {
39     case 1:
40         shouldBeTrue("node.element.childElementCount === 3");
41         shouldBeTrue("node.element.firstElementChild === a.element");
42         shouldBeTrue("node.element.firstElementChild.nextElementSibling === b.element");
43         shouldBeTrue("node.element.lastElementChild === c.element");
44         debug("");
45         debug("Set children to [b, a]");
46         node.children = [b, a];
47         shouldBeTrue("node.children.length === 2");
48         shouldBeTrue("node.children[0] === b");
49         shouldBeTrue("node.children[1] === a");
50         break;
51     case 2:
52         shouldBeTrue("node.element.childElementCount === 2");
53         shouldBeTrue("node.element.firstElementChild === b.element");
54         shouldBeTrue("node.element.lastElementChild === a.element");
55         debug("");
56         debug("Set children to []");
57         node.children = [];
58         shouldBeTrue("node.children.length === 0");
59         break;
60     case 3:
61         shouldBeTrue("node.element.childElementCount === 0");
62         finishMediaControlsTest();
63         break;
64     }
65 };
66
67 </script>
68 <script src="../../../resources/js-test-post.js"></script>