Commit 52aa895f authored by David Dorwin's avatar David Dorwin Committed by Commit Bot

[fuchsia] Set console log level based on ApplicationConfig

The default is changed from WARN to NONE.

Bug: 1145025
Change-Id: Iab4cd336ebf44d2a71eabb199bf7f2cfcdebfc6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517006Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823703}
parent 187965d7
......@@ -82,6 +82,7 @@ source_set("cast_runner_core") {
"//components/cast/named_message_port_connector:named_message_port_connector",
"//fuchsia/base",
"//fuchsia/base:modular",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.diagnostics",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular",
"//third_party/fuchsia-sdk/sdk/pkg/scenic_cpp",
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
......
......@@ -4,6 +4,8 @@
#include "fuchsia/runners/cast/application_controller_impl.h"
#include <fuchsia/diagnostics/cpp/fidl.h>
#include <utility>
#include "base/check.h"
......
......@@ -5,6 +5,7 @@
#ifndef FUCHSIA_RUNNERS_CAST_APPLICATION_CONTROLLER_IMPL_H_
#define FUCHSIA_RUNNERS_CAST_APPLICATION_CONTROLLER_IMPL_H_
#include <fuchsia/diagnostics/cpp/fidl.h>
#include <fuchsia/media/sessions2/cpp/fidl.h>
#include <fuchsia/web/cpp/fidl.h>
#include <lib/fidl/cpp/binding.h>
......
......@@ -30,6 +30,27 @@ namespace {
constexpr int kBindingsFailureExitCode = 129;
constexpr int kRewriteRulesProviderDisconnectExitCode = 130;
fuchsia::web::ConsoleLogLevel SeverityToConsoleLogLevel(
fuchsia::diagnostics::Severity severity) {
switch (severity) {
case fuchsia::diagnostics::Severity::TRACE:
case fuchsia::diagnostics::Severity::DEBUG:
return fuchsia::web::ConsoleLogLevel::DEBUG;
case fuchsia::diagnostics::Severity::INFO:
return fuchsia::web::ConsoleLogLevel::INFO;
case fuchsia::diagnostics::Severity::WARN:
return fuchsia::web::ConsoleLogLevel::WARN;
case fuchsia::diagnostics::Severity::ERROR:
return fuchsia::web::ConsoleLogLevel::ERROR;
case fuchsia::diagnostics::Severity::FATAL:
// FATAL means none per the FIDL definition.
return fuchsia::web::ConsoleLogLevel::NONE;
}
// The safest thing to do for unrecognized values is to not log.
return fuchsia::web::ConsoleLogLevel::NONE;
}
} // namespace
CastComponent::Params::Params() = default;
......@@ -94,7 +115,10 @@ void CastComponent::StartComponent() {
frame()->SetMediaSessionId(media_session_id_);
frame()->ConfigureInputTypes(fuchsia::web::InputTypes::ALL,
fuchsia::web::AllowInputState::DENY);
frame()->SetJavaScriptLogLevel(fuchsia::web::ConsoleLogLevel::WARN);
if (application_config_.has_initial_min_console_log_severity()) {
frame()->SetJavaScriptLogLevel(SeverityToConsoleLogLevel(
application_config_.initial_min_console_log_severity()));
}
if (IsAppConfigForCastStreaming(application_config_)) {
// TODO(crbug.com/1082821): Remove this once the Cast Streaming Receiver
......
......@@ -1045,6 +1045,36 @@ TEST_F(CastRunnerIntegrationTest, OnTerminated_ComponentKill) {
component_controller_.Unbind();
}
// Ensures that CastRunner handles the value not being specified.
// TODO(https://crrev.com/c/2516246): Check for no logging.
TEST_F(CastRunnerIntegrationTest, InitialMinConsoleLogSeverity_NotSet) {
GURL app_url = test_server_.GetURL(kBlankAppUrl);
auto app_config =
FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url);
EXPECT_FALSE(app_config.has_initial_min_console_log_severity());
app_config_manager_.AddAppConfig(std::move(app_config));
CreateComponentContextAndStartComponent();
CheckAppUrl(app_url);
}
// TODO(https://crrev.com/c/2516246): Check for logging.
TEST_F(CastRunnerIntegrationTest, InitialMinConsoleLogSeverity_DEBUG) {
GURL app_url = test_server_.GetURL(kBlankAppUrl);
auto app_config =
FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url);
*app_config.mutable_initial_min_console_log_severity() =
fuchsia::diagnostics::Severity::DEBUG;
app_config_manager_.AddAppConfig(std::move(app_config));
CreateComponentContextAndStartComponent();
CheckAppUrl(app_url);
}
TEST_F(CastRunnerIntegrationTest, WebGLContextAbsentWithoutVulkanFeature) {
const char kTestPath[] = "/webgl_presence.html";
const GURL test_url = test_server_.GetURL(kTestPath);
......
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