blob: b7313776e98f52da6071f244df939ff745be1148 [file] [log] [blame]
<!DOCTYPE html>
<style>
body {
height: 2000px;
width: 2000px;
}
</style>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script>
var numCallsScroll = 0;
var numCallsResize = 0;
var pageScaleFactor = 2;
var source = GestureSourceType.MOUSE_INPUT;
var t = async_test('verify that the scroll and resize events get fired on window.visualViewport');
window.onload = async () => {
window.visualViewport.addEventListener('scroll', function(e) {
numCallsScroll++;
});
window.visualViewport.addEventListener('resize', function(e) {
numCallsResize++;
});
// Register the event handlers after the waitForCompositorCommit.
await waitForCompositorCommit();
numCallsScroll = 0;
numCallsResize = 0;
// Scroll both viewports.
await smoothScroll(100, 100, 100, source, 'downright', SPEED_INSTANT);
chrome.gpuBenchmarking.setPageScaleFactor(pageScaleFactor);
// Verify viewport dimensions exclude scrollbar.
requestAnimationFrame(function() {
t.step(function() {
assert_equals(numCallsScroll, 0, "scroll listener not called for scale");
assert_equals(numCallsResize, 1, "resize listener called for scale");
});
internals.setVisualViewportOffset(10, 10);
requestAnimationFrame(function() {
t.step(function() {
assert_equals(numCallsScroll, 1, "scroll listener called for offset change");
assert_equals(numCallsResize, 1, "resize listener not called for offset change");
});
t.done();
});
});
}
</script>