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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/webusb/resources/usb-helpers.js

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 24 matching lines...) Expand all
35 } else if (Array.isArray(deviceInit[property])) { 35 } else if (Array.isArray(deviceInit[property])) {
36 assert_equals(usbDevice[property].length, deviceInit[property].length); 36 assert_equals(usbDevice[property].length, deviceInit[property].length);
37 for (var i = 0; i < usbDevice[property].length; ++i) 37 for (var i = 0; i < usbDevice[property].length; ++i)
38 assertDeviceInfoEquals(usbDevice[property][i], deviceInit[property][i]); 38 assertDeviceInfoEquals(usbDevice[property][i], deviceInit[property][i]);
39 } else { 39 } else {
40 assert_equals(usbDevice[property], deviceInit[property], property); 40 assert_equals(usbDevice[property], deviceInit[property], property);
41 } 41 }
42 } 42 }
43 } 43 }
44 44
45 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: 45 // TODO(reillyg): Remove when jyasskin upstreams this to testharness.js:
ortuno 2017/04/03 01:47:19 I don't think we can upstream yet because of this
Navid Zolghadr 2017/04/03 14:24:34 I'm trying to push it through this PR. https://git
ortuno 2017/04/03 23:22:30 We don't necessarily need injecting key inputs. Th
foolip 2017/04/05 06:03:32 It looks like all the calls to callWithKeyDown() w
Reilly Grant (use Gerrit) 2017/04/05 18:39:37 callWithKeyDown() is used when testing navigator.u
46 // https://crbug.com/509058. 46 // https://crbug.com/509058.
47 function callWithKeyDown(functionCalledOnKeyPress) { 47 function callWithKeyDown(functionCalledOnKeyPress) {
48 return new Promise(resolve => { 48 return new Promise(resolve => {
49 function onKeyPress() { 49 function onKeyPress() {
50 document.removeEventListener('keypress', onKeyPress, false); 50 document.removeEventListener('keypress', onKeyPress, false);
51 resolve(functionCalledOnKeyPress()); 51 resolve(functionCalledOnKeyPress());
52 } 52 }
53 document.addEventListener('keypress', onKeyPress, false); 53 document.addEventListener('keypress', onKeyPress, false);
54 54
55 eventSender.keyDown(' ', []); 55 eventSender.keyDown(' ', []);
56 }); 56 });
57 } 57 }
58 58
59 function runGarbageCollection() { 59 function runGarbageCollection() {
ortuno 2017/04/03 01:47:19 This is also Chromium specific. I think we will ha
Reilly Grant (use Gerrit) 2017/04/05 18:39:37 I've moved the one test that used this back to Lay
60 // Run gc() as a promise. 60 // Run gc() as a promise.
61 return new Promise((resolve, reject) => { 61 return new Promise((resolve, reject) => {
62 GCController.collect(); 62 GCController.collect();
63 setTimeout(resolve, 0); 63 setTimeout(resolve, 0);
64 }); 64 });
65 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698