function simulateEvent(type, x, y, opt_shiftKey) {
    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 event = {
      type: type,
      target: viewport.firstChild,
      clientX: position.left + x + width / 2,
      clientY: position.top + y + height / 2,
      shiftKey: shiftKey,
      stopPropagation: () => {
        event.propagationStopped = true;
      },
    };
    map.handleMapBrowserEvent(new MapBrowserEvent(type, map, 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.