Skip to content

Commit

Permalink
Bug 1585682 [wpt PR 19467] - [sensors] Round off Ambient Light Sensor…
Browse files Browse the repository at this point in the history
… readouts to the nearest 50 Lux., a=testonly

Automatic update from web-platform-tests
[sensors] Round off Ambient Light Sensor readouts to the nearest 50 Lux.

There have been some concerns regarding the precision of readouts from the
Ambient Light Sensor. To decrease the entropy, we are rounding off the
illuminance value to the nearest 50 Lux to mitigate the known attack
vectors as summarized in [1].

[1] w3c/ambient-light#13 (comment)

This CL is based on
https://chromium-review.googlesource.com/c/chromium/src/+/1695412 by
Rijubrata Bhaumik and myself.

Bug: 642731, 606766
Change-Id: I85449bdb835e8486b080fc269938b6c96f000c2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834346
Reviewed-by: Reilly Grant <reillygchromium.org>
Reviewed-by: Kentaro Hara <harakenchromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costaintel.com>
Cr-Commit-Position: refs/heads/master{#705486}

--

wpt-commits: b5c2b81b664dbf9fccf7316017ada0878fc10fa1
wpt-pr: 19467

UltraBlame original commit: 36a1b8d7d73706d8223e20f47649db4e8741d20f
  • Loading branch information
marco-c committed Oct 27, 2019
1 parent c8de81c commit f8959c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_),
Expand Down

0 comments on commit f8959c9

Please sign in to comment.