<!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';

sensor_test(async (t, sensorProvider) => {
  const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);

  let setMockDataPromise = setMockOrientationData(sensorProvider, orientationData);
  // Add an empty listener to make sure the event pump is running and the mock
  // sensor is created and configured. If the pump and fake sensor weren't set
  // up ahead of time, then the fact that we get an asynchronous event could be
  // due to the asynchronous set up process.
  window.addEventListener('deviceorientation', event => {});
  await setMockDataPromise;

  return new Promise((resolve, reject) => {
    let result = reject;
    window.addEventListener('deviceorientation', event => result());
    result = resolve;
  });
}, 'Tests that events are never fired synchronously from a call to window.addEventListener().');
</script>
