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: LayoutTests/fast/forms/radio/radio_checked_dynamic.html

Issue 1298133002: Convert radio_checked_dynamic.html to the testharness style. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
1 <html> 1 <html>
2 <head> 2 <body>
3 <style> 3 <script src="../../../resources/testharness.js"></script>
4 div { font-weight: bold; } 4 <script src="../../../resources/testharnessreport.js"></script>
5 </style> 5 <div id="log"></div>
6 6
7 </head>
8
9 <body>
10 This will test that radio buttons can be moved in and out of forms while maintai ning only one checked button per group, per form.
11 <br>
12 Test 1: Transfer radio buttons from &lt;body&gt; to &lt;form&gt;:
13 <input type="radio" name="group1" id="radio1" checked="checked"> 7 <input type="radio" name="group1" id="radio1" checked="checked">
14 <input type="radio" name="group1" id="radio2"> 8 <input type="radio" name="group1" id="radio2">
15 <form id="test1"> 9 <form id="test1">
16 </form> 10 </form>
17 <div id="result1">Test 1 Failed</div> 11
18 <br>
19 Test 2: Transfer radio buttons from &lt;form&gt; to &lt;body&gt;:
20 <form> 12 <form>
21 <input type="radio" name="group2" id="radio3" checked="checked"> 13 <input type="radio" name="group2" id="radio3" checked="checked">
22 <input type="radio" name="group2" id="radio4"> 14 <input type="radio" name="group2" id="radio4">
23 </form> 15 </form>
24 <div id="result2">Test 2 Failed</div> 16
25 <br>
26 Test 3: Transfer radio buttons from &lt;form&gt; to &lt;body&gt; with a dormant state in the middle:
27 <form> 17 <form>
28 <input type="radio" name="group3" id="radio5" checked="checked"> 18 <input type="radio" name="group3" id="radio5" checked="checked">
29 <input type="radio" name="group3" id="radio6"> 19 <input type="radio" name="group3" id="radio6">
30 </form> 20 </form>
31 <div id="result3">Test 3 Failed</div> 21
32 <br>
33 Test 4: Transfer from &lt;form&gt; to &lt;form&gt;
34 <form> 22 <form>
35 <input type="radio" name="group4" id="radio7" checked="checked" style="outline:1 px solid red"> 23 <input type="radio" name="group4" id="radio7" checked="checked" style="outline:1 px solid red">
36 <input type="radio" name="group4" id="radio8" style="outline:1px solid blue"> 24 <input type="radio" name="group4" id="radio8" style="outline:1px solid blue">
37 </form> 25 </form>
38 <form id="test4"> 26 <form id="test4">
39 <input type="radio" name="group4" id="radio9" checked="checked" style="outline:1 px solid green"> 27 <input type="radio" name="group4" id="radio9" checked="checked" style="outline:1 px solid green">
40 </form> 28 </form>
41 <div id="result4">Test 4 Failed</div>
42 29
43 <script> 30 <script>
44 if (window.testRunner) 31 // This will test that radio buttons can be moved in and out of forms while
45 testRunner.dumpAsText(); 32 // maintaining only one checked button per group, per form.
46 33
47 var radio1 = document.getElementById("radio1"); 34 test(function() {
48 var radio2 = document.getElementById("radio2"); 35 var radio1 = document.getElementById("radio1");
49 var form = document.getElementById("test1"); 36 var radio2 = document.getElementById("radio2");
50 var result1 = document.getElementById("result1"); 37 var form = document.getElementById("test1");
51 form.appendChild(radio1); 38 var result1 = document.getElementById("result1");
52 form.appendChild(radio2); 39 form.appendChild(radio1);
53 radio2.checked = true; 40 form.appendChild(radio2);
54 41 radio2.checked = true;
55 var radio3 = document.getElementById("radio3"); 42 assert_false(radio1.checked);
56 var radio4 = document.getElementById("radio4"); 43 assert_true(radio2.checked);
57 document.body.appendChild(radio3); 44 }, "Transfer radio buttons from <body> to <form>.");
58 document.body.appendChild(radio4); 45
59 radio4.checked = true; 46 test(function() {
60 47 var radio3 = document.getElementById("radio3");
61 var radio5 = document.getElementById("radio5"); 48 var radio4 = document.getElementById("radio4");
62 var radio6 = document.getElementById("radio6"); 49 document.body.appendChild(radio3);
63 radio5.parentNode.removeChild(radio5); 50 document.body.appendChild(radio4);
64 radio6.parentNode.removeChild(radio6); 51 radio4.checked = true;
65 document.body.appendChild(radio5); 52 assert_false(radio3.checked);
66 document.body.appendChild(radio6); 53 assert_true(radio4.checked);
67 radio6.checked = true; 54 }, "Transfer radio buttons from <form> to <body>.");
68 55
69 var radio7 = document.getElementById("radio7"); 56 test(function() {
70 var radio8 = document.getElementById("radio8"); 57 var radio5 = document.getElementById("radio5");
71 var radio9wasChecked = true; 58 var radio6 = document.getElementById("radio6");
72 var form4 = document.getElementById("test4"); 59 radio5.parentNode.removeChild(radio5);
73 form4.appendChild(radio7); 60 radio6.parentNode.removeChild(radio6);
74 form4.appendChild(radio8); 61 document.body.appendChild(radio5);
75 radio9wasChecked = radio9.checked; 62 document.body.appendChild(radio6);
76 radio8.checked = true; 63 radio6.checked = true;
77 64 assert_false(radio5.checked);
78 if (!radio1.checked && radio2.checked) 65 assert_true(radio6.checked);
79 result1.innerHTML = "Test 1 Passed"; 66 }, "Transfer radio buttons from <form> to <body> with a dormant state in the mid dle.");
80 if (!radio3.checked && radio4.checked) 67
81 result2.innerHTML = "Test 2 Passed"; 68 test(function() {
82 if (!radio5.checked && radio6.checked) 69 var radio7 = document.getElementById("radio7");
83 result3.innerHTML = "Test 3 Passed"; 70 var radio8 = document.getElementById("radio8");
84 if (!radio7.checked && radio8.checked && !radio9.checked && !radio9wasChecked) 71 var radio9wasChecked = true;
85 result4.innerHTML = "Test 4 Passed"; 72 var form4 = document.getElementById("test4");
73 form4.appendChild(radio7);
74 form4.appendChild(radio8);
75 radio9wasChecked = radio9.checked;
76 radio8.checked = true;
77 assert_false(radio7.checked);
78 assert_true(radio8.checked);
79 assert_false(radio9.checked);
80 assert_false(radio9wasChecked);
81 }, "Transfer from <form> to <form>.");
86 </script> 82 </script>
87 </body> 83 </body>
88 </html> 84 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/forms/radio/radio_checked_dynamic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698