mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb/HTML: Add environment discarding steps
Exactly one place seems to define these at the moment: service worker clients. Since we don't have a type for these and just use EnvironmentSettingsObject, I've put it there.
This commit is contained in:
parent
a15a55e858
commit
5a4f15d8f5
Notes:
github-actions[bot]
2025-03-14 17:06:43 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/5a4f15d8f58 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3914 Reviewed-by: https://github.com/gmta ✅
4 changed files with 24 additions and 2 deletions
|
@ -1287,7 +1287,13 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
|
|||
|
||||
// 4. If navigationParams is not null, then:
|
||||
if (!navigation_params.has<NullOrError>()) {
|
||||
// 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<NavigationParams> 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.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<JS::ExecutionContext>);
|
||||
|
||||
|
|
|
@ -156,7 +156,9 @@ void DedicatedWorkerHost::run(GC::Ref<Web::Page> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue