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 262145feca1793baebf1d93189cdde29be69e497..236262f349f50d185ffa0fb3476e589cc635b794 100644 |
--- a/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
+++ b/third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js |
@@ -41,6 +41,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; |
@@ -63,6 +64,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) { |
@@ -127,6 +131,7 @@ function sensor_mocks(mojo) { |
this.stopReading(); |
this.expects_modified_reading_ = false; |
+ this.reading_updates_count_ = 0; |
this.start_should_fail_ = false; |
this.update_reading_function_ = null; |
this.active_sensor_configurations_ = []; |
@@ -194,13 +199,17 @@ function sensor_mocks(mojo) { |
startReading() { |
if (this.update_reading_function_ != null) { |
+ this.stopReading(); |
let max_frequency_used = |
this.active_sensor_configurations_[0].frequency; |
let timeout = (1 / max_frequency_used) * 1000; |
this.sensor_reading_timer_id_ = window.setInterval(() => { |
- 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(); |
} |