OLD | NEW |
1 <html xmlns="http://www.w3.org/1999/xhtml"> | 1 <html xmlns="http://www.w3.org/1999/xhtml"> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 var globalValue = "I am not 42."; | 4 var globalValue = "I am not 42."; |
5 | 5 |
6 // Some helper functions that track the focus state of a form on the toolbar. | 6 // Some helper functions that track the focus state of a form on the toolbar. |
7 var formFocused = false; | 7 var formFocused = false; |
8 function onFormFocused() { | 8 function onFormFocused() { |
9 formFocused = true; | 9 formFocused = true; |
10 } | 10 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 chrome.test.listenOnce(chrome.experimental.popup.onClosed, function() { | 104 chrome.test.listenOnce(chrome.experimental.popup.onClosed, function() { |
105 // TODO(twiz): getPopupView() should return undefined, but, due to | 105 // TODO(twiz): getPopupView() should return undefined, but, due to |
106 // shut-down races, it is sometimes still defined. See BUG 27658. | 106 // shut-down races, it is sometimes still defined. See BUG 27658. |
107 // chrome.test.assertTrue( | 107 // chrome.test.assertTrue( |
108 // chrome.experimental.extension.getPopupView() == undefined); | 108 // chrome.experimental.extension.getPopupView() == undefined); |
109 }); | 109 }); |
110 chrome.experimental.extension.getPopupView().close(); | 110 chrome.experimental.extension.getPopupView().close(); |
111 }, | 111 }, |
112 function popupBlackBorder() { | 112 function popupBlackBorder() { |
113 // Ensure that the test waits until the popup is dismissed. | 113 // Ensure that the test waits until the popup is dismissed. |
114 chrome.test.listenOnce(chrome.experimental.popup.onClosed, | 114 chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
115 function() {}); | |
116 | 115 |
117 // Validate that displaying a pop-up with a black border still invokes | 116 // Validate that displaying a pop-up with a black border still invokes |
118 // the callback successfully. Note that this test does not validate | 117 // the callback successfully. Note that this test does not validate |
119 // the actual style of the border displayed. | 118 // the actual style of the border displayed. |
120 var showDetails = { | 119 var showDetails = { |
121 "relativeTo": document.getElementById("anchorHere"), | 120 "relativeTo": document.getElementById("anchorHere"), |
122 "borderStyle": "rectangle" | 121 "borderStyle": "rectangle" |
123 }; | 122 }; |
124 chrome.experimental.popup.show("toolband_popup.html", | 123 chrome.experimental.popup.show("toolband_popup.html", |
125 showDetails, | 124 showDetails, |
126 chrome.test.callbackPass(function() { | 125 chrome.test.callbackPass(function() { |
127 chrome.experimental.extension.getPopupView().close(); | 126 chrome.experimental.extension.getPopupView().close(); |
128 })); | 127 })); |
129 }, | 128 }, |
| 129 function disallowMultiplePopups() { |
| 130 // This test ensures that for a given extension with a popup displayed, |
| 131 // displaying a subsequent popup will dismiss the first. |
| 132 var showDetails1 = { |
| 133 "relativeTo": document.getElementById("anchorHere"), |
| 134 }; |
| 135 |
| 136 var showDetails2 = { |
| 137 "relativeTo": document.getElementById("anchorHere2"), |
| 138 "borderStyle": "rectangle" |
| 139 }; |
| 140 |
| 141 // Track the number of popups opened and closed, so that we can signal |
| 142 // the test as completed when appropriate. |
| 143 var numberClosed = 0; |
| 144 var doneListening = chrome.test.listenForever( |
| 145 chrome.experimental.popup.onClosed, |
| 146 function() { |
| 147 // This test expects to open and close two popups, so signify that |
| 148 // the test has succeeded, after closing the second popup. |
| 149 if (++numberClosed == 2) { |
| 150 doneListening(); |
| 151 } |
| 152 }); |
| 153 |
| 154 chrome.experimental.popup.show("toolband_popup_a.html", |
| 155 showDetails1, |
| 156 function() { |
| 157 // Validate that the popup view returned is the one we expect. |
| 158 chrome.test.assertEq( |
| 159 'a', |
| 160 chrome.experimental.extension.getPopupView().getIdentity()); |
| 161 |
| 162 // Ensure that only one popup is open. |
| 163 chrome.test.assertEq( |
| 164 1, |
| 165 chrome.extension.getViews({type: "popup"}).length); |
| 166 |
| 167 chrome.experimental.popup.show("toolband_popup_b.html", |
| 168 showDetails2, |
| 169 function() { |
| 170 // Validate that the first popup view is fully closed, and that |
| 171 // getPopupView returns the most recently opened popup. |
| 172 chrome.test.assertEq( |
| 173 'b', |
| 174 chrome.experimental.extension.getPopupView().getIdentity()); |
| 175 |
| 176 // Ensure that only one popup is open. |
| 177 chrome.test.assertEq( |
| 178 1, |
| 179 chrome.extension.getViews({type: 'popup'}).length); |
| 180 |
| 181 chrome.experimental.extension.getPopupView().close(); |
| 182 }); |
| 183 }); |
| 184 }, |
130 function popupChromeSizing() { | 185 function popupChromeSizing() { |
131 // Ensure that the test waits until the popup is dismissed. | 186 // Ensure that the test waits until the popup is dismissed. |
132 chrome.test.listenOnce(chrome.experimental.popup.onClosed); | 187 chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
133 | 188 |
134 // Ensure that popups with a chrome border are repositioned and sized | 189 // Ensure that popups with a chrome border are repositioned and sized |
135 // correctly. | 190 // correctly. |
136 var showDetails = { | 191 var showDetails = { |
137 "relativeTo": document.getElementById("anchorHere") | 192 "relativeTo": document.getElementById("anchorHere") |
138 }; | 193 }; |
139 | 194 |
(...skipping 12 matching lines...) Expand all Loading... |
152 }; | 207 }; |
153 | 208 |
154 chrome.experimental.popup.show("toolband_popup_sizing.html", | 209 chrome.experimental.popup.show("toolband_popup_sizing.html", |
155 showDetails); | 210 showDetails); |
156 } | 211 } |
157 ]); | 212 ]); |
158 } | 213 } |
159 </script> | 214 </script> |
160 </head> | 215 </head> |
161 <body> | 216 <body> |
162 <div> | 217 <div id="anchorHere"> |
163 <span id="anchorHere">TEST</span> | 218 <span>TEST</span> |
| 219 </div> |
| 220 <div id="anchorHere2"> |
| 221 <span>TESTING 2</span> |
164 </div> | 222 </div> |
165 <form> | 223 <form> |
166 <input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> | 224 <input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> |
167 </form> | 225 </form> |
168 </body> | 226 </body> |
169 </html> | 227 </html> |
OLD | NEW |