OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 function usb_test(func, name, properties) { | 3 function usb_test(func, name, properties) { |
4 promise_test(() => { | 4 promise_test(() => { |
5 return navigator.usb.test.initialize().then(() => { | 5 return navigator.usb.test.initialize().then(() => { |
6 let testResult = func(); | 6 let testResult = func(); |
7 let cleanup = () => { | 7 let cleanup = () => { |
8 navigator.usb.test.reset(); | 8 navigator.usb.test.reset(); |
9 }; | 9 }; |
10 testResult.then(cleanup, cleanup); | 10 testResult.then(cleanup, cleanup); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } else if (Array.isArray(deviceInit[property])) { | 67 } else if (Array.isArray(deviceInit[property])) { |
68 assert_equals(usbDevice[property].length, deviceInit[property].length); | 68 assert_equals(usbDevice[property].length, deviceInit[property].length); |
69 for (var i = 0; i < usbDevice[property].length; ++i) | 69 for (var i = 0; i < usbDevice[property].length; ++i) |
70 assertDeviceInfoEquals(usbDevice[property][i], deviceInit[property][i]); | 70 assertDeviceInfoEquals(usbDevice[property][i], deviceInit[property][i]); |
71 } else { | 71 } else { |
72 assert_equals(usbDevice[property], deviceInit[property], property); | 72 assert_equals(usbDevice[property], deviceInit[property], property); |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: | 77 function callWithTrustedClick(callback) { |
78 // https://crbug.com/509058. | |
79 function callWithKeyDown(functionCalledOnKeyPress) { | |
80 return new Promise(resolve => { | 78 return new Promise(resolve => { |
81 function onKeyPress() { | 79 let button = document.createElement('button'); |
82 document.removeEventListener('keypress', onKeyPress, false); | 80 button.textContent = 'click to continue test'; |
83 resolve(functionCalledOnKeyPress()); | 81 button.style.display = 'block'; |
84 } | 82 button.style.fontSize = '20px'; |
85 document.addEventListener('keypress', onKeyPress, false); | 83 button.style.padding = '10px'; |
86 | 84 button.onclick = () => { |
87 eventSender.keyDown(' ', []); | 85 resolve(callback()); |
| 86 document.body.removeChild(button); |
| 87 }; |
| 88 document.body.appendChild(button); |
88 }); | 89 }); |
89 } | 90 } |
90 | |
91 function runGarbageCollection() { | |
92 // Run gc() as a promise. | |
93 return new Promise((resolve, reject) => { | |
94 GCController.collect(); | |
95 setTimeout(resolve, 0); | |
96 }); | |
97 } | |
OLD | NEW |