OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <style> |
| 5 .target { |
| 6 background-color:blue; |
| 7 color:white; |
| 8 width:100px; height:40px; |
| 9 margin:10px; |
| 10 } |
| 11 </style> |
| 12 <div id="container"> |
| 13 <p>To test manually, hover over blue boxes and see if the tooltip says "PASS
"</p> |
| 14 <div id="fromdoc" title="PASS-fromdoc"></div> |
| 15 <div id="distributed" title="NG-distributed"><div class="target">Distributed
</div></div> |
| 16 <div id="multiple" title="NG-multiple"><div class="target">Distributed to th
e youngest</div></div> |
| 17 <div id="multilevel" title="NG-multilevel"><div class="target">Multi-level D
istributed</div></div> |
| 18 <div id="older" title="NG-older"></div> |
| 19 <div id="redistributed" title="NG-redistributed"><div class="target">Redistr
ibuted</div></div> |
| 20 </div> |
| 21 <script> |
| 22 setup({ explicit_done: true }); |
| 23 var style = "<style>.target { background-color:blue; color:white; width:100px; h
eight:40px; margin:10px; }</style>"; |
| 24 |
| 25 if (!window.eventSender || !window.testRunner) |
| 26 test(function () { assert_unreached(); }, "Cannot automate the tests without
eventSender and testRunner"); |
| 27 |
| 28 var host = document.getElementById("fromdoc"); |
| 29 var root = createShadowRootWithInnerHtml(host, style + "<div class=target>Shadow
</div>"); |
| 30 testTooltipTextInShadow("The title of elements in shadow inherits from the docum
ent", root.querySelector(".target"), "PASS-fromdoc"); |
| 31 |
| 32 host = document.getElementById("distributed"); |
| 33 createShadowRootWithInnerHtml(host, "<div title='PASS-distributed'><content></co
ntent></div>"); |
| 34 testTooltipTextInShadow("The title of distributed elements inherits in the compo
sed tree", host.querySelector(".target"), "PASS-distributed"); |
| 35 |
| 36 host = document.getElementById("multiple"); |
| 37 createShadowRootWithInnerHtml(host, "<div title='NG-multiple'><content></content
></div>"); |
| 38 createShadowRootWithInnerHtml(host, "<div title='PASS-multiple'><content></conte
nt></div>"); |
| 39 testTooltipTextInShadow("The title of distributed elements inherits in the compo
sed tree (multiple shadow roots)", host.querySelector(".target"), "PASS-multiple
"); |
| 40 |
| 41 host = document.getElementById("multilevel"); |
| 42 var host2ndLevel = createShadowRootWithInnerHtml(host, "<div title='NG-multileve
l'><content></content></div>").firstChild; |
| 43 createShadowRootWithInnerHtml(host2ndLevel, "<div title='PASS-multilevel'><conte
nt></content></div>"); |
| 44 testTooltipTextInShadow("The title of distributed elements inherits in the compo
sed tree (multiple levels)", host.querySelector(".target"), "PASS-multilevel"); |
| 45 |
| 46 host = document.getElementById("older"); |
| 47 root = createShadowRootWithInnerHtml(host, style + "<div class=target>Older</div
>"); |
| 48 createShadowRootWithInnerHtml(host, "<div title='PASS-older'><shadow></shadow></
div>"); |
| 49 testTooltipTextInShadow("The title of elements in older shadow roots inherits in
the composed tree", root.querySelector(".target"), "PASS-older"); |
| 50 |
| 51 host = document.getElementById("redistributed"); |
| 52 createShadowRootWithInnerHtml(host, "<content></content>"); |
| 53 createShadowRootWithInnerHtml(host, "<div title='PASS-redistributed'><shadow></s
hadow></div>"); |
| 54 testTooltipTextInShadow("The title of re-distributed elements inherits in the co
mposed tree (multiple shadow roots)", host.querySelector(".target"), "PASS-redis
tributed"); |
| 55 |
| 56 function testTooltipTextInShadow(description, element, expected) { |
| 57 if (!window.eventSender || !window.testRunner) |
| 58 return; |
| 59 eventSender.dragMode = false; |
| 60 eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop + element.offs
etHeight / 2); |
| 61 test(function () { |
| 62 assert_equals(testRunner.tooltipText, expected); |
| 63 }, description); |
| 64 } |
| 65 |
| 66 function createShadowRootWithInnerHtml(host, shadowHtml) { |
| 67 var root = host.createShadowRoot(); |
| 68 root.innerHTML = shadowHtml; |
| 69 return root; |
| 70 } |
| 71 |
| 72 if (window.testRunner) |
| 73 container.style.display = "none"; |
| 74 done(); |
| 75 </script> |
OLD | NEW |