OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <template id='template'> |
| 5 <style> |
| 6 div { |
| 7 background-color: rgb(255, 0, 0); |
| 8 } |
| 9 div:hover { |
| 10 background-color: rgb(0, 128, 0); |
| 11 } |
| 12 div:hover:active { |
| 13 background-color: rgb(0, 255, 255); |
| 14 } |
| 15 div:active { |
| 16 background-color: rgb(0, 0, 255); |
| 17 } |
| 18 </style> |
| 19 <div id='div-in-shadow'> |
| 20 <content></content> |
| 21 </div> |
| 22 </template> |
| 23 <style> |
| 24 span:hover { |
| 25 color: rgb(0, 128, 0); |
| 26 } |
| 27 span:active:hover { |
| 28 color: rgb(0, 255, 255); |
| 29 } |
| 30 span:active { |
| 31 color: rgb(0, 0, 255); |
| 32 } |
| 33 </style> |
| 34 </head> |
| 35 <body> |
| 36 <div id='host'>Top-level text <span>Nested text</span></div> |
| 37 <div id='other'>Other div</div> |
| 38 <pre id='console'></pre> |
| 39 </body> |
| 40 |
| 41 <script src="../../js/resources/js-test-pre.js"></script> |
| 42 <script> |
| 43 var backgroundColor, textColor; |
| 44 |
| 45 function shouldHaveBackgroundColor(element, bg) { |
| 46 backgroundColor = getComputedStyle(element, null).getPropertyValue("backgrou
nd-color") |
| 47 shouldBeEqualToString('backgroundColor', bg) |
| 48 } |
| 49 |
| 50 function shouldHaveTextColor(element, col) { |
| 51 textColor = getComputedStyle(element, null).getPropertyValue("color") |
| 52 shouldBeEqualToString('textColor', col) |
| 53 } |
| 54 |
| 55 var host = document.getElementById('host'); |
| 56 var shadowRoot = host.webkitCreateShadowRoot(); |
| 57 var temp = document.getElementById('template'); |
| 58 shadowRoot.appendChild(temp.content.cloneNode(true)); |
| 59 var div = shadowRoot.querySelector('div'); |
| 60 var span = host.querySelector(':scope > span'); |
| 61 |
| 62 var divRect = div.getBoundingClientRect(); |
| 63 var spanRect = span.getBoundingClientRect(); |
| 64 var otherRect = document.getElementById('other').getBoundingClientRect(); |
| 65 |
| 66 eventSender.dragMode = false; |
| 67 eventSender.mouseDown(); |
| 68 eventSender.mouseUp(); |
| 69 |
| 70 var posDivNotSpanX = parseInt((spanRect.right + divRect.right) / 2); |
| 71 var spanCenterPosX = parseInt((spanRect.left + spanRect.right) / 2); |
| 72 var spanCenterPosY = parseInt((spanRect.top + spanRect.bottom) / 2); |
| 73 var topTextPosX = parseInt((divRect.left + spanRect.left) / 2); |
| 74 var topTextPosY = spanCenterPosY; |
| 75 var otherPosX = parseInt((otherRect.left + otherRect.right) / 2); |
| 76 var otherPosY = parseInt((otherRect.top + otherRect.bottom) / 2); |
| 77 |
| 78 eventSender.mouseMoveTo(posDivNotSpanX, spanCenterPosY); |
| 79 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 80 eventSender.mouseDown(); |
| 81 shouldHaveBackgroundColor(div, 'rgb(0, 255, 255)'); |
| 82 eventSender.mouseUp(); |
| 83 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 84 eventSender.mouseMoveTo(otherPosX, otherPosY); |
| 85 shouldHaveBackgroundColor(div, 'rgb(255, 0, 0)'); |
| 86 |
| 87 eventSender.mouseMoveTo(spanCenterPosX, spanCenterPosY); |
| 88 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 89 shouldHaveTextColor(span, 'rgb(0, 128, 0)'); |
| 90 eventSender.mouseDown(); |
| 91 shouldHaveBackgroundColor(div, 'rgb(0, 255, 255)'); |
| 92 shouldHaveTextColor(span, 'rgb(0, 255, 255)'); |
| 93 eventSender.mouseUp(); |
| 94 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 95 shouldHaveTextColor(span, 'rgb(0, 128, 0)'); |
| 96 eventSender.mouseMoveTo(otherPosX, otherPosY); |
| 97 shouldHaveBackgroundColor(div, 'rgb(255, 0, 0)'); |
| 98 shouldHaveTextColor(span, 'rgb(0, 0, 0)'); |
| 99 |
| 100 eventSender.mouseMoveTo(topTextPosX, topTextPosY); |
| 101 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 102 eventSender.mouseDown(); |
| 103 shouldHaveBackgroundColor(div, 'rgb(0, 255, 255)'); |
| 104 eventSender.mouseUp(); |
| 105 shouldHaveBackgroundColor(div, 'rgb(0, 128, 0)'); |
| 106 eventSender.mouseMoveTo(otherPosX, otherPosY); |
| 107 shouldHaveBackgroundColor(div, 'rgb(255, 0, 0)'); |
| 108 </script> |
| 109 </html> |
OLD | NEW |