Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: chrome/test/automation/automation_proxy.cc

Issue 10282: Only block alert() requests from blocked popups; not all popups.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/automation/automation_proxy.cc
===================================================================
--- chrome/test/automation/automation_proxy.cc (revision 5108)
+++ chrome/test/automation/automation_proxy.cc (working copy)
@@ -302,6 +302,53 @@
return false;
}
+bool AutomationProxy::GetShowingAppModalDialog(bool* showing_app_modal_dialog) {
+ if (!showing_app_modal_dialog) {
+ NOTREACHED();
+ return false;
+ }
+
+ IPC::Message* response = NULL;
+ bool is_timeout = true;
+ bool succeeded = SendAndWaitForResponseWithTimeout(
+ new AutomationMsg_ShowingAppModalDialogRequest(0), &response,
+ AutomationMsg_ShowingAppModalDialogResponse::ID,
+ kMaxCommandExecutionTime, &is_timeout);
+ if (!succeeded)
+ return false;
+
+ if (is_timeout) {
+ DLOG(ERROR) << "ShowingAppModalDialog did not complete in a timely fashion";
+ return false;
+ }
+
+ void* iter = NULL;
+ if (!response->ReadBool(&iter, showing_app_modal_dialog)) {
+ succeeded = false;
+ }
+
+ delete response;
+ return succeeded;
+}
+
+bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
+ const TimeTicks start = TimeTicks::Now();
+ const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
+ while (TimeTicks::Now() - start < timeout) {
+ bool dialog_shown;
Finnur 2008/11/11 07:30:03 For good measure I would initialize this to false.
+ bool succeeded = GetShowingAppModalDialog(&dialog_shown);
+ if (!succeeded) {
+ // Try again next round, but log it.
+ DLOG(ERROR) << "GetBrowserWindowCount returned false";
+ } else if (dialog_shown) {
+ return true;
+ }
+ Sleep(automation::kSleepTime);
+ }
+ // Dialog never shown.
+ return false;
+}
+
bool AutomationProxy::SetFilteredInet(bool enabled) {
return Send(new AutomationMsg_SetFilteredInet(0, enabled));
}

Powered by Google App Engine
This is Rietveld 408576698