<!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>
<script>
if (window.internals)
internals.settings.setTouchDragDropEnabled(true);
// The iframe will call top.dragStarted() or top.mousedownTriggered() on
// receiving the corresponding event.
function mousedownTriggered() {
rejectDragStartPromise();
}
function dragStarted() {
resolveDragStartPromise();
}
let resolveDragStartPromise = undefined;
let rejectDragStartPromise = undefined;
function dragStartEvent() {
return new Promise((resolve, reject) => {
resolveDragStartPromise = resolve;
rejectDragStartPromise = () => {
reject('missing dragstart event');
}
});
}
</script>
<iframe src="resources/drag-inside-iframe2.html">
</iframe>
<p>This test checks that a long press gesture on a draggable element in an
iframe starts a drag/drop session.</p>
<script>
// The runTest method is triggered when the iframe is loaded.
function runTest() {
promise_test(async t => {
preventContextMenu(t);
const target = document.querySelector('iframe');
const dragPromise = dragStartEvent();
// Shift the long-press position to be over a draggable div within the
// iframe.
const longpressOptions = { x: -50, y: -50, duration: 1200 };
await touchLongPressElement(target, longpressOptions);
return dragPromise;
}, 'Long press gesture on a draggable element in an iframe starts a ' +
'drag/drop session.');
}
</script>
</body>
</html>