summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authortwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 16:53:12 +0000
committertwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 16:53:12 +0000
commitd557b97a8ee9f66bda9216c66fff677229322876 (patch)
tree263de7bfce088e18e63f41c5f62e1db438a54730 /chrome/test
parent4fca287ea20f4e092d3de4a123f9dde6533473e5 (diff)
downloadchromium_src-d557b97a8ee9f66bda9216c66fff677229322876.zip
chromium_src-d557b97a8ee9f66bda9216c66fff677229322876.tar.gz
chromium_src-d557b97a8ee9f66bda9216c66fff677229322876.tar.bz2
A CL implementing a collection of fixes to tidy up experimental popups.
The following are fixed: - Modified test\data\extension\api_test\popup to account for the removal of toolbar support. The tests now start with a background page that creates a tab pointing to an extension dom-ui that runs the tests. - Changed the positioning of experimental popup views with the arrow location set to the right. Popups used to always be anchored to the left edge of their relative dom element, now popups with a right-arrow will be attached to the right edge of their relative dom anchor. Note that this only impacts popups with the 'rectangle' chrome. - Removed empty directory, test\data\extensions\api_test\popup_api BUG=46601, 51821 TEST=ExtensionApiTest.Popup Review URL: http://codereview.chromium.org/3155044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/popup/background_page.html10
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui.html (renamed from chrome/test/data/extensions/api_test/popup/toolband.html)20
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui_popup.html (renamed from chrome/test/data/extensions/api_test/popup/toolband_popup.html)0
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui_popup_a.html (renamed from chrome/test/data/extensions/api_test/popup/toolband_popup_a.html)46
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui_popup_b.html (renamed from chrome/test/data/extensions/api_test/popup/toolband_popup_b.html)46
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui_popup_dismissal.html (renamed from chrome/test/data/extensions/api_test/popup/toolband_domui_popup_dismissal.html)96
-rw-r--r--chrome/test/data/extensions/api_test/popup/dom_ui_popup_sizing.html (renamed from chrome/test/data/extensions/api_test/popup/toolband_popup_sizing.html)118
-rw-r--r--chrome/test/data/extensions/api_test/popup/manifest.json4
8 files changed, 183 insertions, 157 deletions
diff --git a/chrome/test/data/extensions/api_test/popup/background_page.html b/chrome/test/data/extensions/api_test/popup/background_page.html
new file mode 100644
index 0000000..aec295a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/popup/background_page.html
@@ -0,0 +1,10 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script>
+window.onload = function() {
+ // Create a tab in which the popup tests can execute.
+ chrome.tabs.create({ "url": "dom_ui.html" });
+}
+</script>
+</head>
+</html>
diff --git a/chrome/test/data/extensions/api_test/popup/toolband.html b/chrome/test/data/extensions/api_test/popup/dom_ui.html
index ca36d6b..cf1e58d 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui.html
@@ -1,6 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
+// A token assigned to the global context of this script so that subsequently
+// created tabs/views may find this view.
+var TESTING_TOKEN = true;
+
var globalValue = "I am not 42.";
// Some helper functions that track the focus state of a form on the toolbar.
@@ -60,7 +64,7 @@ window.onload = function() {
chrome.test.assertTrue(formFocused);
});
- chrome.experimental.popup.show("toolband_popup.html",
+ chrome.experimental.popup.show("dom_ui_popup.html",
showDetails,
chrome.test.callbackPass(function() {
chrome.test.assertTrue(formFocused);
@@ -83,7 +87,7 @@ window.onload = function() {
var showDetails = {
"relativeTo": document.getElementById("anchorHere")
};
- chrome.experimental.popup.show("toolband_popup.html",
+ chrome.experimental.popup.show("dom_ui_popup.html",
showDetails,
chrome.test.callbackPass(function() {
chrome.test.assertTrue(
@@ -133,7 +137,7 @@ window.onload = function() {
"relativeTo": document.getElementById("anchorHere"),
"borderStyle": "rectangle"
};
- chrome.experimental.popup.show("toolband_popup.html",
+ chrome.experimental.popup.show("dom_ui_popup.html",
showDetails,
chrome.test.callbackPass(function() {
chrome.experimental.extension.getPopupView().close();
@@ -164,7 +168,7 @@ window.onload = function() {
}
});
- chrome.experimental.popup.show("toolband_popup_a.html",
+ chrome.experimental.popup.show("dom_ui_popup_a.html",
showDetails1,
function() {
// Validate that the popup view returned is the one we expect.
@@ -177,7 +181,7 @@ window.onload = function() {
1,
chrome.extension.getViews({type: "popup"}).length);
- chrome.experimental.popup.show("toolband_popup_b.html",
+ chrome.experimental.popup.show("dom_ui_popup_b.html",
showDetails2,
function() {
// Validate that the first popup view is fully closed, and that
@@ -205,7 +209,7 @@ window.onload = function() {
"relativeTo": document.getElementById("anchorHere")
};
- chrome.experimental.popup.show("toolband_popup_sizing.html",
+ chrome.experimental.popup.show("dom_ui_popup_sizing.html",
showDetails);
},
function popupRectangleSizing() {
@@ -219,14 +223,14 @@ window.onload = function() {
"borderStyle": "rectangle"
};
- chrome.experimental.popup.show("toolband_popup_sizing.html",
+ chrome.experimental.popup.show("dom_ui_popup_sizing.html",
showDetails);
},
function popupTeardownDismissal() {
// This test verifies that closing of views that launched active popups
// results in a popup dismissal.
var tabProperties = {
- "url": "toolband_domui_popup_dismissal.html"
+ "url": "dom_ui_popup_dismissal.html"
};
chrome.tabs.create(tabProperties);
}
diff --git a/chrome/test/data/extensions/api_test/popup/toolband_popup.html b/chrome/test/data/extensions/api_test/popup/dom_ui_popup.html
index 67d4cdf..67d4cdf 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband_popup.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui_popup.html
diff --git a/chrome/test/data/extensions/api_test/popup/toolband_popup_a.html b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_a.html
index ad453ff..621fbec 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband_popup_a.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_a.html
@@ -1,24 +1,24 @@
-<html>
-<head>
-<script>
-function getIdentity() {
- return 'a';
-}
-</script>
-</head>
-<body>
-Popup-A-Contents
-</body>
-</html>
-<html>
-<head>
-<script>
-function getIdentity() {
- return 'a';
-}
-</script>
-</head>
-<body>
-Popup-A-Contents
-</body>
+<html>
+<head>
+<script>
+function getIdentity() {
+ return 'a';
+}
+</script>
+</head>
+<body>
+Popup-A-Contents
+</body>
+</html>
+<html>
+<head>
+<script>
+function getIdentity() {
+ return 'a';
+}
+</script>
+</head>
+<body>
+Popup-A-Contents
+</body>
</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/popup/toolband_popup_b.html b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_b.html
index 5d8b815..5dd9792 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband_popup_b.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_b.html
@@ -1,24 +1,24 @@
-<html>
-<head>
-<script>
-function getIdentity() {
- return 'b';
-}
-</script>
-</head>
-<body>
-Popup-B-Contents
-</body>
-</html>
-<html>
-<head>
-<script>
-function getIdentity() {
- return 'b';
-}
-</script>
-</head>
-<body>
-Popup-B-Contents
-</body>
+<html>
+<head>
+<script>
+function getIdentity() {
+ return 'b';
+}
+</script>
+</head>
+<body>
+Popup-B-Contents
+</body>
+</html>
+<html>
+<head>
+<script>
+function getIdentity() {
+ return 'b';
+}
+</script>
+</head>
+<body>
+Popup-B-Contents
+</body>
</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/popup/toolband_domui_popup_dismissal.html b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_dismissal.html
index b51dc0b..5ba2839 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband_domui_popup_dismissal.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_dismissal.html
@@ -1,46 +1,60 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
-<script>
-var onbeforeunloadInvoked= false;
-var onunloadInvoked = false;
-var popupDismissed = false;
-var toolbarView = chrome.extension.getToolstrips()[0];
-
-// Onload handler that tests the popup dismissal behaviour when closing the
-// current tab. A popup is launched and the timing of the onClosed callback
-// is tested wrt the onbeforeunload and onunload callbacks.
-window.onload = function() {
- chrome.experimental.popup.onClosed.addListener(function() {
- toolbarView.assertTrue(onbeforeunloadInvoked,
- "Popup dismissed before onbeforeunload called.");
- toolbarView.assertTrue(!onunloadInvoked,
- "Popup dismissed after onunload called.");
- popupDismissed = true;
- });
-
- var showDetails = {
- "relativeTo": document.getElementById("popupAnchor")
- };
- chrome.experimental.popup.show("toolband_popup.html",
- showDetails,
- function() {
- chrome.tabs.getSelected(null, function(tab) {
- chrome.tabs.remove(tab.id);
- });
- });
-}
-
-window.onbeforeunload = function() {
- onbeforeunloadInvoked = true;
-}
-
-window.onunload = function() {
- onunloadInvoked = true;
-
- // If the popup was not yet dismissed, do not signal that the test has
- // completed. Let the test time-out to signal failure.
- if (popupDismissed)
- toolbarView.testCompleted();
+<script>
+var onbeforeunloadInvoked= false;
+var onunloadInvoked = false;
+var popupDismissed = false;
+var testingWindow = locateTestingWindow();
+
+// Helper function that locates the main tab that is being used
+// to drive the popup tests.
+function locateTestingWindow() {
+ var extensionViews = chrome.extension.getViews();
+ for (var i = 0; i < extensionViews.length; ++i) {
+ // Look for the magic token defined on the testing page.
+ if (typeof extensionViews[i].TESTING_TOKEN != "undefined" &&
+ !!extensionViews[i].TESTING_TOKEN) {
+ return extensionViews[i];
+ }
+ }
+ return null;
+}
+
+// Onload handler that tests the popup dismissal behaviour when closing the
+// current tab. A popup is launched and the timing of the onClosed callback
+// is tested wrt the onbeforeunload and onunload callbacks.
+window.onload = function() {
+ chrome.experimental.popup.onClosed.addListener(function() {
+ testingWindow.assertTrue(onbeforeunloadInvoked,
+ "Popup dismissed before onbeforeunload called.");
+ testingWindow.assertTrue(!onunloadInvoked,
+ "Popup dismissed after onunload called.");
+ popupDismissed = true;
+ });
+
+ var showDetails = {
+ "relativeTo": document.getElementById("popupAnchor")
+ };
+ chrome.experimental.popup.show("dom_ui_popup.html",
+ showDetails,
+ function() {
+ chrome.tabs.getSelected(null, function(tab) {
+ chrome.tabs.remove(tab.id);
+ });
+ });
+}
+
+window.onbeforeunload = function() {
+ onbeforeunloadInvoked = true;
+}
+
+window.onunload = function() {
+ onunloadInvoked = true;
+
+ // If the popup was not yet dismissed, do not signal that the test has
+ // completed. Let the test time-out to signal failure.
+ if (popupDismissed)
+ testingWindow.testCompleted();
};
</script>
</head>
diff --git a/chrome/test/data/extensions/api_test/popup/toolband_popup_sizing.html b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_sizing.html
index 07d57857..29fe0f2 100644
--- a/chrome/test/data/extensions/api_test/popup/toolband_popup_sizing.html
+++ b/chrome/test/data/extensions/api_test/popup/dom_ui_popup_sizing.html
@@ -1,65 +1,65 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
-<script>
-// Returns the current size of the displayed popup view.
-function getCurrentWindowSize() {
- return {
- "top": window.screenTop,
- "left": window.screenLeft,
- "width": window.outerWidth,
- "height": window.outerHeight
- };
-}
-
-// 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();
-
- // Move the browser, and ensure that the popup is repositioned correctly,
- // and retains its proper size.
- var offset = {'x': 5, 'y': 5};
- chrome.windows.getCurrent(function(browserWindow) {
- chrome.windows.update(browserWindow.id,
- {
- "left": browserWindow.left + offset.x,
- "top": browserWindow.top + offset.y
- },
- function(UpdatedWindow) {
- // Yield so that the window move notification may be processed before
- // invoking the callback. This is required because chrome.windows.update
- // calls its callback in a race with the windows message that repositions
- // the browser.
- // 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();
- if (newPosition.top != initialSize.top) {
- clearInterval(updatePoller);
- chrome.experimental.popup.getParentWindow().onWindowMoveCompleted(
- offset,
- initialSize,
- newPosition);
- window.close();
- }
- }, 50);
- });
+<script>
+// Returns the current size of the displayed popup view.
+function getCurrentWindowSize() {
+ return {
+ "top": window.screenTop,
+ "left": window.screenLeft,
+ "width": window.outerWidth,
+ "height": window.outerHeight
+ };
+}
+
+// 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();
+
+ // Move the browser, and ensure that the popup is repositioned correctly,
+ // and retains its proper size.
+ var offset = {'x': 5, 'y': 5};
+ chrome.windows.getCurrent(function(browserWindow) {
+ chrome.windows.update(browserWindow.id,
+ {
+ "left": browserWindow.left + offset.x,
+ "top": browserWindow.top + offset.y
+ },
+ function(UpdatedWindow) {
+ // Yield so that the window move notification may be processed before
+ // invoking the callback. This is required because chrome.windows.update
+ // calls its callback in a race with the windows message that repositions
+ // the browser.
+ // 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();
+ if (newPosition.top != initialSize.top) {
+ clearInterval(updatePoller);
+ chrome.experimental.popup.getParentWindow().onWindowMoveCompleted(
+ offset,
+ initialSize,
+ newPosition);
+ window.close();
+ }
+ }, 50);
+ });
});
-}
-
-window.onload = function() {
- // Delay invocation of the sizing test so that layout of the popup may
- // 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.
- var positionPoller = setInterval(function() {
- var initialSize = getCurrentWindowSize();
- if (initialSize.width != 0) {
- clearInterval(positionPoller);
- doSizingValidation();
- }
- }, 50);
+}
+
+window.onload = function() {
+ // Delay invocation of the sizing test so that layout of the popup may
+ // 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.
+ var positionPoller = setInterval(function() {
+ var initialSize = getCurrentWindowSize();
+ if (initialSize.width != 0) {
+ clearInterval(positionPoller);
+ doSizingValidation();
+ }
+ }, 50);
}
</script>
</head>
diff --git a/chrome/test/data/extensions/api_test/popup/manifest.json b/chrome/test/data/extensions/api_test/popup/manifest.json
index 3ab7d85..11f279d 100644
--- a/chrome/test/data/extensions/api_test/popup/manifest.json
+++ b/chrome/test/data/extensions/api_test/popup/manifest.json
@@ -2,8 +2,6 @@
"name": "Popup tester",
"version": "0.1",
"description": "apitest for the popup api",
- "toolstrips": [
- "toolband.html"
- ],
+ "background_page": "background_page.html",
"permissions": ["experimental", "tabs"]
}