| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test.js"></script> |
| </head> |
| <body> |
| <pre id="console"> |
| This tests the correctness of includers of forwarded children. |
| Note that this test needs internals object thus cannot run outside DRT. |
| </pre> |
| <div id="container"></div> |
| <script> |
| function includerFor(element) { |
| var insertionPoints = element.getDestinationInsertionPoints(); |
| if (insertionPoints.length == 0) |
| return null; |
| return insertionPoints.item(insertionPoints.length - 1); |
| } |
| var container = document.getElementById("container"); |
| |
| var shadowRoot = null; |
| |
| var elementWithoutShadow = document.createElement("div"); |
| container.appendChild(elementWithoutShadow); |
| var childOfElementWithoutShadow = document.createElement("span"); |
| elementWithoutShadow.appendChild(childOfElementWithoutShadow); |
| container.offsetLeft; |
| shouldBe("includerFor(childOfElementWithoutShadow)", "null"); |
| |
| var elementWithShadow = document.createElement("div"); |
| container.appendChild(elementWithShadow); |
| var shadowRootOfElementWithShadow = elementWithShadow.createShadowRoot(); |
| shadowRootOfElementWithShadow.appendChild(document.createElement("div")); // Gives non-content child. |
| var childOfElementWithShadow = document.createElement("span"); |
| elementWithShadow.appendChild(childOfElementWithShadow); |
| container.offsetLeft; |
| shouldBe("includerFor(childOfElementWithShadow)", "null"); |
| |
| var elementWithShadowContent = document.createElement("div"); |
| container.appendChild(elementWithShadowContent); |
| var shadowRootOfElementWithShadowContent = elementWithShadowContent.createShadowRoot(); |
| var shadowContentOfElementWithShadowContent = document.createElement('content'); |
| shadowRootOfElementWithShadowContent.appendChild(shadowContentOfElementWithShadowContent); |
| var childOfElementWithShadowContent = document.createElement("span"); |
| elementWithShadowContent.appendChild(childOfElementWithShadowContent); |
| container.offsetLeft; |
| shouldBe("includerFor(childOfElementWithShadowContent)", "shadowContentOfElementWithShadowContent"); |
| |
| // |
| // Testing dynamic change |
| // |
| var movingChild = childOfElementWithShadowContent; |
| |
| // Removing |
| elementWithShadowContent.removeChild(movingChild); |
| shouldBe("includerFor(movingChild)", "null"); |
| |
| // Moving to content-less tree |
| elementWithShadow.appendChild(movingChild); |
| shouldBe("includerFor(movingChild)", "null"); |
| elementWithShadow.removeChild(movingChild); |
| |
| // Moving to another content-full tree |
| var anotherElementWithShadowContent = document.createElement("div"); |
| container.appendChild(anotherElementWithShadowContent); |
| var anotherShadowRootOfElementWithShadowContent = anotherElementWithShadowContent.createShadowRoot(); |
| var anotherShadowContentOfElementWithShadowContent = document.createElement('content'); |
| anotherShadowRootOfElementWithShadowContent.appendChild(anotherShadowContentOfElementWithShadowContent); |
| |
| anotherElementWithShadowContent.appendChild(movingChild); |
| container.offsetLeft; |
| shouldBe("includerFor(movingChild)", "anotherShadowContentOfElementWithShadowContent"); |
| </script> |
| </body> |
| </html> |