0

Disable client-side content decoding for Service Worker script requests.

Enabling the RendererSideContentDecoding flag caused failures in
webgpu_cts_tests running on Service Workers (crbug.com/405078730)

This is because the client_side_content_decoding_enabled flag was set to
true for Service Worker registration script requests but false for
requests from the Service Worker update checker in the browser process.
This discrepancy led to checksum differences, causing the service worker
executing the tests to be terminated.

While storing scripts in a compressed state would save space in Service
Worker Storage, there is currently no flag in Service Worker Storage to
indicate whether stored data is decoded or not.

This CL resolves the issue by always setting the
client_side_content_decoding_enabled flag to false for Service Worker
script requests. This ensures consistency and prevents the checksum
mismatches.

Fixed: 405078730, 405200443
Bug: 391950057
Change-Id: I07a2c4216ccd0a20fd828c0ba7d7bfd93a2161cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6381432
Reviewed-by: Shunya Shishido <sisidovski@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1436638}
This commit is contained in:
Tsuyoshi Horo
2025-03-23 16:45:16 -07:00
committed by Chromium LUCI CQ
parent 6cf3d99749
commit a6f85d93cf
2 changed files with 22 additions and 2 deletions

@ -103,6 +103,7 @@
#include "net/base/test_completion_callback.h"
#include "net/cert/cert_status_flags.h"
#include "net/dns/mock_host_resolver.h"
#include "net/filter/filter_source_stream_test_util.h"
#include "net/http/http_status_code.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
@ -2293,8 +2294,14 @@ struct ServiceWorkerScriptChecksumInfo {
class ServiceWorkerSha256ScriptChecksumBrowserTest
: public ServiceWorkerBrowserTest,
public testing::WithParamInterface<
std::tuple<ServiceWorkerScriptImportType, bool, bool>> {
std::tuple<ServiceWorkerScriptImportType, bool, bool, bool>> {
public:
ServiceWorkerSha256ScriptChecksumBrowserTest() {
if (IsCompressed()) {
scoped_feature_list_.InitWithFeatures(
{network::features::kRendererSideContentDecoding}, {});
}
}
void SetUpOnMainThread() override {
ServiceWorkerBrowserTest::SetUpOnMainThread();
// Set a custom request handler for Sha256ScriptChecksum test.
@ -2389,6 +2396,7 @@ class ServiceWorkerSha256ScriptChecksumBrowserTest
}
bool IsMainScriptChanged() { return std::get<1>(GetParam()); }
bool IsImportedScriptChanged() { return std::get<2>(GetParam()); }
bool IsCompressed() { return std::get<3>(GetParam()); }
private:
std::unique_ptr<net::test_server::HttpResponse>
@ -2444,7 +2452,13 @@ class ServiceWorkerSha256ScriptChecksumBrowserTest
auto http_response =
std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_OK);
http_response->set_content(updated_content);
if (IsCompressed()) {
auto compressed = net::CompressGzip(updated_content);
http_response->set_content(base::as_string_view(compressed));
http_response->AddCustomHeader("Content-Encoding", "gzip");
} else {
http_response->set_content(updated_content);
}
http_response->set_content_type("text/javascript");
http_response->AddCustomHeader("Service-Worker-Allowed", "/");
@ -2453,6 +2467,7 @@ class ServiceWorkerSha256ScriptChecksumBrowserTest
int64_t request_counter_for_main_script_ = 0;
int64_t request_counter_for_imported_script_ = 0;
base::test::ScopedFeatureList scoped_feature_list_;
};
IN_PROC_BROWSER_TEST_P(ServiceWorkerSha256ScriptChecksumBrowserTest,
@ -2549,6 +2564,7 @@ INSTANTIATE_TEST_SUITE_P(
testing::Values(ServiceWorkerScriptImportType::kImportScripts,
ServiceWorkerScriptImportType::kStaticImport),
testing::Bool(),
testing::Bool(),
testing::Bool()));
class CacheStorageSideDataSizeChecker

@ -148,6 +148,10 @@ ServiceWorkerNewScriptLoader::ServiceWorkerNewScriptLoader(
resource_request.load_flags |= net::LOAD_VALIDATE_CACHE;
}
// Because the flag indicating whether decoding has occurred is not stored in
// Service Worker Storage, we always decode on the network service side.
resource_request.client_side_content_decoding_enabled = false;
mojo::Remote<storage::mojom::ServiceWorkerResourceWriter> writer;
version_->context()
->registry()