testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html
author Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Wed, 13 May 2020 09:48:44 +0000
changeset 531162 7143cd0578a92d557e51976c537783f2f988fc9b
parent 530146 267cd03f6f5c9a7984056554c2296939a79afdf0
permissions -rw-r--r--
Bug 1636462 [wpt PR 23481] - device orientation: Try to remove flakiness from tests., a=testonly Automatic update from web-platform-tests device orientation: Try to remove flakiness from tests. https://crrev.com/c/2154389 ("[device-orientation] Simplifies tests by using EventWatcher") ended up introducing some Chromium-specific flakiness to most tests that started using EventWatcher, and the Mac bots in particular seem to trigger this flakiness very often. This comes from the fact that EventWatcher will continue watching for events until the end of the test, and the Blink implementation of the DeviceOrientation Event specification ends up emitting a non-standard null event whenever there are no more events to send. This event can end up being caught by EventWatcher, which correctly reports it as unexpected. For now, replace most usages of EventWatcher with a much simplified version of the waitForEvent() function removed in the CL above that only subscribes to events once. Bug: 816462, 1078298 Change-Id: I181219f2be19bba8a392c2bf64373f01df46c398 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2190273 Commit-Queue: Reilly Grant <reillyg@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Cr-Commit-Position: refs/heads/master@{#766988} -- wpt-commits: 54b6be43d7c1be3393ddf921703e60dee74e7777 wpt-pr: 23481

<!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);
  setMockOrientationData(sensorProvider, orientationData);
  return waitForEvent(getExpectedOrientationEvent(orientationData));
}, 'Tests basic operation of deviceorientation event using mock data.');

sensor_test(async (t, sensorProvider) => {
  const orientationData = generateOrientationData(null, null, null, false);
  const watcher = new EventWatcher(t, window, ['deviceorientation']);

  // Make the orientation sensor unavailable
  sensorProvider.setGetSensorShouldFail('AbsoluteOrientationEulerAngles', true);
  sensorProvider.setGetSensorShouldFail('RelativeOrientationEulerAngles', true);
  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>