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

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/radio.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>input type radio</title>
4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
5 <link rel=help href="https://html.spec.whatwg.org/multipage/#radio-button-state- (type=radio)">
6 <script src="../../../../../../resources/testharness.js"></script>
7 <script src="../../../../../../resources/testharnessreport.js"></script>
8 <div id="log"></div>
9 <input type=radio name=group1 id=radio1>
10 <input type=radio name=group1 id=radio2>
11
12 <input type=radio name=groüp2 id=radio3>
13 <input type=radio name=groÜp2 id=radio4>
14
15 <input type=radio id=radio5>
16 <input type=radio id=radio6 disabled>
17
18 <input type=radio id=radio71 checked>
19 <input type=radio id=radio72>
20
21 <input type=radio name=group3 id=radio8 checked>
22 <input type=radio name=group3 id=radio9>
23 <input type=radio name=group4 id=radio10>
24 <input type=radio name=group4 id=radio11 checked>
25
26
27 <script>
28 var radio1 = document.getElementById('radio1'),
29 radio2 = document.getElementById('radio2'),
30 radio3 = document.getElementById('radio3'),
31 radio4 = document.getElementById('radio4'),
32 radio5 = document.getElementById('radio5'),
33 radio6 = document.getElementById('radio6'),
34 radio71 = document.getElementById('radio71'),
35 radio72 = document.getElementById('radio72'),
36 radio8 = document.getElementById('radio8'),
37 radio9 = document.getElementById('radio9'),
38 radio10 = document.getElementById('radio10'),
39 radio11 = document.getElementById('radio11'),
40 t1 = async_test("click on mutable radio fires the input event"),
41 t2 = async_test("click on mutable radio fires the change event"),
42 t3 = async_test("click on non-mutable radio doesn't fire the input event") ,
43 t4 = async_test("click on non-mutable radio doesn't fire the change event" ),
44 t5 = async_test("canceled activation steps on unchecked radio"),
45 input_fired = false,
46 change_fired = false;
47
48 test(function(){
49 assert_false(radio1.checked);
50 assert_false(radio2.checked);
51 radio1.checked = true;
52 assert_true(radio1.checked);
53 assert_false(radio2.checked);
54 radio2.checked = true;
55 assert_false(radio1.checked);
56 assert_true(radio2.checked);
57 }, "only one control of a radio button group can have its checkedness set to t rue");
58
59 test(function(){
60 assert_false(radio3.checked);
61 assert_false(radio4.checked);
62 radio3.checked = true;
63 assert_true(radio3.checked);
64 assert_false(radio4.checked);
65 radio4.checked = true;
66 assert_false(radio3.checked);
67 assert_true(radio4.checked);
68 }, "radio inputs with name attributes groüp2 and groÜp2 belong to the same rad io button group");
69
70 test(function(){
71 assert_true(radio8.checked);
72 assert_false(radio9.checked);
73 assert_false(radio10.checked);
74 assert_true(radio11.checked);
75 radio9.name="group4";
76 radio9.checked = true;
77 assert_true(radio8.checked);
78 assert_true(radio9.checked);
79 assert_false(radio10.checked);
80 assert_false(radio11.checked);
81 }, "changing the name of a radio input element and setting its checkedness to true makes all the other elements' checkedness in the same radio button group be set to false");
82
83 radio5.oninput= t1.step_func(function(e) {
84 input_fired = true;
85 assert_true(e.bubbles, "event should bubble")
86 assert_true(e.isTrusted, "event should be trusted");
87 assert_false(e.cancelable, "event shoud not be cancelable");
88 });
89
90 radio5.onchange = t2.step_func(function(e) {
91 change_fired = true;
92 assert_true(e.bubbles, "event should bubble")
93 assert_true(e.isTrusted, "event should be trusted");
94 assert_false(e.cancelable, "event shoud not be cancelable");
95 });
96
97 radio6.oninput= t3.step_func_done(function(e) {
98 assert_unreached("event input fired");
99 });
100
101 radio6.onchange = t4.step_func_done(function(e) {
102 assert_unreached("event change fired");
103 });
104
105 t1.step(function() {
106 radio5.click();
107 assert_true(input_fired);
108 t1.done();
109 });
110
111 t2.step(function() {
112 assert_true(change_fired);
113 t2.done();
114 })
115
116 t3.step(function(){
117 radio6.click();
118 t3.done();
119 t4.done();
120 });
121
122 radio72.onclick = t5.step_func_done(function(e){
123 assert_false(radio71.checked);
124 assert_true(radio72.checked);
125 e.preventDefault();
126 assert_false(radio71.checked);
127 assert_true(radio72.checked);
128 });
129
130 t5.step(function(){
131 assert_true(radio71.checked);
132 assert_false(radio72.checked);
133 radio72.click();
134 assert_true(radio71.checked);
135 assert_false(radio72.checked);
136 });
137 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698