Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / selectors / style-sharing-children-prevent-sharing.html
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <style>
4 .root + #lastChildRules {
5     color: red;
6 }
7 </style>
8
9 <div id="y" class="root">
10     <div></div>
11 </div>
12
13 <div id="x" class="root">
14     <div></div>
15 </div>
16
17 <script>
18 description("Test dynamic changes to the childrenSupportStyleSharing flag.");
19
20 var x = document.getElementById("x");
21 var y = document.getElementById("y");
22
23 // Attach the whole tree, this makes x and y share, and the children of x and y share.
24 document.body.offsetTop;
25
26 // Add a child that make us match sibling rules. This will set the ChildrenAffectedByDirectAdjacentRules
27 // flag on #x preventing its children from sharing in the future.
28 var lastChildRules = x.appendChild(document.createElement("div"));
29 lastChildRules.id = "lastChildRules";
30 x.appendChild(document.createElement("div"));
31
32 // Add a new child to #y. Normally it could share with children of #x since both #x and #y share,
33 // but now #x has children affected by RestyleFlags so they can no longer share.
34 // FIXME: This element could technically share with the other <div> inside #y, but recalcStyle
35 // goes from lastChild -> firstChild so we haven't added the firstChild (which doesn't need a recalc)
36 // to the candidate list yet.
37 y.appendChild(document.createElement("div"));
38
39 document.body.offsetTop;
40
41 if (window.internals) {
42     shouldBeTrue("internals.isSharingStyle(x, y)");
43     shouldBeTrue("internals.isSharingStyle(x.firstElementChild, y.firstElementChild)");
44     shouldBeFalse("internals.isSharingStyle(x.firstElementChild, y.firstElementChild.nextElementSibling)");
45     shouldBeFalse("internals.isSharingStyle(lastChildRules, x.firstElementChild)");
46     shouldBeFalse("internals.isSharingStyle(lastChildRules, y.firstElementChild)");
47
48     // FIXME: We should see if we can look at direct siblings somehow since these elements do
49     // match the same rules at the same depth, recalcStyle is just in the wrong order to allow
50     // them to share.
51     shouldBeFalse("internals.isSharingStyle(y.firstElementChild, y.firstElementChild.nextElementSibling)");
52 }
53 </script>