OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 margin:0; |
| 5 } |
| 6 |
| 7 #pagedContainer { |
| 8 overflow: -webkit-paged-x; |
| 9 -webkit-column-gap: 0; |
| 10 width: 200px; |
| 11 height: 150px; |
| 12 margin: 40px 100px; |
| 13 font: 40px/1 Ahem; |
| 14 } |
| 15 |
| 16 #log { |
| 17 position: absolute; |
| 18 top: 201px; |
| 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("To the left of page 1:"); |
| 34 shouldBe("document.caretRangeFromPoint(0,20).startOffset", "0"); |
| 35 shouldBe("document.caretRangeFromPoint(0,60).startOffset", "0"); |
| 36 shouldBe("document.caretRangeFromPoint(0,100).startOffset", "4"); |
| 37 |
| 38 debug("Above page 1:"); |
| 39 shouldBe("document.caretRangeFromPoint(80,0).startOffset", "0"); |
| 40 shouldBe("document.caretRangeFromPoint(200,0).startOffset", "0"); |
| 41 shouldBe("document.caretRangeFromPoint(299,0).startOffset", "0"); |
| 42 |
| 43 debug("Below page 1:"); |
| 44 shouldBe("document.caretRangeFromPoint(80,200).startOffset", "12"); |
| 45 shouldBe("document.caretRangeFromPoint(200,200).startOffset", "12"); |
| 46 shouldBe("document.caretRangeFromPoint(299,200).startOffset", "12"); |
| 47 |
| 48 debug("Scroll to page 2"); |
| 49 document.getElementById("pagedContainer").scrollLeft = 200; |
| 50 |
| 51 debug("Above page 2:"); |
| 52 shouldBe("document.caretRangeFromPoint(200,0).startOffset", "12"); |
| 53 shouldBe("document.caretRangeFromPoint(299,0).startOffset", "12"); |
| 54 |
| 55 debug("Below page 2:"); |
| 56 shouldBe("document.caretRangeFromPoint(200,200).startOffset", "24"); |
| 57 shouldBe("document.caretRangeFromPoint(299,200).startOffset", "24"); |
| 58 |
| 59 debug("Scroll to page 3"); |
| 60 document.getElementById("pagedContainer").scrollLeft = 400; |
| 61 |
| 62 debug("Above page 3:"); |
| 63 shouldBe("document.caretRangeFromPoint(200,0).startOffset", "24"); |
| 64 shouldBe("document.caretRangeFromPoint(299,0).startOffset", "24"); |
| 65 |
| 66 debug("To the right of page 3:"); |
| 67 shouldBe("document.caretRangeFromPoint(400,20).startOffset", "24"); |
| 68 shouldBe("document.caretRangeFromPoint(400,60).startOffset", "27"); |
| 69 shouldBe("document.caretRangeFromPoint(400,100).startOffset", "31"); |
| 70 shouldBe("document.caretRangeFromPoint(400,140).startOffset", "35"); |
| 71 </script> |
OLD | NEW |