What does this test check?
The compass test verifies that your device can report orientation data through the browser. It checks:
- Sensor availability — whether DeviceOrientationEvent is supported and sensors are present on the device.
- Heading accuracy — the compass heading in degrees (0–360°) relative to magnetic north.
- Absolute orientation — whether the device provides absolute (true north) or relative orientation data.
- Permission status — whether the browser has granted sensor access (required on iOS 13+).
How the compass test works
- The page requests permission to access device orientation sensors (required on iOS and some other platforms).
- Once granted, it listens to the DeviceOrientationEvent and DeviceOrientationAbsoluteOrientationEvent.
- The heading, beta, and gamma values are displayed in real time.
- You can verify the compass reacts when you rotate or tilt the device.
Understanding the values
- Heading (alpha) — rotation around the z-axis in degrees. 0° is north, 90° is east, 180° is south, 270° is west.
- Beta — front-to-back tilt in degrees. -180° to 180°.
- Gamma — left-to-right tilt in degrees. -90° to 90°.
- Absolute— whether the orientation is relative to Earth's coordinate frame (true north) or relative to the device's initial position.
Why might the compass not work?
Several factors can prevent compass readings:
- The device lacks a magnetometer (common on many desktops and some budget laptops).
- The browser denied sensor permission — try reloading and accepting the prompt.
- Magnetic interference from nearby metal objects, cases with magnets, or electronic devices.
- The device is stationary and the API only provides relative orientation on that platform.