Chromium Code Reviews| 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 // A token assigned to the global context of this script so that subsequently | 4 // A token assigned to the global context of this script so that subsequently |
| 5 // created tabs/views may find this view. | 5 // created tabs/views may find this view. |
| 6 var TESTING_TOKEN = true; | 6 var TESTING_TOKEN = true; |
| 7 | 7 |
| 8 // Constant storing the maximal size to which the popup may expand in the | |
| 9 // following tests: popupRectangleMaxBoundsSizing, popupChromeMaxBoundsSizing | |
| 10 var MAXIMAL_POPUP_SIZE = { | |
| 11 "width": 320, | |
| 12 "height": 240 | |
| 13 }; | |
| 14 | |
| 8 var globalValue = "I am not 42."; | 15 var globalValue = "I am not 42."; |
| 9 | 16 |
| 10 // Some helper functions that track the focus state of a form on the toolbar. | 17 // Some helper functions that track the focus state of a form on the toolbar. |
| 11 var formFocused = false; | 18 var formFocused = false; |
| 12 function onFormFocused() { | 19 function onFormFocused() { |
| 13 formFocused = true; | 20 formFocused = true; |
| 14 } | 21 } |
| 15 | 22 |
| 16 function onFormBlurred() { | 23 function onFormBlurred() { |
| 17 formFocused = false; | 24 formFocused = false; |
| 18 } | 25 } |
| 19 | 26 |
| 27 // Global variable accessed by tests that run in popup views to indicate which | |
| 28 // suite of tests to execute. | |
| 29 var currentTest = null; | |
| 30 | |
| 20 // Callback that validates popup repositioning, and is invoked during execution | 31 // Callback that validates popup repositioning, and is invoked during execution |
| 21 // of the following tests: | 32 // of the following tests: |
| 22 // popupRectangleSizing and popupChromeSizing. | 33 // popupRectangleSizing and popupChromeSizing. |
| 23 // |offset| specifies the delta in screen-space by which the browser was moved. | 34 // |offset| specifies the delta in screen-space by which the browser was moved. |
| 24 // |initialSize| specfies the rect of the popup before the brower move. | 35 // |initialSize| specfies the rect of the popup before the brower move. |
| 25 // |movedSize| specifies the rect of the popup after the browser move. | 36 // |movedSize| specifies the rect of the popup after the browser move. |
| 26 function onWindowMoveCompleted(offset, initialSize, movedSize) { | 37 function onWindowMoveCompleted(offset, initialSize, movedSize) { |
| 27 chrome.test.assertEq(initialSize.width, movedSize.width); | 38 chrome.test.assertEq(initialSize.width, movedSize.width); |
| 28 chrome.test.assertEq(initialSize.height, movedSize.height); | 39 chrome.test.assertEq(initialSize.height, movedSize.height); |
| 29 chrome.test.assertTrue( | 40 chrome.test.assertTrue( |
| 30 initialSize.top + offset.y == movedSize.top && | 41 initialSize.top + offset.y == movedSize.top && |
| 31 initialSize.left + offset.x == movedSize.left, | 42 initialSize.left + offset.x == movedSize.left, |
| 32 "Popup repositioned incorrectly after browser move."); | 43 "Popup repositioned incorrectly after browser move."); |
| 33 } | 44 } |
| 34 | 45 |
| 46 // Callback invoked upon completion of popup bounds validation tests. | |
| 47 // |newSize| is the size of the popup window after a resize operation. | |
| 48 function onPopupWindowResizeCompleted(newSize) { | |
| 49 // Note, we do not test for equality because the popup chrome may slightly | |
| 50 // boost the size of the popup. For example, the rectangle chrome adds | |
| 51 // a pixel to the dimensions of the popup. | |
| 52 chrome.test.assertTrue(newSize.width - MAXIMAL_POPUP_SIZE.width <= 2); | |
| 53 chrome.test.assertTrue(newSize.height - MAXIMAL_POPUP_SIZE.height <= 2); | |
| 54 } | |
| 55 | |
| 35 // Assert function used by tests executed in separate extension views. | 56 // Assert function used by tests executed in separate extension views. |
| 36 // Used by the following test: popupTeardownDismissal | 57 // Used by the following test: popupTeardownDismissal |
| 37 // |value| is value upon which to assert. | 58 // |value| is value upon which to assert. |
| 38 // |message| is displayed if |value| is false. | 59 // |message| is displayed if |value| is false. |
| 39 function assertTrue(value, message) { | 60 function assertTrue(value, message) { |
| 40 chrome.test.assertTrue(value, message); | 61 chrome.test.assertTrue(value, message); |
| 41 } | 62 } |
| 42 | 63 |
| 43 // Function used to signal completion of tests run in separate extension views. | 64 // Function used to signal completion of tests run in separate extension views. |
| 44 // Used by the following test: popupTeardownDismissal | 65 // Used by the following test: popupTeardownDismissal |
| 45 function testCompleted() { | 66 function testCompleted() { |
| 46 chrome.test.succeed(); | 67 chrome.test.succeed(); |
| 47 } | 68 } |
| 48 | 69 |
| 49 window.onload = function() { | 70 window.onload = function() { |
| 50 chrome.test.runTests([ | 71 chrome.test.runTests([ |
| 51 function showNoFocusShift() { | 72 function showNoFocusShift() { |
|
Jeff Timanus
2010/11/25 23:35:30
Oops. Inserted an extra space here. Corrected.
| |
| 52 var entryForm = document.getElementById("entryForm").focus(); | 73 var entryForm = document.getElementById("entryForm").focus(); |
| 53 chrome.test.assertTrue(formFocused); | 74 chrome.test.assertTrue(formFocused); |
| 54 | 75 |
| 55 // Validate that displaying a pop-up with the giveFocus parameter assigned | 76 // Validate that displaying a pop-up with the giveFocus parameter assigned |
| 56 // to false does not touch the focus setting of the input field. | 77 // to false does not touch the focus setting of the input field. |
| 57 var showDetails = { | 78 var showDetails = { |
| 58 "relativeTo": document.getElementById("anchorHere"), | 79 "relativeTo": document.getElementById("anchorHere"), |
| 59 "giveFocus": false | 80 "giveFocus": false |
| 60 }; | 81 }; |
| 61 | 82 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 function popupChromeSizing() { | 225 function popupChromeSizing() { |
| 205 // Ensure that the test waits until the popup is dismissed. | 226 // Ensure that the test waits until the popup is dismissed. |
| 206 chrome.test.listenOnce(chrome.experimental.popup.onClosed); | 227 chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
| 207 | 228 |
| 208 // Ensure that popups with a chrome border are repositioned and sized | 229 // Ensure that popups with a chrome border are repositioned and sized |
| 209 // correctly. | 230 // correctly. |
| 210 var showDetails = { | 231 var showDetails = { |
| 211 "relativeTo": document.getElementById("anchorHere") | 232 "relativeTo": document.getElementById("anchorHere") |
| 212 }; | 233 }; |
| 213 | 234 |
| 235 currentTest = "doSizingValidation"; | |
| 214 chrome.experimental.popup.show("dom_ui_popup_sizing.html", | 236 chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
| 215 showDetails); | 237 showDetails); |
| 216 }, | 238 }, |
| 217 function popupRectangleSizing() { | 239 function popupRectangleSizing() { |
| 218 // Ensure that the test waits until the popup is dismissed. | 240 // Ensure that the test waits until the popup is dismissed. |
| 219 chrome.test.listenOnce(chrome.experimental.popup.onClosed); | 241 chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
| 220 | 242 |
| 221 // Ensure that popups with a rectangle border are repositioned and sized | 243 // Ensure that popups with a rectangle border are repositioned and sized |
| 222 // correctly. | 244 // correctly. |
| 223 var showDetails = { | 245 var showDetails = { |
| 224 "relativeTo": document.getElementById("anchorHere"), | 246 "relativeTo": document.getElementById("anchorHere"), |
| 225 "borderStyle": "rectangle" | 247 "borderStyle": "rectangle" |
| 226 }; | 248 }; |
| 227 | 249 |
| 250 currentTest = "doSizingValidation"; | |
| 251 chrome.experimental.popup.show("dom_ui_popup_sizing.html", | |
| 252 showDetails); | |
| 253 }, | |
| 254 function popupChromeMaxBoundsSizing() { | |
| 255 // Ensure that the test waits until the popup is dismissed. | |
| 256 chrome.test.listenOnce(chrome.experimental.popup.onClosed); | |
| 257 | |
| 258 // Ensure that popups with a chrome border are repositioned and sized | |
| 259 // correctly. | |
| 260 var showDetails = { | |
| 261 "relativeTo": document.getElementById("anchorHere"), | |
| 262 "maxSize": MAXIMAL_POPUP_SIZE | |
| 263 }; | |
| 264 | |
| 265 currentTest = "doMaximalBoundsValidation"; | |
| 266 chrome.experimental.popup.show("dom_ui_popup_sizing.html", | |
| 267 showDetails); | |
| 268 }, | |
| 269 function popupRectangleMaxBoundsSizing() { | |
| 270 // Ensure that the test waits until the popup is dismissed. | |
| 271 chrome.test.listenOnce(chrome.experimental.popup.onClosed); | |
| 272 | |
| 273 // Ensure that popups with a rectangle border respects the maximal bounds. | |
| 274 var showDetails = { | |
| 275 "relativeTo": document.getElementById("anchorHere"), | |
| 276 "borderStyle": "rectangle", | |
| 277 "maxSize": MAXIMAL_POPUP_SIZE | |
| 278 }; | |
| 279 | |
| 280 currentTest = "doMaximalBoundsValidation"; | |
| 228 chrome.experimental.popup.show("dom_ui_popup_sizing.html", | 281 chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
| 229 showDetails); | 282 showDetails); |
| 230 }, | 283 }, |
| 231 function popupTeardownDismissal() { | 284 function popupTeardownDismissal() { |
| 232 // This test verifies that closing of views that launched active popups | 285 // This test verifies that closing of views that launched active popups |
| 233 // results in a popup dismissal. | 286 // results in a popup dismissal. |
| 234 var tabProperties = { | 287 var tabProperties = { |
| 235 "url": "dom_ui_popup_dismissal.html" | 288 "url": "dom_ui_popup_dismissal.html" |
| 236 }; | 289 }; |
| 237 chrome.tabs.create(tabProperties); | 290 chrome.tabs.create(tabProperties); |
| 238 } | 291 } |
| 239 ]); | 292 ]); |
| 240 } | 293 } |
| 241 </script> | 294 </script> |
| 242 </head> | 295 </head> |
| 243 <body> | 296 <body> |
| 244 <div id="anchorHere"> | 297 <div id="anchorHere"> |
| 245 <span>TEST</span> | 298 <span>TEST</span> |
| 246 </div> | 299 </div> |
| 247 <div id="anchorHere2"> | 300 <div id="anchorHere2"> |
| 248 <span>TESTING 2</span> | 301 <span>TESTING 2</span> |
| 249 </div> | 302 </div> |
| 250 <form> | 303 <form> |
| 251 <input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> | 304 <input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> |
| 252 </form> | 305 </form> |
| 253 </body> | 306 </body> |
| 254 </html> | 307 </html> |
| OLD | NEW |