Skip to content

Commit 0e1907f

Browse files
rename
1 parent a1e473f commit 0e1907f

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/bidiMapper/modules/browser/UserContextConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class UserContextConfig {
2828
readonly userContextId: string;
2929
viewport?: BrowsingContext.Viewport | null;
3030
devicePixelRatio?: number | null;
31-
emulatedGeolocation?:
31+
geolocationOverride?:
3232
| Emulation.GeolocationCoordinates
3333
| Emulation.GeolocationPositionError
3434
| null;

src/bidiMapper/modules/cdp/CdpTarget.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,12 @@ export class CdpTarget {
637637
}
638638

639639
if (
640-
this.#userContextConfig.emulatedGeolocation !== undefined &&
641-
this.#userContextConfig.emulatedGeolocation !== null
640+
this.#userContextConfig.geolocationOverride !== undefined &&
641+
this.#userContextConfig.geolocationOverride !== null
642642
) {
643643
promises.push(
644644
this.setGeolocationOverride(
645-
this.#userContextConfig.emulatedGeolocation,
645+
this.#userContextConfig.geolocationOverride,
646646
),
647647
);
648648
}
@@ -673,32 +673,32 @@ export class CdpTarget {
673673
}
674674

675675
async setGeolocationOverride(
676-
coordinates:
676+
geolocationOverride:
677677
| Emulation.GeolocationCoordinates
678678
| Emulation.GeolocationPositionError
679679
| null,
680680
): Promise<void> {
681-
if (coordinates === null) {
681+
if (geolocationOverride === null) {
682682
await this.cdpClient.sendCommand('Emulation.clearGeolocationOverride');
683-
} else if ('type' in coordinates) {
684-
if (coordinates.type !== 'positionUnavailable') {
683+
} else if ('type' in geolocationOverride) {
684+
if (geolocationOverride.type !== 'positionUnavailable') {
685685
// Unreachable.
686686
throw new UnknownErrorException(
687-
`Unknown geolocation error ${coordinates.type}`,
687+
`Unknown geolocation error ${geolocationOverride.type}`,
688688
);
689689
}
690690
// Omitting latitude, longitude or accuracy emulates position unavailable.
691691
await this.cdpClient.sendCommand('Emulation.setGeolocationOverride', {});
692-
} else if ('latitude' in coordinates) {
692+
} else if ('latitude' in geolocationOverride) {
693693
await this.cdpClient.sendCommand('Emulation.setGeolocationOverride', {
694-
latitude: coordinates.latitude,
695-
longitude: coordinates.longitude,
696-
accuracy: coordinates.accuracy ?? 1,
694+
latitude: geolocationOverride.latitude,
695+
longitude: geolocationOverride.longitude,
696+
accuracy: geolocationOverride.accuracy ?? 1,
697697
// `null` value is treated as "missing".
698-
altitude: coordinates.altitude ?? undefined,
699-
altitudeAccuracy: coordinates.altitudeAccuracy ?? undefined,
700-
heading: coordinates.heading ?? undefined,
701-
speed: coordinates.speed ?? undefined,
698+
altitude: geolocationOverride.altitude ?? undefined,
699+
altitudeAccuracy: geolocationOverride.altitudeAccuracy ?? undefined,
700+
heading: geolocationOverride.heading ?? undefined,
701+
speed: geolocationOverride.speed ?? undefined,
702702
});
703703
} else {
704704
// Unreachable.

src/bidiMapper/modules/emulation/EmulationProcessor.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class EmulationProcessor {
4545
);
4646
}
4747

48-
let emulatedGeolocation:
48+
let geolocationOverride:
4949
| Emulation.GeolocationCoordinates
5050
| Emulation.GeolocationPositionError
5151
| null = null;
@@ -60,15 +60,16 @@ export class EmulationProcessor {
6060
);
6161
}
6262

63-
emulatedGeolocation = params.coordinates;
63+
geolocationOverride = params.coordinates;
6464
} else if ('error' in params) {
6565
if (params.error.type !== 'positionUnavailable') {
6666
throw new InvalidArgumentException(
6767
`Unknown geolocation error ${params.error.type}`,
6868
);
6969
}
70-
emulatedGeolocation = params.error;
70+
geolocationOverride = params.error;
7171
} else {
72+
// Unreachable.
7273
throw new InvalidArgumentException(`Coordinates or error should be set`);
7374
}
7475

@@ -80,13 +81,13 @@ export class EmulationProcessor {
8081
for (const userContextId of params.userContexts ?? []) {
8182
const userContextConfig =
8283
this.#userContextStorage.getConfig(userContextId);
83-
userContextConfig.emulatedGeolocation = emulatedGeolocation;
84+
userContextConfig.geolocationOverride = geolocationOverride;
8485
}
8586

8687
await Promise.all(
8788
browsingContexts.map(
8889
async (context) =>
89-
await context.cdpTarget.setGeolocationOverride(emulatedGeolocation),
90+
await context.cdpTarget.setGeolocationOverride(geolocationOverride),
9091
),
9192
);
9293
return {};

0 commit comments

Comments
 (0)