<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<script src="../../../../resources/testdriver.js"></script>
<script src="../../../../resources/testdriver-actions.js"></script>
<script src="../../../..//resources/testdriver-vendor.js"></script>
</head>
<body>
<div id="mainFrameText">
This test checks that long press to select text focuses the pressed frame.
</div>
<script>
var framesLoaded = 0;
function frameLoaded() {
framesLoaded++;
if (framesLoaded == 2)
runTest();
}
function runTest() {
promise_test(async t => {
// Text selection requires a longer long-press duration than a context menu
// popup.
const longPressOptions = { duration: 1200 };
preventContextMenu(t);
mainFrameText = document.getElementById("mainFrameText");
frame1 = document.getElementById("frame1");
frame2 = document.getElementById("frame2");
await touchLongPressElement(frame1, longPressOptions);
assert_equals(document.activeElement, frame1);
await touchLongPressElement(frame2, longPressOptions);
assert_equals(document.activeElement, frame2);
await touchLongPressElement(mainFrameText, longPressOptions);
assert_equals(document.activeElement, document.body);
}, 'Long press to select text focuses the pressed frame');
}
</script>
<iframe id="frame1" onload="frameLoaded()" src="data:text/html,
<html>
<body>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum posuere ipsum. Sed laoreet porttitor tortor ut sollicitudin. Quisque eu arcu in magna ornare pretium. In hac habitasse platea dictumst. Morbi vitae blandit mi. Phasellus pellentesque consequat leo, at auctor ligula tempus sed. Aenean magna mi, suscipit vitae auctor non, luctus a sem. Morbi nec purus massa. In hac habitasse platea dictumst. Vivamus dictum justo eu diam suscipit porttitor. Donec ipsum urna, laoreet in feugiat sit amet, imperdiet ac lorem. Pellentesque massa odio, accumsan nec varius sed, tristique ac felis. Phasellus quis mi ac mauris venenatis malesuada. Quisque placerat bibendum enim, eget tempor ipsum molestie quis. Nam eget purus lorem, a dignissim enim.
</body>
</html>
"></iframe>
<iframe id="frame2" onload="frameLoaded()" src="data:text/html,
<html>
<body>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum posuere ipsum. Sed laoreet porttitor tortor ut sollicitudin. Quisque eu arcu in magna ornare pretium. In hac habitasse platea dictumst. Morbi vitae blandit mi. Phasellus pellentesque consequat leo, at auctor ligula tempus sed. Aenean magna mi, suscipit vitae auctor non, luctus a sem. Morbi nec purus massa. In hac habitasse platea dictumst. Vivamus dictum justo eu diam suscipit porttitor. Donec ipsum urna, laoreet in feugiat sit amet, imperdiet ac lorem. Pellentesque massa odio, accumsan nec varius sed, tristique ac felis. Phasellus quis mi ac mauris venenatis malesuada. Quisque placerat bibendum enim, eget tempor ipsum molestie quis. Nam eget purus lorem, a dignissim enim.
</body>
</html>
"></iframe>
</body>
</html>