function simulateEvent(type, x, y, opt_shiftKey, button) {
    const viewport = map.getViewport();
    // calculated in case body has top < 0 (test runner with small window)
    const position = viewport.getBoundingClientRect();
    const shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
    const pointerEvent = {};
    pointerEvent.type = type;
    pointerEvent.target = viewport.firstChild;
    pointerEvent.button = button;
    pointerEvent.clientX = position.left + x + width / 2;
    pointerEvent.clientY = position.top - y + height / 2;
    pointerEvent.shiftKey = shiftKey;
    pointerEvent.pointerId = 0;
    pointerEvent.preventDefault = function () {};
    const event = new MapBrowserEvent(type, map, pointerEvent);
    event.originalEvent.pointerId = 1;
    map.handleMapBrowserEvent(event);
  }
Simulates a browser event on the map viewport.  The client x/y location
will be adjusted as if the map were centered at 0,0.
@param {string} type Event type.
@param {number} x Horizontal offset from map center.
@param {number} y Vertical offset from map center.
@param {boolean} [opt_shiftKey] Shift key is pressed.
@param {number} button The mouse button.