Skip to content

Truly independent web browser

LibWeb: Remove the Web Serial API

Shannon Booth40387760a834
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index 2dfb30f73c2..e1dc54a39bb 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -404,8 +404,6 @@ set(SOURCES
Gamepad/GamepadRegistry.cpp
Gamepad/NavigatorGamepad.cpp
Geolocation/Geolocation.cpp
- Serial/Serial.cpp
- Serial/SerialPort.cpp
Geolocation/GeolocationCoordinates.cpp
Geolocation/GeolocationPosition.cpp
Geolocation/GeolocationPositionError.cpp
diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h
index 7db3c303388..abc9955653d 100644
--- a/Libraries/LibWeb/Forward.h
+++ b/Libraries/LibWeb/Forward.h
@@ -1070,13 +1070,6 @@ class Selection;
}
-namespace Web::Serial {
-
-class Serial;
-class SerialPort;
-
-}
-
namespace Web::ServiceWorker {
class Cache;
diff --git a/Libraries/LibWeb/HTML/EventNames.h b/Libraries/LibWeb/HTML/EventNames.h
index 3cc4ef43bfe..2e95d9b53bb 100644
--- a/Libraries/LibWeb/HTML/EventNames.h
+++ b/Libraries/LibWeb/HTML/EventNames.h
@@ -53,7 +53,6 @@ namespace Web::HTML::EventNames {
__ENUMERATE_HTML_EVENT(cut) \
__ENUMERATE_HTML_EVENT(datachannel) \
__ENUMERATE_HTML_EVENT(devicechange) \
- __ENUMERATE_HTML_EVENT(disconnect) \
__ENUMERATE_HTML_EVENT(dispose) \
__ENUMERATE_HTML_EVENT(DOMContentLoaded) \
__ENUMERATE_HTML_EVENT(drag) \
diff --git a/Libraries/LibWeb/HTML/Navigator.cpp b/Libraries/LibWeb/HTML/Navigator.cpp
index 2cd0861134e..7c6f3456fc0 100644
--- a/Libraries/LibWeb/HTML/Navigator.cpp
+++ b/Libraries/LibWeb/HTML/Navigator.cpp
@@ -82,7 +82,6 @@ void Navigator::visit_edges(GC::Cell::Visitor& visitor)
visitor.visit(m_plugin_array);
visitor.visit(m_clipboard);
visitor.visit(m_geolocation);
- visitor.visit(m_serial);
visitor.visit(m_user_activation);
visitor.visit(m_service_worker_container);
visitor.visit(m_media_capabilities);
@@ -119,13 +118,6 @@ GC::Ref<Geolocation::Geolocation> Navigator::geolocation()
return *m_geolocation;
}
-GC::Ref<Serial::Serial> Navigator::serial()
-{
- if (!m_serial)
- m_serial = Serial::Serial::create();
- return *m_serial;
-}
-
GC::Ref<UserActivation> Navigator::user_activation()
{
if (!m_user_activation)
diff --git a/Libraries/LibWeb/HTML/Navigator.h b/Libraries/LibWeb/HTML/Navigator.h
index 1ca3c573d99..2274345d98c 100644
--- a/Libraries/LibWeb/HTML/Navigator.h
+++ b/Libraries/LibWeb/HTML/Navigator.h
@@ -21,7 +21,6 @@
#include <LibWeb/HTML/UserActivation.h>
#include <LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h>
#include <LibWeb/MediaCapture/MediaDevices.h>
-#include <LibWeb/Serial/Serial.h>
#include <LibWeb/StorageAPI/NavigatorStorage.h>
#include <LibWeb/WebLocks/NavigatorLocks.h>
@@ -66,7 +65,6 @@ public:
[[nodiscard]] GC::Ref<PluginArray> plugins();
[[nodiscard]] GC::Ref<Clipboard::Clipboard> clipboard();
[[nodiscard]] GC::Ref<Geolocation::Geolocation> geolocation();
- [[nodiscard]] GC::Ref<Serial::Serial> serial();
[[nodiscard]] GC::Ref<UserActivation> user_activation();
[[nodiscard]] GC::Ref<CredentialManagement::CredentialsContainer> credentials();
GC::Ref<WebIDL::Promise> get_battery();
@@ -110,9 +108,6 @@ private:
// https://w3c.github.io/geolocation/#navigator_interface
GC::Ptr<Geolocation::Geolocation> m_geolocation;
- // https://wicg.github.io/serial/#extensions-to-the-navigator-interface
- GC::Ptr<Serial::Serial> m_serial;
-
// https://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation
GC::Ptr<UserActivation> m_user_activation;
diff --git a/Libraries/LibWeb/HTML/Navigator.idl b/Libraries/LibWeb/HTML/Navigator.idl
index e9bbbc1b22f..11a0a50c0ea 100644
--- a/Libraries/LibWeb/HTML/Navigator.idl
+++ b/Libraries/LibWeb/HTML/Navigator.idl
@@ -12,9 +12,6 @@ interface Navigator {
// https://w3c.github.io/pointerevents/#extensions-to-the-navigator-interface
readonly attribute long maxTouchPoints;
- // https://wicg.github.io/serial/#extensions-to-the-navigator-interface
- [SameObject] readonly attribute Serial serial;
-
// https://html.spec.whatwg.org/multipage/interaction.html#useractivation
[SameObject] readonly attribute UserActivation userActivation;
diff --git a/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Libraries/LibWeb/HTML/WorkerNavigator.cpp
index 73f4063fe34..c90a451766d 100644
--- a/Libraries/LibWeb/HTML/WorkerNavigator.cpp
+++ b/Libraries/LibWeb/HTML/WorkerNavigator.cpp
@@ -37,7 +37,6 @@ void WorkerNavigator::visit_edges(GC::Cell::Visitor& visitor)
Base::visit_edges(visitor);
visitor.visit(m_global_scope);
visitor.visit(m_media_capabilities);
- visitor.visit(m_serial);
visitor.visit(m_service_worker_container);
visitor.visit(m_permissions);
}
@@ -54,13 +53,6 @@ GC::Ref<MediaCapabilitiesAPI::MediaCapabilities> WorkerNavigator::media_capabili
return *m_media_capabilities;
}
-GC::Ref<Serial::Serial> WorkerNavigator::serial()
-{
- if (!m_serial)
- m_serial = GC::Heap::the().allocate<Serial::Serial>();
- return *m_serial;
-}
-
GC::Ref<ServiceWorker::ServiceWorkerContainer> WorkerNavigator::service_worker()
{
if (!m_service_worker_container)
diff --git a/Libraries/LibWeb/HTML/WorkerNavigator.h b/Libraries/LibWeb/HTML/WorkerNavigator.h
index 409e5a5704e..9b59f0c23b4 100644
--- a/Libraries/LibWeb/HTML/WorkerNavigator.h
+++ b/Libraries/LibWeb/HTML/WorkerNavigator.h
@@ -15,7 +15,6 @@
#include <LibWeb/HTML/NavigatorLanguage.h>
#include <LibWeb/HTML/NavigatorOnLine.h>
#include <LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h>
-#include <LibWeb/Serial/Serial.h>
#include <LibWeb/ServiceWorker/ServiceWorkerContainer.h>
#include <LibWeb/StorageAPI/NavigatorStorage.h>
#include <LibWeb/WebLocks/NavigatorLocks.h>
@@ -44,8 +43,6 @@ public:
GC::Ref<MediaCapabilitiesAPI::MediaCapabilities> media_capabilities();
- [[nodiscard]] GC::Ref<Serial::Serial> serial();
-
[[nodiscard]] GC::Ref<PermissionsAPI::Permissions> permissions();
private:
@@ -67,9 +64,6 @@ private:
// https://w3c.github.io/media-capabilities/#dom-workernavigator-mediacapabilities
GC::Ptr<MediaCapabilitiesAPI::MediaCapabilities> m_media_capabilities;
- // https://wicg.github.io/serial/#extensions-to-the-workernavigator-interface
- GC::Ptr<Serial::Serial> m_serial;
-
GC::Ptr<ServiceWorker::ServiceWorkerContainer> m_service_worker_container;
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
diff --git a/Libraries/LibWeb/HTML/WorkerNavigator.idl b/Libraries/LibWeb/HTML/WorkerNavigator.idl
index 398eaae5d7f..441d91b49f9 100644
--- a/Libraries/LibWeb/HTML/WorkerNavigator.idl
+++ b/Libraries/LibWeb/HTML/WorkerNavigator.idl
@@ -4,9 +4,6 @@ interface WorkerNavigator {
// https://w3c.github.io/media-capabilities/#dom-workernavigator-mediacapabilities
[SameObject] readonly attribute MediaCapabilities mediaCapabilities;
- // https://wicg.github.io/serial/#extensions-to-the-workernavigator-interface
- [SameObject] readonly attribute Serial serial;
-
// https://w3c.github.io/ServiceWorker/#navigator-serviceworker
[SecureContext, SameObject] readonly attribute ServiceWorkerContainer serviceWorker;
diff --git a/Libraries/LibWeb/Serial/Serial.cpp b/Libraries/LibWeb/Serial/Serial.cpp
deleted file mode 100644
index b953d1d7e5a..00000000000
--- a/Libraries/LibWeb/Serial/Serial.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2025, Edwin Hoksberg <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibGC/Heap.h>
-#include <LibWeb/HTML/EventNames.h>
-#include <LibWeb/Serial/Serial.h>
-#include <LibWeb/Serial/SerialPort.h>
-#include <LibWeb/WebIDL/DOMException.h>
-#include <LibWeb/WebIDL/Promise.h>
-
-namespace Web::Serial {
-
-GC_DEFINE_ALLOCATOR(Serial);
-
-GC::Ref<Serial> Serial::create()
-{
- return GC::Heap::the().allocate<Serial>();
-}
-
-Serial::Serial()
- : DOM::EventTarget()
-{
-}
-
-static void reject_unknown_error(GC::Ref<WebIDL::Promise> promise)
-{
- WebIDL::reject_promise(promise, WebIDL::UnknownError::create(Utf16String {}));
-}
-
-// https://wicg.github.io/serial/#requestport-method
-void Serial::request_port(SerialPortRequestOptions const&, GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this's relevant global object's associated Document is not allowed to use the policy-controlled feature named "serial",
- // reject promise with a "SecurityError" DOMException and return promise.
-
- // FIXME: 3. If the relevant global object of this does not have transient activation, reject promise with a "SecurityError" DOMException and return promise.
-
- // FIXME: 4. If options["filters"] is present, then for each filter in options["filters"] run the following steps:
-
- // FIXME: 5. Run the following steps in parallel:
- {
- // FIXME: 1. Let allPorts be an empty list.
-
- // FIXME: 2. For each Bluetooth device registered with the system:
-
- // FIXME: 3. For each available non-Bluetooth serial port:
- {
- // FIXME: 1. Let port be a SerialPort representing the port.
-
- // FIXME: 2. Append port to allPorts.
- }
-
- // FIXME: 4. Prompt the user to grant the site access to a serial port by presenting them with a list of ports
- // in allPorts that match any filter in options["filters"] if present and allPorts otherwise.
-
- // FIXME: 5. If the user does not choose a port, queue a global task on the relevant global object of this using the
- // serial port task source to reject promise with a "NotFoundError" DOMException and abort these steps.
-
- // FIXME: 6. Let port be a SerialPort representing the port chosen by the user.
-
- // FIXME: 7. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with port.
- }
-
- // 6. Return promise.
- dbgln("FIXME: Unimplemented Serial::request_port()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#getports-method
-void Serial::get_ports(GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this's relevant global object's associated Document is not allowed to use the policy-controlled feature named "serial",
- // reject promise with a "SecurityError" DOMException and return promise.
-
- // FIXME: 3. Run the following steps in parallel:
- {
- // FIXME: 1. Let availablePorts be the sequence of available serial ports which the user has allowed the site to
- // access as the result of a previous call to requestPort().
-
- // FIXME: 2. Let ports be the sequence of the SerialPorts representing the ports in availablePorts.
-
- // FIXME: 3. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with ports.
- }
-
- // 4. Return promise.
- dbgln("FIXME: Unimplemented Serial::get_ports()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#onconnect-attribute
-void Serial::set_onconnect(WebIDL::CallbackType* event_handler)
-{
- set_event_handler_attribute(HTML::EventNames::connect, event_handler);
-}
-
-WebIDL::CallbackType* Serial::onconnect()
-{
- return event_handler_attribute(HTML::EventNames::connect);
-}
-
-// https://wicg.github.io/serial/#ondisconnect-attribute
-void Serial::set_ondisconnect(WebIDL::CallbackType* event_handler)
-{
- set_event_handler_attribute(HTML::EventNames::disconnect, event_handler);
-}
-
-WebIDL::CallbackType* Serial::ondisconnect()
-{
- return event_handler_attribute(HTML::EventNames::disconnect);
-}
-
-}
diff --git a/Libraries/LibWeb/Serial/Serial.h b/Libraries/LibWeb/Serial/Serial.h
deleted file mode 100644
index 6f083f87d55..00000000000
--- a/Libraries/LibWeb/Serial/Serial.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2025, Edwin Hoksberg <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Bindings/Serial.h>
-#include <LibWeb/DOM/EventTarget.h>
-#include <LibWeb/WebIDL/Promise.h>
-#include <LibWebCommon/WebIDL/Types.h>
-
-namespace Web::Serial {
-
-using SerialPortRequestOptions = Bindings::SerialPortRequestOptions;
-
-// https://wicg.github.io/serial/#serial-interface
-class Serial : public DOM::EventTarget {
- WEB_WRAPPABLE(Serial, DOM::EventTarget);
- GC_DECLARE_ALLOCATOR(Serial);
-
-public:
- [[nodiscard]] static GC::Ref<Serial> create();
-
- // https://wicg.github.io/serial/#requestport-method
- void request_port(SerialPortRequestOptions const&, GC::Ref<WebIDL::Promise>);
- // https://wicg.github.io/serial/#getports-method
- void get_ports(GC::Ref<WebIDL::Promise>);
-
- // https://wicg.github.io/serial/#onconnect-attribute
- void set_onconnect(WebIDL::CallbackType*);
- WebIDL::CallbackType* onconnect();
-
- // https://wicg.github.io/serial/#ondisconnect-attribute
- void set_ondisconnect(WebIDL::CallbackType*);
- WebIDL::CallbackType* ondisconnect();
-
-private:
- explicit Serial();
-};
-
-}
diff --git a/Libraries/LibWeb/Serial/Serial.idl b/Libraries/LibWeb/Serial/Serial.idl
deleted file mode 100644
index ce3dc89ba9a..00000000000
--- a/Libraries/LibWeb/Serial/Serial.idl
+++ /dev/null
@@ -1,23 +0,0 @@
-// https://wicg.github.io/serial/#serial-interface
-[Exposed=(DedicatedWorker, Window), SecureContext]
-interface Serial : EventTarget {
- attribute EventHandler onconnect;
- attribute EventHandler ondisconnect;
- [CreatesPromise] Promise<sequence<SerialPort>> getPorts();
- [Exposed=Window, CreatesPromise] Promise<SerialPort> requestPort(optional SerialPortRequestOptions options = {});
-};
-
-// https://wicg.github.io/serial/#serialportfilter-dictionary
-dictionary SerialPortFilter {
- unsigned short usbVendorId;
- unsigned short usbProductId;
- // FIXME: Should be a BluetoothServiceUUID
- DOMString bluetoothServiceClassId;
-};
-
-// https://wicg.github.io/serial/#serialportrequestoptions-dictionary
-dictionary SerialPortRequestOptions {
- sequence<SerialPortFilter> filters;
- // FIXME: Should be a BluetoothServiceUUID
- sequence<DOMString> allowedBluetoothServiceClassIds;
-};
diff --git a/Libraries/LibWeb/Serial/SerialPort.cpp b/Libraries/LibWeb/Serial/SerialPort.cpp
deleted file mode 100644
index 1395de4735f..00000000000
--- a/Libraries/LibWeb/Serial/SerialPort.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2025, Edwin Hoksberg <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWeb/HTML/EventNames.h>
-#include <LibWeb/Serial/SerialPort.h>
-#include <LibWeb/WebIDL/DOMException.h>
-#include <LibWeb/WebIDL/Promise.h>
-
-namespace Web::Serial {
-
-SerialPort::SerialPort()
- : DOM::EventTarget()
-{
-}
-
-static void reject_unknown_error(GC::Ref<WebIDL::Promise> promise)
-{
- WebIDL::reject_promise(promise, WebIDL::UnknownError::create(Utf16String {}));
-}
-
-// https://wicg.github.io/serial/#getinfo-method
-SerialPortInfo SerialPort::get_info() const
-{
- // 1. Let info be an empty ordered map.
- auto info = SerialPortInfo {};
-
- // FIXME: 2. If the port is part of a USB device, perform the following steps:
- {
- // FIXME: 1. Set info["usbVendorId"] to the vendor ID of the device.
-
- // FIXME: 2. Set info["usbProductId"] to the product ID of the device.
- }
-
- // FIXME: 3. If the port is a service on a Bluetooth device, perform the following steps:
- {
- // FIXME: 1. Set info["bluetoothServiceClassId"] to the service class UUID of the Bluetooth service.
- }
-
- // 4. Return info.
- return info;
-}
-
-// https://wicg.github.io/serial/#open-method
-void SerialPort::open(SerialOptions const&, GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this.[[state]] is not "closed", reject promise with an "InvalidStateError" DOMException and return promise.
-
- // FIXME: 3. If options["dataBits"] is not 7 or 8, reject promise with TypeError and return promise.
-
- // FIXME: 4. If options["stopBits"] is not 1 or 2, reject promise with TypeError and return promise.
-
- // FIXME: 5. If options["bufferSize"] is 0, reject promise with TypeError and return promise.
-
- // FIXME: 6. Optionally, if options["bufferSize"] is larger than the implementation is able to support, reject promise with a TypeError and return promise.
-
- // FIXME: 7. Set this.[[state]] to "opening".
-
- // FIXME: 8. Perform the following steps in parallel.
- {
- // FIXME: 1. Invoke the operating system to open the serial port using the connection parameters (or their defaults) specified in options.
-
- // FIXME: 2. If this fails for any reason, queue a global task on the relevant global object of this using the serial port task source to reject promise with a "NetworkError" DOMException and abort these steps.
-
- // FIXME: 3. Set this.[[state]] to "opened".
-
- // FIXME: 4. Set this.[[bufferSize]] to options["bufferSize"].
-
- // FIXME: 5. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
- }
-
- // FIXME: 9. Return promise.
- dbgln("FIXME: Unimplemented SerialPort::open()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#setsignals-method
-void SerialPort::set_signals(SerialOutputSignals const&, GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this.[[state]] is not "opened", reject promise with an "InvalidStateError" DOMException and return promise.
-
- // FIXME: 3. If all of the specified members of signals are not present reject promise with TypeError and return promise.
-
- // FIXME: 4. Perform the following steps in parallel:
- {
- // FIXME: 1. If signals["dataTerminalReady"] is present, invoke the operating system to either assert (if true) or
- // deassert (if false) the "data terminal ready" or "DTR" signal on the serial port.
-
- // FIXME: 2. If signals["requestToSend"] is present, invoke the operating system to either assert (if true) or
- // deassert (if false) the "request to send" or "RTS" signal on the serial port.
-
- // FIXME: 3. If signals["break"] is present, invoke the operating system to either assert (if true) or
- // deassert (if false) the "break" signal on the serial port.
-
- // FIXME: 4. If the operating system fails to change the state of any of these signals for any reason, queue a global task
- // on the relevant global object of this using the serial port task source to reject promise with a "NetworkError" DOMException.
-
- // FIXME: 5. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
- }
-
- // 5. Return promise.
- dbgln("FIXME: Unimplemented SerialPort::set_signals()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#getsignals-method
-void SerialPort::get_signals(GC::Ref<WebIDL::Promise> promise) const
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this.[[state]] is not "opened", reject promise with an "InvalidStateError" DOMException and return promise.
-
- // FIXME: 3. Perform the following steps in parallel:
- {
- // FIXME: 1. Query the operating system for the status of the control signals that may be asserted by the device connected to the serial port.
-
- // FIXME: 2. If the operating system fails to determine the status of these signals for any reason, queue a global task on the relevant global object of
- // this using the serial port task source to reject promise with a "NetworkError" DOMException and abort these steps.
-
- // FIXME: 3. Let dataCarrierDetect be true if the "data carrier detect" or "DCD" signal has been asserted by the device, and false otherwise.
-
- // FIXME: 4. Let clearToSend be true if the "clear to send" or "CTS" signal has been asserted by the device, and false otherwise.
-
- // FIXME: 5. Let ringIndicator be true if the "ring indicator" or "RI" signal has been asserted by the device, and false otherwise.
-
- // FIXME: 6. Let dataSetReady be true if the "data set ready" or "DSR" signal has been asserted by the device, and false otherwise.
-
- // FIXME: 7. Let signals be the ordered map «[ "dataCarrierDetect" → dataCarrierDetect, "clearToSend" → clearToSend, "ringIndicator" → ringIndicator, "dataSetReady" → dataSetReady ]».
-
- // FIXME: 8. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with signals.
- }
-
- // 4. Return promise.
- dbgln("FIXME: Unimplemented SerialPort::get_signals()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#close-method
-void SerialPort::close(GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 2. If this.[[state]] is not "opened", reject promise with an "InvalidStateError" DOMException and return promise.
-
- // FIXME: 3. Let cancelPromise be the result of invoking cancel on this.[[readable]] or a promise resolved with undefined if this.[[readable]] is null.
-
- // FIXME: 4. Let abortPromise be the result of invoking abort on this.[[writable]] or a promise resolved with undefined if this.[[writable]] is null.
-
- // FIXME: 5. Let pendingClosePromise be a new promise.
-
- // FIXME: 6. If this.[[readable]] and this.[[writable]] are null, resolve pendingClosePromise with undefined.
-
- // FIXME: 7. Set this.[[pendingClosePromise]] to pendingClosePromise.
-
- // FIXME: 8. Let combinedPromise be the result of getting a promise to wait for all with «cancelPromise, abortPromise, pendingClosePromise».
-
- // FIXME: 9. Set this.[[state]] to "closing".
-
- // FIXME: 10. React to combinedPromise.
- {
- // If combinedPromise was fulfilled, then:
- // FIXME: 1. Run the following steps in parallel:
- {
- // FIXME: 1. Invoke the operating system to close the serial port and release any associated resources.
-
- // FIXME: 2. Set this.[[state]] to "closed".
-
- // FIXME: 3. Set this.[[readFatal]] and this.[[writeFatal]] to false.
-
- // FIXME: 4. Set this.[[pendingClosePromise]] to null.
-
- // FIXME: 5. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
- }
-
- // If combinedPromise was rejected with reason r, then:
- {
- // FIXME: 1. Set this.[[pendingClosePromise]] to null.
-
- // FIXME: 2. Queue a global task on the relevant global object of this using the serial port task source to reject promise with r.
- }
- }
-
- // 11. Return promise.
- dbgln("FIXME: Unimplemented SerialPort::close()");
- reject_unknown_error(promise);
-}
-
-// https://wicg.github.io/serial/#forget-method
-void SerialPort::forget(GC::Ref<WebIDL::Promise> promise)
-{
- // FIXME: 1. Let promise be a new promise.
-
- // FIXME: 1. If the user agent can't perform this action (e.g. permission was granted by administrator policy), return a promise resolved with undefined.
-
- // FIXME: 2. Run the following steps in parallel:
- {
- // FIXME: 1. Set this.[[state]] to "forgetting".
-
- // FIXME: 2. Remove this from the sequence of serial ports on the system which the user has allowed the site to access as the result of a previous call to requestPort().
-
- // FIXME: 3. Set this.[[state]] to "forgotten".
-
- // FIXME: 4. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
- }
-
- // 7. Return promise.
- dbgln("FIXME: Unimplemented SerialPort::forget()");
- reject_unknown_error(promise);
-}
-
-void SerialPort::visit_edges(Cell::Visitor& visitor)
-{
- Base::visit_edges(visitor);
- visitor.visit(m_readable);
- visitor.visit(m_writable);
- visitor.visit(m_pending_close_promise);
-}
-
-// https://wicg.github.io/serial/#onconnect-attribute-0
-void SerialPort::set_onconnect(WebIDL::CallbackType* event_handler)
-{
- set_event_handler_attribute(HTML::EventNames::connect, event_handler);
-}
-
-WebIDL::CallbackType* SerialPort::onconnect()
-{
- return event_handler_attribute(HTML::EventNames::connect);
-}
-
-// https://wicg.github.io/serial/#ondisconnect-attribute-0
-void SerialPort::set_ondisconnect(WebIDL::CallbackType* event_handler)
-{
- set_event_handler_attribute(HTML::EventNames::disconnect, event_handler);
-}
-
-WebIDL::CallbackType* SerialPort::ondisconnect()
-{
- return event_handler_attribute(HTML::EventNames::disconnect);
-}
-
-}
diff --git a/Libraries/LibWeb/Serial/SerialPort.h b/Libraries/LibWeb/Serial/SerialPort.h
deleted file mode 100644
index cac74820ab9..00000000000
--- a/Libraries/LibWeb/Serial/SerialPort.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2025, Edwin Hoksberg <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Bindings/SerialPort.h>
-#include <LibWeb/DOM/EventTarget.h>
-#include <LibWeb/Export.h>
-#include <LibWeb/Streams/ReadableStream.h>
-#include <LibWeb/Streams/WritableStream.h>
-#include <LibWeb/WebIDL/Promise.h>
-#include <LibWebCommon/WebIDL/Types.h>
-
-namespace Web::Serial {
-
-using SerialInputSignals = Bindings::SerialInputSignals;
-using SerialOptions = Bindings::SerialOptions;
-using SerialOutputSignals = Bindings::SerialOutputSignals;
-using SerialPortInfo = Bindings::SerialPortInfo;
-
-enum SerialPortState : u8 {
- Closed,
- Opening,
- Opened,
- Closing,
- Forgetting,
- Forgotten,
-};
-
-// https://wicg.github.io/serial/#serialport-interface
-class SerialPort : public DOM::EventTarget {
- WEB_WRAPPABLE(SerialPort, DOM::EventTarget);
- GC_DECLARE_ALLOCATOR(SerialPort);
-
-public:
- // https://wicg.github.io/serial/#getinfo-method
- SerialPortInfo get_info() const;
- // https://wicg.github.io/serial/#open-method
- void open(SerialOptions const&, GC::Ref<WebIDL::Promise>);
- // https://wicg.github.io/serial/#setsignals-method
- void set_signals(SerialOutputSignals const&, GC::Ref<WebIDL::Promise>);
- // https://wicg.github.io/serial/#getsignals-method
- void get_signals(GC::Ref<WebIDL::Promise>) const;
- // https://wicg.github.io/serial/#close-method
- void close(GC::Ref<WebIDL::Promise>);
- // https://wicg.github.io/serial/#forget-method
- void forget(GC::Ref<WebIDL::Promise>);
-
- // https://wicg.github.io/serial/#connected-attribute
- bool connected() const { return m_connected; }
- // https://wicg.github.io/serial/#readable-attribute
- GC::Ptr<Streams::ReadableStream> readable() { return m_readable; }
- // https://wicg.github.io/serial/#writable-attribute
- GC::Ptr<Streams::WritableStream> writable() { return m_writable; }
-
- // https://wicg.github.io/serial/#onconnect-attribute-0
- void set_onconnect(WebIDL::CallbackType*);
- WebIDL::CallbackType* onconnect();
-
- // https://wicg.github.io/serial/#ondisconnect-attribute-0
- void set_ondisconnect(WebIDL::CallbackType*);
- WebIDL::CallbackType* ondisconnect();
-
-protected:
- virtual void visit_edges(Cell::Visitor&) override;
-
-private:
- explicit SerialPort();
-
- // https://wicg.github.io/serial/#dfn-state
- // Tracks the active state of the SerialPort
- SerialPortState m_state { SerialPortState::Closed };
-
- // https://wicg.github.io/serial/#dfn-buffersize
- // The amount of data to buffer for transmit and receive
- unsigned long m_buffer_size = {};
-
- // https://wicg.github.io/serial/#dfn-connected
- // A flag indicating the logical connection state of serial port
- bool m_connected { false };
-
- // https://wicg.github.io/serial/#dfn-readable
- // A ReadableStream that receives data from the port
- GC::Ptr<Streams::ReadableStream> m_readable = {};
-
- // https://wicg.github.io/serial/#dfn-readfatal
- // A flag indicating that the port has encountered a fatal read error
- bool m_read_fatal { false };
-
- // https://wicg.github.io/serial/#dfn-writable
- // A WritableStream that transmits data to the port
- GC::Ptr<Streams::WritableStream> m_writable = {};
-
- // https://wicg.github.io/serial/#dfn-writefatal
- // A flag indicating that the port has encountered a fatal write error
- bool m_write_fatal { false };
-
- // https://wicg.github.io/serial/#dfn-pendingclosepromise
- // A Promise used to wait for readable and writable to close
- GC::Ptr<WebIDL::Promise> m_pending_close_promise = {};
-};
-
-}
diff --git a/Libraries/LibWeb/Serial/SerialPort.idl b/Libraries/LibWeb/Serial/SerialPort.idl
deleted file mode 100644
index f6331fb8447..00000000000
--- a/Libraries/LibWeb/Serial/SerialPort.idl
+++ /dev/null
@@ -1,63 +0,0 @@
-// https://wicg.github.io/serial/#serialport-interface
-[Exposed=(DedicatedWorker,Window), SecureContext]
-interface SerialPort : EventTarget {
- attribute EventHandler onconnect;
- attribute EventHandler ondisconnect;
- readonly attribute boolean connected;
- readonly attribute ReadableStream? readable;
- readonly attribute WritableStream? writable;
-
- SerialPortInfo getInfo();
-
- [CreatesPromise] Promise<undefined> open(SerialOptions options);
- [CreatesPromise] Promise<undefined> setSignals(optional SerialOutputSignals signals = {});
- [CreatesPromise] Promise<SerialInputSignals> getSignals();
- [CreatesPromise] Promise<undefined> close();
- [CreatesPromise] Promise<undefined> forget();
-};
-
-// https://wicg.github.io/serial/#serialoptions-dictionary
-dictionary SerialOptions {
- [EnforceRange] required unsigned long baudRate;
- [EnforceRange] octet dataBits = 8;
- [EnforceRange] octet stopBits = 1;
- ParityType parity = "none";
- [EnforceRange] unsigned long bufferSize = 255;
- FlowControlType flowControl = "none";
-};
-
-// https://wicg.github.io/serial/#serialoutputsignals-dictionary
-dictionary SerialOutputSignals {
- boolean dataTerminalReady;
- boolean requestToSend;
- boolean break;
-};
-
-// https://wicg.github.io/serial/#serialinputsignals-dictionary
-dictionary SerialInputSignals {
- required boolean dataCarrierDetect;
- required boolean clearToSend;
- required boolean ringIndicator;
- required boolean dataSetReady;
-};
-
-// https://wicg.github.io/serial/#serialportinfo-dictionary
-dictionary SerialPortInfo {
- unsigned short usbVendorId;
- unsigned short usbProductId;
- // FIXME: Should be a BluetoothServiceUUID
- DOMString bluetoothServiceClassId;
-};
-
-// https://wicg.github.io/serial/#paritytype-enum
-enum ParityType {
- "none",
- "even",
- "odd"
-};
-
-// https://wicg.github.io/serial/#flowcontroltype-enum
-enum FlowControlType {
- "none",
- "hardware"
-};
diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake
index c149f0c0d26..28d13f27440 100644
--- a/Libraries/LibWeb/idl_files.cmake
+++ b/Libraries/LibWeb/idl_files.cmake
@@ -454,8 +454,6 @@ libweb_js_bindings(ResizeObserver/ResizeObserverEntry)
libweb_js_bindings(ResizeObserver/ResizeObserverSize)
libweb_js_bindings(ResourceTiming/PerformanceResourceTiming)
libweb_js_bindings(Selection/Selection)
-libweb_js_bindings(Serial/Serial)
-libweb_js_bindings(Serial/SerialPort)
libweb_js_bindings(ServerTiming/PerformanceResourceTimingExtensions)
libweb_js_bindings(ServerTiming/PerformanceServerTiming)
libweb_js_bindings(ServiceWorker/Cache)
diff --git a/Meta/Generators/libweb_bindings/REALM_POLICY.md b/Meta/Generators/libweb_bindings/REALM_POLICY.md
index 4302e9f376e..494f294cd66 100644
--- a/Meta/Generators/libweb_bindings/REALM_POLICY.md
+++ b/Meta/Generators/libweb_bindings/REALM_POLICY.md
@@ -44,7 +44,7 @@ Current `[NeedsCallerRealm]` opt-out categories:
- WebAssembly JS API objects and namespace functions: JS-API algorithms create
ArrayBuffers, typed arrays, and promises in the caller realm.
-- Promise/body/fetch/cache/credential/permission/serial/gamepad/media APIs:
+- Promise/body/fetch/cache/credential/permission/gamepad/media APIs:
promise capability and result object allocation is caller-observable.
- Structured serialization APIs (`postMessage`, `History`, `Navigation`
state): cloning/deserialization is defined against the caller/current realm.
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 821fa526da4..f32a56084dd 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -554,7 +554,6 @@ Text/input/wpt-import/notifications/idlharness.https.any.html
Text/input/wpt-import/permissions/idlharness.any.html
Text/input/wpt-import/permissions/idlharness.any.worker.html
Text/input/wpt-import/scroll-animations/scroll-timelines/idlharness.window.html
-Text/input/wpt-import/serial/idlharness.https.any.html
Text/input/wpt-import/server-timing/idlharness.https.any.html
Text/input/wpt-import/server-timing/idlharness.https.any.worker.html
Text/input/wpt-import/speech-api/idlharness.https.window.html
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index 32852dbd263..9cecff5d60f 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -538,8 +538,6 @@ ScriptProcessorNode
ScrollTimeline
SecurityPolicyViolationEvent
Selection
-Serial
-SerialPort
ServiceWorker
ServiceWorkerContainer
ServiceWorkerRegistration
diff --git a/Tests/LibWeb/Text/expected/wpt-import/serial/idlharness.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/serial/idlharness.https.any.txt
deleted file mode 100644
index c60f122ea71..00000000000
--- a/Tests/LibWeb/Text/expected/wpt-import/serial/idlharness.https.any.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-Harness status: OK
-
-Found 57 tests
-
-57 Pass
-Pass idl_test setup
-Pass idl_test validation
-Pass Partial interface Navigator: original interface defined
-Pass Partial interface Navigator: valid exposure set
-Pass Partial interface Navigator: member names are unique
-Pass Partial interface WorkerNavigator: original interface defined
-Pass Partial interface WorkerNavigator: valid exposure set
-Pass Partial interface WorkerNavigator: member names are unique
-Pass Partial interface Navigator[2]: member names are unique
-Pass Partial interface mixin NavigatorID: member names are unique
-Pass Navigator includes NavigatorID: member names are unique
-Pass Navigator includes NavigatorLanguage: member names are unique
-Pass Navigator includes NavigatorOnLine: member names are unique
-Pass Navigator includes NavigatorContentUtils: member names are unique
-Pass Navigator includes NavigatorCookies: member names are unique
-Pass Navigator includes NavigatorPlugins: member names are unique
-Pass Navigator includes NavigatorConcurrentHardware: member names are unique
-Pass WorkerNavigator includes NavigatorID: member names are unique
-Pass WorkerNavigator includes NavigatorLanguage: member names are unique
-Pass WorkerNavigator includes NavigatorOnLine: member names are unique
-Pass WorkerNavigator includes NavigatorConcurrentHardware: member names are unique
-Pass Serial interface: existence and properties of interface object
-Pass Serial interface object length
-Pass Serial interface object name
-Pass Serial interface: existence and properties of interface prototype object
-Pass Serial interface: existence and properties of interface prototype object's "constructor" property
-Pass Serial interface: existence and properties of interface prototype object's @@unscopables property
-Pass Serial interface: attribute onconnect
-Pass Serial interface: attribute ondisconnect
-Pass Serial interface: operation getPorts()
-Pass Serial interface: operation requestPort(optional SerialPortRequestOptions)
-Pass Serial must be primary interface of navigator.serial
-Pass Stringification of navigator.serial
-Pass Serial interface: navigator.serial must inherit property "onconnect" with the proper type
-Pass Serial interface: navigator.serial must inherit property "ondisconnect" with the proper type
-Pass Serial interface: navigator.serial must inherit property "getPorts()" with the proper type
-Pass Serial interface: navigator.serial must inherit property "requestPort(optional SerialPortRequestOptions)" with the proper type
-Pass Serial interface: calling requestPort(optional SerialPortRequestOptions) on navigator.serial with too few arguments must throw TypeError
-Pass SerialPort interface: existence and properties of interface object
-Pass SerialPort interface object length
-Pass SerialPort interface object name
-Pass SerialPort interface: existence and properties of interface prototype object
-Pass SerialPort interface: existence and properties of interface prototype object's "constructor" property
-Pass SerialPort interface: existence and properties of interface prototype object's @@unscopables property
-Pass SerialPort interface: attribute onconnect
-Pass SerialPort interface: attribute ondisconnect
-Pass SerialPort interface: attribute connected
-Pass SerialPort interface: attribute readable
-Pass SerialPort interface: attribute writable
-Pass SerialPort interface: operation getInfo()
-Pass SerialPort interface: operation open(SerialOptions)
-Pass SerialPort interface: operation setSignals(optional SerialOutputSignals)
-Pass SerialPort interface: operation getSignals()
-Pass SerialPort interface: operation close()
-Pass SerialPort interface: operation forget()
-Pass Navigator interface: attribute serial
-Pass Navigator interface: navigator must inherit property "serial" with the proper type
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/interfaces/serial.idl b/Tests/LibWeb/Text/input/wpt-import/interfaces/serial.idl
deleted file mode 100644
index 71b595100c4..00000000000
--- a/Tests/LibWeb/Text/input/wpt-import/interfaces/serial.idl
+++ /dev/null
@@ -1,89 +0,0 @@
-// GENERATED CONTENT - DO NOT EDIT
-// Content was automatically extracted by Reffy into webref
-// (https://github.com/w3c/webref)
-// Source: Web Serial API (https://wicg.github.io/serial/)
-
-[Exposed=Window, SecureContext]
-partial interface Navigator {
- [SameObject] readonly attribute Serial serial;
-};
-
-[Exposed=DedicatedWorker, SecureContext]
-partial interface WorkerNavigator {
- [SameObject] readonly attribute Serial serial;
-};
-
-[Exposed=(DedicatedWorker, Window), SecureContext]
-interface Serial : EventTarget {
- attribute EventHandler onconnect;
- attribute EventHandler ondisconnect;
- Promise<sequence<SerialPort>> getPorts();
- [Exposed=Window] Promise<SerialPort> requestPort(optional SerialPortRequestOptions options = {});
-};
-
-dictionary SerialPortRequestOptions {
- sequence<SerialPortFilter> filters;
- sequence<BluetoothServiceUUID> allowedBluetoothServiceClassIds;
-};
-
-dictionary SerialPortFilter {
- unsigned short usbVendorId;
- unsigned short usbProductId;
- BluetoothServiceUUID bluetoothServiceClassId;
-};
-
-[Exposed=(DedicatedWorker,Window), SecureContext]
-interface SerialPort : EventTarget {
- attribute EventHandler onconnect;
- attribute EventHandler ondisconnect;
- readonly attribute boolean connected;
- readonly attribute ReadableStream? readable;
- readonly attribute WritableStream? writable;
-
- SerialPortInfo getInfo();
-
- Promise<undefined> open(SerialOptions options);
- Promise<undefined> setSignals(optional SerialOutputSignals signals = {});
- Promise<SerialInputSignals> getSignals();
- Promise<undefined> close();
- Promise<undefined> forget();
-};
-
-dictionary SerialPortInfo {
- unsigned short usbVendorId;
- unsigned short usbProductId;
- BluetoothServiceUUID bluetoothServiceClassId;
-};
-
-dictionary SerialOptions {
- [EnforceRange] required unsigned long baudRate;
- [EnforceRange] octet dataBits = 8;
- [EnforceRange] octet stopBits = 1;
- ParityType parity = "none";
- [EnforceRange] unsigned long bufferSize = 255;
- FlowControlType flowControl = "none";
-};
-
-enum ParityType {
- "none",
- "even",
- "odd"
-};
-
-enum FlowControlType {
- "none",
- "hardware"
-};
-
-dictionary SerialOutputSignals {
- boolean dataTerminalReady;
- boolean requestToSend;
- boolean break;
-};
-
-dictionary SerialInputSignals {
- required boolean dataCarrierDetect;
- required boolean clearToSend;
- required boolean ringIndicator;
- required boolean dataSetReady;
-};
diff --git a/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.html b/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.html
deleted file mode 100644
index a76b59fbc1b..00000000000
--- a/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-
-<script>
-self.GLOBAL = {
- isWindow: function() { return true; },
- isWorker: function() { return false; },
- isShadowRealm: function() { return false; },
-};
-</script>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="../resources/WebIDLParser.js"></script>
-<script src="../resources/idlharness.js"></script>
-<div id=log></div>
-<script src="../serial/idlharness.https.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.js b/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.js
deleted file mode 100644
index b240da933ad..00000000000
--- a/Tests/LibWeb/Text/input/wpt-import/serial/idlharness.https.any.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// META: script=/resources/WebIDLParser.js
-// META: script=/resources/idlharness.js
-
-'use strict';
-
-idl_test(
- ['serial'],
- ['html', 'dom'],
- idl_array => {
- idl_array.add_objects({
- Serial: ['navigator.serial'],
- // TODO: SerialPort
- // TODO: SerialPortInfo
- });
-
- if (self.GLOBAL.isWorker()) {
- idl_array.add_objects({ WorkerNavigator: ['navigator'] });
- } else {
- idl_array.add_objects({ Navigator: ['navigator'] });
- }
- }
-);