diff --git a/Userland/Libraries/LibWeb/HTML/Worker.idl b/Userland/Libraries/LibWeb/HTML/Worker.idl
index b439406b6e7..1980c0ce0d2 100644
--- a/Userland/Libraries/LibWeb/HTML/Worker.idl
+++ b/Userland/Libraries/LibWeb/HTML/Worker.idl
@@ -2,6 +2,7 @@
#import
#import
#import
+#import
// https://html.spec.whatwg.org/#worker
[Exposed=(Window,DedicatedWorker,SharedWorker)]
@@ -18,9 +19,11 @@ interface Worker : EventTarget {
};
dictionary WorkerOptions {
- USVString type = "classic";
- USVString credentials = "same-origin";
+ WorkerType type = "classic";
+ RequestCredentials credentials = "same-origin";
DOMString name = "";
};
+enum WorkerType { "classic", "module" };
+
Worker includes AbstractWorker;
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerAgent.h b/Userland/Libraries/LibWeb/HTML/WorkerAgent.h
index 24acd7a2a56..d0f4bd8b68e 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerAgent.h
+++ b/Userland/Libraries/LibWeb/HTML/WorkerAgent.h
@@ -6,6 +6,8 @@
#pragma once
+#include
+#include
#include
#include
#include
@@ -13,8 +15,8 @@
namespace Web::HTML {
struct WorkerOptions {
- String type { "classic"_string };
- String credentials { "same-origin"_string };
+ Bindings::WorkerType type { Bindings::WorkerType::Classic };
+ Bindings::RequestCredentials credentials { Bindings::RequestCredentials::SameOrigin };
String name { String {} };
};
diff --git a/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc b/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc
index 0c218111547..240e469ab69 100644
--- a/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc
+++ b/Userland/Libraries/LibWeb/Worker/WebWorkerServer.ipc
@@ -2,10 +2,11 @@
#include
#include
#include
+#include
endpoint WebWorkerServer {
- start_dedicated_worker(URL::URL url, String type, String credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =|
+ start_dedicated_worker(URL::URL url, Web::Bindings::WorkerType type, Web::Bindings::RequestCredentials credentials, String name, Web::HTML::TransferDataHolder message_port, Web::HTML::SerializedEnvironmentSettingsObject outside_settings) =|
close_worker() =|
diff --git a/Userland/Services/WebWorker/ConnectionFromClient.cpp b/Userland/Services/WebWorker/ConnectionFromClient.cpp
index 7cf23268651..3ecaceb4f49 100644
--- a/Userland/Services/WebWorker/ConnectionFromClient.cpp
+++ b/Userland/Services/WebWorker/ConnectionFromClient.cpp
@@ -63,7 +63,7 @@ Web::Page const& ConnectionFromClient::page() const
return m_page_host->page();
}
-void ConnectionFromClient::start_dedicated_worker(URL::URL const& url, String const& type, String const&, String const& name, Web::HTML::TransferDataHolder const& implicit_port, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings)
+void ConnectionFromClient::start_dedicated_worker(URL::URL const& url, Web::Bindings::WorkerType const& type, Web::Bindings::RequestCredentials const&, String const& name, Web::HTML::TransferDataHolder const& implicit_port, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings)
{
m_worker_host = make_ref_counted(url, type, name);
// FIXME: Yikes, const_cast to move? Feels like a LibIPC bug.
diff --git a/Userland/Services/WebWorker/ConnectionFromClient.h b/Userland/Services/WebWorker/ConnectionFromClient.h
index b6d86c3edfe..3fa2f64aaf9 100644
--- a/Userland/Services/WebWorker/ConnectionFromClient.h
+++ b/Userland/Services/WebWorker/ConnectionFromClient.h
@@ -41,7 +41,7 @@ private:
Web::Page& page();
Web::Page const& page() const;
- virtual void start_dedicated_worker(URL::URL const& url, String const& type, String const&, String const& name, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override;
+ virtual void start_dedicated_worker(URL::URL const& url, Web::Bindings::WorkerType const& type, Web::Bindings::RequestCredentials const& credentials, String const& name, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override;
virtual void handle_file_return(i32 error, Optional const& file, i32 request_id) override;
JS::Handle m_page_host;
diff --git a/Userland/Services/WebWorker/DedicatedWorkerHost.cpp b/Userland/Services/WebWorker/DedicatedWorkerHost.cpp
index 13fcaf22329..262b935c97a 100644
--- a/Userland/Services/WebWorker/DedicatedWorkerHost.cpp
+++ b/Userland/Services/WebWorker/DedicatedWorkerHost.cpp
@@ -21,9 +21,9 @@
namespace WebWorker {
-DedicatedWorkerHost::DedicatedWorkerHost(URL::URL url, String type, String name)
+DedicatedWorkerHost::DedicatedWorkerHost(URL::URL url, Web::Bindings::WorkerType type, String name)
: m_url(move(url))
- , m_type(move(type))
+ , m_type(type)
, m_name(move(name))
{
}
@@ -219,14 +219,14 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr page, Web::HTML::Trans
// and with onComplete and performFetch as defined below.
// module: Fetch a module worker script graph given url, outside settings, destination, the value of the credentials member of options, inside settings,
// and with onComplete and performFetch as defined below.
- if (m_type == "classic"sv) {
+ if (m_type == Web::Bindings::WorkerType::Classic) {
if (auto err = Web::HTML::fetch_classic_worker_script(m_url, outside_settings, destination, inner_settings, perform_fetch, on_complete); err.is_error()) {
dbgln("Failed to run worker script");
// FIXME: Abort the worker properly
TODO();
}
} else {
- VERIFY(m_type == "module"sv);
+ VERIFY(m_type == Web::Bindings::WorkerType::Module);
// FIXME: Pass credentials
if (auto err = Web::HTML::fetch_module_worker_script_graph(m_url, outside_settings, destination, inner_settings, perform_fetch, on_complete); err.is_error()) {
dbgln("Failed to run worker script");
diff --git a/Userland/Services/WebWorker/DedicatedWorkerHost.h b/Userland/Services/WebWorker/DedicatedWorkerHost.h
index 9fe1f05ce93..7712ec157d4 100644
--- a/Userland/Services/WebWorker/DedicatedWorkerHost.h
+++ b/Userland/Services/WebWorker/DedicatedWorkerHost.h
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -17,7 +18,7 @@ namespace WebWorker {
class DedicatedWorkerHost : public RefCounted {
public:
- explicit DedicatedWorkerHost(URL::URL url, String type, String name);
+ explicit DedicatedWorkerHost(URL::URL url, Web::Bindings::WorkerType type, String name);
~DedicatedWorkerHost();
void run(JS::NonnullGCPtr, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const&);
@@ -26,7 +27,7 @@ private:
JS::Handle m_console;
URL::URL m_url;
- String m_type;
+ Web::Bindings::WorkerType m_type;
String m_name;
};