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

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

Issue 2381913002: [sensors] Dispatch sensor events using postTask (Closed)
Patch Set: Rebased. Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/sensor-helpers.js"></script> 5 <script src="resources/sensor-helpers.js"></script>
6 <script> 6 <script>
7 7
8 'use strict'; 8 'use strict';
9 9
10 if (!window.testRunner) 10 if (!window.testRunner)
11 debug('This test cannot be run without the TestRunner'); 11 debug('This test cannot be run without the TestRunner');
12 12
13 const kDefaultReadingValue = 3.1415; 13 const kDefaultReadingValue = 3.1415;
14 14
15 function update_sensor_reading(buffer) { 15 function update_sensor_reading(buffer) {
16 buffer[0] = window.performance.now(); 16 buffer[0] = window.performance.now();
17 buffer[1] = kDefaultReadingValue; 17 buffer[1] = kDefaultReadingValue;
18 } 18 }
19 19
20 test(() => assert_throws( 20 test(() => assert_throws(
21 new RangeError(), 21 new RangeError(),
22 () => new AmbientLightSensor({frequency: -60})), 22 () => new AmbientLightSensor({frequency: -60})),
23 'Test that negative frequency causes exception from constructor.'); 23 'Test that negative frequency causes exception from constructor.');
24 24
25 sensor_test(sensor => { 25 sensor_test(sensor => {
26 sensor.mockSensorProvider.setGetSensorShouldFail(true);
27 let ambientLightSensor = new AmbientLightSensor();
28 ambientLightSensor.start();
29 return new Promise((resolve, reject) => {
30 ambientLightSensor.onstatechange = event => {
31 if(ambientLightSensor.state == 'errored') {
32 resolve();
33 }
34 };
35 });
36 }, 'Test that sensor state changes to "errored" when sensor is not supported.');
37
38 sensor_test(sensor => {
26 let ambientLightSensor = new AmbientLightSensor({frequency: 560}); 39 let ambientLightSensor = new AmbientLightSensor({frequency: 560});
27 ambientLightSensor.start(); 40 ambientLightSensor.start();
28 41
29 let testPromise = sensor.mockSensorProvider.getCreatedSensor() 42 let testPromise = sensor.mockSensorProvider.getCreatedSensor()
30 .then(mockSensor => { return mockSensor.addConfigurationCalled(); }) 43 .then(mockSensor => { return mockSensor.addConfigurationCalled(); })
31 .then(mockSensor => { 44 .then(mockSensor => {
32 return new Promise((resolve, reject) => { 45 return new Promise((resolve, reject) => {
33 ambientLightSensor.onstatechange = event => { 46 ambientLightSensor.onstatechange = event => {
34 if (ambientLightSensor.state === 'idle') { 47 if (ambientLightSensor.state === 'idle') {
35 resolve(mockSensor); 48 resolve(mockSensor);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 ambientLightSensor.onerror = reject; 224 ambientLightSensor.onerror = reject;
212 }); 225 });
213 }) 226 })
214 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); 227 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
215 228
216 return testPromise; 229 return testPromise;
217 }, 'Test that sensor receives suspend / resume notifications when page' 230 }, 'Test that sensor receives suspend / resume notifications when page'
218 +' visibility changes.'); 231 +' visibility changes.');
219 232
220 </script> 233 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698