summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authortwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-08 04:28:58 +0000
committertwiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-08 04:28:58 +0000
commitbf7e9637d7935075e56bd3d15df864f78312df53 (patch)
tree30ee46ce46c99585a43f9dc06788e69772f18bd1 /chrome/test
parente36ddc88da9374cfa6853101b2b81eb20a081026 (diff)
downloadchromium_src-bf7e9637d7935075e56bd3d15df864f78312df53.zip
chromium_src-bf7e9637d7935075e56bd3d15df864f78312df53.tar.gz
chromium_src-bf7e9637d7935075e56bd3d15df864f78312df53.tar.bz2
Addition of a new parameter to the popup.show(...) Chrome extension API that allows the caller to specify the behaviour of the window focus when the pop-up is displayed.
I added a test for the new parameter in the ExtensionApiTest.FLAKY_Popup test. I also corrected a truncated string in the unit-test. Because the pop-up actually uses two windows, I had to change the WidgetWin::Show() routine to also reposition the window at the top. If a window is shown and activated, it is automatically brought to the front. Because we don't activate the pop-up when we want to keep the focus in the current extension view, I had to bring it to the front so that it wouldn't be hidden behind the 'chrome-bubble' window. BUG=none TEST=ExtensionApiTest.FLAKY_Popup Review URL: http://codereview.chromium.org/454019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/popup_api/toolband.html46
1 files changed, 40 insertions, 6 deletions
diff --git a/chrome/test/data/extensions/api_test/popup_api/toolband.html b/chrome/test/data/extensions/api_test/popup_api/toolband.html
index cde3a31..77467ee 100644
--- a/chrome/test/data/extensions/api_test/popup_api/toolband.html
+++ b/chrome/test/data/extensions/api_test/popup_api/toolband.html
@@ -3,8 +3,41 @@
<script>
var globalValue = "I am not 42.";
+// Some helper functions that track the focus state of a form on the toolbar.
+var formFocused = false;
+function onFormFocused() {
+ formFocused = true;
+}
+
+function onFormBlurred() {
+ formFocused = false;
+}
+
window.onload = function() {
chrome.test.runTests([
+ function showNoFocusShift() {
+ var entryForm = document.getElementById("entryForm").focus();
+ chrome.test.assertTrue(formFocused);
+
+ // Validate that displaying a pop-up with the giveFocus parameter assigned
+ // to false does not touch the focus setting of the input field.
+ var showDetails = {
+ "relativeTo": document.getElementById("anchorHere"),
+ "giveFocus": false
+ };
+
+ // The focus should also remain untouched during closing of the popup.
+ chrome.test.listenOnce(chrome.experimental.popup.onClosed, function(){
+ chrome.test.assertTrue(formFocused);
+ });
+
+ chrome.experimental.popup.show("toolband_popup.html",
+ showDetails,
+ chrome.test.callbackPass(function() {
+ chrome.test.assertTrue(formFocused);
+ chrome.experimental.extension.getPopupView().close();
+ }));
+ },
function noPopup() {
chrome.test.assertTrue(
undefined === chrome.experimental.extension.getPopupView(),
@@ -14,7 +47,7 @@ window.onload = function() {
function noParentWindow() {
chrome.test.assertTrue(
undefined === chrome.experimental.popup.getParentWindow(),
- "Parent );
+ "Parent window accessible outside of popup view.");
chrome.test.succeed();
},
function show() {
@@ -39,7 +72,6 @@ window.onload = function() {
chrome.test.assertEq(42, popupView.theAnswer());
chrome.test.succeed();
},
-
function accessHost() {
var popupView = chrome.experimental.extension.getPopupView();
chrome.test.assertTrue(popupView != undefined,
@@ -52,13 +84,12 @@ window.onload = function() {
chrome.test.assertEq(42, globalValue);
chrome.test.succeed();
},
-
function closePopup() {
chrome.test.listenOnce(chrome.experimental.popup.onClosed, function(){
// TODO(twiz): getPopupView() should return undefined, but, due to
- // shut-down races, it is sometimes still defined. See BUG
- //chrome.test.assertTrue(
- // chrome.experimental.extension.getPopupView() == undefined);
+ // shut-down races, it is sometimes still defined. See BUG 27658.
+ // chrome.test.assertTrue(
+ // chrome.experimental.extension.getPopupView() == undefined);
});
chrome.experimental.extension.getPopupView().close();
}
@@ -70,5 +101,8 @@ window.onload = function() {
<div>
<span id="anchorHere">TEST</span>
</div>
+<form>
+<input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/>
+</form>
</body>
</html>