#include "chrome/test/chromedriver/session_commands.h"
#include <list>
#include <memory>
#include <thread>
#include <utility>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/system/sys_info.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "chrome/test/chromedriver/basic_types.h"
#include "chrome/test/chromedriver/bidimapper/bidimapper.h"
#include "chrome/test/chromedriver/capabilities.h"
#include "chrome/test/chromedriver/chrome/bidi_tracker.h"
#include "chrome/test/chromedriver/chrome/browser_info.h"
#include "chrome/test/chromedriver/chrome/chrome.h"
#include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h"
#include "chrome/test/chromedriver/chrome/chrome_impl.h"
#include "chrome/test/chromedriver/chrome/device_manager.h"
#include "chrome/test/chromedriver/chrome/devtools_client_impl.h"
#include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
#include "chrome/test/chromedriver/chrome/geoposition.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/web_view.h"
#include "chrome/test/chromedriver/chrome_launcher.h"
#include "chrome/test/chromedriver/command_listener.h"
#include "chrome/test/chromedriver/constants/version.h"
#include "chrome/test/chromedriver/logging.h"
#include "chrome/test/chromedriver/session.h"
#include "chrome/test/chromedriver/util.h"
#include "services/device/public/cpp/generic_sensor/orientation_util.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
namespace {
const int kWifiMask = …;
const int k4GMask = …;
const int k3GMask = …;
const int k2GMask = …;
const int kAirplaneModeLatency = …;
const int kAirplaneModeThroughput = …;
const int kWifiLatency = …;
const int kWifiThroughput = …;
const int k4GLatency = …;
const int k4GThroughput = …;
const int k3GLatency = …;
const int k3GThroughput = …;
const int k2GLatency = …;
const int k2GThroughput = …;
Status EvaluateScriptAndIgnoreResult(Session* session,
std::string expression,
const bool await_promise = false) { … }
base::RepeatingCallback<Status(bool*)> BidiResponseIsReceivedCallback(
Session* session) { … }
}
InitSessionParams::InitSessionParams(
network::mojom::URLLoaderFactory* factory,
const SyncWebSocketFactory& socket_factory,
DeviceManager* device_manager,
const scoped_refptr<base::SingleThreadTaskRunner> cmd_task_runner,
SessionConnectionMap* session_map)
: … { … }
InitSessionParams::InitSessionParams(const InitSessionParams& other) = default;
InitSessionParams::~InitSessionParams() = default;
bool GetW3CSetting(const base::Value::Dict& params) { … }
namespace {
std::string PlatformNameToW3C(const std::string& platform_name) { … }
base::Value::Dict CreateCapabilities(Session* session,
const Capabilities& capabilities,
const base::Value::Dict& desired_caps) { … }
Status InitSessionHelper(const InitSessionParams& bound_params,
Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
}
namespace internal {
Status ConfigureSession(Session* session,
const base::Value::Dict& params,
const base::Value::Dict*& desired_caps,
base::Value::Dict& merged_caps,
Capabilities* capabilities) { … }
Status ConfigureHeadlessSession(Session* session,
const Capabilities& capabilities) { … }
}
bool MergeCapabilities(const base::Value::Dict& always_match,
const base::Value::Dict& first_match,
base::Value::Dict& merged) { … }
bool MatchCapabilities(const base::Value::Dict& capabilities) { … }
Status ProcessCapabilities(const base::Value::Dict& params,
base::Value::Dict& result_capabilities) { … }
Status ExecuteInitSession(const InitSessionParams& bound_params,
Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteQuit(bool allow_detach,
Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteBidiSessionEnd(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetSessionCapabilities(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetCurrentWindowHandle(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteClose(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetWindowHandles(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSwitchToWindow(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetTimeoutLegacy(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetTimeoutsW3C(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetTimeouts(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetTimeouts(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetScriptTimeout(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteImplicitlyWait(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteIsLoading(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteCreateVirtualSensor(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
namespace {
bool ParseSingleValue(const std::string& key_name,
const base::Value::Dict& params,
base::Value::Dict* out_params) { … }
bool ParseXYZValue(const base::Value::Dict& params,
base::Value::Dict* out_params) { … }
bool ParseOrientationEuler(const base::Value::Dict& params,
base::Value::Dict* out_params) { … }
base::expected<base::Value::Dict, Status> ParseSensorUpdateParams(
const base::Value::Dict& params) { … }
}
Status ExecuteUpdateVirtualSensor(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>*) { … }
Status ExecuteRemoveVirtualSensor(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetVirtualSensorInformation(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetLocation(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetNetworkConnection(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetNetworkConditions(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetNetworkConnection(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetWindowPosition(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetWindowPosition(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetWindowSize(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetWindowSize(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetAvailableLogTypes(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGetLog(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteUploadFile(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetSPCTransactionMode(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteGenerateTestReport(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteSetTimeZone(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteCreateVirtualPressureSource(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteUpdateVirtualPressureSource(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ExecuteRemoveVirtualPressureSource(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status ForwardBidiCommand(Session* session,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }