Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js

Issue 2589283003: [Sensors] Reland: Align sensor reading updates and 'onchange' notification with rAF. (Closed)
Patch Set: Robust tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
diff --git a/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js b/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
index 03f32d9418ec51e827ddf52841cb44a74f8de4da..1225458173fdaddd59fc9c06a0af4ea64684937d 100644
--- a/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
+++ b/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js
@@ -39,6 +39,7 @@ function sensor_mocks(mojo) {
this.reporting_mode_ = reportingMode;
this.sensor_reading_timer_id_ = null;
this.update_reading_function_ = null;
+ this.reading_updates_count_ = 0;
this.suspend_called_ = null;
this.resume_called_ = null;
this.add_configuration_called_ = null;
@@ -62,6 +63,9 @@ function sensor_mocks(mojo) {
return Promise.resolve({frequency: 5});
}
+ reading_updates_count() {
+ return this.reading_updates_count_;
+ }
// Adds configuration for the sensor and starts reporting fake data
// through update_reading_function_ callback.
addConfiguration(configuration) {
@@ -197,9 +201,12 @@ function sensor_mocks(mojo) {
this.active_sensor_configurations_[0].frequency;
let timeout = (1 / max_frequency_used) * 1000;
this.sensor_reading_timer_id_ = window.setInterval(() => {
shalamov 2016/12/21 10:41:03 Should we clear previous interval if addConfigurat
Mikhail 2016/12/21 13:06:28 Right, thanks for the catch!
- if (this.update_reading_function_)
+ if (this.update_reading_function_) {
this.update_reading_function_(this.buffer_,
- this.expects_modified_reading_);
+ this.expects_modified_reading_,
+ this.reading_updates_count_);
+ this.reading_updates_count_++;
+ }
if (this.reporting_mode_ === sensor.ReportingMode.ON_CHANGE) {
this.client_.sensorReadingChanged();
}

Powered by Google App Engine
This is Rietveld 408576698