Skip to content

Files

Latest commit

ea2a5d6 · Oct 26, 2023

History

History
This branch is 7636 commits behind web-platform-tests/wpt:master.

generic-sensor

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 26, 2023
Jan 26, 2022
Sep 18, 2019
Jan 22, 2020
Sep 23, 2020
Oct 26, 2023
Dec 2, 2022
Oct 26, 2023
Oct 15, 2021

The resources/generic-sensor-helpers.js tests require an implementation of the GenericSensorTest interface, which should emulate platform sensor backends. The GenericSensorTest interface is defined as:

  class MockSensor {
    // Sets fake data that is used to deliver sensor reading updates.
    async setSensorReading(FrozenArray<double> readingData);
    setStartShouldFail(boolean shouldFail); // Sets flag that forces sensor to fail.
    getSamplingFrequency(); // Return the sampling frequency.
  };

  class MockSensorProvider {
    // Sets flag that forces mock SensorProvider to fail when getSensor() is
    // invoked.
    setGetSensorShouldFail(DOMString sensorType, boolean shouldFail);
    // Sets flag that forces mock SensorProvider to permissions denied when
    // getSensor() is invoked.
    setPermissionsDenied(DOMString sensorType, boolean permissionsDenied);
    getCreatedSensor(DOMString sensorType); // Return `MockSensor` interface.
    setMaximumSupportedFrequency(double frequency); // Sets the maximum frequency.
    setMinimumSupportedFrequency(double frequency); // Sets the minimum frequency.
  }

  class GenericSensorTest {
    initialize();  // Sets up the testing environment.
    async reset(); // Frees the resources.
    getSensorProvider(); // Returns `MockSensorProvider` interface.
  };

The Chromium implementation of the GenericSensorTest interface is located in generic_sensor_mocks.js.

Other browser vendors should provide their own implementations of the GenericSensorTest interface.

Known issue: a WebDriver extension is a better approach for the Generic Sensor tests automation.