diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp
index 88570545cfa..a579aad692e 100644
--- a/Libraries/LibWeb/HTML/Navigable.cpp
+++ b/Libraries/LibWeb/HTML/Navigable.cpp
@@ -1287,7 +1287,13 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document(
// 4. If navigationParams is not null, then:
if (!navigation_params.has()) {
- // FIXME: 1. Run the environment discarding steps for navigationParams's reserved environment.
+ // 1. Run the environment discarding steps for navigationParams's reserved environment.
+ navigation_params.visit(
+ [](GC::Ref const& it) {
+ it->reserved_environment->discard_environment();
+ },
+ [](auto const&) {});
+
// FIXME: 2. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is navigationParams's response's URL.
}
}
diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cpp
index 1f0140b4347..16ad19bf15d 100644
--- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp
+++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp
@@ -67,6 +67,15 @@ void EnvironmentSettingsObject::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_service_worker_object_map);
}
+void EnvironmentSettingsObject::discard_environment()
+{
+ // https://w3c.github.io/ServiceWorker/#ref-for-environment-discarding-steps
+ // Each service worker client has the following environment discarding steps:
+
+ // 1. Set client’s discarded flag.
+ set_discarded(true);
+}
+
JS::ExecutionContext& EnvironmentSettingsObject::realm_execution_context()
{
// NOTE: All environment settings objects are created with a realm execution context, so it's stored and returned here in the base class.
diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.h b/Libraries/LibWeb/HTML/Scripting/Environments.h
index affcb5d3f27..21879f1dfb3 100644
--- a/Libraries/LibWeb/HTML/Scripting/Environments.h
+++ b/Libraries/LibWeb/HTML/Scripting/Environments.h
@@ -46,6 +46,9 @@ public:
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-execution-ready-flag
bool execution_ready { false };
+ // https://html.spec.whatwg.org/multipage/webappapis.html#environment-discarding-steps
+ virtual void discard_environment() { }
+
protected:
virtual void visit_edges(Cell::Visitor&) override;
};
@@ -115,6 +118,8 @@ public:
[[nodiscard]] bool discarded() const { return m_discarded; }
void set_discarded(bool b) { m_discarded = b; }
+ virtual void discard_environment() override;
+
protected:
explicit EnvironmentSettingsObject(NonnullOwnPtr);
diff --git a/Services/WebWorker/DedicatedWorkerHost.cpp b/Services/WebWorker/DedicatedWorkerHost.cpp
index a2b7087bcbf..9ebabc5430d 100644
--- a/Services/WebWorker/DedicatedWorkerHost.cpp
+++ b/Services/WebWorker/DedicatedWorkerHost.cpp
@@ -156,7 +156,9 @@ void DedicatedWorkerHost::run(GC::Ref page, Web::HTML::TransferDataHo
if (!script || !script->error_to_rethrow().is_null()) {
// FIXME: 1. Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
// FIXME: Notify Worker parent through IPC to fire an error event at Worker
- // FIXME 2. Run the environment discarding steps for inside settings.
+
+ // 2. Run the environment discarding steps for inside settings.
+ inside_settings->discard_environment();
// 3. Abort these steps.
dbgln("DedicatedWorkerHost: Unable to fetch script {} because {}", url, script ? script->error_to_rethrow().to_string_without_side_effects() : "script was null"_string);