Commit f84df4c7 authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] Fix takeHeapSnapshot command

Return heap snapshot as a string instead of JSON object.
This resolves two issues:
* The snapshot sometimes uses characters not allowed by our JSON parser.
* Chrome's snapshot reader is sensitive to the ordering of properties
  in the snapshot. Converting the snapshot into JSON object and then
  re-serialize into string often results in a file not loadable by the
  snapshot reader.

Bug: chromedriver:2964, chromedriver:1616
Change-Id: Ia721c28ed78a085d567111459c9e50d8bc26f81d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1679224Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672666}
parent 5dc8d827
......@@ -28,13 +28,7 @@ Status HeapSnapshotTaker::TakeSnapshot(std::unique_ptr<base::Value>* snapshot) {
Status status3(kOk);
if (status1.IsOk() && status2.IsOk()) {
std::unique_ptr<base::Value> value =
base::JSONReader::ReadDeprecated(snapshot_);
if (!value) {
status3 = Status(kUnknownError, "heap snapshot not in JSON format");
} else {
*snapshot = std::move(value);
}
*snapshot = std::make_unique<base::Value>(std::move(snapshot_));
}
snapshot_.clear();
if (status1.IsError()) {
......
......@@ -22,10 +22,8 @@ namespace {
const char* const chunks[] = {"{\"a\": 1,", "\"b\": 2}"};
std::unique_ptr<base::Value> GetSnapshotAsValue() {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger("a", 1);
dict->SetInteger("b", 2);
return std::move(dict);
std::string str_snapshot = "{\"a\": 1,\"b\": 2}";
return std::make_unique<base::Value>(std::move(str_snapshot));;
}
class DummyDevToolsClient : public StubDevToolsClient {
......
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