| Index: chrome/test/chromedriver/chrome/navigation_tracker.cc
|
| diff --git a/chrome/test/chromedriver/chrome/navigation_tracker.cc b/chrome/test/chromedriver/chrome/navigation_tracker.cc
|
| index a0f26a86a525ec483138e69b9d79b75f31f2e61a..74c392ed62438b501c8b63a6332935baf9efd748 100644
|
| --- a/chrome/test/chromedriver/chrome/navigation_tracker.cc
|
| +++ b/chrome/test/chromedriver/chrome/navigation_tracker.cc
|
| @@ -43,7 +43,13 @@ NavigationTracker::NavigationTracker(DevToolsClient* client,
|
|
|
| NavigationTracker::~NavigationTracker() {}
|
|
|
| +Status MakeNavigationCheckFailedStatus(Status command_status) {
|
| + return Status(command_status.code() == kTimeout ? kTimeout : kUnknownError,
|
| + "cannot determine loading status", command_status);
|
| +}
|
| +
|
| Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
|
| + const Timeout* timeout,
|
| bool* is_pending) {
|
| if (!IsExpectingFrameLoadingEvents()) {
|
| // Some DevTools commands (e.g. Input.dispatchMouseEvent) are handled in the
|
| @@ -54,8 +60,8 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
|
| base::DictionaryValue params;
|
| params.SetString("expression", "1");
|
| scoped_ptr<base::DictionaryValue> result;
|
| - Status status = client_->SendCommandAndGetResult(
|
| - "Runtime.evaluate", params, &result);
|
| + Status status = client_->SendCommandAndGetResultWithTimeout(
|
| + "Runtime.evaluate", params, timeout, &result);
|
| int value = 0;
|
| if (status.code() == kDisconnected) {
|
| // If we receive a kDisconnected status code from Runtime.evaluate, don't
|
| @@ -66,7 +72,7 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
|
| } else if (status.IsError() ||
|
| !result->GetInteger("result.value", &value) ||
|
| value != 1) {
|
| - return Status(kUnknownError, "cannot determine loading status", status);
|
| + return MakeNavigationCheckFailedStatus(status);
|
| }
|
| }
|
|
|
| @@ -76,11 +82,11 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
|
| // for the new window. In such case, the baseURL will be empty.
|
| base::DictionaryValue empty_params;
|
| scoped_ptr<base::DictionaryValue> result;
|
| - Status status = client_->SendCommandAndGetResult(
|
| - "DOM.getDocument", empty_params, &result);
|
| + Status status = client_->SendCommandAndGetResultWithTimeout(
|
| + "DOM.getDocument", empty_params, timeout, &result);
|
| std::string base_url;
|
| if (status.IsError() || !result->GetString("root.baseURL", &base_url))
|
| - return Status(kUnknownError, "cannot determine loading status", status);
|
| + return MakeNavigationCheckFailedStatus(status);
|
| if (base_url.empty()) {
|
| *is_pending = true;
|
| loading_state_ = kLoading;
|
| @@ -107,10 +113,10 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
|
| "}";
|
| base::DictionaryValue params;
|
| params.SetString("expression", kStartLoadingIfMainFrameNotLoading);
|
| - status = client_->SendCommandAndGetResult(
|
| - "Runtime.evaluate", params, &result);
|
| + status = client_->SendCommandAndGetResultWithTimeout(
|
| + "Runtime.evaluate", params, timeout, &result);
|
| if (status.IsError())
|
| - return Status(kUnknownError, "cannot determine loading status", status);
|
| + return MakeNavigationCheckFailedStatus(status);
|
|
|
| // Between the time the JavaScript is evaluated and
|
| // SendCommandAndGetResult returns, OnEvent may have received info about
|
|
|