Skip to content

Truly independent web browser

LibWebView: Keep a worker's script blob URL alive until it is loaded

Andreas Kling7db45d907598
diff --git a/Libraries/LibWebView/WorkerProcessManager.cpp b/Libraries/LibWebView/WorkerProcessManager.cpp
index 6baf1a4c3f7..b1f4566fbea 100644
--- a/Libraries/LibWebView/WorkerProcessManager.cpp
+++ b/Libraries/LibWebView/WorkerProcessManager.cpp
@@ -300,8 +300,14 @@ Web::HTML::WorkerAgentId WorkerProcessManager::start_worker_agent(Owner owner, O
.owners = move(owners),
.inside_settings = move(inside_settings),
.may_read_local_files = may_read_local_files,
+ .script_blob_url = {},
};
+ // NB: The worker's URL was parsed with its blob URL entry, so revoking the URL must not stop the worker from
+ // fetching its script.
+ if (auto session = client->session())
+ agent.script_blob_url = BlobURLHandle::for_url(session->blob_url_store.ptr(), request.url);
+
if (request.agent_type == Web::HTML::AgentType::SharedWorker) {
agent.shared_worker_key = SharedWorkerKey {
.is_private = is_private,
@@ -551,6 +557,7 @@ void WorkerProcessManager::worker_did_finish_loading_script(Web::HTML::WorkerAge
auto& agent = maybe_agent->value;
agent.worker_is_secure_context = worker_is_secure_context;
+ agent.script_blob_url = {};
}
void WorkerProcessManager::worker_did_fail_loading_script(Web::HTML::WorkerAgentId agent_id)
diff --git a/Libraries/LibWebView/WorkerProcessManager.h b/Libraries/LibWebView/WorkerProcessManager.h
index 0c27a1c41ff..5b96f2df21a 100644
--- a/Libraries/LibWebView/WorkerProcessManager.h
+++ b/Libraries/LibWebView/WorkerProcessManager.h
@@ -23,6 +23,7 @@
#include <LibWebCommon/HTML/WorkerAgentTypes.h>
#include <LibWebCommon/Loader/NavigatorCompatibilityMode.h>
#include <LibWebCommon/Page/PageId.h>
+#include <LibWebView/BlobURLStore.h>
#include <LibWebView/BrowsingSession.h>
#include <LibWebView/Forward.h>
@@ -138,6 +139,9 @@ private:
Vector<Owner> owners;
NonnullOwnPtr<CanonicalWorkerEnvironmentSettingsObject> inside_settings;
bool may_read_local_files { false };
+ // Keeps the blob URL entry of the worker's script alive until the script is loaded, so that the owner can
+ // revoke the URL right after constructing the worker.
+ BlobURLHandle script_blob_url;
};
// A worker whose agent is gone counts toward the workers of its top-level site until its process exits, or until its
diff --git a/Tests/LibWeb/Text/expected/Worker/Worker-blob-url-revoked-after-construction.txt b/Tests/LibWeb/Text/expected/Worker/Worker-blob-url-revoked-after-construction.txt
index 8276753746b..0279c7bf6ad 100644
--- a/Tests/LibWeb/Text/expected/Worker/Worker-blob-url-revoked-after-construction.txt
+++ b/Tests/LibWeb/Text/expected/Worker/Worker-blob-url-revoked-after-construction.txt
@@ -1 +1 @@
-error
+message: hello