Userland: Remove some SerenityOS checks

This commit is contained in:
circl 2024-06-09 12:10:28 +02:00 committed by Andreas Kling
commit c169e43e13
Notes: sideshowbarker 2024-07-17 08:13:43 +09:00
18 changed files with 10 additions and 177 deletions

View file

@ -38,7 +38,7 @@ public:
private: private:
CGLContextObj m_context; CGLContextObj m_context;
}; };
#elif !defined(AK_OS_SERENITY) #else
class EGLContextWrapper : public Context { class EGLContextWrapper : public Context {
public: public:
EGLContextWrapper(EGLContext context) EGLContextWrapper(EGLContext context)
@ -96,7 +96,7 @@ static ErrorOr<NonnullOwnPtr<CGLContextWrapper>> make_context_cgl()
return make<CGLContextWrapper>(context); return make<CGLContextWrapper>(context);
} }
#elif !defined(AK_OS_SERENITY) #else
static StringView format_egl_error(EGLint error) static StringView format_egl_error(EGLint error)
{ {

View file

@ -9,9 +9,7 @@
#include <AK/Platform.h> #include <AK/Platform.h>
#include <LibCore/ThreadedPromise.h> #include <LibCore/ThreadedPromise.h>
#if defined(AK_OS_SERENITY) #if defined(HAVE_PULSEAUDIO)
# include <LibAudio/PlaybackStreamSerenity.h>
#elif defined(HAVE_PULSEAUDIO)
# include <LibAudio/PlaybackStreamPulseAudio.h> # include <LibAudio/PlaybackStreamPulseAudio.h>
#elif defined(AK_OS_MACOS) #elif defined(AK_OS_MACOS)
# include <LibAudio/PlaybackStreamAudioUnit.h> # include <LibAudio/PlaybackStreamAudioUnit.h>
@ -23,9 +21,7 @@ ErrorOr<NonnullRefPtr<PlaybackStream>> PlaybackStream::create(OutputState initia
{ {
VERIFY(data_request_callback); VERIFY(data_request_callback);
// Create the platform-specific implementation for this stream. // Create the platform-specific implementation for this stream.
#if defined(AK_OS_SERENITY) #if defined(HAVE_PULSEAUDIO)
return PlaybackStreamSerenity::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
#elif defined(HAVE_PULSEAUDIO)
return PlaybackStreamPulseAudio::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback)); return PlaybackStreamPulseAudio::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
#elif defined(AK_OS_MACOS) #elif defined(AK_OS_MACOS)
return PlaybackStreamAudioUnit::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback)); return PlaybackStreamAudioUnit::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));

View file

@ -12,9 +12,7 @@
#include <LibFileSystem/FileSystem.h> #include <LibFileSystem/FileSystem.h>
#include <limits.h> #include <limits.h>
#if defined(AK_OS_SERENITY) #if !defined(AK_OS_IOS) && defined(AK_OS_BSD_GENERIC)
# include <serenity.h>
#elif !defined(AK_OS_IOS) && defined(AK_OS_BSD_GENERIC)
# include <sys/disk.h> # include <sys/disk.h>
#elif defined(AK_OS_LINUX) #elif defined(AK_OS_LINUX)
# include <linux/fs.h> # include <linux/fs.h>
@ -391,11 +389,7 @@ ErrorOr<off_t> block_device_size_from_ioctl(StringView path)
ErrorOr<off_t> block_device_size_from_ioctl(int fd) ErrorOr<off_t> block_device_size_from_ioctl(int fd)
{ {
#if defined(AK_OS_SERENITY) #if defined(AK_OS_MACOS)
u64 size = 0;
TRY(Core::System::ioctl(fd, STORAGE_DEVICE_GET_SIZE, &size));
return static_cast<off_t>(size);
#elif defined(AK_OS_MACOS)
u64 block_count = 0; u64 block_count = 0;
u32 block_size = 0; u32 block_size = 0;
TRY(Core::System::ioctl(fd, DKIOCGETBLOCKCOUNT, &block_count)); TRY(Core::System::ioctl(fd, DKIOCGETBLOCKCOUNT, &block_count));

View file

@ -16,8 +16,7 @@
# include <sanitizer/lsan_interface.h> # include <sanitizer/lsan_interface.h>
#endif #endif
// FIXME: Implement MADV_FREE and/or MADV_DONTNEED on SerenityOS. #if defined(AK_OS_GNU_HURD) || (!defined(MADV_FREE) && !defined(MADV_DONTNEED))
#if defined(AK_OS_SERENITY) || defined(AK_OS_GNU_HURD) || (!defined(MADV_FREE) && !defined(MADV_DONTNEED))
# define USE_FALLBACK_BLOCK_DEALLOCATION # define USE_FALLBACK_BLOCK_DEALLOCATION
#endif #endif
@ -45,20 +44,10 @@ void* BlockAllocator::allocate_block([[maybe_unused]] char const* name)
auto* block = m_blocks.unstable_take(random_index); auto* block = m_blocks.unstable_take(random_index);
ASAN_UNPOISON_MEMORY_REGION(block, HeapBlock::block_size); ASAN_UNPOISON_MEMORY_REGION(block, HeapBlock::block_size);
LSAN_REGISTER_ROOT_REGION(block, HeapBlock::block_size); LSAN_REGISTER_ROOT_REGION(block, HeapBlock::block_size);
#ifdef AK_OS_SERENITY
if (set_mmap_name(block, HeapBlock::block_size, name) < 0) {
perror("set_mmap_name");
VERIFY_NOT_REACHED();
}
#endif
return block; return block;
} }
#ifdef AK_OS_SERENITY
auto* block = (HeapBlock*)serenity_mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RANDOMIZED | MAP_PRIVATE, -1, 0, HeapBlock::block_size, name);
#else
auto* block = (HeapBlock*)mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); auto* block = (HeapBlock*)mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
#endif
VERIFY(block != MAP_FAILED); VERIFY(block != MAP_FAILED);
LSAN_REGISTER_ROOT_REGION(block, HeapBlock::block_size); LSAN_REGISTER_ROOT_REGION(block, HeapBlock::block_size);
return block; return block;

View file

