| Index: chrome/test/chromedriver/commands.cc
|
| diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc
|
| index 05fb4b662b16cc56d3eeaff1e00b688c3dccb680..219ea1d20240c7cf6e5ea2109389aad39f8a05b1 100644
|
| --- a/chrome/test/chromedriver/commands.cc
|
| +++ b/chrome/test/chromedriver/commands.cc
|
| @@ -6,9 +6,12 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| +#include "base/environment.h"
|
| #include "base/file_util.h"
|
| #include "base/format_macros.h"
|
| #include "base/rand_util.h"
|
| +#include "base/string_number_conversions.h"
|
| +#include "base/string_split.h"
|
| #include "base/stringprintf.h"
|
| #include "base/time.h"
|
| #include "base/values.h"
|
| @@ -16,6 +19,7 @@
|
| #include "chrome/test/chromedriver/chrome_launcher.h"
|
| #include "chrome/test/chromedriver/session.h"
|
| #include "chrome/test/chromedriver/status.h"
|
| +#include "chrome/test/chromedriver/version.h"
|
| #include "third_party/webdriver/atoms.h"
|
|
|
| namespace {
|
| @@ -116,6 +120,31 @@ Status ExecuteNewSession(
|
| if (status.IsError())
|
| return Status(kSessionNotCreatedException, status.message());
|
|
|
| + scoped_ptr<base::Environment> env(base::Environment::Create());
|
| + scoped_ptr<base::Value> chrome_version_value;
|
| + std::string chrome_version;
|
| + status = chrome->EvaluateScript(
|
| + "",
|
| + "navigator.appVersion.match(/Chrome\\/.* /)[0].split('/')[1].trim()",
|
| + &chrome_version_value);
|
| + if (status.IsError() || !chrome_version_value->GetAsString(&chrome_version))
|
| + return Status(kUnknownError, "unable to detect Chrome version");
|
| + // Check the version of Chrome is supported.
|
| + // Allow the version check to be skipped for testing/development purposes.
|
| + if (!env->HasVar("IGNORE_CHROME_VERSION")) {
|
| + int build_no;
|
| + std::vector<std::string> chrome_version_parts;
|
| + base::SplitString(chrome_version, '.', &chrome_version_parts);
|
| + if (chrome_version_parts.size() != 4 ||
|
| + !base::StringToInt(chrome_version_parts[2], &build_no)) {
|
| + return Status(kUnknownError, "unrecognized Chrome version: " +
|
| + chrome_version);
|
| + }
|
| + if (build_no < kMinimumSupportedChromeBuildNo)
|
| + return Status(kUnknownError, "Chrome version must be >= " +
|
| + GetMinimumSupportedChromeVersion());
|
| + }
|
| +
|
| uint64 msb = base::RandUint64();
|
| uint64 lsb = base::RandUint64();
|
| std::string new_id =
|
| @@ -127,6 +156,8 @@ Status ExecuteNewSession(
|
|
|
| base::DictionaryValue* returned_value = new base::DictionaryValue();
|
| returned_value->SetString("browserName", "chrome");
|
| + returned_value->SetString("version", chrome_version);
|
| + returned_value->SetString("driverVersion", kChromeDriverVersion);
|
| out_value->reset(returned_value);
|
| *out_session_id = new_id;
|
| return Status(kOk);
|
|
|