test_bug567938-1.html (1813B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=567938 5 --> 6 <head> 7 <title>Test for Bug 567938</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 onload="runTests();"> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=567938">Mozilla Bug 567938</a> 14 <p id="display"></p> 15 <iframe id='iframe' name="submit_frame" style="visibility: hidden;"></iframe> 16 <div id="content" style="display: none"> 17 <form id='f' method='get' target='submit_frame'> 18 </form> 19 </div> 20 <pre id="test"> 21 <script type="application/javascript"> 22 23 /** Test for Bug 567938 */ 24 25 SimpleTest.waitForExplicitFinish(); 26 27 var gTestData = ["submit", "image"]; 28 var gCurrentTest = 0; 29 30 function initializeNextTest() 31 { 32 var form = document.forms[0]; 33 34 // Cleaning-up. 35 form.textContent = ""; 36 37 // Add the new element. 38 var element = document.createElement("input"); 39 element.id = 'i'; 40 element.type = gTestData[gCurrentTest]; 41 element.onclick = function() { form.submit(); return false; }; 42 form.action = gTestData[gCurrentTest]; 43 form.appendChild(element); 44 45 sendMouseEvent({type: 'click'}, 'i'); 46 } 47 48 function runTests() 49 { 50 document.getElementById('iframe').addEventListener('load', function(aEvent) { 51 is(frames.submit_frame.location.href, 52 `${location.origin}/tests/dom/html/test/${gTestData[gCurrentTest]}?`, 53 "The form should have been submitted"); 54 gCurrentTest++; 55 if (gCurrentTest < gTestData.length) { 56 initializeNextTest(); 57 } else { 58 aEvent.target.removeEventListener('load', arguments.callee); 59 SimpleTest.finish(); 60 } 61 }); 62 63 initializeNextTest(); 64 } 65 66 </script> 67 </pre> 68 </body> 69 </html>