Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!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, 'devicemotion');
// 1. Explicitly deny permissions via test_driver.
await test_driver.set_permission({name: 'accelerometer'}, 'denied');
await test_driver.set_permission({name: 'gyroscope'}, 'denied');
// 2. Initialize virtual sensors (ensure the environment is consistent).
await helper.initializeSensors();
// 3. Define the expected null data.
const expectedData = generateMotionData(null, null, null,
null, null, null,
null, null, null);
const expectedEvent = getExpectedMotionEvent(expectedData);
// 4. Wait for the one-time null event.
// This will add the event listener and resolve when the event fires and matches.
await waitForEvent(expectedEvent);
}, 'DeviceMotion event fires once with null values when user permission is denied');
</script>