diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 21:49:14 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 21:49:14 +0000 |
commit | d4db6c702d284543ba49b63eee555bf864becb09 (patch) | |
tree | 99164f6d796fcce380f8ba83b7c74c2bf072b6d3 /chrome/test | |
parent | 15549947e651f2a4d9b1ec01019893ee5cc4bbbd (diff) | |
download | chromium_src-d4db6c702d284543ba49b63eee555bf864becb09.zip chromium_src-d4db6c702d284543ba49b63eee555bf864becb09.tar.gz chromium_src-d4db6c702d284543ba49b63eee555bf864becb09.tar.bz2 |
Add focused property to chrome.windows.create extension API.
Add BrowserWindow::ShowInactive.
BUG=None
TEST=Added api test. Also tested manually on CR-48.
Review URL: http://codereview.chromium.org/6688036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
4 files changed, 97 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/window_open/focus/blank.html b/chrome/test/data/extensions/api_test/window_open/focus/blank.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/chrome/test/data/extensions/api_test/window_open/focus/blank.html diff --git a/chrome/test/data/extensions/api_test/window_open/focus/manifest.json b/chrome/test/data/extensions/api_test/window_open/focus/manifest.json new file mode 100644 index 0000000..94c0527 --- /dev/null +++ b/chrome/test/data/extensions/api_test/window_open/focus/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "window/create.focus", + "version": "0.1", + "description": "Tests the window.create focus parameter.", + "background_page": "test.html", + "permissions": ["tabs"] +} diff --git a/chrome/test/data/extensions/api_test/window_open/focus/test.html b/chrome/test/data/extensions/api_test/window_open/focus/test.html new file mode 100644 index 0000000..6a040cd5 --- /dev/null +++ b/chrome/test/data/extensions/api_test/window_open/focus/test.html @@ -0,0 +1,89 @@ +<script> +var expectFocusChange; +var createdWinId; +var focusedWinId; +var listenDoneCallback; + +function resetTest(focused) { + expectFocusChange = focused; + createdWinId = chrome.windows.WINDOW_ID_NONE; + focusedWinId = chrome.windows.WINDOW_ID_NONE; + listenDoneCallback = chrome.test.listenForever( + chrome.windows.onFocusChanged, onFocusChanged); +} + +function onFocusChanged(changedWinId) { + if (chrome.windows.WINDOW_ID_NONE != changedWinId) { + focusedWinId = changedWinId; + if (expectFocusChange) + maybeFocusedTestDone(); + } +} + +function checkFocused(win) { + createdWinId = win.id; + maybeFocusedTestDone(); +} + +// Test is done when focus has changed to the created window. +function maybeFocusedTestDone() { + if (focusedWinId != chrome.windows.WINDOW_ID_NONE && + createdWinId != chrome.windows.WINDOW_ID_NONE) { + listenDoneCallback(); + chrome.test.assertEq(focusedWinId, createdWinId); + } +} + +function checkUnfocused(win) { + createdWinId = win.id; + setTimeout(chrome.test.callbackPass(function () { + listenDoneCallback(); + chrome.test.assertTrue(focusedWinId != createdWinId); + }), 500); +} + +chrome.test.runTests([ + function defaultHasFocus() { + resetTest(true); + chrome.windows.create( + { 'url': 'blank.html' }, + chrome.test.callbackPass(checkFocused) + ); + }, + function defaultHasFocusPopup() { + resetTest(true); + chrome.windows.create( + { 'url': 'blank.html', 'type': 'popup' }, + chrome.test.callbackPass(checkFocused) + ); + }, + function withFocus() { + resetTest(true); + chrome.windows.create( + { 'url': 'blank.html', 'focused': true }, + chrome.test.callbackPass(checkFocused) + ); + }, + function withFocusPopup() { + resetTest(true); + chrome.windows.create( + { 'url': 'blank.html', 'focused': true, 'type': 'popup' }, + chrome.test.callbackPass(checkFocused) + ); + }, + function withoutFocus() { + resetTest(false); + chrome.windows.create( + { 'url': 'blank.html', 'focused': false }, + chrome.test.callbackPass(checkUnfocused) + ); + }, + function withoutFocusPopup() { + resetTest(false); + chrome.windows.create( + { 'url': 'blank.html', 'focused': false, 'type': 'popup' }, + chrome.test.callbackPass(checkUnfocused) + ); + } +]); +</script> diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h index 8708226..46a83c5 100644 --- a/chrome/test/test_browser_window.h +++ b/chrome/test/test_browser_window.h @@ -19,6 +19,7 @@ class TestBrowserWindow : public BrowserWindow { virtual void Init() {} virtual void Show() {} + virtual void ShowInactive() {} virtual void SetBounds(const gfx::Rect& bounds) {} virtual void Close() {} virtual void Activate() {} |