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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html

Issue 1813583002: Convert radio-group-keyboard-change-event.html to a testharness.js test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script>
6 <div id="log"></div>
4 7
5 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32013">https://bugs .webkit.org/show_bug.cgi?id=32013</a>. 8 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32013">https://bugs .webkit.org/show_bug.cgi?id=32013</a>.
6 9
7 <p>For manual testing, focus a radio button in the first group and use the arrow keys. Changing the checked 10 <p>For manual testing, focus a radio button in the first group and use the arrow keys. Changing the checked
8 radio button should fire change events. 11 radio button should fire change events.
9 12
10 <p> 13 <p>
11 <input type=radio name=aaa value=a checked onchange="handleChange(event)" onclic k="handleClick(event)">a 14 <input type=radio name=aaa value=a checked onchange="handleChange(event)">a
12 <input type=radio name=aaa value=b onchange="handleChange(event)" onclick="handl eClick(event)">b 15 <input type=radio name=aaa value=b onchange="handleChange(event)">b
13 <input type=radio name=aaa value=c onchange="handleChange(event)" onclick="handl eClick(event)">c 16 <input type=radio name=aaa value=c onchange="handleChange(event)">c
14 17
15 <p>For manual testing, focus a radio button in the second group and use the arro w keys. Change events 18 <p>For manual testing, focus a radio button in the second group and use the arro w keys. Change events
16 should still be dispatched but the checked radio should not change. 19 should still be dispatched but the checked radio should not change.
17 20
18 <p> 21 <p>
19 <input type=radio name=bbb value=d checked onchange="handleChange(event)" onclic k="handleClick(event)">d 22 <input type=radio name=bbb value=d checked onchange="handleChange(event)" onclic k="preventClick(event)">d
20 <input type=radio name=bbb value=e onchange="handleChange(event)" onclick="handl eClick(event)">e 23 <input type=radio name=bbb value=e onchange="handleChange(event)" onclick="preve ntClick(event)">e
21 <input type=radio name=bbb value=f onchange="handleChange(event)" onclick="handl eClick(event)">f 24 <input type=radio name=bbb value=f onchange="handleChange(event)" onclick="preve ntClick(event)">f
22 25
23 <p>Test for <a href="https://code.google.com/p/chromium/issues/detail?id=556677" >https://code.google.com/p/chromium/issues/detail?id=556677</a>. 26 <p>Test for <a href="https://code.google.com/p/chromium/issues/detail?id=556677" >https://code.google.com/p/chromium/issues/detail?id=556677</a>.
24 27
25 <p>For manual testing, focus a radio button in the first group and use the arrow keys. Changing the 28 <p>For manual testing, focus a radio button in the first group and use the arrow keys. Changing the
26 radio button should fire change events in the direction of left to right. 29 radio button should fire change events in the direction of left to right.
27 30
28 <div dir="rtl"> 31 <div dir="rtl">
29 <p> 32 <p>
30 <input type=radio name=ccc value=x onchange="handleChange(event)"><span dir="rtl ">x</span> 33 <input type=radio name=ccc value=x onchange="handleChange(event)"><span dir="rtl ">x</span>
31 <input type=radio name=ccc value=y onchange="handleChange(event)"><span dir="rtl ">y</span> 34 <input type=radio name=ccc value=y onchange="handleChange(event)"><span dir="rtl ">y</span>
32 <input type=radio name=ccc value=z onchange="handleChange(event)"><span dir="rtl ">z</span> 35 <input type=radio name=ccc value=z onchange="handleChange(event)"><span dir="rtl ">z</span>
33 </div> 36 </div>
34 <pre id=out></pre>
35 37
36 <script> 38 <script>
37 39 var lastChangeEventValue = null;
38 var preventClickValues = 'def';
39 40
40 function handleChange(e) 41 function handleChange(e)
41 { 42 {
42 var value = e.target.value; 43 lastChangeEventValue = e.target.value;
43 print(value + ' dispatched change event');
44 } 44 }
45 45
46 function handleClick(e) 46 function preventClick(e)
47 { 47 {
48 var value = e.target.value; 48 e.preventDefault();
49 if (preventClickValues.indexOf(value) !== -1)
50 e.preventDefault();
51 }
52
53 function print(s)
54 {
55 document.getElementById('out').textContent += s + '\n';
56 }
57
58 function pass(s) {
59 print('PASS: ' + s);
60 }
61
62 function fail(s) {
63 print('FAIL: ' + s);
64 } 49 }
65 50
66 function getRadio(value) 51 function getRadio(value)
67 { 52 {
68 return document.querySelector('input[value="' + value + '"]'); 53 return document.querySelector('input[value="' + value + '"]');
69 } 54 }
70 55
71 function assertChecked(value) 56 if (window.eventSender) {
72 { 57 test(function() {
73 if (getRadio(value).checked) 58 getRadio('a').focus();
74 pass(value + ' is checked'); 59 eventSender.keyDown('downArrow');
75 else 60 assert_equals(lastChangeEventValue, 'b');
76 fail(value + ' should be checked'); 61 eventSender.keyDown('downArrow');
62 assert_equals(lastChangeEventValue, 'c');
63 assert_false(getRadio('a').checked);
64 assert_false(getRadio('b').checked);
65 assert_true(getRadio('c').checked);
66 }, 'Pressing an arrow key moves checked state in a radio button group.');
67
68 test(function() {
69 getRadio('d').focus();
70 eventSender.keyDown('downArrow');
71 eventSender.keyDown('downArrow');
72 assert_true(getRadio('d').checked);
73 assert_false(getRadio('e').checked);
74 assert_false(getRadio('f').checked);
75 }, 'Pressing an arrow key doesn\'t move checked state in a radio button grou p if click events are prevented.');
76
77 test(function() {
78 getRadio('x').focus();
79 eventSender.keyDown('rightArrow');
80 assert_equals(lastChangeEventValue, 'z');
81 assert_false(getRadio('x').checked);
82 assert_false(getRadio('y').checked);
83 assert_true(getRadio('z').checked);
84
85 eventSender.keyDown('rightArrow');
86 assert_equals(lastChangeEventValue, 'y');
87 assert_false(getRadio('x').checked);
88 assert_true(getRadio('y').checked);
89 assert_false(getRadio('z').checked);
90 }, 'Right arrow key should move checked state backward in RTL.');
91
92 test(function() {
93 getRadio('x').focus();
94 getRadio('x').checked = true;
95 eventSender.keyDown('downArrow');
96 assert_equals(lastChangeEventValue, 'y');
97 assert_false(getRadio('x').checked);
98 assert_true(getRadio('y').checked);
99 assert_false(getRadio('z').checked);
100 }, 'Down arrow key should move checked state forward regardless of RTL.');
77 } 101 }
78
79 function assertNotChecked(value)
80 {
81 if (!getRadio(value).checked)
82 pass(value + ' is not checked');
83 else
84 fail(value + ' should not be checked');
85 }
86
87 if (window.testRunner)
88 testRunner.dumpAsText();
89
90 if (window.eventSender) {
91 getRadio('a').focus();
92 eventSender.keyDown('downArrow');
93 eventSender.keyDown('downArrow');
94
95 getRadio('d').focus();
96 eventSender.keyDown('downArrow');
97 eventSender.keyDown('downArrow');
98
99 assertNotChecked('a');
100 assertNotChecked('b');
101 assertChecked('c');
102
103 assertChecked('d');
104 assertNotChecked('e');
105 assertNotChecked('f');
106
107 getRadio('x').focus();
108 eventSender.keyDown('rightArrow');
109 eventSender.keyDown('rightArrow');
110
111 assertNotChecked('x');
112 assertChecked('y');
113 assertNotChecked('z');
114
115 getRadio('x').focus();
116 eventSender.keyDown('downArrow');
117
118 assertNotChecked('x');
119 assertChecked('y');
120 assertNotChecked('z');
121
122
123 }
124
125 </script> 102 </script>
126 </body> 103 </body>
127 </html> 104 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698