PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 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
20SimpleTest.waitForExplicitFinish();
21
22var gMenus = [];
23
24function popupsOpened()
25{
26  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
27
28  var framedoc = $("frame").contentDocument;
29  framedoc.addEventListener("DOMAttrModified", modified, false);
30
31  // this is the order in which the menus should be hidden (reverse of the
32  // order they were opened in). The second menu is removed during the
33  // mutation listener, so gets the event afterwards.
34  gMenus.push(framedoc.getElementById("nestedmenu4"));
35  gMenus.push(framedoc.getElementById("nestedmenu2"));
36  gMenus.push(framedoc.getElementById("nestedmenu3"));
37  gMenus.push(framedoc.getElementById("nestedmenu1"));
38  gMenus.push(framedoc.getElementById("separatemenu4"));
39  gMenus.push(framedoc.getElementById("separatemenu2"));
40  gMenus.push(framedoc.getElementById("separatemenu3"));
41  gMenus.push(framedoc.getElementById("separatemenu1"));
42
43  framedoc.location = "about:blank";
44}
45
46function modified(event)
47{
48  if (event.attrName != "open")
49    return;
50
51  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
52
53  var framedoc = $("frame").contentDocument;
54
55  var tohide = null;
56  if (event.target.id == "separatemenu3")
57    tohide = framedoc.getElementById("separatemenu2");
58  else if (event.target.id == "nestedmenu3")
59    tohide = framedoc.getElementById("nestedmenu2");
60
61  if (tohide) {
62    tohide.hidden = true;
63    // force a layout flush
64    $("frame").contentDocument.documentElement.boxObject.width;
65  }
66
67  is(event.target, gMenus.shift(), event.target.id + " hidden");
68  if (gMenus.length == 0)
69    SimpleTest.finish();
70}
71
72]]>
73</script>
74
75<body xmlns="http://www.w3.org/1999/xhtml">
76<p id="display">
77</p>
78<div id="content" style="display: none">
79</div>
80<pre id="test">
81</pre>
82</body>
83
84</window>