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

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: minor fixes 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 id='foo' autofocus>
5 <input id='bar'>
6 <input 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 window.internals.setFocused(false);
49 document.querySelector('#foo').addEventListener('focus', () => logs.push('fo cus foo'), false);
50 document.querySelector('#foo').addEventListener('blur', () => logs.push('blu r foo'), false);
51 document.querySelector('#bar').addEventListener('focus', () => logs.push('fo cus bar'), false);
52 document.querySelector('#bar').addEventListener('blur', () => logs.push('blu r bar'), false);
53 document.querySelector('#baz').addEventListener('focus', () => logs.push('fo cus baz'), false);
54 document.querySelector('#baz').addEventListener('blur', () => logs.push('blu r baz'), false);
55 `);
56 type('foo');
57 typeTab();
58 type('bar');
59 typeTab();
60 testRunner.log(await session.evaluate(`
61 logs.push('================');
62 logs.push('value of foo:' + document.getElementById('foo').value);
63 logs.push('value of bar:' + document.getElementById('bar').value);
64 logs.push('value of baz:' + document.getElementById('baz').value);
65 window.internals.setFocused(true);
66 logs.join('\\n')
67 `));
68 testRunner.completeTest();
69 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698