Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Popup Removing Tests" |
michael@0 | 6 | onload="setTimeout(nextTest, 0)" |
michael@0 | 7 | onDOMAttrModified="modified(event)" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | |
michael@0 | 10 | <!-- |
michael@0 | 11 | This test checks that popup elements can be removed in various ways without |
michael@0 | 12 | crashing. It tests two situations, one with menus that are 'separate', and |
michael@0 | 13 | one with menus that are 'nested'. In each case, there are four levels of menu. |
michael@0 | 14 | |
michael@0 | 15 | The nextTest function starts the process by opening the first menu. A set of |
michael@0 | 16 | popupshown event listeners are used to open the next menu until all four are |
michael@0 | 17 | showing. This last one calls removePopup to remove the menu node from the |
michael@0 | 18 | tree. This should hide the popups as they are no longer in a document. |
michael@0 | 19 | |
michael@0 | 20 | A mutation listener is triggered when the fourth menu closes by having its |
michael@0 | 21 | open attribute cleared. This listener hides the third popup which causes |
michael@0 | 22 | its frame to be removed. Naturally, we want to ensure that this doesn't |
michael@0 | 23 | crash when the third menu is removed. |
michael@0 | 24 | --> |
michael@0 | 25 | |
michael@0 | 26 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 27 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 28 | |
michael@0 | 29 | <hbox> |
michael@0 | 30 | |
michael@0 | 31 | <menu id="nestedmenu1" label="1"> |
michael@0 | 32 | <menupopup id="nestedpopup1" onpopupshown="if (event.target == this) this.firstChild.open = true"> |
michael@0 | 33 | <menu id="nestedmenu2" label="2"> |
michael@0 | 34 | <menupopup id="nestedpopup2" onpopupshown="if (event.target == this) this.firstChild.open = true"> |
michael@0 | 35 | <menu id="nestedmenu3" label="3"> |
michael@0 | 36 | <menupopup id="nestedpopup3" onpopupshown="if (event.target == this) this.firstChild.open = true"> |
michael@0 | 37 | <menu id="nestedmenu4" label="4" onpopupshown="removePopups()"> |
michael@0 | 38 | <menupopup id="nestedpopup4"> |
michael@0 | 39 | <menuitem label="Nested 1"/> |
michael@0 | 40 | <menuitem label="Nested 2"/> |
michael@0 | 41 | <menuitem label="Nested 3"/> |
michael@0 | 42 | </menupopup> |
michael@0 | 43 | </menu> |
michael@0 | 44 | </menupopup> |
michael@0 | 45 | </menu> |
michael@0 | 46 | </menupopup> |
michael@0 | 47 | </menu> |
michael@0 | 48 | </menupopup> |
michael@0 | 49 | </menu> |
michael@0 | 50 | |
michael@0 | 51 | <menu id="separatemenu1" label="1"> |
michael@0 | 52 | <menupopup id="separatepopup1" onpopupshown="$('separatemenu2').open = true"> |
michael@0 | 53 | <menuitem label="L1 One"/> |
michael@0 | 54 | <menuitem label="L1 Two"/> |
michael@0 | 55 | <menuitem label="L1 Three"/> |
michael@0 | 56 | </menupopup> |
michael@0 | 57 | </menu> |
michael@0 | 58 | |
michael@0 | 59 | <menu id="separatemenu2" label="2"> |
michael@0 | 60 | <menupopup id="separatepopup2" onpopupshown="$('separatemenu3').open = true" |
michael@0 | 61 | onpopuphidden="popup2Hidden()"> |
michael@0 | 62 | <menuitem label="L2 One"/> |
michael@0 | 63 | <menuitem label="L2 Two"/> |
michael@0 | 64 | <menuitem label="L2 Three"/> |
michael@0 | 65 | </menupopup> |
michael@0 | 66 | </menu> |
michael@0 | 67 | |
michael@0 | 68 | <menu id="separatemenu3" label="3" onpopupshown="$('separatemenu4').open = true"> |
michael@0 | 69 | <menupopup id="separatepopup3"> |
michael@0 | 70 | <menuitem label="L3 One"/> |
michael@0 | 71 | <menuitem label="L3 Two"/> |
michael@0 | 72 | <menuitem label="L3 Three"/> |
michael@0 | 73 | </menupopup> |
michael@0 | 74 | </menu> |
michael@0 | 75 | |
michael@0 | 76 | <menu id="separatemenu4" label="4" onpopupshown="removePopups()" |
michael@0 | 77 | onpopuphidden="$('separatemenu2').open = false"> |
michael@0 | 78 | <menupopup id="separatepopup3"> |
michael@0 | 79 | <menuitem label="L4 One"/> |
michael@0 | 80 | <menuitem label="L4 Two"/> |
michael@0 | 81 | <menuitem label="L4 Three"/> |
michael@0 | 82 | </menupopup> |
michael@0 | 83 | </menu> |
michael@0 | 84 | |
michael@0 | 85 | </hbox> |
michael@0 | 86 | |
michael@0 | 87 | <script class="testbody" type="application/javascript"> |
michael@0 | 88 | <![CDATA[ |
michael@0 | 89 | |
michael@0 | 90 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 91 | |
michael@0 | 92 | var gKey = ""; |
michael@0 | 93 | gTriggerMutation = null; |
michael@0 | 94 | gChangeMutation = null; |
michael@0 | 95 | |
michael@0 | 96 | function nextTest() |
michael@0 | 97 | { |
michael@0 | 98 | if (gKey == "") { |
michael@0 | 99 | gKey = "separate"; |
michael@0 | 100 | } |
michael@0 | 101 | else if (gKey == "separate") { |
michael@0 | 102 | gKey = "nested"; |
michael@0 | 103 | } |
michael@0 | 104 | else { |
michael@0 | 105 | SimpleTest.finish(); |
michael@0 | 106 | return; |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | $(gKey + "menu1").open = true; |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | function modified(event) |
michael@0 | 113 | { |
michael@0 | 114 | // use this mutation listener to hide the third popup, destroying its frame. |
michael@0 | 115 | // It gets triggered when the open attribute is cleared on the fourth menu. |
michael@0 | 116 | |
michael@0 | 117 | if (event.target == gTriggerMutation && |
michael@0 | 118 | event.attrName == "open") { |
michael@0 | 119 | gChangeMutation.hidden = true; |
michael@0 | 120 | // force a layout flush |
michael@0 | 121 | document.documentElement.boxObject.width; |
michael@0 | 122 | gTriggerMutation = null; |
michael@0 | 123 | gChangeMutation = null; |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | function removePopups() |
michael@0 | 128 | { |
michael@0 | 129 | var menu2 = $(gKey + "menu2"); |
michael@0 | 130 | var menu3 = $(gKey + "menu3"); |
michael@0 | 131 | is(menu2.getAttribute("open"), "true", gKey + " menu 2 open before"); |
michael@0 | 132 | is(menu3.getAttribute("open"), "true", gKey + " menu 3 open before"); |
michael@0 | 133 | |
michael@0 | 134 | gTriggerMutation = menu3; |
michael@0 | 135 | gChangeMutation = $(gKey + "menu4"); |
michael@0 | 136 | var menu = $(gKey + "menu1"); |
michael@0 | 137 | menu.parentNode.removeChild(menu); |
michael@0 | 138 | |
michael@0 | 139 | if (gKey == "nested") { |
michael@0 | 140 | // the 'separate' test checks this during the popup2 hidden event handler |
michael@0 | 141 | is(menu2.hasAttribute("open"), false, gKey + " menu 2 open after"); |
michael@0 | 142 | is(menu3.hasAttribute("open"), false, gKey + " menu 3 open after"); |
michael@0 | 143 | nextTest(); |
michael@0 | 144 | } |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | function popup2Hidden() |
michael@0 | 148 | { |
michael@0 | 149 | is($(gKey + "menu2").hasAttribute("open"), false, gKey + " menu 2 open after"); |
michael@0 | 150 | nextTest(); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | ]]> |
michael@0 | 154 | </script> |
michael@0 | 155 | |
michael@0 | 156 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 157 | <p id="display"> |
michael@0 | 158 | </p> |
michael@0 | 159 | <div id="content" style="display: none"> |
michael@0 | 160 | </div> |
michael@0 | 161 | <pre id="test"> |
michael@0 | 162 | </pre> |
michael@0 | 163 | </body> |
michael@0 | 164 | |
michael@0 | 165 | </window> |