Skip to content

Commit ec41686

Browse files
authored
tools: update inspector_protocol to 69d69dd
PR-URL: #58900 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 46508d9 commit ec41686

20 files changed

+159
-307
lines changed

deps/inspector_protocol/BUILD.gn

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,95 @@
1-
# Copyright 2019 the V8 project authors. All rights reserved.
1+
# Copyright 2018 The Chromium Authors
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
static_library("encoding") {
5+
# This BUILD.gn file is specific to the standalone project. Do not
6+
# copy this downstream.
7+
8+
import("//testing/test.gni")
9+
10+
static_library("crdtp") {
611
sources = [
7-
"encoding/encoding.cc",
8-
"encoding/encoding.h",
12+
"crdtp/cbor.cc",
13+
"crdtp/cbor.h",
14+
"crdtp/dispatch.cc",
15+
"crdtp/dispatch.h",
16+
"crdtp/error_support.cc",
17+
"crdtp/error_support.h",
18+
"crdtp/export.h",
19+
"crdtp/find_by_first.h",
20+
"crdtp/frontend_channel.h",
21+
"crdtp/glue.h",
22+
"crdtp/json.cc",
23+
"crdtp/json.h",
24+
"crdtp/parser_handler.h",
25+
"crdtp/protocol_core.cc",
26+
"crdtp/protocol_core.h",
27+
"crdtp/serializable.cc",
28+
"crdtp/serializable.h",
29+
"crdtp/span.cc",
30+
"crdtp/span.h",
31+
"crdtp/status.cc",
32+
"crdtp/status.h",
933
]
34+
deps = [ ":crdtp_platform" ]
1035
}
1136

12-
# encoding_test is part of the unittests, defined in
13-
# test/unittests/BUILD.gn.
37+
# A small adapter library which only :crdtp may depend on.
38+
static_library("crdtp_platform") {
39+
sources = [
40+
"crdtp/json_platform.cc",
41+
"crdtp/json_platform.h",
42+
]
43+
}
1444

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

17-
v8_source_set("encoding_test") {
52+
test("crdtp_test") {
1853
sources = [
19-
"encoding/encoding_test.cc",
20-
"encoding/encoding_test_helper.h",
21-
]
22-
configs = [
23-
"../..:external_config",
24-
"../..:internal_config_base",
54+
"crdtp/cbor_test.cc",
55+
"crdtp/dispatch_test.cc",
56+
"crdtp/error_support_test.cc",
57+
"crdtp/find_by_first_test.cc",
58+
"crdtp/json_test.cc",
59+
"crdtp/protocol_core_test.cc",
60+
"crdtp/serializable_test.cc",
61+
"crdtp/span_test.cc",
62+
"crdtp/status_test.cc",
63+
"crdtp/status_test_support.cc",
64+
"crdtp/status_test_support.h",
65+
"crdtp/test_string_traits.cc",
66+
"crdtp/test_string_traits.h",
2567
]
68+
include_dirs = [ "." ]
2669
deps = [
27-
":encoding",
28-
"../..:v8_libbase",
29-
"../../src/inspector:inspector_string_conversions",
70+
":crdtp",
71+
":crdtp_test_platform",
72+
]
73+
}
74+
75+
# A small adapter library which only :crdtp_test may depend on.
76+
static_library("crdtp_test_platform") {
77+
sources = [
78+
"crdtp/test_platform.cc",
79+
"crdtp/test_platform.h",
80+
]
81+
testonly = true
82+
include_dirs = [ "." ]
83+
public_deps = [
84+
"//base",
3085
"//testing/gmock",
3186
"//testing/gtest",
87+
"//testing/gtest:gtest_main",
3288
]
33-
testonly = true
89+
}
90+
91+
# A command line utility for converting between JSON and CBOR.
92+
executable("transcode") {
93+
sources = [ "crdtp/transcode.cc" ]
94+
deps = [ ":crdtp" ]
3495
}

deps/inspector_protocol/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Chromium Authors. All rights reserved.
1+
// Copyright 2016 The Chromium Authors.
22
//
33
// Redistribution and use in source and binary forms, with or without
44
// modification, are permitted provided that the following conditions are

deps/inspector_protocol/README.node

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: inspector protocol
22
Short Name: inspector_protocol
33
URL: https://chromium.googlesource.com/deps/inspector_protocol/
44
Version: 0
5-
Revision: 64cc2301620c04f0fe0313ae94a9319f003603cf
5+
Revision: 69d69ddf3aa698b171886551a4a672c5af1ad902
66
License: BSD
77
License File: LICENSE
88
Security Critical: no

deps/inspector_protocol/code_generator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def dash_to_camelcase(word):
147147

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

152152

153153
def to_method_case(config, name):
@@ -542,6 +542,12 @@ def resolve_type(self, prop):
542542
return wrap_array_definition(self.resolve_type(prop["items"]))
543543
return self.type_definitions[prop["type"]]
544544

545+
def optional_type(self, prop):
546+
type = self.resolve_type(prop)
547+
template = ("std::optional<{}>" if type.get('is_primitive', False)
548+
else "std::unique_ptr<{}>")
549+
return template.format(type.get("raw_type"))
550+
545551
def generate_command(self, domain, command):
546552
if not self.config.protocol.options:
547553
return domain in self.generate_domains

deps/inspector_protocol/crdtp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ to fetch the package (and dependencies) and build and run the tests:
5151
ninja -C out/Release crdtp_test
5252
out/Release/crdtp_test
5353

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

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

5959
# Purpose of the tests
6060

deps/inspector_protocol/crdtp/cbor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ class CRDTP_EXPORT CBORTokenizer {
255255
span<uint8_t> GetString8() const;
256256

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

261262
// To be called only if ::TokenTag() == CBORTokenTag::BINARY.

deps/inspector_protocol/crdtp/dispatch_test.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ TEST(DispatchableTest, MessageWithUnknownProperty) {
169169
}
170170

171171
TEST(DispatchableTest, DuplicateMapKey) {
172-
for (const std::string& json :
173-
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
174-
"{\"method\":\"foo\",\"method\":\"foo\"}",
175-
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}) {
172+
const std::array<std::string, 4> jsons = {
173+
{"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}",
174+
"{\"method\":\"foo\",\"method\":\"foo\"}",
175+
"{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}};
176+
for (const std::string& json : jsons) {
176177
SCOPED_TRACE("json = " + json);
177178
std::vector<uint8_t> cbor;
178179
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());
@@ -185,11 +186,12 @@ TEST(DispatchableTest, DuplicateMapKey) {
185186
}
186187

187188
TEST(DispatchableTest, ValidMessageParsesOK_NoParams) {
188-
for (const std::string& json :
189-
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
190-
"\"f421ssvaz4\"}",
191-
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
192-
"\"params\":null}"}) {
189+
const std::array<std::string, 2> jsons = {
190+
{"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":"
191+
"\"f421ssvaz4\"}",
192+
"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\","
193+
"\"params\":null}"}};
194+
for (const std::string& json : jsons) {
193195
SCOPED_TRACE("json = " + json);
194196
std::vector<uint8_t> cbor;
195197
ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok());

deps/inspector_protocol/crdtp/frontend_channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CRDTP_EXPORT FrontendChannel {
2424
// responses may be sent from an untrusted source to a trusted process (e.g.
2525
// from Chromium's renderer (blink) to the browser process), which needs
2626
// to be able to match the response to an earlier request without parsing the
27-
// messsage.
27+
// message.
2828
virtual void SendProtocolResponse(int call_id,
2929
std::unique_ptr<Serializable> message) = 0;
3030
virtual void SendProtocolNotification(

deps/inspector_protocol/crdtp/json_test.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -704,15 +704,16 @@ using ContainerTestTypes = ::testing::Types<std::vector<uint8_t>, std::string>;
704704
TYPED_TEST_SUITE(ConvertJSONToCBORTest, ContainerTestTypes);
705705

706706
TYPED_TEST(ConvertJSONToCBORTest, RoundTripValidJson) {
707-
for (const std::string& json_in : {
708-
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
709-
"3.1415",
710-
"false",
711-
"true",
712-
"\"Hello, world.\"",
713-
"[1,2,3]",
714-
"[]",
715-
}) {
707+
const std::array<std::string, 7> jsons = {{
708+
"{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}",
709+
"3.1415",
710+
"false",
711+
"true",
712+
"\"Hello, world.\"",
713+
"[1,2,3]",
714+
"[]",
715+
}};
716+
for (const std::string& json_in : jsons) {
716717
SCOPED_TRACE(json_in);
717718
TypeParam json(json_in.begin(), json_in.end());
718719
std::vector<uint8_t> cbor;

deps/inspector_protocol/crdtp/maybe.h

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)