GPS chips and accelerometers can be difficult to test since most desktops don't have them. The Chrome DevTools Sensors emulation pane reduces the overhead of testing by emulating common mobile device sensors.
- Emulate geolocation coordinates to test geolocation overrides.
- Simulate device orientation to test accelerometer data.
Access sensor controls
To access the Chrome DevTools sensor controls:
- Open the DevTools main menu, then
- Under More Tools, click on Sensors
Override geolocation data
Unlike desktops, mobile devices commonly use GPS hardware to detect location. In the Sensors pane, you can simulate geolocation coordinates to use with the Geolocation API.
Enable the geolocation emulation by selecting the Emulate geolocation coordinates checkbox in the sensors pane of the emulation drawer.
You can use this emulator to override position values for
navigator.geolocation, as well as to simulate cases when geolocation data is unavailable.
Emulate Accelerometer (Device Orientation)
To test accelerometer data coming from the Orientation API, enable the accelerometer emulator by selecting the Accelerometer checkbox in the Sensors pane.
You can manipulate the following orientation parameters:
- Rotation around the z-axis.
- Left-to-right tilt.
- Front-to-back tilt.
You can also click and drag the model accelerometer to the desired orientation.
Try out the accelerometer emulator using this device orientation demo.
Was this page helpful?