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

Unified Diff: chrome/test/chromedriver/chrome/browser_info.cc

Issue 2731403008: Add headless chrome as an accepted browser string in chromedriver. (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chrome/browser_info.cc
diff --git a/chrome/test/chromedriver/chrome/browser_info.cc b/chrome/test/chromedriver/chrome/browser_info.cc
index c790bfd5d6de310e73e5ff24d4d721de4ec0c562..736a6af617d833e0d15d9a065088565c7443f0d5 100644
--- a/chrome/test/chromedriver/chrome/browser_info.cc
+++ b/chrome/test/chromedriver/chrome/browser_info.cc
@@ -19,6 +19,9 @@ namespace {
const char kVersionPrefix[] = "Chrome/";
const size_t kVersionPrefixLen = sizeof(kVersionPrefix) - 1;
+const char kHeadlessVersionPrefix[] = "HeadlessChrome/";
+const size_t kHeadlessVersionPrefixLen = sizeof(kHeadlessVersionPrefix) - 1;
+
} // namespace
BrowserInfo::BrowserInfo()
@@ -104,6 +107,23 @@ Status ParseBrowserString(bool has_android_package,
}
}
+ if (base::StartsWith(browser_string, kHeadlessVersionPrefix,
+ base::CompareCase::SENSITIVE)) {
+ std::string version = browser_string.substr(kHeadlessVersionPrefixLen);
+
+ Status status = ParseBrowserVersionString(
+ version, &browser_info->major_version, &build_no);
+ if (status.IsError())
+ return status;
+
+ if (build_no != 0) {
+ browser_info->browser_name = "headless chrome";
+ browser_info->browser_version = version;
+ browser_info->build_no = build_no;
+ return Status(kOk);
+ }
+ }
+
if (browser_string.find("Version/") == 0u || // KitKat
(has_android_package && build_no == 0)) { // Lollipop
size_t pos = browser_string.find(kVersionPrefix);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698