| OLD | NEW |
| 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) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 sensor_test(sensor => { | 38 sensor_test(sensor => { |
| 39 sensor.mockSensorProvider.setGetSensorShouldFail(true); | 39 sensor.mockSensorProvider.setGetSensorShouldFail(true); |
| 40 let ambientLightSensor = new AmbientLightSensor(); | 40 let ambientLightSensor = new AmbientLightSensor(); |
| 41 ambientLightSensor.start(); | 41 ambientLightSensor.start(); |
| 42 return new Promise((resolve, reject) => { | 42 return new Promise((resolve, reject) => { |
| 43 ambientLightSensor.onerror = event => { | 43 ambientLightSensor.onerror = event => { |
| 44 assert_equals(ambientLightSensor.state, 'errored'); | 44 assert_equals(ambientLightSensor.state, 'errored'); |
| 45 console.log(event.error.message); | 45 console.log(event.error.message); |
| 46 assert_equals(event.error.name, 'NotFoundError'); | 46 assert_equals(event.error.name, 'NotFoundError'); |
| 47 ambientLightSensor.onerror = null; |
| 47 resolve(); | 48 resolve(); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 }); | 51 }); |
| 51 }, 'Test that "onerror" is send when sensor is not supported.'); | 52 }, 'Test that "onerror" is send when sensor is not supported.'); |
| 52 | 53 |
| 53 | 54 |
| 54 sensor_test(sensor => { | 55 sensor_test(sensor => { |
| 55 let ambientLightSensor = new AmbientLightSensor({frequency: 560}); | 56 let ambientLightSensor = new AmbientLightSensor({frequency: 560}); |
| 56 ambientLightSensor.start(); | 57 ambientLightSensor.start(); |
| 57 | 58 |
| 58 let testPromise = sensor.mockSensorProvider.getCreatedSensor() | 59 let testPromise = sensor.mockSensorProvider.getCreatedSensor() |
| 59 .then(mockSensor => { | 60 .then(mockSensor => { |
| 60 mockSensor.setStartShouldFail(true); | 61 mockSensor.setStartShouldFail(true); |
| 61 return mockSensor.addConfigurationCalled(); }) | 62 return mockSensor.addConfigurationCalled(); }) |
| 62 .then(mockSensor => { | 63 .then(mockSensor => { |
| 63 return new Promise((resolve, reject) => { | 64 return new Promise((resolve, reject) => { |
| 64 ambientLightSensor.onerror = event => { | 65 ambientLightSensor.onerror = event => { |
| 65 assert_equals(ambientLightSensor.state, 'errored'); | 66 assert_equals(ambientLightSensor.state, 'errored'); |
| 66 assert_equals(event.error.name, 'OperationError'); | 67 assert_equals(event.error.name, 'OperationError'); |
| 68 ambientLightSensor.onerror = null; |
| 67 resolve(); | 69 resolve(); |
| 68 }; | 70 }; |
| 69 }); | 71 }); |
| 70 }); | 72 }); |
| 71 return testPromise; | 73 return testPromise; |
| 72 }, 'Test that "onerror" is send when start() call has failed.'); | 74 }, 'Test that "onerror" is send when start() call has failed.'); |
| 73 | 75 |
| 74 sensor_test(sensor => { | 76 sensor_test(sensor => { |
| 75 let ambientLightSensor = new AmbientLightSensor({frequency: 560}); | 77 let ambientLightSensor = new AmbientLightSensor({frequency: 560}); |
| 76 ambientLightSensor.start(); | 78 ambientLightSensor.start(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 ambientLightSensor.onerror = reject; | 262 ambientLightSensor.onerror = reject; |
| 261 }); | 263 }); |
| 262 }) | 264 }) |
| 263 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); | 265 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); |
| 264 | 266 |
| 265 return testPromise; | 267 return testPromise; |
| 266 }, 'Test that sensor receives suspend / resume notifications when page' | 268 }, 'Test that sensor receives suspend / resume notifications when page' |
| 267 +' visibility changes.'); | 269 +' visibility changes.'); |
| 268 | 270 |
| 269 </script> | 271 </script> |
| OLD | NEW |