toolkit/content/tests/chrome/test_popupremoving_frame.xul

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

mercurial