mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWebView+test-web: Print heap explorer URL after dumping GC graph
When dumping a GC graph, we now write the output as a .js file containing `var GC_GRAPH_DUMP = <json>;` instead of raw JSON. This allows gc-heap-explorer.html to load the dump via a dynamically created <script> element, avoiding CORS restrictions that prevent file:// pages from fetching other file:// URLs. After dumping, both the browser and test-web print a clickable file:// URL that opens the heap explorer with the dump pre-loaded. The heap explorer's drag-and-drop file picker also accepts both the new .js format and plain .json files.
This commit is contained in:
committed by
Andreas Kling
parent
34ae80d602
commit
64d033b31a
Notes:
github-actions[bot]
2026-02-06 10:47:20 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/64d033b31ab Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7718
@@ -806,10 +806,13 @@ ErrorOr<LexicalPath> ViewImplementation::dump_gc_graph()
|
||||
auto gc_graph_json = TRY(promise->await());
|
||||
|
||||
LexicalPath path { Core::StandardPaths::tempfile_directory() };
|
||||
path = path.append(TRY(AK::UnixDateTime::now().to_string("gc-graph-%Y-%m-%d-%H-%M-%S.json"sv)));
|
||||
path = path.append(TRY(AK::UnixDateTime::now().to_string("gc-graph-%Y-%m-%d-%H-%M-%S.js"sv)));
|
||||
|
||||
// Write as a .js file so gc-heap-explorer.html can load it via <script> tag (avoiding CORS issues with file:// URLs)
|
||||
auto dump_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
|
||||
TRY(dump_file->write_until_depleted("var GC_GRAPH_DUMP = "sv.bytes()));
|
||||
TRY(dump_file->write_until_depleted(gc_graph_json.bytes()));
|
||||
TRY(dump_file->write_until_depleted(";\n"sv.bytes()));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user