зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637933 [wpt PR 23595] - device orientation: Ensure new reading values are available in tests., a=testonly
Automatic update from web-platform-tests device orientation: Ensure new reading values are available in tests. Several tests in external/wpt/orientation-event/ have been flaky, especially the Device Orientation ones. The Device Orientation spec implementation in Blink uses its own timer at 60Hz to read from the shared memory buffer updated by the platform sensors, rather than relying on OnSensorReadingChanged() being called by the platform side. The MockSensor implementation in WPT uses window.setInterval() to update the shared memory buffer and simulate a real platform sensor. For some reason, the Mac bots in particular seem to cause those two timers to get out of sync quite often, in which case the Device Orientation implementation might end up reading an older value even though a test has already called setMock{Motion,Orientation}Data() again. Fix it by adding a workaround: in the Device Orientation tests (but not the Generic Sensors ones), we immediately update the shared memory buffer when changing a mock sensor's reading so that the value will always be available to the Device Orientation code. Bug: 1081633 Change-Id: Id12bbfc5c2b2f9dca6127797a95982b208fc4b5b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199066 Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#769207} -- wpt-commits: dcc8f62cca9a82c05d0a70cdaf01d271301702d8 wpt-pr: 23595
This commit is contained in:
Родитель
661184a9e5
Коммит
0ef457aa6c
|
@ -91,7 +91,15 @@ function generateOrientationData(alpha, beta, gamma, absolute) {
|
|||
|
||||
async function setMockSensorDataForType(sensorProvider, sensorType, mockDataArray) {
|
||||
const createdSensor = await sensorProvider.getCreatedSensor(sensorType);
|
||||
return createdSensor.setSensorReading([mockDataArray]);
|
||||
// We call setSensorReadingAndUpdateSharedBuffer() rather than
|
||||
// setSensorReading() to accommodate Blink's Device Orientation
|
||||
// implementation, which uses its own timer to read the sensor's shared
|
||||
// memory buffer rather than relying on SensorReadingChanged(). This timer
|
||||
// may fire out of sync with the JS timer in MockSensor.startReading(), so
|
||||
// the former might read the shared memory buffer before the latter has
|
||||
// updated |this.buffer_|. We thus immediately update the buffer here
|
||||
// (without consuming data from the ring buffer).
|
||||
return createdSensor.setSensorReadingImmediately([mockDataArray]);
|
||||
}
|
||||
|
||||
// Device[Orientation|Motion]EventPump treat NaN as a missing value.
|
||||
|
|
|
@ -21,6 +21,10 @@ class RingBuffer {
|
|||
return { done: false, value: value };
|
||||
}
|
||||
|
||||
value() {
|
||||
return this.data_[this.bufferPosition_];
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
|
@ -112,6 +116,17 @@ var GenericSensorTest = (() => {
|
|||
return this;
|
||||
}
|
||||
|
||||
// This is a workaround to accommodate Blink's Device Orientation
|
||||
// implementation. In general, all tests should use setSensorReading()
|
||||
// instead.
|
||||
setSensorReadingImmediately(readingData) {
|
||||
this.setSensorReading(readingData);
|
||||
|
||||
const reading = this.readingData_.value();
|
||||
this.buffer_.set(reading, 2);
|
||||
this.buffer_[1] = window.performance.now() * 0.001;
|
||||
}
|
||||
|
||||
// Sets flag that forces sensor to fail when addConfiguration is invoked.
|
||||
setStartShouldFail(shouldFail) {
|
||||
this.startShouldFail_ = shouldFail;
|
||||
|
|
Загрузка…
Ссылка в новой задаче