test_bug986542.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=986542
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 986542</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. <script type="application/javascript">
  12. /** Test for Bug 986542 **/
  13. SimpleTest.waitForExplicitFinish();
  14. addLoadEvent(function() {
  15. var ifr = document.getElementById("ifr");
  16. var doc = ifr.contentDocument;
  17. var scr = doc.createElement("script");
  18. scr.textContent = "function f() { onF(); }";
  19. ifr.contentWindow.onF = function() {
  20. ok(true, "Called event handler in detached window");
  21. SimpleTest.finish();
  22. }
  23. doc.body.appendChild(scr);
  24. var target = document.getElementById("target");
  25. target.onclick = ifr.contentWindow.f;
  26. ifr.parentNode.removeChild(ifr);
  27. info("Removed frame from document. Waiting for event handler to be called.");
  28. target.dispatchEvent(new MouseEvent('click'));
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=986542">Mozilla Bug 986542</a>
  34. <p id="display"></p>
  35. <div id="content" style="display: none">
  36. </div>
  37. <div id="target"></div>
  38. <iframe id="ifr"></iframe>
  39. <pre id="test">
  40. </pre>
  41. </body>
  42. </html>