<!DOCTYPE html>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<style type="text/css">
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
#bluebox {
width: 100px;
height: 100px;
background: blue;
padding: 0px;
margin: 0px;
}
#outerdiv {
width: 200px;
height: 200px;
overflow-y: scroll;
overflow-x: scroll;
}
td {
padding: 0px;
}
</style>
<body style="margin:0" >
<div id="outerdiv">
<table border="0" cellspacing="0px" >
<tr><td>
<iframe style="display: block;" frameBorder="0" id="touchtargetiframe"
src="resources/scroll-inside-editable-iframe-promise-resolve-on-load.html"></iframe>
</td></tr>
<tr><td>
<div id="bluebox"></div>
</td></tr>
</table>
</div>
</body>
<script type="text/javascript">
var movedbox = document.getElementById("outerdiv");
var touchtarget = document.getElementById("touchtargetiframe");
var iframe;
var iframeScrollingElement;
var expectedGesturesTotal = 1;
var gesturesOccurred = 0;
var scrollAmountX = [0];
var scrollAmountY = [50];
var scrolledElement = movedbox;
var scrollEventsOccurred = 0;
var expectedScrollEventsOccurred = 1;
promise_test (async () => {
await iframeOnLoadPromise;
touchtarget.contentDocument.addEventListener("scroll", recordScroll);
iframe = touchtarget;
iframeScrollingElement = iframe.contentDocument.scrollingElement;
var amountToScroll = iframeScrollingElement.scrollHeight - iframe.clientHeight;
iframeScrollingElement.scrollTop = amountToScroll;
// Sanity - make sure the iframe is actually fully scrolled
assert_equals(iframeScrollingElement.scrollHeight -
iframeScrollingElement.scrollTop, iframe.clientHeight,
"iframe must be fully scrolled");
var x = 10;
var y = 72;
// scroll for 63 pixels or till the outer div is fully scrolled.
scrollAmountY[0] = Math.min(movedbox.scrollHeight - movedbox.clientHeight, 63);
await smoothScroll(63, x, y, GestureSourceType.TOUCH_INPUT, "down");
// Wait for layout.
await waitFor(checkScrollOffset);
assert_equals(scrollEventsOccurred, expectedScrollEventsOccurred);
}, 'This tests that a scroll gesture sent to an iframe with no remaining ' +
'scroll offset is correctly targeting the parent container.');
</script>