mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
14
lib/Page.js
14
lib/Page.js
@@ -144,6 +144,20 @@ class Page extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!{longitude: number, latitude: number, accuracy: (number|undefined)}} options
|
||||
*/
|
||||
async setGeolocation(options) {
|
||||
const { longitude, latitude, accuracy = 0} = options;
|
||||
if (longitude < -180 || longitude > 180)
|
||||
throw new Error(`Invalid longitude "${longitude}": precondition -180 <= LONGITUDE <= 180 failed.`);
|
||||
if (latitude < -90 || latitude > 90)
|
||||
throw new Error(`Invalid latitude "${latitude}": precondition -90 <= LATITUDE <= 90 failed.`);
|
||||
if (accuracy < 0)
|
||||
throw new Error(`Invalid accuracy "${accuracy}": precondition 0 <= ACCURACY failed.`);
|
||||
await this._client.send('Emulation.setGeolocationOverride', {longitude, latitude, accuracy});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Puppeteer.Target}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user