Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /orientation-event/orientation/basic-operation.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="../resources/orientation-event-helpers.js"></script>
<script>
'use strict';
promise_test(async (t) => {
const helper = new SensorTestHelper(t, 'deviceorientation');
await helper.grantSensorsPermissions();
await helper.initializeSensors();
const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);
await helper.setData(orientationData);
await waitForEvent(getExpectedOrientationEvent(orientationData));
}, 'Tests basic operation of deviceorientation event using mock data.');
promise_test(async (t) => {
const helper = new SensorTestHelper(t, 'deviceorientation');
await helper.grantSensorsPermissions();
await helper.initializeSensors({disabledSensors: ['relative-orientation']});
const orientationData = generateOrientationData(null, null, null, false);
const watcher = new EventWatcher(t, window, ['deviceorientation']);
const event = await watcher.wait_for('deviceorientation');
assert_equals(event.type, 'deviceorientation', 'type is set to \"deviceorientation\"');
assert_true(event instanceof DeviceOrientationEvent, 'event is DeviceOrientationEvent');
assertEventEquals(event, getExpectedOrientationEvent(orientationData));
}, 'If UA can never provide orientation information, the event should be fired as a null event.');
</script>