Index: chrome/test/data/extensions/api_test/window_update/show_state/test.html |
diff --git a/chrome/test/data/extensions/api_test/window_update/show_state/test.html b/chrome/test/data/extensions/api_test/window_update/show_state/test.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d46353192e4ef60d7db192f56cf6d2f4700088c7 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/window_update/show_state/test.html |
@@ -0,0 +1,76 @@ |
+<script> |
+var pass = chrome.test.callbackPass; |
+ |
+var width = 0; |
+var height = 0; |
+var changedWidth = 500; |
+var changedHeight = 500; |
+ |
+function checkRestoreWithBounds(theWindow) { |
+ chrome.test.assertEq('normal', theWindow.state); |
+ if (theWindow.type == 'panel') { |
+ // Panels decide their own bounds. |
+ chrome.test.assertEq(width, theWindow.width); |
+ chrome.test.assertEq(height, theWindow.height); |
+ } else { |
+ chrome.test.assertEq(changedWidth, theWindow.width); |
+ chrome.test.assertEq(changedHeight, theWindow.height); |
+ } |
+ |
+ chrome.windows.remove(theWindow.id, pass()); |
+} |
+ |
+function checkMaximized(theWindow) { |
+ if (theWindow.type == 'panel') { |
+ // Maximize is the same as restore for panels. |
+ chrome.test.assertEq('normal', theWindow.state); |
+ chrome.test.assertEq(width, theWindow.width); |
+ chrome.test.assertEq(height, theWindow.height); |
+ } else { |
+ chrome.test.assertEq('maximized', theWindow.state); |
+ chrome.test.assertTrue(width < theWindow.width || |
+ height < theWindow.height); |
+ } |
+ |
+ chrome.windows.update(theWindow.id, |
+ {'state': 'normal', width: changedWidth, height: changedHeight}, |
+ pass(checkRestoreWithBounds)); |
+} |
+ |
+function checkRestored(theWindow) { |
+ chrome.test.assertEq('normal', theWindow.state); |
+ chrome.test.assertEq(width, theWindow.width); |
+ chrome.test.assertEq(height, theWindow.height); |
+ |
+ chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximized)); |
+} |
+ |
+function checkMinimized(theWindow) { |
+ chrome.test.assertEq('minimized', theWindow.state); |
+ chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored)); |
+} |
+ |
+function minimizeWindow(theWindow) { |
+ chrome.test.assertEq('normal', theWindow.state); |
+ width = theWindow.width; |
+ height = theWindow.height; |
+ chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimized)); |
+} |
+ |
+function testWindowState(windowType) { |
+ chrome.windows.create({'url': 'hello.html', 'type': windowType}, |
+ pass(minimizeWindow)); |
+} |
+ |
+chrome.test.runTests([ |
+ function changeWindowState() { |
+ testWindowState('normal'); |
+ }, |
+ function changePopupWindowState() { |
+ testWindowState('popup'); |
+ }, |
+ function changePanelWindowState() { |
+ testWindowState('panel'); |
+ } |
+]); |
+</script> |