<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
var numCallsScroll = 0;
var numCallsResize = 0;
promise_test(async () => {
// Turn off smooth scrolling.
internals.settings.setScrollAnimatorEnabled(false);
window.visualViewport.addEventListener('scroll', function(e) {
numCallsScroll++;
});
window.visualViewport.addEventListener('resize', function(e) {
numCallsResize++;
});
// Request resize, and then wait for an animation frame to ensure
// there was only one resize event.
var resizePromise = new Promise(resolve => window.onresize = resolve);
window.resizeTo(window.outerWidth - 24, window.outerHeight - 24);
await resizePromise;
await new Promise(resolve => requestAnimationFrame(resolve));
assert_equals(numCallsScroll, 0, "resize 1 doesn't fire scroll event");
assert_equals(numCallsResize, 1, "resize 1 fires resize event");
var resizePromise = new Promise(resolve => window.onresize = resolve);
window.resizeTo(window.outerWidth + 24, window.outerHeight + 24);
await resizePromise;
await new Promise(resolve => requestAnimationFrame(resolve));
assert_equals(numCallsScroll, 0, "resize 2 doesn't fire scroll event");
assert_equals(numCallsResize, 2, "resize 2 fires resize event");
});
</script>