Skip to content

Commit

Permalink
Added dump-devtools-protocol command line switch.
Browse files Browse the repository at this point in the history
Inspecting protocol log is a great way to analyze what's going on under
the hood of a test and should be instantly available.

Change-Id: I238499f50074cc1eb6b6666ecc19b2fce17ddbe6
Reviewed-on: https://chromium-review.googlesource.com/1147752
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577684}
  • Loading branch information
Peter Kvitek authored and Commit Bot committed Jul 24, 2018
1 parent 821db80 commit 19f479b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions headless/test/headless_protocol_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace headless {

namespace {
static const char kResetResults[] = "reset-results";
static const char kDumpDevToolsProtocol[] = "dump-devtools-protocol";
} // namespace

class HeadlessProtocolBrowserTest
Expand Down Expand Up @@ -112,6 +113,10 @@ class HeadlessProtocolBrowserTest
}

if (method != "DONE") {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
kDumpDevToolsProtocol)) {
LOG(INFO) << "FromJS: " << json_message;
}
// Pass unhandled commands onto the inspector.
browser_devtools_client_->SendRawDevToolsMessage(json_message);
return;
Expand Down Expand Up @@ -156,6 +161,12 @@ class HeadlessProtocolBrowserTest
void SendMessageToJS(const std::string& message) {
if (test_finished_)
return;

if (base::CommandLine::ForCurrentProcess()->HasSwitch(
kDumpDevToolsProtocol)) {
LOG(INFO) << "ToJS: " << message;
}

std::string encoded;
base::Base64Encode(message, &encoded);
devtools_client_->GetRuntime()->Evaluate("onmessage(atob(\"" + encoded +
Expand Down

0 comments on commit 19f479b

Please sign in to comment.