DevTools: Map Fetch and EventSource to XHR for interception [chromium/src : main]

0 views
Skip to first unread message

Wang Neden (Gerrit)

unread,
Nov 3, 2025, 8:00:21 AM (2 days ago) Nov 3
to Alex Rudenko, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org

Wang Neden voted

Auto-Submit+1
Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
Gerrit-Change-Number: 7107298
Gerrit-PatchSet: 5
Gerrit-Owner: Wang Neden <nede...@gmail.com>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
Gerrit-Comment-Date: Mon, 03 Nov 2025 12:59:45 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Wang Neden (Gerrit)

unread,
Nov 3, 2025, 8:52:01 AM (2 days ago) Nov 3
to Alex Rudenko, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
Attention needed from Alex Rudenko

Wang Neden added 2 comments

Commit Message
Line 29, Patchset 2:Clients wishing to intercept `fetch()` API calls must now explicitly
Alex Rudenko . resolved

to fix the reported bug: let's change the mapping to map XHR, Fetch, Prefetch and EventSource to XHR for the interception? (per https://g-issues.chromium.org/issues/40256663#comment10)

Wang Neden

Thanks for the clear direction! I've updated the CL to implement the core of this suggestion.

The code now maps `Fetch` and `EventSource` to `kXhr` for interception, which resolves the main issue reported in the bug. The web tests have been updated to confirm this fix.

I have intentionally **excluded `Prefetch`** from this mapping for now, based directly on your initial, very valid concern about breaking changes. Currently, `Fetch.enable({ resourceType: 'Prefetch' })` fails with a clear error. Mapping it to `kXhr` would change this explicit failure to a silent one, which feels like a more subtle and problematic breaking change.

I believe the right way to handle `Prefetch` is part of a larger, dedicated effort, which I've detailed in my reply to your other comment about the reverse mapping.

File content/browser/devtools/protocol/network_handler.cc
Line 1363, Patchset 2: if (resource_type ==
Alex Rudenko . resolved

there is a reverse of this mapping later in the file https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/protocol/network_handler.cc;l=1420;drc=6297ba28da79fc75d2f2d58bf79cfca949beef86 where blink::mojom::ResourceType::kPrefetch it re-mapped to Fetch.

Wang Neden

That is an excellent catch, and you are absolutely right. Thank you for pointing this out. It highlights a much more fundamental inconsistency, and my current change would indeed make the meaning of the `Fetch` type even more ambiguous across the protocol.

I believe this requires a proper, architectural solution rather than a simple mapping fix.

Here is the two-phased engineering plan I propose:

1. **This CL**: Lands the immediate fix for the user-reported issue.
2. **A Follow-up CL**: This will be a dedicated effort to **implement true interception for Prefetch requests**. This will likely involve investigating the `SubresourceProxyingURLLORLaderService` path. As part of that correct implementation, I will also fix this reverse mapping, ensuring `blink::mojom::ResourceType::kPrefetch` consistently and correctly maps to the `'Prefetch'` protocol type everywhere.

This plan ensures we solve the deeper inconsistency correctly in the long term.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Rudenko
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
    Gerrit-Change-Number: 7107298
    Gerrit-PatchSet: 5
    Gerrit-Owner: Wang Neden <nede...@gmail.com>
    Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
    Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Comment-Date: Mon, 03 Nov 2025 13:51:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Rudenko (Gerrit)

    unread,
    Nov 4, 2025, 2:17:18 AM (yesterday) Nov 4
    to Wang Neden, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
    Attention needed from Wang Neden

    Alex Rudenko added 1 comment

    File third_party/blink/web_tests/http/tests/inspector-protocol/fetch/enable-by-resource-type.js
    Line 118, Patchset 5 (Latest): triggerAction: null
    Alex Rudenko . unresolved

    does it make sense to include options that do not have a trigger action?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Wang Neden
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
      Gerrit-Change-Number: 7107298
      Gerrit-PatchSet: 5
      Gerrit-Owner: Wang Neden <nede...@gmail.com>
      Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
      Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
      Gerrit-Attention: Wang Neden <nede...@gmail.com>
      Gerrit-Comment-Date: Tue, 04 Nov 2025 07:17:00 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Wang Neden (Gerrit)

      unread,
      Nov 4, 2025, 3:03:31 AM (yesterday) Nov 4
      to Alex Rudenko, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
      Attention needed from Alex Rudenko

      Wang Neden voted and added 1 comment

      Votes added by Wang Neden

      Auto-Submit+1
      Commit-Queue+1

      1 comment

      File third_party/blink/web_tests/http/tests/inspector-protocol/fetch/enable-by-resource-type.js
      Line 118, Patchset 5: triggerAction: null
      Alex Rudenko . resolved

      does it make sense to include options that do not have a trigger action?

      Wang Neden

      You're right, the original test file was confusing because it mixed tests with two different purposes.

      To make the testing intent crystal clear, I've adopted your feedback and taken it a step further: I've split the tests into two separate files:

      1. `...-interception.js`: This file now exclusively tests successful interception scenarios, and every test case in it has a `triggerAction`.
      2. `...-validation.js`: This file is now dedicated to testing the input validation of `Fetch.enable` for unsupported types.

      This structure completely separates the two concerns and makes each test file's purpose immediately obvious from its name. I've just pushed the update.

      Thanks for pushing for better clarity here!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alex Rudenko
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
        Gerrit-Change-Number: 7107298
        Gerrit-PatchSet: 6
        Gerrit-Owner: Wang Neden <nede...@gmail.com>
        Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
        Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
        Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
        Gerrit-Comment-Date: Tue, 04 Nov 2025 08:02:55 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Alex Rudenko (Gerrit)

        unread,
        Nov 4, 2025, 4:22:03 AM (yesterday) Nov 4
        to Wang Neden, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
        Attention needed from Wang Neden

        Alex Rudenko added 1 comment

        File content/browser/devtools/protocol/network_handler.cc
        Line 1364, Patchset 6 (Parent): intercepted_resource_types->insert(blink::mojom::ResourceType::kPrefetch);
        Alex Rudenko . unresolved

        I think we should still keep this right? (by moving this condition to line 1369).

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Wang Neden
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
          Gerrit-Change-Number: 7107298
          Gerrit-PatchSet: 6
          Gerrit-Owner: Wang Neden <nede...@gmail.com>
          Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
          Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
          Gerrit-Attention: Wang Neden <nede...@gmail.com>
          Gerrit-Comment-Date: Tue, 04 Nov 2025 09:21:51 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Wang Neden (Gerrit)

          unread,
          Nov 4, 2025, 4:48:23 AM (yesterday) Nov 4
          to Alex Rudenko, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
          Attention needed from Alex Rudenko

          Wang Neden voted and added 1 comment

          Votes added by Wang Neden

          Auto-Submit+1

          1 comment

          File content/browser/devtools/protocol/network_handler.cc
          Line 1364, Patchset 6 (Parent): intercepted_resource_types->insert(blink::mojom::ResourceType::kPrefetch);
          Alex Rudenko . unresolved

          I think we should still keep this right? (by moving this condition to line 1369).

          Wang Neden

          Thanks for the quick feedback! I've just pushed an update to address your comment.

          I've implemented it so that the original `Fetch` -> `kPrefetch` mapping is preserved, in addition to the new `kXhr` mapping. This is now handled within the unified `if` block, but the `kPrefetch` logic is applied **only** when `resourceType` is `Fetch`, to avoid any side effects on `XHR` and `EventSource`.

          The code now reflects the logic we discussed. Please let me know if this updated implementation matches what you had in mind.

          Thanks!

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Alex Rudenko
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
          Gerrit-Change-Number: 7107298
          Gerrit-PatchSet: 7
          Gerrit-Owner: Wang Neden <nede...@gmail.com>
          Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
          Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
          Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
          Gerrit-Comment-Date: Tue, 04 Nov 2025 09:47:50 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Alex Rudenko (Gerrit)

          unread,
          Nov 4, 2025, 4:49:07 AM (yesterday) Nov 4
          to Wang Neden, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, blink-...@chromium.org, devtools-re...@chromium.org, devtools...@chromium.org
          Attention needed from Wang Neden

          Alex Rudenko voted and added 1 comment

          Votes added by Alex Rudenko

          Code-Review+1

          1 comment

          File content/browser/devtools/protocol/network_handler.cc
          Line 1364, Patchset 6 (Parent): intercepted_resource_types->insert(blink::mojom::ResourceType::kPrefetch);
          Alex Rudenko . resolved

          I think we should still keep this right? (by moving this condition to line 1369).

          Wang Neden

          Thanks for the quick feedback! I've just pushed an update to address your comment.

          I've implemented it so that the original `Fetch` -> `kPrefetch` mapping is preserved, in addition to the new `kXhr` mapping. This is now handled within the unified `if` block, but the `kPrefetch` logic is applied **only** when `resourceType` is `Fetch`, to avoid any side effects on `XHR` and `EventSource`.

          The code now reflects the logic we discussed. Please let me know if this updated implementation matches what you had in mind.

          Thanks!

          Alex Rudenko

          Thanks!

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Wang Neden
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I92040f04e4d9016a317e602d431797c48cb1c249
          Gerrit-Change-Number: 7107298
          Gerrit-PatchSet: 7
          Gerrit-Owner: Wang Neden <nede...@gmail.com>
          Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
          Gerrit-Reviewer: Wang Neden <nede...@gmail.com>
          Gerrit-Attention: Wang Neden <nede...@gmail.com>
          Gerrit-Comment-Date: Tue, 04 Nov 2025 09:48:49 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
          Comment-In-Reply-To: Wang Neden <nede...@gmail.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages