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

Unified Diff: third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html

Issue 2353493002: [Sensors] Allow Sensor API only on secure top-level browsing contexts and add frequency checks (Closed)
Patch Set: Comments from Tim Created 4 years, 3 months 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/ambient-light-sensor.html
diff --git a/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html b/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
index 340cd572d7dd92bbefffaa5ebe5205e6dec141bf..00fbba52ce1d0a5a1ab2f2ab1682575d545bfe4c 100644
--- a/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
+++ b/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
@@ -17,6 +17,37 @@ function update_sensor_reading(buffer) {
buffer[1] = kDefaultReadingValue;
}
+test(() => assert_throws(
+ new RangeError(),
+ () => new AmbientLightSensor({frequency: -60})),
+ 'Test that negative frequency causes exception from constructor.');
+
+sensor_test(sensor => {
+ let ambientLightSensor = new AmbientLightSensor({frequency: 560});
+ ambientLightSensor.start();
+
+ let testPromise = sensor.mockSensorProvider.getCreatedSensor()
+ .then(mockSensor => { return mockSensor.addConfigurationCalled(); })
+ .then(mockSensor => {
+ return new Promise((resolve, reject) => {
+ ambientLightSensor.onstatechange = event => {
+ if (ambientLightSensor.state === 'idle') {
timvolodine 2016/09/20 17:46:37 why is this case needed?
Mikhail 2016/09/21 10:00:42 here we wait when the sensor gets actually stopped
+ resolve(mockSensor);
+ }
+
+ if (ambientLightSensor.state === 'active') {
+ let configuration = mockSensor.active_sensor_configurations_[0];
+ assert_equals(configuration.frequency, 60);
+ ambientLightSensor.stop();
+ }
+ };
+ });
+ })
+ .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
+
+ return testPromise;
+}, 'Test that frequency is capped to 60.0 Hz.');
+
sensor_test(sensor => {
let ambientLightSensor = new AmbientLightSensor({frequency: 60});
ambientLightSensor.start();

Powered by Google App Engine
This is Rietveld 408576698