OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <head> |
| 3 <style> |
| 4 #bluebox { |
| 5 width: 100px; |
| 6 height: 100px; |
| 7 background: blue; |
| 8 padding: 0px; |
| 9 margin: 0px; |
| 10 } |
| 11 #redbox { |
| 12 width: 100px; |
| 13 height: 100px; |
| 14 background: red; |
| 15 padding: 0px; |
| 16 margin: 0px; |
| 17 } |
| 18 #spacer { |
| 19 width: 2000px; |
| 20 height: 2000px; |
| 21 padding: 0px; |
| 22 margin: 0px; |
| 23 } |
| 24 #container-vertical { |
| 25 width: 200px; |
| 26 height: 100px; |
| 27 } |
| 28 #container-horizontal { |
| 29 width: 200px; |
| 30 height: 100px; |
| 31 } |
| 32 </style> |
| 33 <script src="../../resources/js-test.js"></script> |
| 34 <script> |
| 35 |
| 36 function focusTextboxHorizontal() { |
| 37 document.getElementById('textBox-horizontal').focus(); |
| 38 } |
| 39 |
| 40 function collapseToggleHorizontal() { |
| 41 var element = document.getElementById('container-horizontal'); |
| 42 |
| 43 if (element.clientWidth > 0) |
| 44 element.style.width = "0px"; |
| 45 else |
| 46 element.style.width = "200px"; |
| 47 } |
| 48 |
| 49 function focusTextboxVertical() { |
| 50 document.getElementById('textBox-vertical').focus(); |
| 51 } |
| 52 |
| 53 function collapseToggleVertical() { |
| 54 var element = document.getElementById('container-vertical'); |
| 55 |
| 56 if (element.clientHeight > 0) |
| 57 element.style.height = "0px"; |
| 58 else |
| 59 element.style.height = "100px"; |
| 60 } |
| 61 |
| 62 addEventListener('load', function() { |
| 63 description('Tests that scrollIntoViewIfNeeded works correctly if the ' |
| 64 + 'enclosing div has no height.'); |
| 65 |
| 66 if (window.testRunner) |
| 67 testRunner.dumpAsText(); |
| 68 |
| 69 window.scrollTo(0, 190); |
| 70 document.getElementById('scroller-vertical').scrollTop = 1000; |
| 71 document.getElementById('container-vertical').style.height = "0px"; |
| 72 document.getElementById('scroller-horizontal').scrollTop = 0; |
| 73 document.getElementById('container-horizontal').style.width = "0px"; |
| 74 |
| 75 shouldBe("window.scrollY", "190"); |
| 76 |
| 77 document.getElementById('textBox-vertical').scrollIntoViewIfNeeded(); |
| 78 |
| 79 shouldBe("window.scrollY", "190"); |
| 80 |
| 81 shouldBe("window.scrollX", "0"); |
| 82 |
| 83 document.getElementById('textBox-horizontal').scrollIntoViewIfNeeded(); |
| 84 |
| 85 shouldBe("window.scrollX", "0"); |
| 86 }); |
| 87 </script> |
| 88 </head> |
| 89 <body> |
| 90 <div style="height:200px"></div> |
| 91 <div id="container-vertical" > |
| 92 <div id="scroller-vertical" style="height: 100%; overflow: auto"> |
| 93 <input type="text" id="textBox-vertical"> |
| 94 <div id="bluebox"></div><div id="redbox"></div> |
| 95 <div id="bluebox"></div><div id="redbox"></div> |
| 96 <div id="bluebox"></div><div id="redbox"></div> |
| 97 <div id="bluebox"></div><div id="redbox"></div> |
| 98 <div id="bluebox"></div><div id="redbox"></div> |
| 99 </div> |
| 100 </div> |
| 101 <button onclick="focusTextboxVertical();">Focus Textbox</button> |
| 102 <button onclick="collapseToggleVertical();">Collapse Div With Textbox</but
ton> |
| 103 <div style="padding-left: 300px"> |
| 104 <div id="container-horizontal" > |
| 105 <div id="scroller-horizontal" style="height: 100%; overflow: auto"> |
| 106 <div style="padding-left: 1000px"><input type="text" id="textBox-hor
izontal"></div> |
| 107 </div> |
| 108 </div> |
| 109 <button onclick="focusTextboxHorizontal();">Focus Textbox</button> |
| 110 <button onclick="collapseToggleHorizontal();">Collapse Div With Textbox<
/button> |
| 111 </div> |
| 112 <div id="console"></div> |
| 113 <div id="spacer"></div> |
| 114 </body> |
OLD | NEW |