blob: 5b0003f0c7046b80560d7ce8a005c879c2ec1e39 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/ahem.js"></script>
<style>
body {
margin:0;
}
/* Need a wrapper to establish the writing mode, thanks to crbug.com/463462 */
#wrapper {
-webkit-writing-mode: vertical-rl;
padding: 50px;
width: 400px;
height: 250px;
}
#pagedContainer {
overflow: -webkit-paged-x;
-webkit-column-gap: 0;
width: 120px;
height: 200px;
font: 40px/1 Ahem;
}
#log {
position: absolute;
top: 351px;
}
</style>
<div id="log">
<p id="description"></p>
<div id="console"></div>
</div>
<div id="wrapper">
<div id="pagedContainer">xxx xxx xxx xxx xxx xxx xxx xxx xxx</div>
</div>
<script src="../../resources/js-test.js"></script>
<script>
onload = function() {
description("Test that hitting areas outside a paged container takes us to the right text content on some page.");
// FIXME: We should ideally test above and below every page, but we get bogus results,
// thanks to crbug.com/466554 , so avoid testing in the problematic areas.
debug("Above page 1:");
shouldBe("document.caretRangeFromPoint(499,0).startOffset", "0");
shouldBe("document.caretRangeFromPoint(430,0).startOffset", "0");
shouldBe("document.caretRangeFromPoint(390,0).startOffset", "4");
debug("Below page 1:");
shouldBe("document.caretRangeFromPoint(499,320).startOffset", "0");
shouldBe("document.caretRangeFromPoint(430,320).startOffset", "3");
shouldBe("document.caretRangeFromPoint(390,320).startOffset", "7");
debug("To the right of page 1:");
shouldBe("document.caretRangeFromPoint(499,320).startOffset", "0");
shouldBe("document.caretRangeFromPoint(499,250).startOffset", "0");
shouldBe("document.caretRangeFromPoint(499,0).startOffset", "0");
debug("Scroll to page 2");
document.getElementById("pagedContainer").scrollLeft = 120;
debug("Above page 2:");
shouldBe("document.caretRangeFromPoint(449,0).startOffset", "12");
shouldBe("document.caretRangeFromPoint(330,0).startOffset", "20");
debug("Below page 2:");
shouldBe("document.caretRangeFromPoint(449,320).startOffset", "15");
shouldBe("document.caretRangeFromPoint(330,320).startOffset", "23");
debug("Scroll to page 3");
document.getElementById("pagedContainer").scrollLeft = 0;
debug("Above page 3:");
shouldBe("document.caretRangeFromPoint(449,0).startOffset", "24");
shouldBe("document.caretRangeFromPoint(330,0).startOffset", "32");
debug("Below page 3:");
shouldBe("document.caretRangeFromPoint(449,320).startOffset", "27");
shouldBe("document.caretRangeFromPoint(330,320).startOffset", "35");
};
</script>