fake-geolocation
    Preparing search index...

    Interface User

    A virtual user that can affect geolocation and permissions.

    interface User {
        accessRequestCount: (descriptor?: PermissionDescriptor) => number;
        accessRequests: (
            descriptor?: PermissionDescriptor,
        ) => AccessRequestRecord[];
        blockAccess: (descriptor: PermissionDescriptor) => void;
        clearAccessRequests: (descriptor?: PermissionDescriptor) => void;
        disableLocationServices: () => void;
        enableLocationServices: () => void;
        grantAccess: (descriptor: PermissionDescriptor) => void;
        jumpToCoordinates: (
            coordsParams: Partial<
                {
                    accuracy: number;
                    altitude: null
                    | number;
                    altitudeAccuracy: null | number;
                    heading: null | number;
                    latitude: number;
                    longitude: number;
                    speed: null | number;
                },
            >,
        ) => void;
        resetAccess: (descriptor: PermissionDescriptor) => void;
        setAccessRequestHandler: (handler: HandleAccessRequest) => void;
    }

    Hierarchy

    Index

    Properties

    accessRequestCount: (descriptor?: PermissionDescriptor) => number

    Get the number of recorded access requests that this user has received.

    If descriptor is provided, only access requests that match the descriptor will be counted. Otherwise, all access requests will be counted.

    Type declaration

    accessRequests: (descriptor?: PermissionDescriptor) => AccessRequestRecord[]

    Get snapshot records of access requests that this user has received.

    The access request records returned are a snapshot of the access requests received as of now. They are not live records, and will not be updated if the access request is completed later. To get a fresh snapshot of the access requests, call this method again.

    If descriptor is provided, only access requests that match the descriptor will be returned. Otherwise, all access requests will be returned.

    Type declaration

    blockAccess: (descriptor: PermissionDescriptor) => void

    Block access to a permission.

    This is equivalent to manually blocking access to a permission via the browser's permission settings. Calling this method will immediately set the permission's access status to "BLOCKED".

    Type declaration

    clearAccessRequests: (descriptor?: PermissionDescriptor) => void

    Clear recorded access requests that this user has received.

    If descriptor is provided, only access requests that match the descriptor will be cleared. Otherwise, all access requests will be cleared.

    Type declaration

    disableLocationServices: () => void

    Disable location services.

    This is equivalent to disabling location services at the device, operating system, or browser level.

    When location services are disabled, the Geolocation API will produce GeolocationPositionError errors with the code 2 (position unavailable).

    enableLocationServices: () => void

    Enable location services.

    This is equivalent to enabling location services at the device, operating system, or browser level.

    grantAccess: (descriptor: PermissionDescriptor) => void

    Grant access to a permission.

    This is equivalent to manually allowing access to a permission via the browser's permission settings. Calling this method will immediately set the permission's access status to "GRANTED".

    Type declaration

    jumpToCoordinates: (
        coordsParams: Partial<
            {
                accuracy: number;
                altitude: null
                | number;
                altitudeAccuracy: null | number;
                heading: null | number;
                latitude: number;
                longitude: number;
                speed: null | number;
            },
        >,
    ) => void

    Jump to the given coordinates.

    This will cause an immediate update to both high and low accuracy coordinates, which will be reflected via the fake Geolocation API in subsequent position retrievals, and will also cause calls to any active position watch callbacks.

    The supplied parameters will first be passed to the user's UserParameters.createCoordinates function to create the high accuracy coordinates. The low accuracy coordinates will then be created by passing the high accuracy coordinates to the user's UserParameters.lowAccuracyTransform function.

    Type declaration

      • (
            coordsParams: Partial<
                {
                    accuracy: number;
                    altitude: null
                    | number;
                    altitudeAccuracy: null | number;
                    heading: null | number;
                    latitude: number;
                    longitude: number;
                    speed: null | number;
                },
            >,
        ): void
      • Parameters

        • coordsParams: Partial<
              {
                  accuracy: number;
                  altitude: null
                  | number;
                  altitudeAccuracy: null | number;
                  heading: null | number;
                  latitude: number;
                  longitude: number;
                  speed: null | number;
              },
          >

          The parameters of the high accuracy coordinates to jump to.

        Returns void

    resetAccess: (descriptor: PermissionDescriptor) => void

    Reset access to a permission.

    This is equivalent to manually resetting access to a permission via the browser's permission settings. Calling this method will immediately set the permission's access status to "PROMPT".

    Type declaration

    setAccessRequestHandler: (handler: HandleAccessRequest) => void

    Change the handler used for permission access requests.

    Type declaration