Commit 4a64ea8e authored by craigdh@chromium.org's avatar craigdh@chromium.org

Fixed bug where the ExecuteJavascript() family of PyAuto hooks ignored the...

Fixed bug where the ExecuteJavascript() family of PyAuto hooks ignored the automation id of messages from DomAutomationController.

This had the effect of hooks returning on the next message from
DomAutomationController regardless of whether that message actually
indicated completion of the injected javascript.

BUG=120769
TEST=functional/execute_javascript.py


Review URL: http://codereview.chromium.org/9950098

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132503 0039d316-1c4b-4281-b951-d872f2087c98
parent 4b90452a
......@@ -1199,7 +1199,8 @@ void FindInPageNotificationObserver::Observe(
// static
const int FindInPageNotificationObserver::kFindInPageRequestId = -1;
DomOperationObserver::DomOperationObserver() {
DomOperationObserver::DomOperationObserver(int automation_id)
: automation_id_(automation_id) {
registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
......@@ -1215,6 +1216,7 @@ void DomOperationObserver::Observe(
const content::NotificationDetails& details) {
if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) {
content::Details<DomOperationNotificationDetails> dom_op_details(details);
if (dom_op_details->automation_id == automation_id_)
OnDomOperationCompleted(dom_op_details->json);
} else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) {
OnModalDialogShown();
......@@ -1237,7 +1239,8 @@ DomOperationMessageSender::DomOperationMessageSender(
AutomationProvider* automation,
IPC::Message* reply_message,
bool use_json_interface)
: automation_(automation->AsWeakPtr()),
: DomOperationObserver(0),
automation_(automation->AsWeakPtr()),
reply_message_(reply_message),
use_json_interface_(use_json_interface) {
}
......
......@@ -608,7 +608,7 @@ class FindInPageNotificationObserver : public content::NotificationObserver {
class DomOperationObserver : public content::NotificationObserver {
public:
DomOperationObserver();
explicit DomOperationObserver(int automation_id);
virtual ~DomOperationObserver();
virtual void Observe(int type,
......@@ -620,6 +620,7 @@ class DomOperationObserver : public content::NotificationObserver {
virtual void OnJavascriptBlocked() = 0;
private:
int automation_id_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(DomOperationObserver);
......@@ -630,7 +631,7 @@ class DomOperationObserver : public content::NotificationObserver {
class DomOperationMessageSender : public DomOperationObserver {
public:
DomOperationMessageSender(AutomationProvider* automation,
IPC::Message* relpy_message,
IPC::Message* reply_message,
bool use_json_interface);
virtual ~DomOperationMessageSender();
......
......@@ -1322,13 +1322,9 @@ void ExecuteJavascriptInRenderViewFrame(
// This routing id needs to be remembered for the reverse
// communication while sending back the response of
// this javascript execution.
std::string set_automation_id;
base::SStringPrintf(&set_automation_id,
"window.domAutomationController.setAutomationId(%d);",
reply_message->routing_id());
render_view_host->ExecuteJavascriptInWebFrame(
frame_xpath, UTF8ToUTF16(set_automation_id));
frame_xpath,
UTF8ToUTF16("window.domAutomationController.setAutomationId(0);"));
render_view_host->ExecuteJavascriptInWebFrame(
frame_xpath, script);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment