summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 00:27:01 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 00:27:01 +0000
commit7dad3d5f3d40d86158ed96536fd681701b43611d (patch)
treeec2dd5d5a9a836eb1244d6b9e1d36a6518a15f17 /chrome/test
parentf661899570cea4abb593ea7d6d8143afe0c7f8b8 (diff)
downloadchromium_src-7dad3d5f3d40d86158ed96536fd681701b43611d.zip
chromium_src-7dad3d5f3d40d86158ed96536fd681701b43611d.tar.gz
chromium_src-7dad3d5f3d40d86158ed96536fd681701b43611d.tar.bz2
Test cookie prompting.
Adds automation plumbing to support changing the content settings. This change also fixes WaitForNavigation to watch for the LOAD_STOP event instead of the NAV_ENTRY_COMMITTED event. This better matches the intent (I think) of the automation interface, and it also matches the similar function defined in ui_test_utils (used by browser tests). This also better matches the NavigationNotificationObserver, which seems desirable given the implementation of AutomationProvider::WaitForNavigation. It turns out that only one UI test was using WaitForNavigation, and I confirmed that it still functions properly. This change also modifies the NavigationNotificationObserver to allow it to watch for the current page load to complete. Normally, it waits for the first LOAD_START or NAV_ENTRY_COMMITTED event to switch into the mode where it watches for LOAD_STOP. However, that makes it not so useful for WaitForNavigation, which is intended to be called after triggering the start of a new navigation. This change also makes it so that the cookie prompt supports the automation message box 'OK' and 'Cancel' buttons, so that we can remotely press those buttons. Leveraging all of these changes enables some basic cookie prompting tests to be written. I had to modify browser_frame_win.cc to ensure that BrowserList::SetLastActive is called even while running under remote desktop. R=phajdan.jr@chromium.org BUG=37182 TEST=cookie_modal_dialog_uitest.cc Review URL: http://codereview.chromium.org/661102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h10
-rw-r--r--chrome/test/automation/browser_proxy.cc19
-rw-r--r--chrome/test/automation/browser_proxy.h10
-rw-r--r--chrome/test/data/cookie2.html19
4 files changed, 58 insertions, 0 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index ae68136..29bd287 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -15,6 +15,7 @@
#include "base/gfx/point.h"
#include "base/gfx/rect.h"
#include "base/string16.h"
+#include "chrome/common/content_settings.h"
#include "chrome/common/navigation_types.h"
#include "chrome/test/automation/autocomplete_edit_proxy.h"
#include "googleurl/src/gurl.h"
@@ -1212,4 +1213,13 @@ IPC_BEGIN_MESSAGES(Automation)
std::string /* cookies */,
int /* opaque_cookie_id */)
+ // If the given host is empty, then the default content settings are
+ // modified.
+ IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_SetContentSetting,
+ int /* browser handle */,
+ std::string /* host */,
+ ContentSettingsType /* content type */,
+ ContentSetting /* setting */,
+ bool /* success */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 7ecb9d9..2b62b71 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -395,6 +395,25 @@ bool BrowserProxy::SetBooleanPreference(const std::wstring& name,
return result;
}
+bool BrowserProxy::SetDefaultContentSetting(ContentSettingsType content_type,
+ ContentSetting setting) {
+ return SetContentSetting(std::string(), content_type, setting);
+}
+
+bool BrowserProxy::SetContentSetting(const std::string& host,
+ ContentSettingsType content_type,
+ ContentSetting setting) {
+ if (!is_valid())
+ return false;
+
+ bool result = false;
+
+ sender_->Send(new AutomationMsg_SetContentSetting(0, handle_, host,
+ content_type, setting,
+ &result));
+ return result;
+}
+
bool BrowserProxy::TerminateSession() {
if (!is_valid())
return false;
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index 76de8f0..939e87b 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -14,6 +14,7 @@
#include <string>
#include "chrome/browser/browser.h"
+#include "chrome/common/content_settings.h"
#include "chrome/test/automation/automation_handle_tracker.h"
class GURL;
@@ -200,6 +201,15 @@ class BrowserProxy : public AutomationResourceProxy {
// Sets the boolean value of the specified preference.
bool SetBooleanPreference(const std::wstring& name, bool value);
+ // Sets default content settings.
+ bool SetDefaultContentSetting(ContentSettingsType content_type,
+ ContentSetting setting);
+
+ // Sets content settings for a particular host (overriding the default).
+ bool SetContentSetting(const std::string& host,
+ ContentSettingsType content_type,
+ ContentSetting setting);
+
// Simulates a termination the browser session (as if the user logged off the
// mahine).
bool TerminateSession();
diff --git a/chrome/test/data/cookie2.html b/chrome/test/data/cookie2.html
new file mode 100644
index 0000000..aa13434
--- /dev/null
+++ b/chrome/test/data/cookie2.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<script>
+function setCookie() {
+ document.cookie = 'foo=baz';
+
+ // If there is a cookie prompt showing, then reading from document.cookie
+ // should block until the dialog is closed.
+ if (document.cookie.indexOf('foo') == -1) {
+ document.title = 'cookie blocked';
+ } else {
+ document.title = 'cookie allowed';
+ }
+}
+</script>
+</head>
+<body onload="setCookie();">
+</body>
+</html>