blob: bd52ecf2fb002cad7fdf01886c3b8900dd670d8f [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<head>
<script src="../../../resources/ui-helper.js"></script>
<script src="../../../resources/js-test.js"></script>
<style>
body {
margin: 0;
}
#absolute {
width: 100vw;
height: 50px;
position: absolute;
left: 0;
top: 0;
font-size: 100px;
}
#content {
background-image: linear-gradient(blue, red);
height: 10000px;
}
</style>
<script>
jsTestIsAsync = true;
function selectTextAt(tapX, tapY)
{
return new Promise(resolve => {
testRunner.runUIScript(`
(function() {
uiController.longPressAtPoint(${tapX}, ${tapY}, function() {
uiController.uiScriptComplete("Done");
});
})();`, resolve);
});
}
function run()
{
if (!window.testRunner || !testRunner.runUIScript) {
description("To manually test, long press this text and scroll up. The selection rect should be in the expected place (in the absolutely positioned div) after scrolling.");
return;
}
selectTextAt(50, 50)
.then(() => UIHelper.getUISelectionRects())
.then((rects) => {
initialSelectionRects = rects;
shouldBe("initialSelectionRects.length", "1");
shouldBe("initialSelectionRects[0].left", "0");
shouldBe("initialSelectionRects[0].top", "0");
shouldBe("initialSelectionRects[0].width", "309");
shouldBe("initialSelectionRects[0].height", "114");
document.scrollingElement.scrollTop += 5000;
return UIHelper.getUISelectionRects();
})
.then((rects) => {
finalSelectionRects = rects;
shouldBe("finalSelectionRects.length", "1");
shouldBe("finalSelectionRects[0].left", "0");
shouldBe("finalSelectionRects[0].top", "0");
shouldBe("finalSelectionRects[0].width", "309");
shouldBe("finalSelectionRects[0].height", "114");
finishJSTest();
});
}
</script>
</head>
<body onload=run()>
<div id="absolute">WebKit</div>
<div id="content"></div>
</body>
</html>