Commit 95a7af97 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Roll inspector_protocol.

New Rev: 607bfb87bdc389997abf6ae3b7e08027856b886e

Change-Id: I3ac8f73776bc4dc6820929faa2c245057b76479e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2018175
Auto-Submit: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734780}
parent ab7bffde
...@@ -2,7 +2,7 @@ Name: inspector protocol ...@@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/ URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0 Version: 0
Revision: 201330a4e7a527dfc6d73bbb3c297562edcf28f8 Revision: 607bfb87bdc389997abf6ae3b7e08027856b886e
License: BSD License: BSD
License File: LICENSE License File: LICENSE
Security Critical: yes Security Critical: yes
......
...@@ -755,7 +755,7 @@ class JsonParser { ...@@ -755,7 +755,7 @@ class JsonParser {
// So, now we transcode to UTF16, // So, now we transcode to UTF16,
// using the math described at https://en.wikipedia.org/wiki/UTF-16, // using the math described at https://en.wikipedia.org/wiki/UTF-16,
// for either one or two 16 bit characters. // for either one or two 16 bit characters.
if (codepoint < 0xffff) { if (codepoint <= 0xffff) {
output->push_back(codepoint); output->push_back(codepoint);
continue; continue;
} }
......
...@@ -259,6 +259,7 @@ class Log : public ParserHandler { ...@@ -259,6 +259,7 @@ class Log : public ParserHandler {
} }
void HandleString16(span<uint16_t> chars) override { void HandleString16(span<uint16_t> chars) override {
raw_log_string16_.emplace_back(chars.begin(), chars.end());
log_ << "string16: " << UTF16ToUTF8(chars) << "\n"; log_ << "string16: " << UTF16ToUTF8(chars) << "\n";
} }
...@@ -282,10 +283,15 @@ class Log : public ParserHandler { ...@@ -282,10 +283,15 @@ class Log : public ParserHandler {
std::string str() const { return status_.ok() ? log_.str() : ""; } std::string str() const { return status_.ok() ? log_.str() : ""; }
std::vector<std::vector<uint16_t>> raw_log_string16() const {
return raw_log_string16_;
}
Status status() const { return status_; } Status status() const { return status_; }
private: private:
std::ostringstream log_; std::ostringstream log_;
std::vector<std::vector<uint16_t>> raw_log_string16_;
Status status_; Status status_;
}; };
...@@ -406,6 +412,31 @@ TEST_F(JsonParserTest, Unicode_ParseUtf16) { ...@@ -406,6 +412,31 @@ TEST_F(JsonParserTest, Unicode_ParseUtf16) {
log_.str()); log_.str());
} }
TEST_F(JsonParserTest, Unicode_ParseUtf16_SingleEscapeUpToFFFF) {
// 0xFFFF is the max codepoint that can be represented as a single \u escape.
// One way to write this is \uffff, another way is to encode it as a 3 byte
// UTF-8 sequence (0xef 0xbf 0xbf). Both are equivalent.
// Example with both ways of encoding code point 0xFFFF in a JSON string.
std::string json = "{\"escape\": \"\xef\xbf\xbf or \\uffff\"}";
ParseJSON(SpanFrom(json), &log_);
EXPECT_TRUE(log_.status().ok());
// Shows both inputs result in equivalent output once converted to UTF-8.
EXPECT_EQ(
"map begin\n"
"string16: escape\n"
"string16: \xEF\xBF\xBF or \xEF\xBF\xBF\n"
"map end\n",
log_.str());
// Make an even stronger assertion: The parser represents \xffff as a single
// UTF-16 char.
ASSERT_EQ(2u, log_.raw_log_string16().size());
std::vector<uint16_t> expected = {0xffff, ' ', 'o', 'r', ' ', 0xffff};
EXPECT_EQ(expected, log_.raw_log_string16()[1]);
}
TEST_F(JsonParserTest, Unicode_ParseUtf8) { TEST_F(JsonParserTest, Unicode_ParseUtf8) {
// Used below: // Used below:
// гласность - example for 2 byte utf8, Russian word "glasnost" // гласность - example for 2 byte utf8, Russian word "glasnost"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment