| Index: chrome/test/data/extensions/api_test/popup/popup_main/dom_ui_popup_sizing.html
|
| ===================================================================
|
| --- chrome/test/data/extensions/api_test/popup/popup_main/dom_ui_popup_sizing.html (revision 67311)
|
| +++ chrome/test/data/extensions/api_test/popup/popup_main/dom_ui_popup_sizing.html (working copy)
|
| @@ -1,20 +1,29 @@
|
| <html xmlns="http://www.w3.org/1999/xhtml">
|
| <head>
|
| <script>
|
| -// Returns the current size of the displayed popup view.
|
| -function getCurrentWindowSize() {
|
| +// Returns the current size of the popup view.
|
| +function getCurrentWindowSize() {
|
| + return {
|
| + "width": window.outerWidth,
|
| + "height": window.outerHeight
|
| + };
|
| +}
|
| +
|
| +// Returns the current bounds of the displayed popup view.
|
| +function getCurrentWindowBounds() {
|
| + var windowSize = getCurrentWindowSize();
|
| return {
|
| "top": window.screenTop,
|
| "left": window.screenLeft,
|
| - "width": window.outerWidth,
|
| - "height": window.outerHeight
|
| + "width": windowSize.width,
|
| + "height": windowSize.height
|
| };
|
| }
|
|
|
| // Utility that captures the size of the popup window before and after a browser
|
| // move and notifies the test's parent view of the respective sizes.
|
| function doSizingValidation() {
|
| - var initialSize = getCurrentWindowSize();
|
| + var initialSize = getCurrentWindowBounds();
|
|
|
| // Move the browser, and ensure that the popup is repositioned correctly,
|
| // and retains its proper size.
|
| @@ -33,7 +42,7 @@
|
| // TODO: Fix this race condition so that the update callback is invoked
|
| // after all of the update machinery has been invoked.
|
| var updatePoller = setInterval(function() {
|
| - var newPosition = getCurrentWindowSize();
|
| + var newPosition = getCurrentWindowBounds();
|
| if (newPosition.top != initialSize.top) {
|
| clearInterval(updatePoller);
|
| chrome.experimental.popup.getParentWindow().onWindowMoveCompleted(
|
| @@ -44,7 +53,41 @@
|
| }
|
| }, 50);
|
| });
|
| - });
|
| + });
|
| +}
|
| +
|
| +// Tests that resizing of the popup window, via a page-layout change, does not
|
| +// result in a popup window that is larger than the specified maximal size.
|
| +function doMaximalBoundsValidation() {
|
| + var initialSize = getCurrentWindowSize();
|
| +
|
| + // Resize a portion of the page, and pass the resulting window size back
|
| + // to the test host for validation.
|
| + //var resizeDiv = document.getElementById("resizeMe");
|
| + //resizeDiv.style.height = 1024;
|
| + //resizeDiv.style.width = 1024;
|
| + document.body.style.width = 1024;
|
| + document.body.style.height = 1024;
|
| +
|
| + // Give the browser a chance to perform the resize.
|
| + var updatePoller = setInterval(function() {
|
| + var newSize = getCurrentWindowSize();
|
| + if (newSize.width != initialSize.width) {
|
| + clearInterval(updatePoller);
|
| + chrome.experimental.popup.getParentWindow().
|
| + onPopupWindowResizeCompleted(newSize);
|
| + window.close();
|
| + }
|
| + }, 50);
|
| +}
|
| +
|
| +// Invokes a test function based on the value of |test|.
|
| +function runTest(test) {
|
| + if ("doSizingValidation" == test)
|
| + doSizingValidation();
|
| +
|
| + if ("doMaximalBoundsValidation" == test)
|
| + doMaximalBoundsValidation();
|
| }
|
|
|
| window.onload = function() {
|
| @@ -52,12 +95,12 @@
|
| // complete. On windows, onload is called before layout has been performed,
|
| // so window.screenTop, and the other fields used in getCurrentWindowSize will
|
| // return 0 until the layout has been performed.
|
| - // TODO: Fix the order of the onload and layout processing.
|
| + // TODO(twiz@chromium.org): Fix the order of the onload and layout processing.
|
| var positionPoller = setInterval(function() {
|
| var initialSize = getCurrentWindowSize();
|
| if (initialSize.width != 0) {
|
| clearInterval(positionPoller);
|
| - doSizingValidation();
|
| + runTest(chrome.experimental.popup.getParentWindow().currentTest);
|
| }
|
| }, 50);
|
| }
|
|
|