0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
app
app_shim_remote_cocoa
browser
child
common
gpu
ppapi_plugin
public
renderer
services
shell
test
utility
web_test
browser
DEPS
OWNERS
devtools_protocol_test_bindings.cc
devtools_protocol_test_bindings.h
fake_bluetooth_chooser.cc
fake_bluetooth_chooser.h
fake_bluetooth_chooser_factory.cc
fake_bluetooth_chooser_factory.h
fake_bluetooth_delegate.cc
fake_bluetooth_delegate.h
leak_detector.cc
leak_detector.h
mojo_echo.cc
mojo_echo.h
mojo_optional_numerics_unittest.cc
mojo_optional_numerics_unittest.h
mojo_web_test_helper.cc
mojo_web_test_helper.h
test_info_extractor.cc
test_info_extractor.h
web_test_background_fetch_delegate.cc
web_test_background_fetch_delegate.h
web_test_bluetooth_adapter_provider.cc
web_test_bluetooth_adapter_provider.h
web_test_bluetooth_chooser_factory.cc
web_test_bluetooth_chooser_factory.h
web_test_bluetooth_fake_adapter_setter_impl.cc
web_test_bluetooth_fake_adapter_setter_impl.h
web_test_browser_context.cc
web_test_browser_context.h
web_test_browser_main_parts.cc
web_test_browser_main_parts.h
web_test_browser_main_platform_support.h
web_test_browser_main_platform_support_linux.cc
web_test_browser_main_platform_support_mac.mm
web_test_browser_main_platform_support_win.cc
web_test_browser_main_runner.cc
web_test_browser_main_runner.h
web_test_content_browser_client.cc
web_test_content_browser_client.h
web_test_control_host.cc
web_test_control_host.h
web_test_cookie_manager.cc
web_test_cookie_manager.h
web_test_device_posture_provider.cc
web_test_device_posture_provider.h
web_test_devtools_bindings.cc
web_test_devtools_bindings.h
web_test_download_manager_delegate.cc
web_test_download_manager_delegate.h
web_test_fedcm_manager.cc
web_test_fedcm_manager.h
web_test_first_device_bluetooth_chooser.cc
web_test_first_device_bluetooth_chooser.h
web_test_javascript_dialog_manager.cc
web_test_javascript_dialog_manager.h
web_test_origin_trial_throttle.cc
web_test_origin_trial_throttle.h
web_test_permission_manager.cc
web_test_permission_manager.h
web_test_pressure_manager.cc
web_test_pressure_manager.h
web_test_push_messaging_service.cc
web_test_push_messaging_service.h
web_test_sensor_provider_manager.cc
web_test_sensor_provider_manager.h
web_test_shell_platform_delegate.cc
web_test_shell_platform_delegate.h
web_test_shell_platform_delegate_aura.cc
web_test_shell_platform_delegate_ios.mm
web_test_shell_platform_delegate_mac.mm
web_test_shell_platform_delegate_views.cc
web_test_storage_access_manager.cc
web_test_storage_access_manager.h
web_test_tracing_controller.cc
web_test_tracing_controller.h
web_test_tts_platform.cc
web_test_tts_platform.h
common
renderer
BUILD.gn
DIR_METADATA
OWNERS
zygote
BUILD.gn
DEPS
DIR_METADATA
OWNERS
README.md
architecture.png
content_resources.grd
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/content/web_test/browser/test_info_extractor.h
Stefan Zager 23e0be190e Add per-test-case tracing and archive trace output for web_tests
Re-land after revert:

https://chromium-review.googlesource.com/c/chromium/src/+/5016143

This CL fixes three bugs in the original:

- a javascript syntax error in results.html
- Previously, when a passing test with a trace file was expanded in
  results. html, the trace file was automatically downloaded without
  clicking on the link.
- a crash when the feature is used due to destructing a RunLoop while
  it was still running.

Bug: None
Change-Id: I8b25ca55a12f58dffbebb492ef7665e8416a13fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5018180
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: Rick Byers <rbyers@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1223805}
2023-11-13 20:09:34 +00:00

101 lines
3.8 KiB
C++

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_
#define CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_
#include <stddef.h>
#include <memory>
#include <string>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "url/gurl.h"
namespace content {
struct TestInfo {
TestInfo(const GURL& url,
const std::string& expected_pixel_hash,
base::FilePath current_working_directory,
bool wpt_print_mode,
bool protocol_mode,
base::FilePath trace_file);
~TestInfo();
GURL url;
std::string expected_pixel_hash;
base::FilePath current_working_directory;
// Forces the default printing format required by WPT print reftests.
bool wpt_print_mode;
// If true, the input and output of content_shell are assumed to follow the
// run_web_tests protocol through pipes that connect stdin and stdout of
// run_web_tests.py and content_shell:
//
// run_web_tests.py content_shell
// | <------ #READY <------ |
// | |
// | ---> <test_name>['(<pixelhash>)?['(print)?['(<trace file>)?]]] ---> |
// | |
// | <------ [<text|audio dump>\n#EOF] ------- |
// | <------ [<pixel dump>\n#EOF] ------- |
// | <------ #EOF ------- |
// | |
// | ---> <test_name>['(<pixelhash>)?['(print)?['(<trace file>)?]]] ---> |
// | .... |
// | |
// | ------> QUIT -------> |
//
// In this mode, each test creates 1 or 2 test output dumps. The first dump
// is text or audio (can be empty), and the second dump is image (can be
// empty, too). Each dump, if not empty, is in the following format:
//
// Content-Type: <mime-type>\n
// [<other headers>]
// [Content-Length: <content-length>\n] # Required for binary content data
// <content data>
//
// If <pixelhash> is provided, the actual pixel results will only be sent if
// a hash of the actual pixels does not match <pixelhash>.
//
// If the static string "print" is provided, the image results will be
// generated according to the requirements for a WPT ref test.
//
// If <trace file> is provided, a perfetto trace covering the execution of the
// test will be saved to the given file.
//
// Content_shell enters the protocol mode when it sees a "-" parameter in the
// command line. For the tests listed in the content_shell command line, this
// field is false, and the test runner will dump pure text only without binary
// data and protocol tags.
bool protocol_mode;
// If non-empty, a chrome://tracing style trace covering the execution of this
// test will be written to the given path.
base::FilePath trace_file;
};
class TestInfoExtractor {
public:
explicit TestInfoExtractor(const base::CommandLine& cmd_line);
TestInfoExtractor(const TestInfoExtractor&) = delete;
TestInfoExtractor& operator=(const TestInfoExtractor&) = delete;
~TestInfoExtractor();
std::unique_ptr<TestInfo> GetNextTest();
private:
base::CommandLine::StringVector cmdline_args_;
size_t cmdline_position_;
};
} // namespace content
#endif // CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_