test_bug601030.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=601030
  5. -->
  6. <head>
  7. <title>Test for Bug 601030</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=601030">Mozilla Bug 601030</a>
  13. <p id="display"></p>
  14. <div id="content">
  15. <iframe src="data:text/html,<input autofocus>"></iframe>
  16. </div>
  17. <pre id="test">
  18. <script type="application/javascript">
  19. /** Test for Bug 601030 **/
  20. SimpleTest.waitForExplicitFinish();
  21. addLoadEvent(function() {
  22. var f = document.createElement("iframe");
  23. var content = document.getElementById('content');
  24. f.addEventListener("load", function() {
  25. f.removeEventListener("load", arguments.callee, false);
  26. SimpleTest.executeSoon(function() {
  27. isnot(document.activeElement, f,
  28. "autofocus should not work when another frame is inserted in the document");
  29. content.removeChild(f);
  30. content.removeChild(document.getElementsByTagName('iframe')[0]);
  31. f = document.createElement('iframe');
  32. f.addEventListener("load", function() {
  33. f.removeEventListener("load", arguments.callee, false);
  34. isnot(document.activeElement, f,
  35. "autofocus should not work in a frame if the top document is already loaded");
  36. SimpleTest.finish();
  37. }, false);
  38. f.src = "data:text/html,<input autofocus>";
  39. content.appendChild(f);
  40. });
  41. }, false);
  42. f.src = "data:text/html,<input autofocus>";
  43. content.appendChild(f);
  44. });
  45. </script>
  46. </pre>
  47. </body>
  48. </html>