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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent-focus.js

Issue 2961493002: [DevTools] Migrate inspector-protocol/{input,network} tests to new harness (Closed)
Patch Set: Created 3 years, 5 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
(Empty)
1 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startHTML(`
3 <div id='inputs'>
4 <input onfocus='log("focus foo")' onblur='log("blur foo")' id='foo' autofo cus>
5 <input onfocus='log("focus bar")' onblur='log("blur bar")' id='bar'>
6 <input onfocus='log("focus baz")' onblur='log("blur baz")' id='baz'>
7 </div>
8 `, ``);
9
10 function type(text) {
11 for (var i = 0; i < text.length; ++i) {
12 var dec = text.charCodeAt(i);
13 var hex = 'U+00' + Number(dec).toString(16);
14 dp.Input.dispatchKeyEvent({
15 'type': 'rawKeyDown',
16 'windowsVirtualKeyCode': dec,
17 'key': text[i]
18 });
19 dp.Input.dispatchKeyEvent({
20 'type': 'char',
21 'text': text[i],
22 'key': text[i],
23 'unmodifiedText': text[i]
24 });
25 dp.Input.dispatchKeyEvent({
26 'type': 'keyUp',
27 'windowsVirtualKeyCode': dec,
28 'key': text[i]
29 });
30 }
31 }
32
33 function typeTab() {
34 dp.Input.dispatchKeyEvent({
35 'type': 'rawKeyDown',
36 'windowsVirtualKeyCode': 9,
37 'key': 'Tab',
38 });
39 dp.Input.dispatchKeyEvent({
40 'type': 'keyUp',
41 'windowsVirtualKeyCode': 9,
42 'key': 'Tab',
43 });
44 }
45
46 await session.evaluate(`
47 window.logs = [];
48 function log(text) {
49 logs.push(text);
50 }
51 window.internals.setFocused(false);
allada 2017/06/26 22:02:53 It looks like the old test was bluring then runnin
dgozman 2017/06/26 23:22:07 Done.
52 `);
53 type('foo');
allada 2017/06/26 22:02:53 At this point the field should be blured and we ar
dgozman 2017/06/26 23:22:07 As I understand it, autofocus affects what is focu
54 typeTab();
55 type('bar');
56 typeTab();
57 testRunner.log(await session.evaluate(`
58 log('================');
59 log('value of foo:' + document.getElementById('foo').value);
60 log('value of bar:' + document.getElementById('bar').value);
61 log('value of baz:' + document.getElementById('baz').value);
62 window.internals.setFocused(true);
63 logs.join('\\n')
64 `));
65 testRunner.completeTest();
66 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698