mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +00:00
LibWeb: Add a simple internals objects only available during testing
This object is available as `window.internals` (or just `internals`) and is only accessible while running in "test mode". This first version only has one API: gc(), which triggers a garbage collection immediately. In the future, we can add more APIs here to help us test parts of the engine that are hard or impossible to reach via public web APIs.
This commit is contained in:
@@ -178,7 +178,7 @@ void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
|
||||
)~~~");
|
||||
};
|
||||
|
||||
auto add_interface = [&](SourceGenerator& gen, StringView name, StringView prototype_class, StringView constructor_class, Optional<LegacyConstructor> const& legacy_constructor) {
|
||||
auto add_interface = [](SourceGenerator& gen, StringView name, StringView prototype_class, StringView constructor_class, Optional<LegacyConstructor> const& legacy_constructor) {
|
||||
gen.set("interface_name", name);
|
||||
gen.set("prototype_class", prototype_class);
|
||||
gen.set("constructor_class", constructor_class);
|
||||
@@ -434,6 +434,8 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
|
||||
auto exposed = maybe_exposed.value().trim_whitespace();
|
||||
if (exposed == "*"sv)
|
||||
return ExposedTo::All;
|
||||
if (exposed == "Nobody"sv)
|
||||
return ExposedTo::Nobody;
|
||||
if (exposed == "Window"sv)
|
||||
return ExposedTo::Window;
|
||||
if (exposed == "Worker"sv)
|
||||
@@ -477,10 +479,8 @@ ErrorOr<void> add_to_interface_sets(IDL::Interface& interface, Vector<IDL::Inter
|
||||
{
|
||||
// TODO: Add service worker exposed and audio worklet exposed
|
||||
auto whom = TRY(parse_exposure_set(interface));
|
||||
VERIFY(whom != ExposedTo::Nobody);
|
||||
|
||||
if ((whom & ExposedTo::Window) || (whom & ExposedTo::DedicatedWorker) || (whom & ExposedTo::SharedWorker))
|
||||
intrinsics.append(interface);
|
||||
intrinsics.append(interface);
|
||||
|
||||
if (whom & ExposedTo::Window)
|
||||
window_exposed.append(interface);
|
||||
|
||||
Reference in New Issue
Block a user