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

Side by Side Diff: third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js

Issue 2660563003: [Sensors] Improve error logging in sensors layout tests (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 // Wraps callback and calls reject_func if callback throws an error. 3 // Wraps callback and calls reject_func if callback throws an error.
4 class CallbackWrapper { 4 class CallbackWrapper {
5 constructor(callback, reject_func) { 5 constructor(callback, reject_func) {
6 this.wrapper_func_ = (args) => { 6 this.wrapper_func_ = (args) => {
7 try { 7 try {
8 callback(args); 8 callback(args);
9 } catch(e) { 9 } catch(e) {
10 reject_func(); 10 reject_func(e);
11 } 11 }
12 } 12 }
13 } 13 }
14 14
15 get callback() { 15 get callback() {
16 return this.wrapper_func_; 16 return this.wrapper_func_;
17 } 17 }
18 } 18 }
19 19
20 function sensor_mocks(mojo) { 20 function sensor_mocks(mojo) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 function sensor_test(func, name, properties) { 367 function sensor_test(func, name, properties) {
368 mojo_test(mojo => sensor_mocks(mojo).then(sensor => { 368 mojo_test(mojo => sensor_mocks(mojo).then(sensor => {
369 // Clean up and reset mock sensor stubs asynchronously, so that the blink 369 // Clean up and reset mock sensor stubs asynchronously, so that the blink
370 // side closes its proxies and notifies JS sensor objects before new test is 370 // side closes its proxies and notifies JS sensor objects before new test is
371 // started. 371 // started.
372 let onSuccess = () => { 372 let onSuccess = () => {
373 sensor.mockSensorProvider.reset(); 373 sensor.mockSensorProvider.reset();
374 return new Promise((resolve, reject) => { setTimeout(resolve, 0); }); 374 return new Promise((resolve, reject) => { setTimeout(resolve, 0); });
375 }; 375 };
376 376
377 let onFailure = () => { 377 let onFailure = error => {
378 sensor.mockSensorProvider.reset(); 378 sensor.mockSensorProvider.reset();
379 return new Promise((resolve, reject) => { setTimeout(reject, 0); }); 379 return new Promise((resolve, reject) => { setTimeout(() => {reject(error); }, 0); });
380 }; 380 };
381 381
382 return Promise.resolve(func(sensor)).then(onSuccess, onFailure); 382 return Promise.resolve(func(sensor)).then(onSuccess, onFailure);
383 }), name, properties); 383 }), name, properties);
384 } 384 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698