blob: ff2e29bc8d212e341a16c185c6956b32cf2f874e [file] [log] [blame]
<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
body {
margin: 0px;
height: 3000px;
width: 3000px;
}
p {
width: 750px;
}
#scrollable {
height: 400px;
width: 400px;
}
</style>
<p>
This test ensures that autoscrolling doesn't scroll an iframe that's marked
as unscrollable via `scrolling="no"`. To test manually, fully scroll the blue
inner scroller and use middle click autoscroll (Windows feature) from the
inner blue scroller to scroll downwards until the main window begins to
scroll. This test passes if the iframe that contains the blue scroller
doesn't scroll.
</p>
<iframe id="scrollable" scrolling="no" srcdoc="
<!DOCTYPE html>
<style>
body {
width: 410px;
height: 410px;
}
#scroller {
width: 300px;
height: 300px;
overflow: scroll;
background-color: blue;
}
#space {
width: 400px;
height: 400px;
}
</style>
<div id='scroller'>
<div id='space'></div>
</div>
"></iframe>
<script>
var scrollable = document.getElementById('scrollable');
function autoScroll(start_x, start_y, end_x, end_y) {
return new Promise((resolve, reject) => {
if (!window.eventSender) {
reject();
} else {
const MIDDLE_BUTTON = 1;
eventSender.mouseMoveTo(start_x, start_y);
eventSender.mouseDown(MIDDLE_BUTTON);
eventSender.mouseUp(MIDDLE_BUTTON);
eventSender.mouseMoveTo(end_x, end_y);
resolve();
}
});
}
function waitForScrollAndCheck() {
return new Promise((resolve, reject) => {
function tick(frames) {
// Wait until the scroll bubbles up to the main window or the iframe scrolls.
if (window.scrollY > 0 || scrollable.contentWindow.scrollY > 0)
resolve();
else
requestAnimationFrame(tick.bind(this, frames + 1));
}
tick(0);
});
}
window.addEventListener('load', () => {
var inner_scroller = frames[0].document.getElementById('scroller');
inner_scroller.scrollTop = 1000;
promise_test(t => {
const MIDDLE_CLICK_AUTOSCROLL_RADIUS = 15; // from blink::kNoMiddleClickAutoscrollRadius
var rect = scrollable.getBoundingClientRect();
var startX = rect.left + 50;
var startY = rect.top + 50;
var endX = startX;
var endY = startY + 5 * MIDDLE_CLICK_AUTOSCROLL_RADIUS;
assert_equals(inner_scroller.scrollTop,
inner_scroller.scrollHeight - inner_scroller.clientHeight,
"Inner scroller starts fully scrolled.");
assert_equals(window.scrollY, 0, "Main window starts unscrolled.");
assert_equals(frames[0].window.scrollY, 0, "IFrame starts unscrolled.");
return autoScroll(startX, startY, endX, endY)
.then(waitForScrollAndCheck)
.then(() => {
assert_greater_than(window.scrollY, 0, "Main window must be scrolled.");
assert_equals(frames[0].window.scrollY, 0, "IFrame must NOT scroll.");
});
});
});
</script>