| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/js-test.js"></script> |
| 3 <script src="resources/shadow-dom.js"></script> |
| 4 <style> |
| 5 div { |
| 6 background-color: white; |
| 7 } |
| 8 |
| 9 div#shadow-host:focus { |
| 10 background-color: green; |
| 11 } |
| 12 </style> |
| 13 <body> |
| 14 <div id="sandbox"></div> |
| 15 </body> |
| 16 <script> |
| 17 function backgroundColorOf(selector) { |
| 18 return window.getComputedStyle(getNodeInTreeOfTrees(selector)).backgroundCol
or; |
| 19 } |
| 20 |
| 21 function backgroundColorShouldBe(selector, expected) { |
| 22 shouldBeEqualToString('backgroundColorOf(\'' + selector + '\')', expected); |
| 23 } |
| 24 |
| 25 function testWithoutDelegatesFocus() |
| 26 { |
| 27 debug(':focus and shadow host without delegatesFocus for crbug/479050'); |
| 28 |
| 29 // Setting up the DOM tree |
| 30 var sandbox = document.querySelector('#sandbox'); |
| 31 sandbox.innerHTML = ''; |
| 32 sandbox.appendChild( |
| 33 createDOM('div', {}, |
| 34 createDOM('input', {'id': 'outer-input1'}), |
| 35 createDOM('div', {'id': 'shadow-host'}, |
| 36 createDOM('input', {'id': 'lightdom-input'}), |
| 37 createShadowRoot( |
| 38 createDOM('content'), |
| 39 createDOM('input', {'id': 'inner-input'}))), |
| 40 createDOM('input', {'id': 'outer-input2'}))); |
| 41 sandbox.offsetTop; |
| 42 |
| 43 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 44 |
| 45 var host = getNodeInTreeOfTrees('shadow-host'); |
| 46 var innerInput = getNodeInTreeOfTrees('shadow-host/inner-input'); |
| 47 var lightdomInput = getNodeInTreeOfTrees('lightdom-input'); |
| 48 var outerInput1 = getNodeInTreeOfTrees('outer-input1'); |
| 49 var outerInput2 = getNodeInTreeOfTrees('outer-input2'); |
| 50 |
| 51 debug('Test shadow host without tabindex'); |
| 52 outerInput1.focus(); |
| 53 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 54 outerInput2.focus(); |
| 55 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 56 innerInput.focus(); |
| 57 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 58 lightdomInput.focus(); |
| 59 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 60 host.focus(); // host will not get focus as it is not focusable. |
| 61 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 62 |
| 63 debug('Test shadow host with tabindex=-1'); |
| 64 host.tabIndex = -1; |
| 65 outerInput1.focus(); |
| 66 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 67 outerInput2.focus(); |
| 68 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 69 innerInput.focus(); |
| 70 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 71 lightdomInput.focus(); |
| 72 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 73 host.focus(); |
| 74 backgroundColorShouldBe('shadow-host', 'rgb(0, 128, 0)'); |
| 75 |
| 76 debug('Test shadow host without tabindex=0'); |
| 77 host.tabIndex = 0; |
| 78 outerInput1.focus(); |
| 79 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 80 outerInput2.focus(); |
| 81 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 82 innerInput.focus(); |
| 83 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 84 lightdomInput.focus(); |
| 85 backgroundColorShouldBe('shadow-host', 'rgb(255, 255, 255)'); |
| 86 host.focus(); |
| 87 backgroundColorShouldBe('shadow-host', 'rgb(0, 128, 0)'); |
| 88 } |
| 89 |
| 90 testWithoutDelegatesFocus(); |
| 91 </script> |
| OLD | NEW |