Don't forget the Chrome Dev Summit, starting Monday at 10:00am (Pacific) and streaming live on YouTube. Schedule.

Emulate Sensors: Geolocation and Accelerometer

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.

TL;DR

  • Emulate geolocation coordinates to test geolocation overrides.
  • Simulate device orientation to test accelerometer data.

Access sensor controls

To access the Chrome DevTools sensor controls:

  1. Open the DevTools main menu, then
  2. Under More Tools, click on Sensors
Navigate to Sensors panel

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.

geolocation emulator enabled

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.

Accelerometer control

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.