@ -24,20 +24,12 @@
#include <LibJS/SafeFunction.h> #include <LibJS/SafeFunction.h>
#include <setjmp.h> #include <setjmp.h>
#ifdef AK_OS_SERENITY
# include <serenity.h>
#endif
#ifdef HAS_ADDRESS_SANITIZER #ifdef HAS_ADDRESS_SANITIZER
# include <sanitizer/asan_interface.h> # include <sanitizer/asan_interface.h>
#endif #endif
namespace JS { namespace JS {
#ifdef AK_OS_SERENITY
static int gc_perf_string_id;
#endif
// NOTE: We keep a per-thread list of custom ranges. This hinges on the assumption that there is one JS VM per thread. // NOTE: We keep a per-thread list of custom ranges. This hinges on the assumption that there is one JS VM per thread.
static __thread HashMap<FlatPtr*, size_t>* s_custom_ranges_for_conservative_scan = nullptr; static __thread HashMap<FlatPtr*, size_t>* s_custom_ranges_for_conservative_scan = nullptr;
static __thread HashMap<FlatPtr*, SourceLocation*>* s_safe_function_locations = nullptr; static __thread HashMap<FlatPtr*, SourceLocation*>* s_safe_function_locations = nullptr;
@ -45,11 +37,6 @@ static __thread HashMap<FlatPtr*, SourceLocation*>* s_safe_function_locations =
Heap::Heap(VM& vm) Heap::Heap(VM& vm)
: HeapBase(vm) : HeapBase(vm)
{ {
#ifdef AK_OS_SERENITY
auto gc_signpost_string = "Garbage collection"sv;
gc_perf_string_id = perf_register_string(gc_signpost_string.characters_without_null_termination(), gc_signpost_string.length());
#endif
static_assert(HeapBlock::min_possible_cell_size <= 32, "Heap Cell tracking uses too much data!"); static_assert(HeapBlock::min_possible_cell_size <= 32, "Heap Cell tracking uses too much data!");
m_size_based_cell_allocators.append(make<CellAllocator>(64)); m_size_based_cell_allocators.append(make<CellAllocator>(64));
m_size_based_cell_allocators.append(make<CellAllocator>(96)); m_size_based_cell_allocators.append(make<CellAllocator>(96));
@ -264,11 +251,6 @@ void Heap::collect_garbage(CollectionType collection_type, bool print_report)
VERIFY(!m_collecting_garbage); VERIFY(!m_collecting_garbage);
TemporaryChange change(m_collecting_garbage, true); TemporaryChange change(m_collecting_garbage, true);
#ifdef AK_OS_SERENITY
static size_t global_gc_counter = 0;
perf_event(PERF_EVENT_SIGNPOST, gc_perf_string_id, global_gc_counter++);
#endif
Core::ElapsedTimer collection_measurement_timer; Core::ElapsedTimer collection_measurement_timer;
if (print_report) if (print_report)
collection_measurement_timer.start(); collection_measurement_timer.start();

View file

@ -20,15 +20,7 @@ namespace JS {
NonnullOwnPtr<HeapBlock> HeapBlock::create_with_cell_size(Heap& heap, CellAllocator& cell_allocator, size_t cell_size, [[maybe_unused]] char const* class_name) NonnullOwnPtr<HeapBlock> HeapBlock::create_with_cell_size(Heap& heap, CellAllocator& cell_allocator, size_t cell_size, [[maybe_unused]] char const* class_name)
{ {
#ifdef AK_OS_SERENITY
char name[64];
if (class_name)
snprintf(name, sizeof(name), "LibJS: HeapBlock(%zu): %s", cell_size, class_name);
else
snprintf(name, sizeof(name), "LibJS: HeapBlock(%zu)", cell_size);
#else
char const* name = nullptr; char const* name = nullptr;
#endif
auto* block = static_cast<HeapBlock*>(cell_allocator.block_allocator().allocate_block(name)); auto* block = static_cast<HeapBlock*>(cell_allocator.block_allocator().allocate_block(name));
new (block) HeapBlock(heap, cell_allocator, cell_size); new (block) HeapBlock(heap, cell_allocator, cell_size);
return NonnullOwnPtr<HeapBlock>(NonnullOwnPtr<HeapBlock>::Adopt, *block); return NonnullOwnPtr<HeapBlock>(NonnullOwnPtr<HeapBlock>::Adopt, *block);

View file

@ -210,9 +210,6 @@ GlobalObject::~GlobalObject() = default;
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::gc) JS_DEFINE_NATIVE_FUNCTION(GlobalObject::gc)
{ {
#ifdef AK_OS_SERENITY
dbgln("Forced garbage collection requested!");
#endif
vm.heap().collect_garbage(); vm.heap().collect_garbage();
return js_undefined(); return js_undefined();
} }

View file

@ -44,9 +44,6 @@ int main(int argc, char** argv)
if (result.is_error()) { if (result.is_error()) {
auto error = result.release_error(); auto error = result.release_error();
warnln("\033[31;1mRuntime error\033[0m: {}", error); warnln("\033[31;1mRuntime error\033[0m: {}", error);
#ifdef AK_OS_SERENITY
dbgln("\033[31;1mExiting with runtime error\033[0m: {}", error);
#endif
return Main::return_code_for_errors(); return Main::return_code_for_errors();
} }
return result.value(); return result.value();

View file

@ -579,10 +579,6 @@ ErrorOr<Vector<Certificate>> DefaultRootCACertificates::load_certificates(Span<B
ByteBuffer data; ByteBuffer data;
if (!cacert_file_or_error.is_error()) if (!cacert_file_or_error.is_error())
data = TRY(cacert_file_or_error.value()->read_until_eof()); data = TRY(cacert_file_or_error.value()->read_until_eof());
#ifdef AK_OS_SERENITY
else
return cacert_file_or_error.release_error();
#endif
auto user_cert_path = TRY(String::formatted("{}/.config/certs.pem", Core::StandardPaths::home_directory())); auto user_cert_path = TRY(String::formatted("{}/.config/certs.pem", Core::StandardPaths::home_directory()));
if (FileSystem::exists(user_cert_path)) { if (FileSystem::exists(user_cert_path)) {

View file

@ -36,10 +36,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#ifdef AK_OS_SERENITY
# include <serenity.h>
#endif
#define STRCAT(x, y) __STRCAT(x, y) #define STRCAT(x, y) __STRCAT(x, y)
#define STRSTRCAT(x, y) __STRSTRCAT(x, y) #define STRSTRCAT(x, y) __STRSTRCAT(x, y)
#define __STRCAT(x, y) x #y #define __STRCAT(x, y) x #y
@ -280,11 +276,6 @@ inline JSFileResult TestRunner::run_file_test(ByteString const& test_path)
{ {
g_currently_running_test = test_path; g_currently_running_test = test_path;
#ifdef AK_OS_SERENITY
auto string_id = perf_register_string(test_path.characters(), test_path.length());
perf_event(PERF_EVENT_SIGNPOST, string_id, 0);
#endif
double start_time = get_time_in_ms(); double start_time = get_time_in_ms();
JS::GCPtr<JS::Realm> realm; JS::GCPtr<JS::Realm> realm;
@ -515,12 +506,7 @@ inline void TestRunner::print_file_result(JSFileResult const& file_result) const
if (!file_result.logged_messages.is_empty()) { if (!file_result.logged_messages.is_empty()) {
print_modifiers({ FG_GRAY, FG_BOLD }); print_modifiers({ FG_GRAY, FG_BOLD });
#ifdef AK_OS_SERENITY
outln(" Console output:");
#else
// This emoji has a second invisible byte after it. The one above does not
outln(" Console output:"); outln(" Console output:");
#endif
print_modifiers({ CLEAR, FG_GRAY }); print_modifiers({ CLEAR, FG_GRAY });
for (auto& message : file_result.logged_messages) for (auto& message : file_result.logged_messages)
outln(" {}", message); outln(" {}", message);
@ -530,12 +516,7 @@ inline void TestRunner::print_file_result(JSFileResult const& file_result) const
auto test_error = file_result.error.value(); auto test_error = file_result.error.value();
print_modifiers({ FG_RED }); print_modifiers({ FG_RED });
#ifdef AK_OS_SERENITY
outln(" ❌ The file failed to parse");
#else
// No invisible byte here, but the spacing still needs to be altered on the host
outln(" ❌ The file failed to parse"); outln(" ❌ The file failed to parse");
#endif
outln(); outln();
print_modifiers({ FG_GRAY }); print_modifiers({ FG_GRAY });
for (auto& message : test_error.hint.split('\n', SplitBehavior::KeepEmpty)) { for (auto& message : test_error.hint.split('\n', SplitBehavior::KeepEmpty)) {
@ -557,19 +538,9 @@ inline void TestRunner::print_file_result(JSFileResult const& file_result) const
print_modifiers({ FG_GRAY, FG_BOLD }); print_modifiers({ FG_GRAY, FG_BOLD });
if (failed) { if (failed) {
#ifdef AK_OS_SERENITY
out(" ❌ Suite: ");
#else
// No invisible byte here, but the spacing still needs to be altered on the host
out(" ❌ Suite: "); out(" ❌ Suite: ");
#endif
} else { } else {
#ifdef AK_OS_SERENITY
out(" ⚠ Suite: ");
#else
// This emoji has a second invisible byte after it. The one above does not
out(" ⚠️ Suite: "); out(" ⚠️ Suite: ");
#endif
} }
print_modifiers({ CLEAR, FG_GRAY }); print_modifiers({ CLEAR, FG_GRAY });

View file

@ -84,12 +84,7 @@ int main(int argc, char** argv)
#endif #endif
bool print_times = false; bool print_times = false;
bool print_progress = bool print_progress = false;
#ifdef AK_OS_SERENITY
true; // Use OSC 9 to print progress
#else
false;
#endif
bool print_json = false; bool print_json = false;
bool per_file = false; bool per_file = false;
StringView specified_test_root; StringView specified_test_root;
@ -139,9 +134,6 @@ int main(int argc, char** argv)
if (!specified_test_root.is_empty()) { if (!specified_test_root.is_empty()) {
test_root = ByteString { specified_test_root }; test_root = ByteString { specified_test_root };
} else { } else {
#ifdef AK_OS_SERENITY
test_root = LexicalPath::join("/home/anon/Tests"sv, ByteString::formatted("{}-tests", program_name.split_view('-').last())).string();
#else
char* ladybird_source_dir = getenv("LADYBIRD_SOURCE_DIR"); char* ladybird_source_dir = getenv("LADYBIRD_SOURCE_DIR");
if (!ladybird_source_dir) { if (!ladybird_source_dir) {
warnln("No test root given, {} requires the LADYBIRD_SOURCE_DIR environment variable to be set", g_program_name); warnln("No test root given, {} requires the LADYBIRD_SOURCE_DIR environment variable to be set", g_program_name);
@ -149,7 +141,6 @@ int main(int argc, char** argv)
} }
test_root = ByteString::formatted("{}/{}", ladybird_source_dir, g_test_root_fragment); test_root = ByteString::formatted("{}/{}", ladybird_source_dir, g_test_root_fragment);
common_path = ByteString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", ladybird_source_dir); common_path = ByteString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", ladybird_source_dir);
#endif
} }
if (!FileSystem::is_directory(test_root)) { if (!FileSystem::is_directory(test_root)) {
warnln("Test root is not a directory: {}", test_root); warnln("Test root is not a directory: {}", test_root);
@ -157,16 +148,12 @@ int main(int argc, char** argv)
} }
if (common_path.is_empty()) { if (common_path.is_empty()) {
#ifdef AK_OS_SERENITY
common_path = "/home/anon/Tests/js-tests/test-common.js";
#else
char* ladybird_source_dir = getenv("LADYBIRD_SOURCE_DIR"); char* ladybird_source_dir = getenv("LADYBIRD_SOURCE_DIR");
if (!ladybird_source_dir) { if (!ladybird_source_dir) {
warnln("No test root given, {} requires the LADYBIRD_SOURCE_DIR environment variable to be set", g_program_name); warnln("No test root given, {} requires the LADYBIRD_SOURCE_DIR environment variable to be set", g_program_name);
return 1; return 1;
} }
common_path = ByteString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", ladybird_source_dir); common_path = ByteString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", ladybird_source_dir);
#endif
} }
auto test_root_or_error = FileSystem::real_path(test_root); auto test_root_or_error = FileSystem::real_path(test_root);

View file

@ -23,12 +23,10 @@ public:
Mutex() Mutex()
: m_lock_count(0) : m_lock_count(0)
{ {
#ifndef AK_OS_SERENITY
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr); pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &attr); pthread_mutex_init(&m_mutex, &attr);
#endif
} }
~Mutex() ~Mutex()
{ {
@ -40,11 +38,7 @@ public:
void unlock(); void unlock();
private: private:
#ifdef AK_OS_SERENITY
pthread_mutex_t m_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#else
pthread_mutex_t m_mutex; pthread_mutex_t m_mutex;
#endif
unsigned m_lock_count { 0 }; unsigned m_lock_count { 0 };
}; };

View file

@ -102,12 +102,6 @@ void Thread::start()
&NonnullRefPtr(*this).leak_ref()); &NonnullRefPtr(*this).leak_ref());
VERIFY(rc == 0); VERIFY(rc == 0);
#ifdef AK_OS_SERENITY
if (!m_thread_name.is_empty()) {
rc = pthread_setname_np(m_tid, m_thread_name.characters());
VERIFY(rc == 0);
}
#endif
} }
void Thread::detach() void Thread::detach()

View file

@ -132,17 +132,8 @@ StringView current_time_zone()
ErrorOr<void> change_time_zone([[maybe_unused]] StringView time_zone) ErrorOr<void> change_time_zone([[maybe_unused]] StringView time_zone)
{ {
#ifdef AK_OS_SERENITY
TimeZoneFile time_zone_file("w");
if (auto new_time_zone = canonicalize_time_zone(time_zone); new_time_zone.has_value())
return time_zone_file.write_time_zone(*new_time_zone);
return Error::from_string_literal("Provided time zone is not supported");
#else
// Do not even attempt to change the time zone of someone's host machine. // Do not even attempt to change the time zone of someone's host machine.
return {}; return {};
#endif
} }
ReadonlySpan<TimeZoneIdentifier> __attribute__((weak)) all_time_zones() ReadonlySpan<TimeZoneIdentifier> __attribute__((weak)) all_time_zones()

View file

@ -24,10 +24,6 @@
#include <LibWeb/Platform/EventLoopPlugin.h> #include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/Platform/Timer.h> #include <LibWeb/Platform/Timer.h>
#ifdef AK_OS_SERENITY
# include <serenity.h>
#endif
namespace Web { namespace Web {
ResourceLoaderConnectorRequest::ResourceLoaderConnectorRequest() = default; ResourceLoaderConnectorRequest::ResourceLoaderConnectorRequest() = default;
@ -140,13 +136,8 @@ static ByteString sanitized_url_for_logging(URL::URL const& url)
static void emit_signpost(ByteString const& message, int id) static void emit_signpost(ByteString const& message, int id)
{ {
#ifdef AK_OS_SERENITY
auto string_id = perf_register_string(message.characters(), message.length());
perf_event(PERF_EVENT_SIGNPOST, string_id, id);
#else
(void)message; (void)message;
(void)id; (void)id;
#endif
} }
static void store_response_cookies(Page& page, URL::URL const& url, ByteString const& set_cookie_entry) static void store_response_cookies(Page& page, URL::URL const& url, ByteString const& set_cookie_entry)

View file

@ -48,10 +48,6 @@
#include <WebContent/PageHost.h> #include <WebContent/PageHost.h>
#include <WebContent/WebContentClientEndpoint.h> #include <WebContent/WebContentClientEndpoint.h>
#ifdef AK_OS_SERENITY
# include <pthread.h>
#endif
namespace WebContent { namespace WebContent {
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket) ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket)
@ -130,16 +126,6 @@ void ConnectionFromClient::load_url(u64 page_id, const URL::URL& url)
if (!page.has_value()) if (!page.has_value())
return; return;
#if defined(AK_OS_SERENITY)
ByteString process_name;
if (url.host().has<Empty>() || url.host() == String {})
process_name = "WebContent";
else
process_name = ByteString::formatted("WebContent: {}", url.serialized_host().release_value_but_fixme_should_propagate_errors());
pthread_setname_np(pthread_self(), process_name.characters());
#endif
page->page().load(url); page->page().load(url);
} }

View file

@ -18,7 +18,9 @@
#include <AK/Platform.h> #include <AK/Platform.h>
#include <AK/String.h> #include <AK/String.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <Ladybird/HelperProcess.h>
#include <Ladybird/Types.h> #include <Ladybird/Types.h>
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/ConfigFile.h> #include <LibCore/ConfigFile.h>
#include <LibCore/DirIterator.h> #include <LibCore/DirIterator.h>
@ -54,11 +56,6 @@
#include <LibWebView/ViewImplementation.h> #include <LibWebView/ViewImplementation.h>
#include <LibWebView/WebContentClient.h> #include <LibWebView/WebContentClient.h>
#if !defined(AK_OS_SERENITY)
# include <Ladybird/HelperProcess.h>
# include <Ladybird/Utilities.h>
#endif
constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec
static StringView s_current_test_path; static StringView s_current_test_path;
@ -69,24 +66,14 @@ public:
{ {
RefPtr<Protocol::RequestClient> request_client; RefPtr<Protocol::RequestClient> request_client;
#if defined(AK_OS_SERENITY)
(void)resources_folder;
(void)certificates;
#else
auto request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv)); auto request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv));
request_client = TRY(launch_request_server_process(request_server_paths, resources_folder, certificates)); request_client = TRY(launch_request_server_process(request_server_paths, resources_folder, certificates));
#endif
auto database = TRY(WebView::Database::create()); auto database = TRY(WebView::Database::create());
auto cookie_jar = TRY(WebView::CookieJar::create(*database)); auto cookie_jar = TRY(WebView::CookieJar::create(*database));
auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView(move(database), move(cookie_jar), request_client))); auto view = TRY(adopt_nonnull_own_or_enomem(new (nothrow) HeadlessWebContentView(move(database), move(cookie_jar), request_client)));
#if defined(AK_OS_SERENITY)
view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
(void)command_line;
(void)is_layout_test_mode;
#else
Ladybird::WebContentOptions web_content_options { Ladybird::WebContentOptions web_content_options {
.command_line = command_line, .command_line = command_line,
.executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))), .executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))),
@ -97,7 +84,6 @@ public:
auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv)); auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv));
view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, web_content_options, move(request_server_socket))); view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, web_content_options, move(request_server_socket)));
#endif
view->client().async_update_system_theme(0, move(theme)); view->client().async_update_system_theme(0, move(theme));
@ -173,12 +159,7 @@ private:
}; };
on_request_worker_agent = [this]() { on_request_worker_agent = [this]() {
#if defined(AK_OS_SERENITY)
auto worker_client = MUST(Web::HTML::WebWorkerClient::try_create());
(void)this;
#else
auto worker_client = MUST(launch_web_worker_process(MUST(get_paths_for_helper_process("WebWorker"sv)), *m_request_client)); auto worker_client = MUST(launch_web_worker_process(MUST(get_paths_for_helper_process("WebWorker"sv)), *m_request_client));
#endif
return worker_client->dup_socket(); return worker_client->dup_socket();
}; };
} }
@ -657,10 +638,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
ByteString test_glob; ByteString test_glob;
Vector<ByteString> certificates; Vector<ByteString> certificates;
#if !defined(AK_OS_SERENITY)
platform_init(); platform_init();
resources_folder = s_serenity_resource_root; resources_folder = s_serenity_resource_root;
#endif
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
args_parser.set_general_help("This utility runs the Browser in headless mode."); args_parser.set_general_help("This utility runs the Browser in headless mode.");

View file

@ -492,9 +492,6 @@ public:
} }
auto output = TRY(generically_format_values(arguments.get<JS::MarkedVector<JS::Value>>())); auto output = TRY(generically_format_values(arguments.get<JS::MarkedVector<JS::Value>>()));
#ifdef AK_OS_SERENITY
m_console->output_debug_message(log_level, output);
#endif
switch (log_level) { switch (log_level) {
case JS::Console::LogLevel::Debug: case JS::Console::LogLevel::Debug: