Skip to content

Commit

Permalink
Skip fetch intercept logic when no active service worker is present.
Browse files Browse the repository at this point in the history
b/295571346
  • Loading branch information
aee-google committed Sep 11, 2023
1 parent 419286c commit b6d729e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cobalt/xhr/xml_http_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,12 @@ void XMLHttpRequestImpl::Send(
const base::Optional<XMLHttpRequest::RequestBodyType>& request_body,
script::ExceptionState* exception_state) {
error_ = false;
bool in_service_worker = environment_settings()
->context()
->GetWindowOrWorkerGlobalScope()
->IsServiceWorker();
if (!in_service_worker && method_ == net::URLFetcher::GET) {
auto* context = environment_settings()->context();
bool in_service_worker =
context->GetWindowOrWorkerGlobalScope()->IsServiceWorker();
bool has_active_service_worker =
!in_service_worker && context->active_service_worker();
if (has_active_service_worker && method_ == net::URLFetcher::GET) {

Check warning on line 526 in cobalt/xhr/xml_http_request.cc

View check run for this annotation

Codecov / codecov/patch

cobalt/xhr/xml_http_request.cc#L521-L526

Added lines #L521 - L526 were not covered by tests
loader::FetchInterceptorCoordinator::GetInstance()->TryIntercept(
request_url_, /*main_resource=*/false, request_headers_, task_runner_,
base::BindOnce(&XMLHttpRequestImpl::SendIntercepted, AsWeakPtr()),
Expand Down

0 comments on commit b6d729e

Please sign in to comment.