OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 margin:0; |
| 5 } |
| 6 |
| 7 #pagedContainer { |
| 8 overflow: -webkit-paged-y; |
| 9 -webkit-column-gap: 0; |
| 10 width: 200px; |
| 11 height: 120px; |
| 12 margin: 40px 100px; |
| 13 font: 40px/1 Ahem; |
| 14 } |
| 15 |
| 16 #log { |
| 17 position: absolute; |
| 18 top: 141px; |
| 19 } |
| 20 </style> |
| 21 <div id="log"> |
| 22 <p id="description"></p> |
| 23 <div id="console"></div> |
| 24 </div> |
| 25 <div id="pagedContainer">xxx xxx xxx xxx xxx xxx xxx xxx xxx</div> |
| 26 <script src="../../resources/js-test.js"></script> |
| 27 <script> |
| 28 description("Test that hitting areas outside a paged container takes us to t
he right text content on some page."); |
| 29 |
| 30 // FIXME: We should ideally test above and below every page, but we get bogu
s results, |
| 31 // thanks to crbug.com/466554 , so avoid testing in the problematic areas. |
| 32 |
| 33 debug("Above page 1:"); |
| 34 shouldBe("document.caretRangeFromPoint(50,0).startOffset", "0"); |
| 35 shouldBe("document.caretRangeFromPoint(150,0).startOffset", "0"); |
| 36 shouldBe("document.caretRangeFromPoint(300,0).startOffset", "0"); |
| 37 |
| 38 debug("To the left of page 1:"); |
| 39 shouldBe("document.caretRangeFromPoint(0,20).startOffset", "0"); |
| 40 shouldBe("document.caretRangeFromPoint(0,60).startOffset", "0"); |
| 41 shouldBe("document.caretRangeFromPoint(0,100).startOffset", "4"); |
| 42 shouldBe("document.caretRangeFromPoint(0,140).startOffset", "8"); |
| 43 |
| 44 debug("To the right of page 1:"); |
| 45 shouldBe("document.caretRangeFromPoint(400,20).startOffset", "0"); |
| 46 shouldBe("document.caretRangeFromPoint(400,60).startOffset", "3"); |
| 47 shouldBe("document.caretRangeFromPoint(400,100).startOffset", "7"); |
| 48 shouldBe("document.caretRangeFromPoint(400,140).startOffset", "11"); |
| 49 |
| 50 debug("Scroll to page 2"); |
| 51 document.getElementById("pagedContainer").scrollTop = 120; |
| 52 |
| 53 debug("To the left of page 2:"); |
| 54 shouldBe("document.caretRangeFromPoint(0,60).startOffset", "12"); |
| 55 shouldBe("document.caretRangeFromPoint(0,100).startOffset", "16"); |
| 56 shouldBe("document.caretRangeFromPoint(0,140).startOffset", "20"); |
| 57 |
| 58 debug("To the right of page 2:"); |
| 59 shouldBe("document.caretRangeFromPoint(400,60).startOffset", "15"); |
| 60 shouldBe("document.caretRangeFromPoint(400,100).startOffset", "19"); |
| 61 shouldBe("document.caretRangeFromPoint(400,140).startOffset", "23"); |
| 62 |
| 63 debug("Scroll to page 3"); |
| 64 document.getElementById("pagedContainer").scrollTop = 240; |
| 65 |
| 66 debug("To the left of page 3:"); |
| 67 shouldBe("document.caretRangeFromPoint(0,60).startOffset", "24"); |
| 68 shouldBe("document.caretRangeFromPoint(0,100).startOffset", "28"); |
| 69 shouldBe("document.caretRangeFromPoint(0,140).startOffset", "32"); |
| 70 |
| 71 debug("To the right of page 3:"); |
| 72 shouldBe("document.caretRangeFromPoint(400,60).startOffset", "27"); |
| 73 shouldBe("document.caretRangeFromPoint(400,100).startOffset", "31"); |
| 74 shouldBe("document.caretRangeFromPoint(400,140).startOffset", "35"); |
| 75 </script> |
OLD | NEW |