test_bug388794.html (3554B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=388794 5 --> 6 <head> 7 <title>Test for Bug 388794</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 <style> 12 input { padding: 0; margin: 0; border: none; } 13 </style> 14 </head> 15 <body> 16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=388794">Mozilla Bug 388794</a> 17 <p id="display"> 18 <form action="dummy_page.html" target="test1" method="GET"> 19 <input id="test1image" type="image" name="testImage"> 20 </form> 21 <form action="dummy_page.html" target="test2" method="GET"> 22 <input id="test2image" type="image"> 23 </form> 24 <form action="dummy_page.html" target="test3" method="GET"> 25 <input id="test3image" type="image" src="nnc_lockup.gif" name="testImage"> 26 </form> 27 <form action="dummy_page.html" target="test4" method="GET"> 28 <input id="test4image" type="image" src="nnc_lockup.gif"> 29 </form> 30 <form action="dummy_page.html" target="test5" method="GET"> 31 <input id="test5image" type="image" src="nnc_lockup.gif" name="testImage"> 32 </form> 33 <form action="dummy_page.html" target="test6" method="GET"> 34 <input id="test6image" type="image" src="nnc_lockup.gif"> 35 </form> 36 <iframe name="test1" id="test1"></iframe> 37 <iframe name="test2" id="test2"></iframe> 38 <iframe name="test3" id="test3"></iframe> 39 <iframe name="test4" id="test4"></iframe> 40 <iframe name="test5" id="test5"></iframe> 41 <iframe name="test6" id="test6"></iframe> 42 </p> 43 <div id="content" style="display: none"> 44 45 </div> 46 <pre id="test"> 47 <script type="application/javascript"> 48 49 /** Test for Bug 388794 */ 50 SimpleTest.waitForExplicitFinish(); 51 52 var pendingLoads = 0; 53 /* Use regex due to rounding error in Fennec with C++APZ enabled */ 54 var hrefs = { 55 test1: /\?testImage\.x=0&testImage\.y=0/, 56 test2: /\?x=0&y=0/, 57 test3: /\?testImage\.x=0&testImage\.y=0/, 58 test4: /\?x=0&y=0/, 59 test5: /\?testImage\.x=[4-6]&testImage\.y=[4-6]/, 60 test6: /\?x=[4-6]&y=[4-6]/, 61 }; 62 63 function submitForm(idNum) { 64 $("test"+idNum).setAttribute("onload", "frameLoaded(this)"); 65 $("test" + idNum + "image").focus(); 66 sendKey("return"); 67 } 68 69 function submitFormMouse(idNum) { 70 $("test"+idNum).setAttribute("onload", "frameLoaded(this)"); 71 // Use 4.99 instead of 5 to guard against the possibility that the 72 // image's 'top' is exactly N + 0.5 pixels from the root. In that case 73 // we'd round up the widget mouse coordinate to N + 6, which relative 74 // to the image would be 5.5, which would get rounded up to 6 when 75 // submitting the form. Instead we round the widget mouse coordinate to 76 // N + 5, which relative to the image would be 4.5 which gets rounded up 77 // to 5. 78 synthesizeMouse($("test" + idNum + "image"), 4.99, 4.99, {}); 79 } 80 81 addLoadEvent(function() { 82 // Need the timeout so painting has a chance to be unsuppressed. 83 setTimeout(function() { 84 submitForm(++pendingLoads); 85 submitForm(++pendingLoads); 86 submitForm(++pendingLoads); 87 submitForm(++pendingLoads); 88 submitFormMouse(++pendingLoads); 89 submitFormMouse(++pendingLoads); 90 }, 0); 91 }); 92 93 function frameLoaded(frame) { 94 ok( 95 hrefs[frame.name].test(frame.contentWindow.location.href), 96 "Unexpected href for frame " + frame.name + " - " + 97 "expected to match: " + hrefs[frame.name].toString() + " got: " + frame.contentWindow.location.href 98 ); 99 if (--pendingLoads == 0) { 100 SimpleTest.finish(); 101 } 102 } 103 104 </script> 105 </pre> 106 </body> 107 </html>