Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 79 additions & 18 deletions deps/inspector_protocol/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,34 +1,95 @@
# Copyright 2019 the V8 project authors. All rights reserved.
# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

static_library("encoding") {
# This BUILD.gn file is specific to the standalone project. Do not
# copy this downstream.

import("//testing/test.gni")

static_library("crdtp") {
sources = [
"encoding/encoding.cc",
"encoding/encoding.h",
"crdtp/cbor.cc",
"crdtp/cbor.h",
"crdtp/dispatch.cc",
"crdtp/dispatch.h",
"crdtp/error_support.cc",
"crdtp/error_support.h",
"crdtp/export.h",
"crdtp/find_by_first.h",
"crdtp/frontend_channel.h",
"crdtp/glue.h",
"crdtp/json.cc",
"crdtp/json.h",
"crdtp/parser_handler.h",
"crdtp/protocol_core.cc",
"crdtp/protocol_core.h",
"crdtp/serializable.cc",
"crdtp/serializable.h",
"crdtp/span.cc",
"crdtp/span.h",
"crdtp/status.cc",
"crdtp/status.h",
]
deps = [ ":crdtp_platform" ]
}

# encoding_test is part of the unittests, defined in
# test/unittests/BUILD.gn.
# A small adapter library which only :crdtp may depend on.
static_library("crdtp_platform") {
sources = [
"crdtp/json_platform.cc",
"crdtp/json_platform.h",
]
}

import("../../gni/v8.gni")
# In this (upstream) standalone package, we declare crdtp_test, and a
# few minimal files in testing (accessed via test_platform.{h,cc}) to
# make it look like Chromium's testing package. In Chromium,
# we run these tests as part of the content_unittests, declared in
# content/test/BUILD.gn, and in V8, we run them via unittests, declared
# in test/unittests/BUILD.gn.

v8_source_set("encoding_test") {
test("crdtp_test") {
sources = [
"encoding/encoding_test.cc",
"encoding/encoding_test_helper.h",
]
configs = [
"../..:external_config",
"../..:internal_config_base",
"crdtp/cbor_test.cc",
"crdtp/dispatch_test.cc",
"crdtp/error_support_test.cc",
"crdtp/find_by_first_test.cc",
"crdtp/json_test.cc",
"crdtp/protocol_core_test.cc",
"crdtp/serializable_test.cc",
"crdtp/span_test.cc",
"crdtp/status_test.cc",
"crdtp/status_test_support.cc",
"crdtp/status_test_support.h",
"crdtp/test_string_traits.cc",
"crdtp/test_string_traits.h",
]
include_dirs = [ "." ]
deps = [
":encoding",
"../..:v8_libbase",
"../../src/inspector:inspector_string_conversions",
":crdtp",
":crdtp_test_platform",
]
}

# A small adapter library which only :crdtp_test may depend on.
static_library("crdtp_test_platform") {
sources = [
"crdtp/test_platform.cc",
"crdtp/test_platform.h",
]
testonly = true
include_dirs = [ "." ]
public_deps = [
"//base",
"//testing/gmock",
"//testing/gtest",
"//testing/gtest:gtest_main",
]
testonly = true
}

# A command line utility for converting between JSON and CBOR.
executable("transcode") {
sources = [ "crdtp/transcode.cc" ]
deps = [ ":crdtp" ]
}
2 changes: 1 addition & 1 deletion deps/inspector_protocol/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Copyright 2016 The Chromium Authors.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
Expand Down
2 changes: 1 addition & 1 deletion deps/inspector_protocol/README.node
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0
Revision: 64cc2301620c04f0fe0313ae94a9319f003603cf
Revision: 69d69ddf3aa698b171886551a4a672c5af1ad902
License: BSD
License File: LICENSE
Security Critical: no
Expand Down
8 changes: 7 additions & 1 deletion deps/inspector_protocol/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def dash_to_camelcase(word):

def to_snake_case(name):
name = re.sub(r"([A-Z]{2,})([A-Z][a-z])", r"\1_\2", name)
return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name, sys.maxsize).lower()
return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name, count=sys.maxsize).lower()


def to_method_case(config, name):
Expand Down Expand Up @@ -542,6 +542,12 @@ def resolve_type(self, prop):
return wrap_array_definition(self.resolve_type(prop["items"]))
return self.type_definitions[prop["type"]]

