1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_popupremoving_frame.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 + 1.8 +<window title="Popup Unload Test" 1.9 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.10 + 1.11 +<!-- 1.12 + This test checks that popup elements are removed when the document is changed. 1.13 + --> 1.14 + 1.15 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.17 + 1.18 +<iframe id="frame" width="300" height="150" src="frame_popupremoving_frame.xul"/> 1.19 + 1.20 +<script class="testbody" type="application/javascript"> 1.21 +<![CDATA[ 1.22 + 1.23 +SimpleTest.waitForExplicitFinish(); 1.24 + 1.25 +var gMenus = []; 1.26 + 1.27 +function popupsOpened() 1.28 +{ 1.29 + var framedoc = $("frame").contentDocument; 1.30 + framedoc.addEventListener("DOMAttrModified", modified, false); 1.31 + 1.32 + // this is the order in which the menus should be hidden (reverse of the 1.33 + // order they were opened in). The second menu is removed during the 1.34 + // mutation listener, so gets the event afterwards. 1.35 + gMenus.push(framedoc.getElementById("nestedmenu4")); 1.36 + gMenus.push(framedoc.getElementById("nestedmenu2")); 1.37 + gMenus.push(framedoc.getElementById("nestedmenu3")); 1.38 + gMenus.push(framedoc.getElementById("nestedmenu1")); 1.39 + gMenus.push(framedoc.getElementById("separatemenu4")); 1.40 + gMenus.push(framedoc.getElementById("separatemenu2")); 1.41 + gMenus.push(framedoc.getElementById("separatemenu3")); 1.42 + gMenus.push(framedoc.getElementById("separatemenu1")); 1.43 + 1.44 + framedoc.location = "about:blank"; 1.45 +} 1.46 + 1.47 +function modified(event) 1.48 +{ 1.49 + if (event.attrName != "open") 1.50 + return; 1.51 + 1.52 + var framedoc = $("frame").contentDocument; 1.53 + 1.54 + var tohide = null; 1.55 + if (event.target.id == "separatemenu3") 1.56 + tohide = framedoc.getElementById("separatemenu2"); 1.57 + else if (event.target.id == "nestedmenu3") 1.58 + tohide = framedoc.getElementById("nestedmenu2"); 1.59 + 1.60 + if (tohide) { 1.61 + tohide.hidden = true; 1.62 + // force a layout flush 1.63 + $("frame").contentDocument.documentElement.boxObject.width; 1.64 + } 1.65 + 1.66 + is(event.target, gMenus.shift(), event.target.id + " hidden"); 1.67 + if (gMenus.length == 0) 1.68 + SimpleTest.finish(); 1.69 +} 1.70 + 1.71 +]]> 1.72 +</script> 1.73 + 1.74 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.75 +<p id="display"> 1.76 +</p> 1.77 +<div id="content" style="display: none"> 1.78 +</div> 1.79 +<pre id="test"> 1.80 +</pre> 1.81 +</body> 1.82 + 1.83 +</window>