/toolkit/content/tests/chrome/test_popupremoving_frame.xul

http://github.com/zpao/v8monkey · Unknown · 84 lines · 64 code · 20 blank · 0 comment · 0 complexity · 8cdbf7aafffe94cff9c3ca62ca59f695 MD5 · raw file

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3. <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
  4. <window title="Popup Unload Test"
  5. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  6. <!--
  7. This test checks that popup elements are removed when the document is changed.
  8. -->
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  10. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  11. <iframe id="frame" width="300" height="150" src="frame_popupremoving_frame.xul"/>
  12. <script class="testbody" type="application/javascript">
  13. <![CDATA[
  14. SimpleTest.waitForExplicitFinish();
  15. var gMenus = [];
  16. function popupsOpened()
  17. {
  18. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  19. var framedoc = $("frame").contentDocument;
  20. framedoc.addEventListener("DOMAttrModified", modified, false);
  21. // this is the order in which the menus should be hidden (reverse of the
  22. // order they were opened in). The second menu is removed during the
  23. // mutation listener, so gets the event afterwards.
  24. gMenus.push(framedoc.getElementById("nestedmenu4"));
  25. gMenus.push(framedoc.getElementById("nestedmenu2"));
  26. gMenus.push(framedoc.getElementById("nestedmenu3"));
  27. gMenus.push(framedoc.getElementById("nestedmenu1"));
  28. gMenus.push(framedoc.getElementById("separatemenu4"));
  29. gMenus.push(framedoc.getElementById("separatemenu2"));
  30. gMenus.push(framedoc.getElementById("separatemenu3"));
  31. gMenus.push(framedoc.getElementById("separatemenu1"));
  32. framedoc.location = "about:blank";
  33. }
  34. function modified(event)
  35. {
  36. if (event.attrName != "open")
  37. return;
  38. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  39. var framedoc = $("frame").contentDocument;
  40. var tohide = null;
  41. if (event.target.id == "separatemenu3")
  42. tohide = framedoc.getElementById("separatemenu2");
  43. else if (event.target.id == "nestedmenu3")
  44. tohide = framedoc.getElementById("nestedmenu2");
  45. if (tohide) {
  46. tohide.hidden = true;
  47. // force a layout flush
  48. $("frame").contentDocument.documentElement.boxObject.width;
  49. }
  50. is(event.target, gMenus.shift(), event.target.id + " hidden");
  51. if (gMenus.length == 0)
  52. SimpleTest.finish();
  53. }
  54. ]]>
  55. </script>
  56. <body xmlns="http://www.w3.org/1999/xhtml">
  57. <p id="display">
  58. </p>
  59. <div id="content" style="display: none">
  60. </div>
  61. <pre id="test">
  62. </pre>
  63. </body>
  64. </window>