chromium/chrome/test/chromedriver/session_commands.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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"  // For CHECK macros.
#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) {}

}  // namespace

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;

// Look for W3C mode setting in InitSession command parameters.
bool GetW3CSetting(const base::Value::Dict& params) {}

namespace {

std::string PlatformNameToW3C(const std::string& platform_name) {}

// Creates a JSON object (represented by base::Value::Dict) that contains
// the capabilities, for returning to the client app as the result of New
// Session command.
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

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) {}

}  // namespace internal

bool MergeCapabilities(const base::Value::Dict& always_match,
                       const base::Value::Dict& first_match,
                       base::Value::Dict& merged) {}

// Implementation of "matching capabilities", as defined in W3C spec at
// https://www.w3.org/TR/webdriver/#dfn-matching-capabilities.
// It checks some requested capabilities and make sure they are supported.
// Currently, we only check "browserName", "platformName", "fedcm:accounts"
// and webauthn capabilities but more can be added as necessary.
bool MatchCapabilities(const base::Value::Dict& capabilities) {}

// Implementation of "process capabilities", as defined in W3C spec at
// https://www.w3.org/TR/webdriver/#processing-capabilities. Step numbers in
// the comments correspond to the step numbers in the spec.
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) {}

// Quits a session.
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) {}

// Handles legacy format SetTimeout command.
// TODO(crbug.com/chromedriver/2596): Remove when we stop supporting legacy
// protocol.
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) {}

}  // namespace

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) {}

// Run a BiDi command
Status ForwardBidiCommand(Session* session,
                          const base::Value::Dict& params,
                          std::unique_ptr<base::Value>* value) {}