def optional_type(self, prop):
type = self.resolve_type(prop)
template = ("std::optional<{}>" if type.get('is_primitive', False)
else "std::unique_ptr<{}>")
return template.format(type.get("raw_type"))

def generate_command(self, domain, command):
if not self.config.protocol.options:
return domain in self.generate_domains
Expand Down
4 changes: 2 additions & 2 deletions deps/inspector_protocol/crdtp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ to fetch the package (and dependencies) and build and run the tests:
ninja -C out/Release crdtp_test
out/Release/crdtp_test

You'll probably also need to install g++, since Clang uses this to find the
You'll probably also need to install libstdc++, since Clang uses this to find the
standard C++ headers. E.g.,

sudo apt-get install g++-8
sudo apt-get install libstdc++-14-dev

# Purpose of the tests

Expand Down
3 changes: 2 additions & 1 deletion deps/inspector_protocol/crdtp/cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ class CRDTP_EXPORT CBORTokenizer {
span<uint8_t> GetString8() const;

// Wire representation for STRING16 is low byte first (little endian).
// To be called only if ::TokenTag() == CBORTokenTag::STRING16.
// To be called only if ::TokenTag() == CBORTokenTag::STRING16. The result is
// guaranteed to have even length.
span<uint8_t> GetString16WireRep() const;

// To be called only if ::TokenTag() == CBORTokenTag::BINARY.
Expand Down
20 changes: 11 additions & 9 deletions deps/inspector_protocol/crdtp/dispatch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ TEST(DispatchableTest, MessageWithUnknownProperty) {
}

TEST(DispatchableTest, DuplicateMapKey) {
for (const std::string& json :
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
"{\"method\":\"foo\",\"method\":\"foo\"}",
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}) {
const std::array<std::string, 4> jsons = {
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
"{\"method\":\"foo\",\"method\":\"foo\"}",
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}};
for (const std::string& json : jsons) {
SCOPED_TRACE("json = " + json);
std::vector<uint8_t> cbor;
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());
Expand All @@ -185,11 +186,12 @@ TEST(DispatchableTest, DuplicateMapKey) {
}

TEST(DispatchableTest, ValidMessageParsesOK_NoParams) {
for (const std::string& json :
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
"\"f421ssvaz4\"}",
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
"\"params\":null}"}) {
const std::array<std::string, 2> jsons = {
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
"\"f421ssvaz4\"}",
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
"\"params\":null}"}};
for (const std::string& json : jsons) {
SCOPED_TRACE("json = " + json);
std::vector<uint8_t> cbor;
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());
Expand Down
2 changes: 1 addition & 1 deletion deps/inspector_protocol/crdtp/frontend_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CRDTP_EXPORT FrontendChannel {
// responses may be sent from an untrusted source to a trusted process (e.g.
// from Chromium's renderer (blink) to the browser process), which needs
// to be able to match the response to an earlier request without parsing the
// messsage.
// message.
virtual void SendProtocolResponse(int call_id,
std::unique_ptr<Serializable> message) = 0;
virtual void SendProtocolNotification(
Expand Down
19 changes: 10 additions & 9 deletions deps/inspector_protocol/crdtp/json_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,15 +704,16 @@ using ContainerTestTypes = ::testing::Types<std::vector<uint8_t>, std::string>;
TYPED_TEST_SUITE(ConvertJSONToCBORTest, ContainerTestTypes);

TYPED_TEST(ConvertJSONToCBORTest, RoundTripValidJson) {
for (const std::string& json_in : {
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
"3.1415",
"false",
"true",
"\"Hello, world.\"",
"[1,2,3]",
"[]",
}) {
const std::array<std::string, 7> jsons = {{
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
"3.1415",
"false",
"true",
"\"Hello, world.\"",
"[1,2,3]",
"[]",
}};
for (const std::string& json_in : jsons) {
SCOPED_TRACE(json_in);
TypeParam json(json_in.begin(), json_in.end());
std::vector<uint8_t> cbor;
Expand Down
154 changes: 0 additions & 154 deletions deps/inspector_protocol/crdtp/maybe.h

This file was deleted.

Loading
Loading