test_bug388794.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="application/javascript" 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="data:text/html," target="test1" method="GET">
  19. <input id="test1image" type="image" name="testImage">
  20. </form>
  21. <form action="data:text/html," target="test2" method="GET">
  22. <input id="test2image" type="image">
  23. </form>
  24. <form action="data:text/html," target="test3" method="GET">
  25. <input id="test3image" type="image" src="nnc_lockup.gif" name="testImage">
  26. </form>
  27. <form action="data:text/html," target="test4" method="GET">
  28. <input id="test4image" type="image" src="nnc_lockup.gif">
  29. </form>
  30. <form action="data:text/html," target="test5" method="GET">
  31. <input id="test5image" type="image" src="nnc_lockup.gif" name="testImage">
  32. </form>
  33. <form action="data:text/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. </div>
  45. <pre id="test">
  46. <script type="application/javascript">
  47. /** Test for Bug 388794 **/
  48. SimpleTest.waitForExplicitFinish();
  49. var pendingLoads = 0;
  50. /* Use regex due to rounding error in Fennec with C++APZ enabled */
  51. var hrefs = {
  52. test1: /data:text\/html,\?testImage\.x=0&testImage\.y=0/,
  53. test2: /data:text\/html,\?x=0&y=0/,
  54. test3: /data:text\/html,\?testImage\.x=0&testImage\.y=0/,
  55. test4: /data:text\/html,\?x=0&y=0/,
  56. test5: /data:text\/html,\?testImage\.x=[4-6]&testImage\.y=[4-6]/,
  57. test6: /data:text\/html,\?x=[4-6]&y=[4-6]/,
  58. };
  59. function submitForm(idNum) {
  60. $("test"+idNum).setAttribute("onload", "frameLoaded(this)");
  61. $("test" + idNum + "image").focus();
  62. sendKey("return");
  63. }
  64. function submitFormMouse(idNum) {
  65. $("test"+idNum).setAttribute("onload", "frameLoaded(this)");
  66. // Use 4.99 instead of 5 to guard against the possibility that the
  67. // image's 'top' is exactly N + 0.5 pixels from the root. In that case
  68. // we'd round up the widget mouse coordinate to N + 6, which relative
  69. // to the image would be 5.5, which would get rounded up to 6 when
  70. // submitting the form. Instead we round the widget mouse coordinate to
  71. // N + 5, which relative to the image would be 4.5 which gets rounded up
  72. // to 5.
  73. synthesizeMouse($("test" + idNum + "image"), 4.99, 4.99, {});
  74. }
  75. addLoadEvent(function() {
  76. // Need the timeout so painting has a chance to be unsuppressed.
  77. setTimeout(function() {
  78. submitForm(++pendingLoads);
  79. submitForm(++pendingLoads);
  80. submitForm(++pendingLoads);
  81. submitForm(++pendingLoads);
  82. submitFormMouse(++pendingLoads);
  83. submitFormMouse(++pendingLoads);
  84. }, 0);
  85. });
  86. function frameLoaded(frame) {
  87. ok(hrefs[frame.name].test(frame.contentWindow.location.href),
  88. "Unexpected href for frame " + frame.name, "expected to match: " + hrefs[frame.name].toString() + " got: " + frame.contentWindow.location.href);
  89. if (--pendingLoads == 0) {
  90. SimpleTest.finish();
  91. }
  92. }
  93. </script>
  94. </pre>
  95. </body>
  96. </html>