#include "headless/test/headless_browser_test_utils.h"
#include <optional>
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "components/devtools/simple_devtools_protocol_client/simple_devtools_protocol_client.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "headless/public/headless_web_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
SimpleDevToolsProtocolClient;
namespace headless {
base::Value::Dict SendCommandSync(SimpleDevToolsProtocolClient& devtools_client,
const std::string& command) { … }
base::Value::Dict SendCommandSync(
simple_devtools_protocol_client::SimpleDevToolsProtocolClient&
devtools_client,
const std::string& command,
base::Value::Dict params) { … }
base::Value::Dict EvaluateScript(HeadlessWebContents* web_contents,
const std::string& script) { … }
bool WaitForLoad(HeadlessWebContents* web_contents, net::Error* error) { … }
void WaitForLoadAndGainFocus(HeadlessWebContents* web_contents) { … }
std::string DictString(const base::Value::Dict& dict, std::string_view path) { … }
int DictInt(const base::Value::Dict& dict, std::string_view path) { … }
bool DictBool(const base::Value::Dict& dict, std::string_view path) { … }
bool DictHas(const base::Value::Dict& dict, std::string_view path) { … }
namespace {
std::string ToJSON(const base::ValueView& value) { … }
class DictHasPathValueMatcher
: public testing::MatcherInterface<const base::Value::Dict&> { … };
class DictHasKeyMatcher
: public testing::MatcherInterface<const base::Value::Dict&> { … };
}
testing::Matcher<const base::Value::Dict&> DictHasPathValue(
const std::string& path,
base::Value expected_value) { … }
testing::Matcher<const base::Value::Dict&> DictHasKey(const std::string& key) { … }
}