function simulateEvent(type, x, y, opt_shiftKey, opt_pointerId = 0) {
    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 = {};
    event.type = type;
    event.target = viewport.firstChild;
    event.clientX = position.left + x + width / 2;
    event.clientY = position.top + y + height / 2;
    event.shiftKey = shiftKey;
    event.preventDefault = function () {};
    event.pointerType = 'mouse';
    event.pointerId = opt_pointerId;
    const simulatedEvent = new MapBrowserEvent(type, map, event);
    map.handleMapBrowserEvent(simulatedEvent);
    return simulatedEvent;
  }
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 {boolean} [opt_pointerId] Pointer id.
@return {module:ol/MapBrowserEvent} The simulated event.