Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3573)

Unified Diff: chrome/test/data/extensions/api_test/popup/popup_main/dom_ui_popup_sizing.html

Issue 5254007: Addition of 'maxSize' to experimental popup extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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() {
@@ -57,7 +100,7 @@
var initialSize = getCurrentWindowSize();
if (initialSize.width != 0) {
clearInterval(positionPoller);
- doSizingValidation();
+ runTest(chrome.experimental.popup.getParentWindow().currentTest);
}
}, 50);
}

Powered by Google App Engine
This is Rietveld 408576698