<!DOCTYPE html>
<style>
  body {
    height: 2000px;
    width: 2000px;
  }
</style>

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
    var pageScaleFactor = 2;

    var test = async_test('Verify that a scroll event gets fired on window.visualViewport when its offset changes');

    function scrollEventHandler() {
        test.done();
    }

    function doAfterZooming() {
        window.visualViewport.addEventListener('scroll', scrollEventHandler);
        window.scrollTo(1000, 1000);
    }

    function getUIScript() {
        return `(function() {
            uiController.zoomToScale(${pageScaleFactor}, function() {
                uiController.uiScriptComplete(uiController.zoomScale);
            });
        })();`;
    }

    window.onload = function() {
        testRunner.runUIScript(getUIScript(), doAfterZooming);
    };
</script>
