diff --git a/testing/web-platform/tests/generic-sensor/generic-sensor-tests.js b/testing/web-platform/tests/generic-sensor/generic-sensor-tests.js index d37b6c1f8cbca..65e853cd8b914 100644 --- a/testing/web-platform/tests/generic-sensor/generic-sensor-tests.js +++ b/testing/web-platform/tests/generic-sensor/generic-sensor-tests.js @@ -246,12 +246,15 @@ function runGenericSensorTests(sensorName, assert_true(verificationFunction(expected, sensor2, true)); }, `${sensorName}: sensor reading is correct.`); - sensor_test(async t => { + sensor_test(async (t, sensorProvider) => { assert_true(sensorName in self); const sensor = new sensorType(); const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]); sensor.start(); + const mockSensor = await sensorProvider.getCreatedSensor(sensorName); + await mockSensor.setSensorReading(readings); + await sensorWatcher.wait_for("reading"); const cachedTimeStamp1 = sensor.timestamp; @@ -392,6 +395,7 @@ function runGenericSensorTests(sensorName, fastSensor.start(); const mockSensor = await sensorProvider.getCreatedSensor(sensorName); + await mockSensor.setSensorReading(readings); const fastCounter = await new Promise((resolve, reject) => { let fastSensorNotifiedCounter = 0; diff --git a/testing/web-platform/tests/resources/chromium/generic_sensor_mocks.js b/testing/web-platform/tests/resources/chromium/generic_sensor_mocks.js index 1efa8e1b04afe..566ebeb19c3e5 100644 --- a/testing/web-platform/tests/resources/chromium/generic_sensor_mocks.js +++ b/testing/web-platform/tests/resources/chromium/generic_sensor_mocks.js @@ -199,6 +199,19 @@ var GenericSensorTest = (() => { this.maxFrequency_ = Math.min(10, this.maxFrequency_); } + + + + + + + if (type == device.mojom.SensorType.AMBIENT_LIGHT) { + this.activeSensors_.get(type).setSensorReading([ + [window.performance.now() * 100], + [(window.performance.now() + 50) * 100] + ]); + } + const initParams = new device.mojom.SensorInitParams({ sensor: sensorPtr, clientReceiver: mojo.makeRequest(this.activeSensors_.get(type).client_),