LibWeb: Add an Internals method to dump the GC graph

This commit is contained in:
Tim Ledbetter 2025-11-04 01:49:40 +00:00 committed by Andreas Kling
parent ab00a4dc1f
commit 74940726d0
Notes: github-actions[bot] 2025-11-04 09:35:39 +00:00
4 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,7 @@
#include <LibWeb/ARIA/StateAndProperties.h> #include <LibWeb/ARIA/StateAndProperties.h>
#include <LibWeb/Bindings/InternalsPrototype.h> #include <LibWeb/Bindings/InternalsPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/EventTarget.h>
@ -342,6 +343,11 @@ String Internals::dump_display_list()
return window().associated_document().dump_display_list(); return window().associated_document().dump_display_list();
} }
String Internals::dump_gc_graph()
{
return Bindings::main_thread_vm().heap().dump_graph().serialized();
}
GC::Ptr<DOM::ShadowRoot> Internals::get_shadow_root(GC::Ref<DOM::Element> element) GC::Ptr<DOM::ShadowRoot> Internals::get_shadow_root(GC::Ref<DOM::Element> element)
{ {
return element->shadow_root(); return element->shadow_root();

View file

@ -68,6 +68,7 @@ public:
bool headless(); bool headless();
String dump_display_list(); String dump_display_list();
String dump_gc_graph();
GC::Ptr<DOM::ShadowRoot> get_shadow_root(GC::Ref<DOM::Element>); GC::Ptr<DOM::ShadowRoot> get_shadow_root(GC::Ref<DOM::Element>);

View file

@ -57,6 +57,7 @@ interface Internals {
readonly attribute boolean headless; readonly attribute boolean headless;
DOMString dumpDisplayList(); DOMString dumpDisplayList();
DOMString dumpGCGraph();
// Returns the shadow root of the element, if it has one, even if it's not normally accessible to JS. // Returns the shadow root of the element, if it has one, even if it's not normally accessible to JS.
ShadowRoot? getShadowRoot(Element element); ShadowRoot? getShadowRoot(Element element);

View file

@ -0,0 +1,4 @@
<!DOCTYPE html>
<script>
internals.dumpGCGraph();
</script>