blob: 11aba334f7f5cd02f90cd1fb087e864e563a151c [file] [log] [blame]
<!-- webkit-test-runner [ useCharacterSelectionGranularity=true ] -->
<meta name=viewport content="width=device-width">
<style>
#target {
height: 100px;
width: 200px;
background-color: silver;
}
</style>
<div id="target">
<p style="font-family: ahem;">PressMe</p>
This test requires UIScriptController to run.
</div>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function getUIScript()
{
return `
(function() {
uiController.longPressAtPoint(30, 20, function() {
uiController.uiScriptComplete(JSON.stringify(uiController.textSelectionRangeRects));
});
})();`
}
function runTest()
{
if (!testRunner.runUIScript)
return;
var target = document.getElementById('target');
if (testRunner.runUIScript) {
testRunner.runUIScript(getUIScript(), function(result) {
var textSelectionRangeRects = JSON.parse(result);
var output;
if (textSelectionRangeRects.length !== 1)
output = 'FAIL: Unexpected number of selection range views: ' + result;
else {
var rect = textSelectionRangeRects[0];
if (rect.left != 8 || rect.top != 8 || rect.width != 112 || rect.height != 17 )
output = 'FAIL: Unexpected selection range view frame: ' + result;
else
output = 'PASS';
}
document.getElementById('target').innerText = output;
testRunner.notifyDone();
});
}
}
runTest();
</script>