Skip to content

Truly independent web browser

LibWeb+LibHTTP: Stop carrying bytecode through fetch

Andreas Kling8eaad740f94c
diff --git a/Libraries/LibHTTP/Cache/MemoryCache.cpp b/Libraries/LibHTTP/Cache/MemoryCache.cpp
index 786e1ffd2b5..addd5d4b86a 100644
--- a/Libraries/LibHTTP/Cache/MemoryCache.cpp
+++ b/Libraries/LibHTTP/Cache/MemoryCache.cpp
@@ -16,8 +16,7 @@ NonnullRefPtr<MemoryCache> MemoryCache::create()
}
// A stored response satisfies a request only if the request header fields nominated by the response's Vary header
-// match those of the request that produced the entry, per RFC 9111 4.1. open_entry() and update_javascript_bytecode_cache()
-// must select entries identically, so share the predicate.
+// match those of the request that produced the entry, per RFC 9111 4.1.
static bool entry_matches_request(HeaderList const& request_headers, MemoryCache::Entry const& entry)
{
return create_vary_key(request_headers, entry.response_headers) == entry.vary_key;
@@ -98,7 +97,7 @@ Optional<MemoryCache::Entry const&> MemoryCache::open_entry(URL::URL const& url,
VERIFY_NOT_REACHED();
}
-void MemoryCache::create_entry(URL::URL const& url, StringView method, HeaderList const& request_headers, UnixDateTime request_time, u32 status_code, ByteString reason_phrase, HeaderList const& received_response_headers, Optional<Core::ImmutableBytes> javascript_bytecode_cache, Optional<u64> javascript_bytecode_cache_vary_key)
+void MemoryCache::create_entry(URL::URL const& url, StringView method, HeaderList const& request_headers, UnixDateTime request_time, u32 status_code, ByteString reason_phrase, HeaderList const& received_response_headers)
{
auto response_headers_without_connection_specific_fields = remove_connection_specific_fields(received_response_headers);
auto const& response_headers = *response_headers_without_connection_specific_fields;
@@ -125,9 +124,6 @@ void MemoryCache::create_entry(URL::URL const& url, StringView method, HeaderLis
return;
}
- auto request_headers_copy = HeaderList::create();
- store_header_and_trailer_fields(request_headers_copy, request_headers);
-
auto response_headers_copy = HeaderList::create();
store_header_and_trailer_fields(response_headers_copy, response_headers);
@@ -135,11 +131,8 @@ void MemoryCache::create_entry(URL::URL const& url, StringView method, HeaderLis
.vary_key = *vary_key,
.status_code = status_code,
.reason_phrase = move(reason_phrase),
- .request_headers = move(request_headers_copy),
.response_headers = move(response_headers_copy),
.response_body = {},
- .javascript_bytecode_cache = move(javascript_bytecode_cache),
- .javascript_bytecode_cache_vary_key = javascript_bytecode_cache_vary_key,
.request_time = request_time,
.response_time = UnixDateTime::now(),
};
@@ -210,35 +203,6 @@ Optional<MemoryCache::Entry> MemoryCache::take_pending_entry(u64 cache_key, Opti
return cache_entry;
}
-void MemoryCache::update_javascript_bytecode_cache(URL::URL const& url, StringView method, HeaderList const& request_headers, u64 vary_key, Core::ImmutableBytes javascript_bytecode_cache)
-{
- if (!is_cacheable(method, request_headers))
- return;
-
- auto serialized_url = serialize_url_for_cache_storage(url);
- auto cache_key = create_cache_key(serialized_url, method);
-
- // Attach the generated bytecode to every cache entry this request would select. Match entries the same way
- // open_entry() does, by re-deriving the vary key from the request and the entry's stored response headers, rather
- // than trusting the supplied vary key (which was computed in another process and can diverge for Vary responses).
- // The supplied vary key is still kept as javascript_bytecode_cache_vary_key so it can be replayed onto a served
- // response.
- auto update_entries = [&](Vector<Entry>& entries) {
- for (auto& entry : entries) {
- if (!entry_matches_request(request_headers, entry))
- continue;
- entry.javascript_bytecode_cache = javascript_bytecode_cache;
- entry.javascript_bytecode_cache_vary_key = vary_key;
- }
- };
-
- if (auto cache_entries = m_complete_entries.get(cache_key); cache_entries.has_value())
- update_entries(*cache_entries);
-
- if (auto cache_entries = m_pending_entries.get(cache_key); cache_entries.has_value())
- update_entries(*cache_entries);
-}
-
// https://httpwg.org/specs/rfc9111.html#invalidation
void MemoryCache::invalidate(URL::URL const& url)
{
diff --git a/Libraries/LibHTTP/Cache/MemoryCache.h b/Libraries/LibHTTP/Cache/MemoryCache.h
index 1361148f45c..ebc2306b6be 100644
--- a/Libraries/LibHTTP/Cache/MemoryCache.h
+++ b/Libraries/LibHTTP/Cache/MemoryCache.h
@@ -25,11 +25,8 @@ public:
u32 status_code { 0 };
ByteString reason_phrase;
- NonnullRefPtr<HeaderList> request_headers;
NonnullRefPtr<HeaderList> response_headers;
Core::ImmutableBytes response_body;
- Optional<Core::ImmutableBytes> javascript_bytecode_cache;
- Optional<u64> javascript_bytecode_cache_vary_key;
UnixDateTime request_time;
UnixDateTime response_time;
@@ -39,12 +36,11 @@ public:
Optional<Entry const&> open_entry(URL::URL const&, StringView method, HeaderList const& request_headers, CacheMode);
- void create_entry(URL::URL const&, StringView method, HeaderList const& request_headers, UnixDateTime request_time, u32 status_code, ByteString reason_phrase, HeaderList const& response_headers, Optional<Core::ImmutableBytes> javascript_bytecode_cache = {}, Optional<u64> javascript_bytecode_cache_vary_key = {});
+ void create_entry(URL::URL const&, StringView method, HeaderList const& request_headers, UnixDateTime request_time, u32 status_code, ByteString reason_phrase, HeaderList const& response_headers);
void finalize_entry(URL::URL const&, StringView method, HeaderList const& request_headers, u32 status_code, HeaderList const& response_headers, Core::ImmutableBytes response_body);
// Drops the oldest pending entry with the request's cache and vary keys, for a response whose body will not be
// finalized.
void abandon_entry(URL::URL const&, StringView method, HeaderList const& request_headers, HeaderList const& response_headers);
- void update_javascript_bytecode_cache(URL::URL const&, StringView method, HeaderList const& request_headers, u64 vary_key, Core::ImmutableBytes javascript_bytecode_cache);
void invalidate(URL::URL const&);
diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
index 0e4244ea543..83385ae2fec 100644
--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
@@ -253,9 +253,6 @@ static RefPtr<Infrastructure::Response> select_response_from_cache(HTTP::MemoryC
response->set_status(cache_entry->status_code);
response->set_status_message(cache_entry->reason_phrase);
response->set_header_list(cache_entry->response_headers);
- response->set_javascript_bytecode_cache(cache_entry->javascript_bytecode_cache);
- response->set_javascript_bytecode_cache_vary_key(cache_entry->javascript_bytecode_cache_vary_key);
- response->set_javascript_bytecode_cache_memory_cache_request_headers(HTTP::HeaderList::create(cache_entry->request_headers->headers()));
response->set_body(Infrastructure::ResponseBody::from_bytes(cache_entry->response_body));
@@ -269,8 +266,7 @@ static void store_response_in_cache(HTTP::MemoryCache& http_cache, Infrastructur
if (request.cache_mode() == HTTP::CacheMode::NoStore)
return;
- response.set_javascript_bytecode_cache_memory_cache_request_headers(HTTP::HeaderList::create(request.header_list()->headers()));
- http_cache.create_entry(request.current_url(), request.method(), request.header_list(), request.request_time(), response.status(), response.status_message(), response.header_list(), response.javascript_bytecode_cache(), response.javascript_bytecode_cache_vary_key());
+ http_cache.create_entry(request.current_url(), request.method(), request.header_list(), request.request_time(), response.status(), response.status_message(), response.header_list());
}
// Ends the delivery of a response's body that the fetch will not read.
@@ -2849,7 +2845,7 @@ GC::Ref<PendingResponse> nonstandard_resource_loader_file_or_http_network_fetch(
// A load without a RequestServer request, such as one for a file: URL, hands over its whole body at once.
auto whole_body_transport = create_whole_body_transport(*delivery_gate, *channel);
- auto on_headers_received = GC::create_function(GC::Heap::the(), [fetch_params = NonnullRefPtr { fetch_params }, pending_response, request, body_pump, channel, delivery_gate, whole_body_transport, http_cache](Engine::NetworkTransportHandle* network_transport, HTTP::HeaderList const& response_headers, Optional<u32> status_code, Optional<String> const& reason_phrase, Optional<Core::ImmutableBytes> javascript_bytecode, Optional<u64> javascript_bytecode_cache_vary_key, Requests::CacheState cache_state) {
+ auto on_headers_received = GC::create_function(GC::Heap::the(), [fetch_params = NonnullRefPtr { fetch_params }, pending_response, request, body_pump, channel, delivery_gate, whole_body_transport, http_cache](Engine::NetworkTransportHandle* network_transport, HTTP::HeaderList const& response_headers, Optional<u32> status_code, Optional<String> const& reason_phrase, Requests::CacheState cache_state) {
if (pending_response->is_resolved()) {
// RequestServer will send us the response headers twice, the second time being for HTTP trailers. This
// fetch algorithm is not interested in trailers, so just drop them here.
@@ -2865,8 +2861,6 @@ GC::Ref<PendingResponse> nonstandard_resource_loader_file_or_http_network_fetch(
if (reason_phrase.has_value())
response->set_status_message(reason_phrase->to_byte_string());
- response->set_javascript_bytecode_cache(move(javascript_bytecode));
- response->set_javascript_bytecode_cache_vary_key(javascript_bytecode_cache_vary_key);
// AD-HOC: RequestServer selects responses from the HTTP cache on WebContent's behalf, so it reports whether
// this response was served from a stored response ("local") or from a stored response that the
@@ -3554,14 +3548,4 @@ void clear_http_memory_cache()
HTML::CompiledScriptCache::the().clear();
}
-void update_javascript_bytecode_cache_in_http_memory_cache(Utf16String const& partition, URL::URL const& url, ByteString const& method, HTTP::HeaderList const& request_headers, u64 vary_key, Core::ImmutableBytes javascript_bytecode_cache)
-{
- if (!g_http_memory_cache_enabled)
- return;
-
- // Only back-fill into a partition that already has a cache; do not create an empty one just to drop bytecode into.
- if (auto* http_cache = HTTPCache::the().get_if_exists(partition))
- http_cache->update_javascript_bytecode_cache(url, method, request_headers, vary_key, move(javascript_bytecode_cache));
-}
-
}
diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.h b/Libraries/LibWeb/Fetch/Fetching/Fetching.h
index fa6f6c3d7c7..e6a9b386f7b 100644
--- a/Libraries/LibWeb/Fetch/Fetching/Fetching.h
+++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.h
@@ -75,6 +75,5 @@ WEB_API void clear_http_memory_cache();
WEB_API Optional<Utf16String> http_cache_partition(Infrastructure::Request const&);
WEB_API void set_disk_cache_enabled_for_navigations_for_testing(bool enabled);
WEB_API bool disk_cache_enabled_for_navigations_for_testing();
-void update_javascript_bytecode_cache_in_http_memory_cache(Utf16String const& partition, URL::URL const&, ByteString const& method, HTTP::HeaderList const& request_headers, u64 vary_key, Core::ImmutableBytes);
}
diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/ResponseView.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/ResponseView.h
index f3b603e02ac..21b953017e5 100644
--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/ResponseView.h
+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/ResponseView.h
@@ -42,9 +42,6 @@ public:
[[nodiscard]] Vector<Vector<String>> const& navigation_timing_allow_values_list() const { return m_record->navigation_timing_allow_values_list(); }
[[nodiscard]] Response::BodyInfo const& body_info() const { return m_record->body_info(); }
[[nodiscard]] RedirectTaint redirect_taint() const { return m_record->redirect_taint(); }
- [[nodiscard]] Optional<Core::ImmutableBytes> const& javascript_bytecode_cache() const { return m_record->javascript_bytecode_cache(); }
- [[nodiscard]] Optional<u64> javascript_bytecode_cache_vary_key() const { return m_record->javascript_bytecode_cache_vary_key(); }
- [[nodiscard]] Optional<NonnullRefPtr<HTTP::HeaderList>> const& javascript_bytecode_cache_memory_cache_request_headers() const { return m_record->javascript_bytecode_cache_memory_cache_request_headers(); }
[[nodiscard]] bool is_aborted_network_error() const { return m_record->is_aborted_network_error(); }
[[nodiscard]] bool is_network_error() const { return m_record->is_network_error(); }
diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
index 7546baac332..196e1df79c3 100644
--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp
@@ -195,12 +195,8 @@ NonnullRefPtr<Response> Response::clone() const
new_response->set_navigation_timing_allow_values_list(m_navigation_timing_allow_values_list);
new_response->set_body_info(m_body_info);
new_response->set_redirect_taint(m_redirect_taint);
- new_response->set_javascript_bytecode_cache(m_javascript_bytecode_cache);
- new_response->set_javascript_bytecode_cache_vary_key(m_javascript_bytecode_cache_vary_key);
if (m_network_transport.has_value())
new_response->set_network_transport(*m_network_transport);
- if (m_javascript_bytecode_cache_memory_cache_request_headers.has_value())
- new_response->set_javascript_bytecode_cache_memory_cache_request_headers(HTTP::HeaderList::create((*m_javascript_bytecode_cache_memory_cache_request_headers)->headers()));
// FIXME: service worker timing info
// 3. If response’s body is non-null, then set newResponse’s body to the result of cloning response’s body.
diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
index 9d845f9a4dd..8a39e2f282d 100644
--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h
@@ -113,13 +113,6 @@ public:
[[nodiscard]] virtual BodyInfo const& body_info() const { return m_body_info; }
virtual void set_body_info(BodyInfo body_info) { m_body_info = move(body_info); }
- [[nodiscard]] Optional<Core::ImmutableBytes> const& javascript_bytecode_cache() const { return m_javascript_bytecode_cache; }
- void set_javascript_bytecode_cache(Optional<Core::ImmutableBytes> javascript_bytecode_cache) { m_javascript_bytecode_cache = move(javascript_bytecode_cache); }
- [[nodiscard]] Optional<u64> javascript_bytecode_cache_vary_key() const { return m_javascript_bytecode_cache_vary_key; }
- void set_javascript_bytecode_cache_vary_key(Optional<u64> javascript_bytecode_cache_vary_key) { m_javascript_bytecode_cache_vary_key = javascript_bytecode_cache_vary_key; }
- [[nodiscard]] Optional<NonnullRefPtr<HTTP::HeaderList>> const& javascript_bytecode_cache_memory_cache_request_headers() const { return m_javascript_bytecode_cache_memory_cache_request_headers; }
- void set_javascript_bytecode_cache_memory_cache_request_headers(Optional<NonnullRefPtr<HTTP::HeaderList>> request_headers) { m_javascript_bytecode_cache_memory_cache_request_headers = move(request_headers); }
-
[[nodiscard]] virtual RedirectTaint redirect_taint() const { return m_redirect_taint; }
virtual void set_redirect_taint(RedirectTaint redirect_taint) { m_redirect_taint = redirect_taint; }
@@ -222,9 +215,6 @@ private:
MonotonicTime m_monotonic_response_time;
Optional<String> m_network_error_message;
- Optional<Core::ImmutableBytes> m_javascript_bytecode_cache;
- Optional<u64> m_javascript_bytecode_cache_vary_key;
- Optional<NonnullRefPtr<HTTP::HeaderList>> m_javascript_bytecode_cache_memory_cache_request_headers;
Optional<NetworkTransport> m_network_transport;
public:
diff --git a/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Libraries/LibWeb/Loader/ResourceLoader.cpp
index 3fc04620b1e..785aae1eb55 100644
--- a/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -484,7 +484,7 @@ RefPtr<Fetch::Engine::NetworkTransportHandle> ResourceLoader::load(LoadRequest&
request,
[on_headers_received = move(on_headers_received), on_data_received = move(on_data_received), on_complete, request](ReadonlyBytes data, Requests::RequestTimingInfo const& timing_info, HTTP::HeaderList const& response_headers) {
log_success(request);
- on_headers_received->function()(nullptr, response_headers, {}, {}, {}, {}, Requests::CacheState::NotCached);
+ on_headers_received->function()(nullptr, response_headers, {}, {}, Requests::CacheState::NotCached);
on_data_received->function()(Requests::ResponseData::from_bytes(data));
on_complete->function()(true, timing_info, {});
},
@@ -500,7 +500,7 @@ RefPtr<Fetch::Engine::NetworkTransportHandle> ResourceLoader::load(LoadRequest&
handle_resource_load_request(
request,
[on_headers_received = move(on_headers_received), on_data_received = move(on_data_received), on_complete](FileLoadResult const& load_result) {
- on_headers_received->function()(nullptr, load_result.response_headers, {}, {}, {}, {}, Requests::CacheState::NotCached);
+ on_headers_received->function()(nullptr, load_result.response_headers, {}, {}, Requests::CacheState::NotCached);
on_data_received->function()(Requests::ResponseData::from_bytes(load_result.data));
on_complete->function()(true, load_result.timing_info, {});
},
@@ -516,7 +516,7 @@ RefPtr<Fetch::Engine::NetworkTransportHandle> ResourceLoader::load(LoadRequest&
request,
[request, on_headers_received = move(on_headers_received), on_data_received = move(on_data_received), on_complete](FileLoadResult const& load_result) {
log_success(request);
- on_headers_received->function()(nullptr, load_result.response_headers, {}, {}, {}, {}, Requests::CacheState::NotCached);
+ on_headers_received->function()(nullptr, load_result.response_headers, {}, {}, Requests::CacheState::NotCached);
on_data_received->function()(Requests::ResponseData::from_bytes(load_result.data));
on_complete->function()(true, load_result.timing_info, {});
},
@@ -552,11 +552,11 @@ RefPtr<Fetch::Engine::NetworkTransportHandle> ResourceLoader::load(LoadRequest&
auto network_transport = Fetch::Engine::NetworkTransportHandle::create(*protocol_request);
- auto protocol_headers_received = [on_headers_received = move(on_headers_received), request, &protocol_request = *protocol_request, network_transport](auto const& response_headers, auto status_code, auto const& reason_phrase, auto javascript_bytecode, auto javascript_bytecode_cache_vary_key, auto cache_state) {
+ auto protocol_headers_received = [on_headers_received = move(on_headers_received), request, &protocol_request = *protocol_request, network_transport](auto const& response_headers, auto status_code, auto const& reason_phrase, auto, auto, auto cache_state) {
if (auto page = request.page())
page->client().page_did_receive_network_response_headers(protocol_request.id(), status_code.value_or(0), reason_phrase, response_headers->headers(), cache_state);
- on_headers_received->function()(network_transport.ptr(), response_headers, move(status_code), reason_phrase, move(javascript_bytecode), javascript_bytecode_cache_vary_key, cache_state);
+ on_headers_received->function()(network_transport.ptr(), response_headers, move(status_code), reason_phrase, cache_state);
};
auto protocol_data_received = [on_data_received = move(on_data_received), request, request_id = protocol_request->id()](auto data) {
diff --git a/Libraries/LibWeb/Loader/ResourceLoader.h b/Libraries/LibWeb/Loader/ResourceLoader.h
index c0821f45d64..e5b5fdade57 100644
--- a/Libraries/LibWeb/Loader/ResourceLoader.h
+++ b/Libraries/LibWeb/Loader/ResourceLoader.h
@@ -41,7 +41,7 @@ public:
// for requests without a site or without a client for that site.
void set_client(Optional<Utf16String> const& top_level_site, NonnullRefPtr<Requests::RequestClient>);
- using OnHeadersReceived = GC::Function<void(Fetch::Engine::NetworkTransportHandle*, HTTP::HeaderList const& response_headers, Optional<u32> status_code, Optional<String> const& reason_phrase, Optional<Core::ImmutableBytes> javascript_bytecode, Optional<u64> javascript_bytecode_cache_vary_key, Requests::CacheState cache_state)>;
+ using OnHeadersReceived = GC::Function<void(Fetch::Engine::NetworkTransportHandle*, HTTP::HeaderList const& response_headers, Optional<u32> status_code, Optional<String> const& reason_phrase, Requests::CacheState cache_state)>;
using OnDataReceived = GC::Function<void(Requests::ResponseData data)>;
using OnCachedBodyAvailable = GC::Function<void(Core::ImmutableBytes data)>;
using OnComplete = GC::Function<void(bool success, Requests::RequestTimingInfo const& timing_info, Optional<StringView> error_message)>;
diff --git a/Tests/LibHTTP/TestMemoryCache.cpp b/Tests/LibHTTP/TestMemoryCache.cpp
index 015ed72db90..ec47e40033c 100644
--- a/Tests/LibHTTP/TestMemoryCache.cpp
+++ b/Tests/LibHTTP/TestMemoryCache.cpp
@@ -43,81 +43,6 @@ static Core::ImmutableBytes immutable_bytes(StringView bytes)
return MUST(Core::ImmutableBytes::copy(bytes.bytes()));
}
-TEST_CASE(javascript_bytecode_cache_round_trips_with_memory_cache_entry)
-{
- auto cache = HTTP::MemoryCache::create();
- auto url = parse_url("https://example.com/script.js"sv);
- auto request_headers = create_cacheable_request_headers();
- auto response_headers = create_cacheable_response_headers();
- auto bytecode = immutable_bytes("cached bytecode"sv);
-
- cache->create_entry(url, "GET"sv, *request_headers, UnixDateTime::now(), 200, "OK"sv, *response_headers, bytecode, 0);
- cache->finalize_entry(url, "GET"sv, *request_headers, 200, *response_headers, immutable_bytes("console.log('hello');"sv));
-
- auto entry = cache->open_entry(url, "GET"sv, *request_headers, HTTP::CacheMode::Default);
- VERIFY(entry.has_value());
- VERIFY(entry->javascript_bytecode_cache.has_value());
- EXPECT_EQ(entry->javascript_bytecode_cache->bytes(), bytecode.bytes());
- EXPECT_EQ(entry->javascript_bytecode_cache_vary_key, Optional<u64> { 0 });
-}
-
-TEST_CASE(javascript_bytecode_cache_update_matches_memory_cache_vary_headers)
-{
- auto cache = HTTP::MemoryCache::create();
- auto url = parse_url("https://example.com/script.js"sv);
- auto script_request_headers = create_cacheable_request_headers();
- auto cache_request_headers = HTTP::HeaderList::create({
- { "Accept"sv, "*/*"sv },
- { "User-Agent"sv, "Ladybird"sv },
- });
- auto response_headers = create_vary_user_agent_response_headers();
- auto bytecode = immutable_bytes("generated bytecode"sv);
- auto vary_key = HTTP::create_vary_key(*cache_request_headers, *response_headers).value();
-
- cache->create_entry(url, "GET"sv, *cache_request_headers, UnixDateTime::now(), 200, "OK"sv, *response_headers);
- cache->finalize_entry(url, "GET"sv, *cache_request_headers, 200, *response_headers, immutable_bytes("console.log('hello');"sv));
-
- cache->update_javascript_bytecode_cache(url, "GET"sv, *script_request_headers, vary_key, bytecode);
-
- auto entry = cache->open_entry(url, "GET"sv, *cache_request_headers, HTTP::CacheMode::Default);
- VERIFY(entry.has_value());
- EXPECT(!entry->javascript_bytecode_cache.has_value());
- EXPECT(!entry->javascript_bytecode_cache_vary_key.has_value());
-
- cache->update_javascript_bytecode_cache(url, "GET"sv, *cache_request_headers, vary_key, bytecode);
-
- entry = cache->open_entry(url, "GET"sv, *cache_request_headers, HTTP::CacheMode::Default);
- VERIFY(entry.has_value());
- VERIFY(entry->javascript_bytecode_cache.has_value());
- EXPECT_EQ(entry->javascript_bytecode_cache->bytes(), bytecode.bytes());
- EXPECT_EQ(entry->javascript_bytecode_cache_vary_key, Optional<u64> { vary_key });
-}
-
-TEST_CASE(javascript_bytecode_cache_can_be_added_after_memory_cache_entry_is_complete)
-{
- auto cache = HTTP::MemoryCache::create();
- auto url = parse_url("https://example.com/script.js"sv);
- auto request_headers = create_cacheable_request_headers();
- auto response_headers = create_cacheable_response_headers();
- auto bytecode = immutable_bytes("generated bytecode"sv);
-
- cache->create_entry(url, "GET"sv, *request_headers, UnixDateTime::now(), 200, "OK"sv, *response_headers);
- cache->finalize_entry(url, "GET"sv, *request_headers, 200, *response_headers, immutable_bytes("console.log('hello');"sv));
-
- auto entry = cache->open_entry(url, "GET"sv, *request_headers, HTTP::CacheMode::Default);
- VERIFY(entry.has_value());
- EXPECT(!entry->javascript_bytecode_cache.has_value());
- EXPECT(!entry->javascript_bytecode_cache_vary_key.has_value());
-
- cache->update_javascript_bytecode_cache(url, "GET"sv, *request_headers, 0, bytecode);
-
- entry = cache->open_entry(url, "GET"sv, *request_headers, HTTP::CacheMode::Default);
- VERIFY(entry.has_value());
- VERIFY(entry->javascript_bytecode_cache.has_value());
- EXPECT_EQ(entry->javascript_bytecode_cache->bytes(), bytecode.bytes());
- EXPECT_EQ(entry->javascript_bytecode_cache_vary_key, Optional<u64> { 0 });
-}
-
TEST_CASE(permanent_redirects_without_explicit_freshness_are_reused)
{
for (auto status_code : Array<u32, 2> { 301, 308 }) {
diff --git a/Tests/LibWeb/TestFetchResponse.cpp b/Tests/LibWeb/TestFetchResponse.cpp
index 80a35039440..83da188d413 100644
--- a/Tests/LibWeb/TestFetchResponse.cpp
+++ b/Tests/LibWeb/TestFetchResponse.cpp
@@ -39,22 +39,6 @@ private:
}
-TEST_CASE(javascript_bytecode_cache_memory_cache_request_headers_are_cloned)
-{
- auto request_headers = HTTP::HeaderList::create({
- { "User-Agent"sv, "Ladybird"sv },
- });
- auto response = Web::Fetch::Infrastructure::Response::create();
- response->set_javascript_bytecode_cache_memory_cache_request_headers(request_headers);
-
- auto cloned_response = response->clone();
- auto const& cloned_request_headers = cloned_response->javascript_bytecode_cache_memory_cache_request_headers();
- request_headers->set({ "User-Agent"sv, "Changed"sv });
-
- VERIFY(cloned_request_headers.has_value());
- EXPECT_EQ((*cloned_request_headers)->get("User-Agent"sv), Optional<ByteString> { "Ladybird" });
-}
-
TEST_CASE(http_redirect_fetch_releases_intermediate_response_transfer_lease)
{
auto vm = JS::VM::create();