From 7402ae3a00be9545a7b6f3a385a9e252d702f96c Mon Sep 17 00:00:00 2001 From: Jonne Ransijn Date: Sun, 3 Nov 2024 16:31:39 +0100 Subject: [PATCH] LibWeb: Use the realm from the `ServiceWorker` client `vm.realm()` might not exist, and was probably not even the right realm to use in the first place. --- Userland/Libraries/LibWeb/ServiceWorker/Job.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/ServiceWorker/Job.cpp b/Userland/Libraries/LibWeb/ServiceWorker/Job.cpp index b0bfd6b90eb..c8eb4be873d 100644 --- a/Userland/Libraries/LibWeb/ServiceWorker/Job.cpp +++ b/Userland/Libraries/LibWeb/ServiceWorker/Job.cpp @@ -401,7 +401,7 @@ static void update(JS::VM& vm, JS::NonnullGCPtr job) // 16. If runResult is failure or an abrupt completion, then: // 17. Else, invoke Install algorithm with job, worker, and registration as its arguments. if (job->client) { - auto& realm = *vm.current_realm(); + auto& realm = job->client->realm(); auto context = HTML::TemporaryExecutionContext(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes); WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion(JS::ErrorType::NotImplemented, "Run Service Worker"sv).value()); finish_job(vm, job); @@ -428,7 +428,7 @@ static void unregister(JS::VM& vm, JS::NonnullGCPtr job) { // If there's no client, there won't be any promises to resolve if (job->client) { - auto& realm = *vm.current_realm(); + auto& realm = job->client->realm(); auto context = HTML::TemporaryExecutionContext(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes); WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion(JS::ErrorType::NotImplemented, "Service Worker unregistration"sv).value()); finish_job(vm, job);