Files
ladybird/Libraries/LibWeb/Internals/XRTest.cpp
Shannon Booth fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00

62 lines
1.8 KiB
C++

/*
* Copyright (c) 2025, Psychpsyo <psychpsyo@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/XRTest.h>
#include <LibWeb/Internals/FakeXRDevice.h>
#include <LibWeb/Internals/XRTest.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/Promise.h>
namespace Web::Internals {
GC_DEFINE_ALLOCATOR(XRTest);
XRTest::XRTest(JS::Realm& realm)
: InternalsBase(realm)
{
}
XRTest::~XRTest() = default;
void XRTest::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(XRTest);
Base::initialize(realm);
}
GC::Ref<WebIDL::Promise> XRTest::simulate_device_connection(FakeXRDeviceInit const&) const
{
// Simulates connecting a device to the system.
// Used to instantiate a fake device for use in tests.
// FIXME: Actually perform whatever device connection steps are needed once those are implemented.
auto& realm = HTML::relevant_realm(*this);
auto promise = WebIDL::create_promise(realm);
WebIDL::resolve_promise(realm, promise, FakeXRDevice::create(realm));
return promise;
}
void XRTest::simulate_user_activation(GC::Ref<WebIDL::CallbackType> function) const
{
// Simulates a user activation (aka user gesture) for the current scope.
// The activation is only guaranteed to be valid in the provided function and only applies to WebXR
// Device API methods.
// FIXME: Actually simulate a user activation here
(void)WebIDL::invoke_callback(*function, {}, {});
}
GC::Ref<WebIDL::Promise> XRTest::disconnect_all_devices() const
{
// Disconnect all fake devices
// FIXME: Actually disconnect fake devices once we have any.
auto& realm = HTML::relevant_realm(*this);
auto promise = WebIDL::create_promise(realm);
WebIDL::resolve_promise(realm, promise);
return promise;
}
}