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

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

Issue 2471103002: [sensors] Close mock sensor stubs after test is finished (Closed)
Patch Set: Fix for comment from Mikhail Created 4 years, 1 month 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)
(...skipping 26 matching lines...) Expand all
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
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>
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