Commit 0889921a authored by gmanikpure's avatar gmanikpure Committed by Commit bot

[Chromedriver] Ensure baseURL is 'about:blank' for dummy page on Chrome 60+.

From Chrome 60 onwards, root.baseURL will no longer be empty and will always return 'about:blank'.
See crbug/711562 for more details.

BUG=chromedriver:1775

Review-Url: https://codereview.chromium.org/2830903005
Cr-Commit-Position: refs/heads/master@{#467328}
parent 09b8b3a2
...@@ -117,15 +117,26 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id, ...@@ -117,15 +117,26 @@ Status NavigationTracker::IsPendingNavigation(const std::string& frame_id,
if (loading_state_ == kUnknown) { if (loading_state_ == kUnknown) {
// In the case that a http request is sent to server to fetch the page // In the case that a http request is sent to server to fetch the page
// content and the server hasn't responded at all, a dummy page is created // content and the server hasn't responded at all, a dummy page is created
// for the new window. In such case, the baseURL will be empty. // for the new window. In such case, the baseURL will be empty for <=M59 ;
// whereas the baseURL will be 'about:blank' for >=M60. See crbug/711562.
// TODO(gmanikpure):Remove condition for <3076 when we stop supporting M59.
base::DictionaryValue empty_params; base::DictionaryValue empty_params;
std::unique_ptr<base::DictionaryValue> result; std::unique_ptr<base::DictionaryValue> result;
Status status = client_->SendCommandAndGetResultWithTimeout( Status status = client_->SendCommandAndGetResultWithTimeout(
"DOM.getDocument", empty_params, timeout, &result); "DOM.getDocument", empty_params, timeout, &result);
std::string base_url; std::string base_url;
if (status.IsError() || !result->GetString("root.baseURL", &base_url)) std::string doc_url;
if (status.IsError() || !result->GetString("root.baseURL", &base_url) ||
!result->GetString("root.documentURL", &doc_url))
return MakeNavigationCheckFailedStatus(status); return MakeNavigationCheckFailedStatus(status);
if (base_url.empty()) {
bool condition;
if (browser_info_->build_no >= 3076)
condition = doc_url != "about:blank" && base_url == "about:blank";
else
condition = base_url.empty();
if (condition) {
*is_pending = true; *is_pending = true;
loading_state_ = kLoading; loading_state_ = kLoading;
return Status(kOk); return Status(kOk);
......
...@@ -46,10 +46,13 @@ class DeterminingLoadStateDevToolsClient : public StubDevToolsClient { ...@@ -46,10 +46,13 @@ class DeterminingLoadStateDevToolsClient : public StubDevToolsClient {
std::unique_ptr<base::DictionaryValue>* result) override { std::unique_ptr<base::DictionaryValue>* result) override {
if (method == "DOM.getDocument") { if (method == "DOM.getDocument") {
base::DictionaryValue result_dict; base::DictionaryValue result_dict;
if (has_empty_base_url_) if (has_empty_base_url_) {
result_dict.SetString("root.baseURL", std::string()); result_dict.SetString("root.baseURL", "about:blank");
else result_dict.SetString("root.documentURL", "http://test");
} else {
result_dict.SetString("root.baseURL", "http://test"); result_dict.SetString("root.baseURL", "http://test");
result_dict.SetString("root.documentURL", "http://test");
}
result->reset(result_dict.DeepCopy()); result->reset(result_dict.DeepCopy());
return Status(kOk); return Status(kOk);
} else if (method == "Runtime.evaluate") { } else if (method == "Runtime.evaluate") {
......
...@@ -73,8 +73,6 @@ _NEGATIVE_FILTER = [ ...@@ -73,8 +73,6 @@ _NEGATIVE_FILTER = [
_VERSION_SPECIFIC_FILTER = {} _VERSION_SPECIFIC_FILTER = {}
_VERSION_SPECIFIC_FILTER['HEAD'] = [ _VERSION_SPECIFIC_FILTER['HEAD'] = [
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=1775
'ChromeDriverTest.testShouldHandleNewWindowLoadingProperly',
] ]
_VERSION_SPECIFIC_FILTER['58'] = [ _VERSION_SPECIFIC_FILTER['58'] = [
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=1673 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1673
......
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