test_bug582412-1.html (7185B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=566160 5 --> 6 <head> 7 <title>Test for Bug 566160</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566160">Mozilla Bug 566160</a> 14 <p id="display"></p> 15 <style> 16 iframe { width: 130px; height: 100px;} 17 </style> 18 <iframe name='frame1' id='frame1'></iframe> 19 <iframe name='frame2' id='frame2'></iframe> 20 <iframe name='frame3' id='frame3'></iframe> 21 <iframe name='frame3bis' id='frame3bis'></iframe> 22 <iframe name='frame4' id='frame4'></iframe> 23 <iframe name='frame5' id='frame5'></iframe> 24 <iframe name='frame6' id='frame6'></iframe> 25 <iframe name='frame7' id='frame7'></iframe> 26 <iframe name='frame8' id='frame8'></iframe> 27 <iframe name='frame9' id='frame9'></iframe> 28 <div id="content"> 29 <!-- submit controls with formaction that are validated with a CLICK --> 30 <form target="frame1" action="dummy_page.html" method="POST"> 31 <input name='foo' value='foo'> 32 <input type='submit' id='is' formmethod="GET"> 33 </form> 34 <form target="frame2" action="dummy_page.html" method="POST"> 35 <input name='bar' value='bar'> 36 <input type='image' id='ii' formmethod="GET"> 37 </form> 38 <form target="frame3" action="dummy_page.html" method="POST"> 39 <input name='tulip' value='tulip'> 40 <button type='submit' id='bs' formmethod="GET">submit</button> 41 </form> 42 <form target="frame3bis" action="dummy_page.html" method="POST"> 43 <input name='tulipbis' value='tulipbis'> 44 <button type='submit' id='bsbis' formmethod="GET">submit</button> 45 </form> 46 47 <!-- submit controls with formaction that are validated with ENTER --> 48 <form target="frame4" action="dummy_page.html" method="POST"> 49 <input name='footulip' value='footulip'> 50 <input type='submit' id='is2' formmethod="GET"> 51 </form> 52 <form target="frame5" action="dummy_page.html" method="POST"> 53 <input name='foobar' value='foobar'> 54 <input type='image' id='ii2' formmethod="GET"> 55 </form> 56 <form target="frame6" action="dummy_page.html" method="POST"> 57 <input name='tulip2' value='tulip2'> 58 <button type='submit' id='bs2' formmethod="GET">submit</button> 59 </form> 60 61 <!-- check that when submitting a from from an element 62 which is not a submit control, @formaction isn't used --> 63 <form target='frame7' action="dummy_page.html" method="GET"> 64 <input id='enter' name='input' value='enter' formmethod="POST"> 65 </form> 66 67 <!-- If formmethod isn't set, it's default value shouldn't be used --> 68 <form target="frame8" action="dummy_page.html" method="POST"> 69 <input name='tulip8' value='tulip8'> 70 <input type='submit' id='i8'> 71 </form> 72 73 <!-- If formmethod is set but has an invalid value, the default value should 74 be used. --> 75 <form target="frame9" action="dummy_page.html" method="POST"> 76 <input name='tulip9' value='tulip9'> 77 <input type='submit' id='i9' formmethod=""> 78 </form> 79 </div> 80 <pre id="test"> 81 <script type="application/javascript"> 82 83 /** Test for Bug 566160 */ 84 85 SimpleTest.waitForExplicitFinish(); 86 addLoadEvent(function() { 87 setTimeout(runTests, 0); 88 }); 89 90 const BASE_URI = `${location.origin}/tests/dom/html/test/dummy_page.html`; 91 var gTestResults = { 92 frame1: BASE_URI + "?foo=foo", 93 frame2: BASE_URI + "?bar=bar&x=0&y=0", 94 frame3: BASE_URI + "?tulip=tulip", 95 frame3bis: BASE_URI + "?tulipbis=tulipbis", 96 frame4: BASE_URI + "?footulip=footulip", 97 frame5: BASE_URI + "?foobar=foobar&x=0&y=0", 98 frame6: BASE_URI + "?tulip2=tulip2", 99 frame7: BASE_URI + "?input=enter", 100 frame8: BASE_URI + "", 101 frame9: BASE_URI + "?tulip9=tulip9", 102 }; 103 104 var gPendingLoad = 0; // Has to be set after depending on the frames number. 105 106 function runTests() 107 { 108 // We add a load event for the frames which will be called when the forms 109 // will be submitted. 110 var frames = [ document.getElementById('frame1'), 111 document.getElementById('frame2'), 112 document.getElementById('frame3'), 113 document.getElementById('frame3bis'), 114 document.getElementById('frame4'), 115 document.getElementById('frame5'), 116 document.getElementById('frame6'), 117 document.getElementById('frame7'), 118 document.getElementById('frame8'), 119 document.getElementById('frame9'), 120 ]; 121 gPendingLoad = frames.length; 122 123 for (var i=0; i<frames.length; i++) { 124 frames[i].setAttribute('onload', "frameLoaded(this);"); 125 } 126 127 /** 128 * We are going to focus each element before interacting with either for 129 * simulating the ENTER key (synthesizeKey) or a click (synthesizeMouse) or 130 * using .click(). This because it may be needed (ENTER) and because we want 131 * to have the element visible in the iframe. 132 * 133 * Focusing the first element (id='is') is launching the tests. 134 */ 135 document.getElementById('is').addEventListener('focus', function(aEvent) { 136 synthesizeMouse(document.getElementById('is'), 5, 5, {}); 137 document.getElementById('ii').focus(); 138 }, {once: true}); 139 140 document.getElementById('ii').addEventListener('focus', function(aEvent) { 141 synthesizeMouse(document.getElementById('ii'), 5, 5, {}); 142 document.getElementById('bs').focus(); 143 }, {once: true}); 144 145 document.getElementById('bs').addEventListener('focus', function(aEvent) { 146 synthesizeMouse(document.getElementById('bs'), 5, 5, {}); 147 document.getElementById('bsbis').focus(); 148 }, {once: true}); 149 150 document.getElementById('bsbis').addEventListener('focus', function(aEvent) { 151 document.getElementById('bsbis').click(); 152 document.getElementById('is2').focus(); 153 }, {once: true}); 154 155 document.getElementById('is2').addEventListener('focus', function(aEvent) { 156 synthesizeKey("KEY_Enter"); 157 document.getElementById('ii2').focus(); 158 }, {once: true}); 159 160 document.getElementById('ii2').addEventListener('focus', function(aEvent) { 161 synthesizeKey("KEY_Enter"); 162 document.getElementById('bs2').focus(); 163 }, {once: true}); 164 165 document.getElementById('bs2').addEventListener('focus', function(aEvent) { 166 synthesizeKey("KEY_Enter"); 167 document.getElementById('enter').focus(); 168 }, {once: true}); 169 170 document.getElementById('enter').addEventListener('focus', function(aEvent) { 171 synthesizeKey("KEY_Enter"); 172 document.getElementById('i8').focus(); 173 }, {once: true}); 174 175 document.getElementById('i8').addEventListener('focus', function(aEvent) { 176 synthesizeKey("KEY_Enter"); 177 document.getElementById('i9').focus(); 178 }, {once: true}); 179 180 document.getElementById('i9').addEventListener('focus', function(aEvent) { 181 synthesizeKey("KEY_Enter"); 182 }, {once: true}); 183 184 document.getElementById('is').focus(); 185 } 186 187 function frameLoaded(aFrame) { 188 // Check if formaction/action has the correct behavior. 189 is(aFrame.contentWindow.location.href, gTestResults[aFrame.name], 190 "the method/formmethod attribute doesn't have the correct behavior"); 191 192 if (--gPendingLoad == 0) { 193 SimpleTest.finish(); 194 } 195 } 196 197 </script> 198 </pre> 199 </body> 200 </html>