summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation
diff options
context:
space:
mode:
authordennisjeffrey@google.com <dennisjeffrey@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 19:16:47 +0000
committerdennisjeffrey@google.com <dennisjeffrey@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 19:16:47 +0000
commit300e4c98f135ea917150b24373ebb799348aa954 (patch)
treed6071f383d582ee3fe937bf44f9920dc35ff1d92 /chrome/browser/automation
parent4b6b2a59970398c68be566d5df753007e94f05be (diff)
downloadchromium_src-300e4c98f135ea917150b24373ebb799348aa954.zip
chromium_src-300e4c98f135ea917150b24373ebb799348aa954.tar.gz
chromium_src-300e4c98f135ea917150b24373ebb799348aa954.tar.bz2
Fix for bug in TestingAutomationProvider::OpenNewBrowserWindowOfType.
The function TestingAutomationProvider::OpenNewBrowserWindowOfType creates a new browser window and adds a blank tab to it, but failed to wait for the new tab to finish loading (it only waited for the new window to open). This is now fixed. BUG=47457 TEST=This change may fix flakiness in PyAuto test content.ContentTest.testThreeWindows. Review URL: http://codereview.chromium.org/6838024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc28
-rw-r--r--chrome/browser/automation/automation_provider_observers.h3
2 files changed, 24 insertions, 7 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 5b8c421..1e73430 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -799,12 +799,16 @@ void ExtensionTestResultNotificationObserver::MaybeSendResult() {
}
BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver(
- AutomationProvider* automation, IPC::Message* reply_message)
+ AutomationProvider* automation,
+ IPC::Message* reply_message)
: automation_(automation->AsWeakPtr()),
reply_message_(reply_message),
+ new_window_id_(extension_misc::kUnknownWindowId),
for_browser_command_(false) {
registrar_.Add(this, NotificationType::BROWSER_OPENED,
NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::LOAD_STOP,
+ NotificationService::AllSources());
}
BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() {
@@ -818,13 +822,23 @@ void BrowserOpenedNotificationObserver::Observe(
return;
}
- if (type == NotificationType::BROWSER_OPENED) {
- if (for_browser_command_) {
- AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(),
- true);
+ if (type.value == NotificationType::BROWSER_OPENED) {
+ // Store the new browser ID and continue waiting for a new tab within it
+ // to stop loading.
+ new_window_id_ = ExtensionTabUtil::GetWindowId(
+ Source<Browser>(source).ptr());
+ } else if (type.value == NotificationType::LOAD_STOP) {
+ // Only send the result if the loaded tab is in the new window.
+ int window_id = Source<NavigationController>(source)->window_id().id();
+ if (window_id == new_window_id_) {
+ if (for_browser_command_) {
+ AutomationMsg_WindowExecuteCommand::WriteReplyParams(
+ reply_message_.get(), true);
+ }
+ automation_->Send(reply_message_.release());
+ delete this;
+ return;
}
- automation_->Send(reply_message_.release());
- delete this;
} else {
NOTREACHED();
}
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index b6ee3b3..b2b3410 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -419,6 +419,8 @@ class ExtensionTestResultNotificationObserver : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(ExtensionTestResultNotificationObserver);
};
+// Observes when a new browser has been opened and a tab within it has stopped
+// loading.
class BrowserOpenedNotificationObserver : public NotificationObserver {
public:
BrowserOpenedNotificationObserver(AutomationProvider* automation,
@@ -435,6 +437,7 @@ class BrowserOpenedNotificationObserver : public NotificationObserver {
NotificationRegistrar registrar_;
base::WeakPtr<AutomationProvider> automation_;
scoped_ptr<IPC::Message> reply_message_;
+ int new_window_id_;
bool for_browser_command_;
DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver);