Preload page contents with CSP as soon as rules have been applied [chromium/src : main]

0 views
Skip to first unread message

Tarcísio Fischer (Gerrit)

unread,
Sep 3, 2024, 2:20:19 PMSep 3
to Yoav Weiss (@Shopify), AyeAye, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org

Tarcísio Fischer added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Tarcísio Fischer . resolved

NOTE: Current Patchset pushed for CI run only.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: Icdf6a47ac916bdabe508128d541c727fd915efe7
Gerrit-Change-Number: 5832754
Gerrit-PatchSet: 1
Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
Gerrit-Comment-Date: Tue, 03 Sep 2024 18:20:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Richard Townsend (Gerrit)

unread,
Sep 10, 2024, 8:14:22 AMSep 10
to Tarcísio Fischer, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
Attention needed from Tarcísio Fischer

Richard Townsend voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Tarcísio Fischer
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: Icdf6a47ac916bdabe508128d541c727fd915efe7
Gerrit-Change-Number: 5832754
Gerrit-PatchSet: 3
Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
Gerrit-CC: Alex N. Jose <ale...@chromium.org>
Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
Gerrit-Comment-Date: Tue, 10 Sep 2024 12:14:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Tarcísio Fischer (Gerrit)

unread,
Sep 16, 2024, 3:41:50 PMSep 16
to Mason Freed, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
Attention needed from Charlie Harrison and Mason Freed

Tarcísio Fischer added 1 comment

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Tarcísio Fischer . resolved

Hey, all!

As mentioned in the commit message, this CL changes the HTML document parser to resolve preloads affected by CSP meta tag as soon as the CSP rules are applied.

Please feel free to ask for any clarification!
Kind regards,
Tarcisio.

Open in Gerrit

Related details

Attention is currently required from:
  • Charlie Harrison
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: Icdf6a47ac916bdabe508128d541c727fd915efe7
Gerrit-Change-Number: 5832754
Gerrit-PatchSet: 5
Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Alex N. Jose <ale...@chromium.org>
Gerrit-CC: Richard Townsend <richard....@arm.com>
Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Mon, 16 Sep 2024 19:41:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Tarcísio Fischer (Gerrit)

unread,
Sep 17, 2024, 5:10:26 AMSep 17
to Ian Kilpatrick, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
Attention needed from Charlie Harrison and Ian Kilpatrick

Tarcísio Fischer added 1 comment

Patchset-level comments
Tarcísio Fischer . resolved

(Just noticed Mason Freed is OOO/Slow, so changing reviewer)

Open in Gerrit

Related details

Attention is currently required from:
  • Charlie Harrison
  • Ian Kilpatrick
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: Icdf6a47ac916bdabe508128d541c727fd915efe7
Gerrit-Change-Number: 5832754
Gerrit-PatchSet: 5
Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
Gerrit-Reviewer: Ian Kilpatrick <ikilp...@chromium.org>
Gerrit-CC: Alex N. Jose <ale...@chromium.org>
Gerrit-CC: Richard Townsend <richard....@arm.com>
Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
Gerrit-Attention: Ian Kilpatrick <ikilp...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Sep 2024 09:10:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Charlie Harrison (Gerrit)

unread,
Sep 17, 2024, 10:35:05 AMSep 17
to Tarcísio Fischer, Ian Kilpatrick, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
Attention needed from Ian Kilpatrick and Tarcísio Fischer

Charlie Harrison added 6 comments

Patchset-level comments
Charlie Harrison . unresolved

Thanks for fixing this. The issue is near and dear to my heart from https://codereview.chromium.org/2242223003 😊

Can you please figure out why the added test in that CL (/multiple-meta-csp.html) did not catch this regression, and fix the test if possible?

File third_party/blink/renderer/core/html/parser/html_document_parser.h
Line 308, Patchset 5 (Latest): unsigned seen_csp_meta_tags_ = 0;
Charlie Harrison . unresolved
Line 306, Patchset 5 (Latest): // yet). This is useful to check if preloads are allowed in the presence of
Charlie Harrison . unresolved

how? Maybe mention what this is actually used for.

File third_party/blink/renderer/core/html/parser/html_document_parser.cc
Line 1691, Patchset 5 (Latest): return !pending_preloads_->IsEmpty();
Charlie Harrison . unresolved

😮. Can we make this a separate CL in case this has its own perf impact?

Line 1783, Patchset 5 (Latest):bool HTMLDocumentParser::AllowPreloadingConsideringCSPMetaTags() {
Charlie Harrison . unresolved

Nit: suggest making this method more generic like `AllowPreloading` and include the following checks:

1. `!queued_preloads_.empty()`
2. `preloader_`

Additionally, we can just call this from within `FetchQueuedPreloads` (you could rename it `MaybeFetchQueuedPreloads` if you want). I think this would simplify call sites a bunch.

File third_party/blink/renderer/core/html/parser/html_resource_preloader.cc
Line 68, Patchset 5 (Latest):bool HTMLResourcePreloader::AllowPreloadConsideringCSP(
Charlie Harrison . unresolved
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Kilpatrick
  • Tarcísio Fischer
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 5
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Tue, 17 Sep 2024 14:34:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Charlie Harrison (Gerrit)

    unread,
    Sep 17, 2024, 10:38:16 AMSep 17
    to Tarcísio Fischer, Kouhei Ueno, Ian Kilpatrick, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Ian Kilpatrick, Kouhei Ueno and Tarcísio Fischer

    Charlie Harrison added 1 comment

    Patchset-level comments
    Charlie Harrison . resolved

    Adding Kouhei for loading expertise too (feel free to reroute though)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ian Kilpatrick
    • Kouhei Ueno
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 5
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Tue, 17 Sep 2024 14:38:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Sep 17, 2024, 12:47:05 PMSep 17
    to Kouhei Ueno, Ian Kilpatrick, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Ian Kilpatrick, Kouhei Ueno and Richard Townsend

    Tarcísio Fischer added 1 comment

    Patchset-level comments
    Charlie Harrison . unresolved

    Thanks for fixing this. The issue is near and dear to my heart from https://codereview.chromium.org/2242223003 😊

    Can you please figure out why the added test in that CL (/multiple-meta-csp.html) did not catch this regression, and fix the test if possible?

    Tarcísio Fischer

    Interesting! To be honest, I didn't know about your "relation" to the issue, as I've added the reviewers in the order they were suggested, skipping anyone that was OOO - So I guess I was very lucky :)

    `multiple-meta-csp.html` has been changed since you've added it, so there's no internals.isPreloaded assertions (assert_true) anymore - only the "negative" ones (assert_false). Culprit is here[1], but I didn't go into understanding the CL entirely yet.

    Regardless of the reason, simply re-adding the assertions won't be enough, as I've just checked. This is because my CL isn't really "preloading" things, but just "early-loading", if that makes sense...? Let me try to explain:

    Once a CSP meta tag has been seen, all preloads are deferred until CSP meta tag is processed.
    But the CSP meta tags will only be processed later (e.g. when PumpTokenizer is called). So it's not really a "preloading", since it'll only happen after several calls for ConstructTreeFromToken. You can see the relevant change here: https://chromium-review.googlesource.com/c/chromium/src/+/5832754/5/third_party/blink/renderer/core/html/parser/html_document_parser.cc#782

    So answering to your question: I don't know how to fix the test with the tools currently available :( I also tried adding a new test to it, but I couldn't do it unless I add a very specific observer variable to keep track of "preloads deferred due to CSP", which doesn't sound great (too specific). Do you have any suggestions?

    [1] https://chromium.googlesource.com/chromium/src/+/bb924e1897f5b4c67325dbfbdf2441e7f0686d53%5E%21/#F1

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Ian Kilpatrick
    • Kouhei Ueno
    • Richard Townsend
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 5
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Attention: Richard Townsend <richard....@arm.com>
    Gerrit-Comment-Date: Tue, 17 Sep 2024 16:46:52 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Charlie Harrison (Gerrit)

    unread,
    Sep 17, 2024, 3:13:38 PMSep 17
    to Tarcísio Fischer, Kouhei Ueno, Ian Kilpatrick, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Ian Kilpatrick, Kouhei Ueno, Richard Townsend and Tarcísio Fischer

    Charlie Harrison added 1 comment

    Patchset-level comments
    Charlie Harrison . unresolved

    Thanks for fixing this. The issue is near and dear to my heart from https://codereview.chromium.org/2242223003 😊

    Can you please figure out why the added test in that CL (/multiple-meta-csp.html) did not catch this regression, and fix the test if possible?

    Tarcísio Fischer

    Interesting! To be honest, I didn't know about your "relation" to the issue, as I've added the reviewers in the order they were suggested, skipping anyone that was OOO - So I guess I was very lucky :)

    `multiple-meta-csp.html` has been changed since you've added it, so there's no internals.isPreloaded assertions (assert_true) anymore - only the "negative" ones (assert_false). Culprit is here[1], but I didn't go into understanding the CL entirely yet.

    Regardless of the reason, simply re-adding the assertions won't be enough, as I've just checked. This is because my CL isn't really "preloading" things, but just "early-loading", if that makes sense...? Let me try to explain:

    Once a CSP meta tag has been seen, all preloads are deferred until CSP meta tag is processed.
    But the CSP meta tags will only be processed later (e.g. when PumpTokenizer is called). So it's not really a "preloading", since it'll only happen after several calls for ConstructTreeFromToken. You can see the relevant change here: https://chromium-review.googlesource.com/c/chromium/src/+/5832754/5/third_party/blink/renderer/core/html/parser/html_document_parser.cc#782

    So answering to your question: I don't know how to fix the test with the tools currently available :( I also tried adding a new test to it, but I couldn't do it unless I add a very specific observer variable to keep track of "preloads deferred due to CSP", which doesn't sound great (too specific). Do you have any suggestions?

    [1] https://chromium.googlesource.com/chromium/src/+/bb924e1897f5b4c67325dbfbdf2441e7f0686d53%5E%21/#F1

    Charlie Harrison

    Hm... would the following test work:

    ```
    <meta tag>
    <script>
    // Poll the server using a looped sync XHR to see if to_preload has been fetched.
    ...
    </script>
    <img src="to_preload.png">
    ```

    It's been a while for me in this code base so I forget the precise parsing semantics, maybe Kouhei has another suggestion though.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ian Kilpatrick
    • Kouhei Ueno
    • Richard Townsend
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 5
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Ian Kilpatrick <ikilp...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Attention: Richard Townsend <richard....@arm.com>
    Gerrit-Comment-Date: Tue, 17 Sep 2024 19:13:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    Comment-In-Reply-To: Tarcísio Fischer <tarcisio...@arm.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Ian Kilpatrick (Gerrit)

    unread,
    Sep 17, 2024, 4:55:29 PMSep 17
    to Tarcísio Fischer, Mason Freed, Joey Arhar, Kouhei Ueno, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Joey Arhar, Kouhei Ueno, Mason Freed, Richard Townsend and Tarcísio Fischer

    Ian Kilpatrick added 1 comment

    Patchset-level comments
    Ian Kilpatrick . resolved

    Sorry I'm not the right reviewer - Mason is likely best. Added jarhar@ as a backup.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joey Arhar
    • Kouhei Ueno
    • Mason Freed
    • Richard Townsend
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 5
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Joey Arhar <jar...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Richard Townsend <richard....@arm.com>
    Gerrit-Comment-Date: Tue, 17 Sep 2024 20:55:19 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Sep 18, 2024, 5:53:06 PMSep 18
    to Tarcísio Fischer, Joey Arhar, Kouhei Ueno, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Joey Arhar, Kouhei Ueno, Richard Townsend and Tarcísio Fischer

    Mason Freed added 6 comments

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5 (Latest): if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . unresolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Line 1691, Patchset 5 (Latest): return !pending_preloads_->IsEmpty();
    Charlie Harrison . unresolved

    😮. Can we make this a separate CL in case this has its own perf impact?

    Mason Freed

    ????? How long has that been there? I'm sure I'm the reviewer, whenever it was.

    Line 1783, Patchset 5 (Latest):bool HTMLDocumentParser::AllowPreloadingConsideringCSPMetaTags() {
    Charlie Harrison . unresolved

    Nit: suggest making this method more generic like `AllowPreloading` and include the following checks:

    1. `!queued_preloads_.empty()`
    2. `preloader_`

    Additionally, we can just call this from within `FetchQueuedPreloads` (you could rename it `MaybeFetchQueuedPreloads` if you want). I think this would simplify call sites a bunch.

    Mason Freed

    This would also be a good place to add a flag guarding this new behavior.

    File third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
    Line 927, Patchset 5 (Latest): int* csp_meta_tag_counter) {
    Mason Freed . unresolved

    two nits:

    • this should be `unsigned` also, or at least should match the other two
    • Perhaps `csp_meta_tag_count` rather than `counter`?
    Line 1034, Patchset 5 (Latest): *csp_meta_tag_counter += 1;
    Mason Freed . unresolved

    nit: `++(*csp_meta_tag_counter)`

    File third_party/blink/renderer/core/html/parser/preload_request.h
    Line 122, Patchset 5 (Parent): const IntegrityMetadataSet& IntegrityMetadataForTestingOnly() const {
    Mason Freed . unresolved

    Without further context, it always worries me to remove `ForTestingOnly` for something. Do you know why this was for testing only previously, and why it's safe now?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Joey Arhar
    • Kouhei Ueno
    • Richard Townsend
    • Tarcísio Fischer
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Joey Arhar <jar...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Attention: Richard Townsend <richard....@arm.com>
    Gerrit-Comment-Date: Wed, 18 Sep 2024 21:52:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Sep 19, 2024, 12:01:37 PMSep 19
    to Mason Freed, Joey Arhar, Kouhei Ueno, Charlie Harrison, Richard Townsend, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Joey Arhar, Kouhei Ueno, Mason Freed and Richard Townsend

    Tarcísio Fischer added 2 comments

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 1691, Patchset 5 (Latest): return !pending_preloads_->IsEmpty();
    Charlie Harrison . unresolved

    😮. Can we make this a separate CL in case this has its own perf impact?

    Mason Freed

    ????? How long has that been there? I'm sure I'm the reviewer, whenever it was.

    File third_party/blink/renderer/core/html/parser/preload_request.h
    Line 122, Patchset 5 (Parent): const IntegrityMetadataSet& IntegrityMetadataForTestingOnly() const {
    Mason Freed . unresolved

    Without further context, it always worries me to remove `ForTestingOnly` for something. Do you know why this was for testing only previously, and why it's safe now?

    Tarcísio Fischer

    I didn't check the history behind it, I thought "ForTestingOnly" just meant it was only being used on test code up to now.

    Regardless of the reason, I'll try to revert this change with Charlie's hypothesis that `HTMLResourcePreloader::AllowPreloadConsideringCSP` is doing duplicated work (Because that's where I was using this).

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Joey Arhar
    • Kouhei Ueno
    • Mason Freed
    • Richard Townsend
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Richard Townsend <richard....@arm.com>
    Gerrit-Comment-Date: Thu, 19 Sep 2024 16:01:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Sep 24, 2024, 8:22:36 AMSep 24
    to Richard Townsend, Mason Freed, Joey Arhar, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Joey Arhar, Kouhei Ueno and Mason Freed

    Tarcísio Fischer added 8 comments

    Patchset-level comments
    File-level comment, Patchset 6 (Latest):
    Tarcísio Fischer . resolved

    Hey, all.


    Thank you for all the review.

    It looks like Charlie's hypothesis that HTMLResourcePreloader::AllowPreloadConsideringCSP was doing duplicated work was correct, since all tests passed and also I didn't have any issues, in local manual experiments. - So I managed to clean up the CL a bit (Thank you).

    There are some remaining questions that I'd be happy to hear your opinions.

    File third_party/blink/renderer/core/html/parser/html_document_parser.h
    Line 308, Patchset 5: unsigned seen_csp_meta_tags_ = 0;
    Charlie Harrison . resolved
    Tarcísio Fischer

    Done

    Line 306, Patchset 5: // yet). This is useful to check if preloads are allowed in the presence of
    Charlie Harrison . resolved

    how? Maybe mention what this is actually used for.

    Tarcísio Fischer

    Done

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5: if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . unresolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Tarcísio Fischer

    Since this is just a nit, I'll prefer following the Chromium Guidelines and just use `int` whenever possible, if that's ok?

    Line 1575, Patchset 6 (Latest): TRACE_EVENT_WITH_FLOW0("blink,devtools.timeline",
    Tarcísio Fischer . unresolved

    I wonder if I should move this up (before the introduced `if`), since the `if` is trying to decide if the function will actually run. Asking here to see if anyone has any opinions on that.

    Line 1783, Patchset 5:bool HTMLDocumentParser::AllowPreloadingConsideringCSPMetaTags() {
    Charlie Harrison . unresolved

    Nit: suggest making this method more generic like `AllowPreloading` and include the following checks:

    1. `!queued_preloads_.empty()`
    2. `preloader_`

    Additionally, we can just call this from within `FetchQueuedPreloads` (you could rename it `MaybeFetchQueuedPreloads` if you want). I think this would simplify call sites a bunch.

    Mason Freed

    This would also be a good place to add a flag guarding this new behavior.

    Tarcísio Fischer

    Now that `FetchQueuedPreloads` has been renamed to `MaybeFetchQueuedPreloads`, I wonder if there's any issue in renaming the `UmaHistogram`. I did rename it, but please let me know if that's the best approach in this case.

    File third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
    Line 927, Patchset 5: int* csp_meta_tag_counter) {
    Mason Freed . unresolved

    two nits:

    • this should be `unsigned` also, or at least should match the other two
    • Perhaps `csp_meta_tag_count` rather than `counter`?
    Tarcísio Fischer

    I've renamed it to `csp_meta_tag_count`, but will keep it as `int` just to follow Chromium's guidelines, if that's ok?

    Line 1034, Patchset 5: *csp_meta_tag_counter += 1;
    Mason Freed . resolved

    nit: `++(*csp_meta_tag_counter)`

    Tarcísio Fischer

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Joey Arhar
    • Kouhei Ueno
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 6
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Joey Arhar <jar...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Tue, 24 Sep 2024 12:22:26 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Sep 26, 2024, 2:03:22 PMSep 26
    to Tarcísio Fischer, Richard Townsend, Joey Arhar, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Joey Arhar, Kouhei Ueno and Tarcísio Fischer

    Mason Freed added 4 comments

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5: if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . unresolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Tarcísio Fischer

    Since this is just a nit, I'll prefer following the Chromium Guidelines and just use `int` whenever possible, if that's ok?

    Mason Freed

    Wow I actually went and read the guidelines for that, which I hadn't noticed before. For reference, it says this:

    In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this.

    I feel like we violate this all over the place. But anyway, I'm ok with an `int` in these cases, but I do want the second part: please add `CHECK(int>=0)` everywhere.

    Line 1575, Patchset 6 (Latest): TRACE_EVENT_WITH_FLOW0("blink,devtools.timeline",
    Tarcísio Fischer . unresolved

    I wonder if I should move this up (before the introduced `if`), since the `if` is trying to decide if the function will actually run. Asking here to see if anyone has any opinions on that.

    Mason Freed

    Since the function is "Maybe", I think I'd log it before the `if()` so you see that the "maybe" got evaluated. Just my opinion.

    Line 1691, Patchset 5: return !pending_preloads_->IsEmpty();
    Charlie Harrison . resolved

    😮. Can we make this a separate CL in case this has its own perf impact?

    Mason Freed

    ????? How long has that been there? I'm sure I'm the reviewer, whenever it was.

    Tarcísio Fischer

    Originally here: https://chromium-review.googlesource.com/c/chromium/src/+/5125772/5/third_party/blink/renderer/core/html/parser/html_document_parser.cc#1596

    This CL was reverted but then re-landed here: https://chromium-review.googlesource.com/c/chromium/src/+/5132495

    I'll move this fix to a separate CL.

    Mason Freed

    Yep, I reviewed it. Thanks for the archaeology.

    File third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
    Line 927, Patchset 5: int* csp_meta_tag_counter) {
    Mason Freed . resolved

    two nits:

    • this should be `unsigned` also, or at least should match the other two
    • Perhaps `csp_meta_tag_count` rather than `counter`?
    Tarcísio Fischer

    I've renamed it to `csp_meta_tag_count`, but will keep it as `int` just to follow Chromium's guidelines, if that's ok?

    Mason Freed

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Joey Arhar
    • Kouhei Ueno
    • Tarcísio Fischer
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Thu, 26 Sep 2024 18:03:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    Comment-In-Reply-To: Tarcísio Fischer <tarcisio...@arm.com>
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Sep 27, 2024, 6:23:26 AMSep 27
    to Richard Townsend, Mason Freed, Joey Arhar, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison, Joey Arhar and Kouhei Ueno

    Tarcísio Fischer added 2 comments

    Patchset-level comments
    Charlie Harrison . unresolved

    Thanks for fixing this. The issue is near and dear to my heart from https://codereview.chromium.org/2242223003 😊

    Can you please figure out why the added test in that CL (/multiple-meta-csp.html) did not catch this regression, and fix the test if possible?

    Tarcísio Fischer

    Interesting! To be honest, I didn't know about your "relation" to the issue, as I've added the reviewers in the order they were suggested, skipping anyone that was OOO - So I guess I was very lucky :)

    `multiple-meta-csp.html` has been changed since you've added it, so there's no internals.isPreloaded assertions (assert_true) anymore - only the "negative" ones (assert_false). Culprit is here[1], but I didn't go into understanding the CL entirely yet.

    Regardless of the reason, simply re-adding the assertions won't be enough, as I've just checked. This is because my CL isn't really "preloading" things, but just "early-loading", if that makes sense...? Let me try to explain:

    Once a CSP meta tag has been seen, all preloads are deferred until CSP meta tag is processed.
    But the CSP meta tags will only be processed later (e.g. when PumpTokenizer is called). So it's not really a "preloading", since it'll only happen after several calls for ConstructTreeFromToken. You can see the relevant change here: https://chromium-review.googlesource.com/c/chromium/src/+/5832754/5/third_party/blink/renderer/core/html/parser/html_document_parser.cc#782

    So answering to your question: I don't know how to fix the test with the tools currently available :( I also tried adding a new test to it, but I couldn't do it unless I add a very specific observer variable to keep track of "preloads deferred due to CSP", which doesn't sound great (too specific). Do you have any suggestions?

    [1] https://chromium.googlesource.com/chromium/src/+/bb924e1897f5b4c67325dbfbdf2441e7f0686d53%5E%21/#F1

    Charlie Harrison

    Hm... would the following test work:

    ```
    <meta tag>
    <script>
    // Poll the server using a looped sync XHR to see if to_preload has been fetched.
    ...
    </script>
    <img src="to_preload.png">
    ```

    It's been a while for me in this code base so I forget the precise parsing semantics, maybe Kouhei has another suggestion though.

    Tarcísio Fischer

    The issue is (unless I am missing something), when things get loaded, the script can't be sure if they were "late-preloaded" or just "regular-loaded".

    There is a `internals.isPreloaded`, but it won't be recognized as preloaded in this case (because my late-preloading is being done later in the `PumpTokenizer`, only after I make sure CSP rules are applied).

    The only way I can think of would be to have a bunch of CSP-dependent resources in a HTML file and then measure how long it takes to load the whole page. For 20 resources, if it's less than ~5 seconds, then things got late-preloaded. If more than ~15 seconds, then things didn't got late-preloaded. If it's anything in between 5-20seconds, it's hard to say. (That's how I manually tested, and that's what's in the bug report). But that's a very bad idea for an automated testing, since it'll probably be flaky.

    File third_party/blink/renderer/core/html/parser/html_resource_preloader.cc
    Line 68, Patchset 5:bool HTMLResourcePreloader::AllowPreloadConsideringCSP(
    Charlie Harrison . resolved
    Tarcísio Fischer

    We don't need it. Thanks for letting me know!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Joey Arhar
    • Kouhei Ueno
    Gerrit-Comment-Date: Fri, 27 Sep 2024 10:23:16 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Sep 27, 2024, 11:42:43 AMSep 27
    to Richard Townsend, Mason Freed, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org

    Tarcísio Fischer added 1 comment

    File third_party/blink/renderer/core/html/parser/preload_request.h
    Line 122, Patchset 5 (Parent): const IntegrityMetadataSet& IntegrityMetadataForTestingOnly() const {
    Mason Freed . resolved

    Without further context, it always worries me to remove `ForTestingOnly` for something. Do you know why this was for testing only previously, and why it's safe now?

    Tarcísio Fischer

    I didn't check the history behind it, I thought "ForTestingOnly" just meant it was only being used on test code up to now.

    Regardless of the reason, I'll try to revert this change with Charlie's hypothesis that `HTMLResourcePreloader::AllowPreloadConsideringCSP` is doing duplicated work (Because that's where I was using this).

    Tarcísio Fischer

    (Reverted)

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 6
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Comment-Date: Fri, 27 Sep 2024 15:42:33 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Charlie Harrison (Gerrit)

    unread,
    Oct 1, 2024, 2:42:44 PMOct 1
    to Tarcísio Fischer, Richard Townsend, Mason Freed, Kouhei Ueno, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Mason Freed and Tarcísio Fischer

    Charlie Harrison added 2 comments

    Patchset-level comments
    Charlie Harrison

    Hm yeah I think I understand the point, but I would have thought my proposed test would catch that, since the script blocks "regular" loading of the <img> tag, so if the tag ever gets loaded, it must have been preloaded / early-loaded.

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5: if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . unresolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Tarcísio Fischer

    Since this is just a nit, I'll prefer following the Chromium Guidelines and just use `int` whenever possible, if that's ok?

    Mason Freed

    Wow I actually went and read the guidelines for that, which I hadn't noticed before. For reference, it says this:

    In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this.

    I feel like we violate this all over the place. But anyway, I'm ok with an `int` in these cases, but I do want the second part: please add `CHECK(int>=0)` everywhere.

    Charlie Harrison

    (FWIW in the past blink and webkit did not follow the google style guide, so it makes sense there is tons of divergence in the code base. I am not sure if we have specific guidance when there is divergence within one file)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mason Freed
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 6
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Tue, 01 Oct 2024 18:42:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Oct 2, 2024, 4:37:46 PMOct 2
    to Tarcísio Fischer, Richard Townsend, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison and Tarcísio Fischer

    Mason Freed added 1 comment

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5: if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . unresolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Tarcísio Fischer

    Since this is just a nit, I'll prefer following the Chromium Guidelines and just use `int` whenever possible, if that's ok?

    Mason Freed

    Wow I actually went and read the guidelines for that, which I hadn't noticed before. For reference, it says this:

    In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this.

    I feel like we violate this all over the place. But anyway, I'm ok with an `int` in these cases, but I do want the second part: please add `CHECK(int>=0)` everywhere.

    Charlie Harrison

    (FWIW in the past blink and webkit did not follow the google style guide, so it makes sense there is tons of divergence in the code base. I am not sure if we have specific guidance when there is divergence within one file)

    Mason Freed

    Yeah, makes sense.

    If we're sticking with `int`, that's fine. But I do want `CHECK(int>=0)` added everywhere we use it. Accidentally forgetting negatives is a bug waiting to happen.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 6
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Wed, 02 Oct 2024 20:37:35 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Oct 3, 2024, 8:11:43 AMOct 3
    to Richard Townsend, Mason Freed, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison and Mason Freed

    Tarcísio Fischer added 4 comments

    Patchset-level comments
    Tarcísio Fischer

    Ohhh- ok, I see your point. I'll try with that specific scenario, sorry I didn't really understood before.

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 783, Patchset 5: if (seen_csp_meta_tags_ > 0 && !queued_preloads_.empty() &&
    Mason Freed . resolved

    nit: you don't need `>0`

    (side-nit: I actually like making this `unsigned` as you have it, so that there's no question about what `<0` means here?)

    Tarcísio Fischer

    Since this is just a nit, I'll prefer following the Chromium Guidelines and just use `int` whenever possible, if that's ok?

    Mason Freed

    Wow I actually went and read the guidelines for that, which I hadn't noticed before. For reference, it says this:

    In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this.

    I feel like we violate this all over the place. But anyway, I'm ok with an `int` in these cases, but I do want the second part: please add `CHECK(int>=0)` everywhere.

    Charlie Harrison

    (FWIW in the past blink and webkit did not follow the google style guide, so it makes sense there is tons of divergence in the code base. I am not sure if we have specific guidance when there is divergence within one file)

    Mason Freed

    Yeah, makes sense.

    If we're sticking with `int`, that's fine. But I do want `CHECK(int>=0)` added everywhere we use it. Accidentally forgetting negatives is a bug waiting to happen.

    Tarcísio Fischer

    Done

    Line 1575, Patchset 6: TRACE_EVENT_WITH_FLOW0("blink,devtools.timeline",
    Tarcísio Fischer . resolved

    I wonder if I should move this up (before the introduced `if`), since the `if` is trying to decide if the function will actually run. Asking here to see if anyone has any opinions on that.

    Mason Freed

    Since the function is "Maybe", I think I'd log it before the `if()` so you see that the "maybe" got evaluated. Just my opinion.

    Tarcísio Fischer

    Done

    Line 1783, Patchset 5:bool HTMLDocumentParser::AllowPreloadingConsideringCSPMetaTags() {
    Charlie Harrison . resolved

    Nit: suggest making this method more generic like `AllowPreloading` and include the following checks:

    1. `!queued_preloads_.empty()`
    2. `preloader_`

    Additionally, we can just call this from within `FetchQueuedPreloads` (you could rename it `MaybeFetchQueuedPreloads` if you want). I think this would simplify call sites a bunch.

    Mason Freed

    This would also be a good place to add a flag guarding this new behavior.

    Tarcísio Fischer

    Now that `FetchQueuedPreloads` has been renamed to `MaybeFetchQueuedPreloads`, I wonder if there's any issue in renaming the `UmaHistogram`. I did rename it, but please let me know if that's the best approach in this case.

    Tarcísio Fischer

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 7
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Thu, 03 Oct 2024 12:11:36 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Oct 3, 2024, 5:18:13 PMOct 3
    to Tarcísio Fischer, Richard Townsend, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison and Tarcísio Fischer

    Mason Freed added 4 comments

    Patchset-level comments
    File-level comment, Patchset 7 (Latest):
    Mason Freed . resolved

    A few small nits, but this LGTM at this point.

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 1786, Patchset 7 (Latest): if (base::FeatureList::IsEnabled(features::kAllowPreloadingWithCSPMetaTag)) {
    Mason Freed . unresolved

    Any reason not to use a normal runtime enabled feature here?

    https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5

    That's the normal way to gate features within blink.

    File third_party/blink/renderer/core/html/parser/html_document_parser_state.h
    Line 157, Patchset 7 (Latest): unsigned seen_csp_counter_ = 0;
    Mason Freed . unresolved

    int?

    File third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
    Line 1288, Patchset 7 (Latest): if (csp_meta_tag_count != 0) {
    Mason Freed . unresolved

    nit: just `if (csp_meta_tag_count)`

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 7
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Thu, 03 Oct 2024 21:18:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Charlie Harrison (Gerrit)

    unread,
    Oct 4, 2024, 5:44:57 PMOct 4
    to Tarcísio Fischer, Richard Townsend, Mason Freed, Kouhei Ueno, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Tarcísio Fischer

    Charlie Harrison added 2 comments

    Patchset-level comments
    Charlie Harrison . resolved

    Change mostly LGTM other than the test if it's possible.

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 1576, Patchset 7 (Latest): // Early return in case preloads are not allowed.
    Charlie Harrison . unresolved

    nit: comment is redundant with the code.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Tarcísio Fischer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 7
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Comment-Date: Fri, 04 Oct 2024 21:44:47 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tarcísio Fischer (Gerrit)

    unread,
    Oct 15, 2024, 3:59:47 PMOct 15
    to Kyra Seevers, Richard Townsend, Mason Freed, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Charlie Harrison and Mason Freed

    Tarcísio Fischer added 5 comments

    Patchset-level comments
    File-level comment, Patchset 5:
    Charlie Harrison . resolved
    Tarcísio Fischer

    Apparently I was wrong before, and `internals.isPreloaded` works just fine. Sorry for my big (flawed) explanation. I don't know what exactly I did different before that wasn't working, to be honest. I am thinking that _maybe_ the implementation changed a bit since I tried. Regardless of the reason, apparently it is now working.

    I've added an `early_load_with_csp.html` web test that ensures that an image is preloaded in the presence of a meta CSP tag.

    File third_party/blink/renderer/core/html/parser/html_document_parser.cc
    Line 1576, Patchset 7: // Early return in case preloads are not allowed.
    Charlie Harrison . resolved

    nit: comment is redundant with the code.

    Tarcísio Fischer

    Done

    Line 1786, Patchset 7: if (base::FeatureList::IsEnabled(features::kAllowPreloadingWithCSPMetaTag)) {
    Mason Freed . resolved

    Any reason not to use a normal runtime enabled feature here?

    https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5

    That's the normal way to gate features within blink.

    Tarcísio Fischer

    Only because I didn't know about this. I changed to use the RuntimeEnabledFeatures. Thanks for suggesting.

    File third_party/blink/renderer/core/html/parser/html_document_parser_state.h
    Line 157, Patchset 7: unsigned seen_csp_counter_ = 0;
    Mason Freed . resolved

    int?

    Tarcísio Fischer

    Done

    File third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
    Line 1288, Patchset 7: if (csp_meta_tag_count != 0) {
    Mason Freed . resolved

    nit: just `if (csp_meta_tag_count)`

    Tarcísio Fischer

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Charlie Harrison
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    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: Icdf6a47ac916bdabe508128d541c727fd915efe7
    Gerrit-Change-Number: 5832754
    Gerrit-PatchSet: 8
    Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
    Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
    Gerrit-CC: Alex N. Jose <ale...@chromium.org>
    Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
    Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
    Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Tue, 15 Oct 2024 19:59:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Charlie Harrison (Gerrit)

    unread,
    Oct 16, 2024, 10:01:42 AMOct 16
    to Tarcísio Fischer, Richard Townsend, Kyra Seevers, Mason Freed, Kouhei Ueno, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
    Attention needed from Mason Freed and Tarcísio Fischer

    Charlie Harrison added 1 comment

    File third_party/blink/web_tests/wpt_internal/preload/early_load_with_csp.html
    Line 19, Patchset 8 (Latest):/* Sync wait acts as a barrier to give the time for the image to be preloaded and avoid loading it */
    Charlie Harrison . unresolved

    Now that I'm thinking about it... I wonder if this is either flaky or not needed.
    IIUC we need the main thread free to initiate a preload request. This means if when the JS has started running we _haven't_ yet sent off the preload request, we will not while the JS is running because the JS is taking control of the main thread.

    Does the `isPreloaded` function work if we just check after the page is finished loading?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mason Freed
    • Tarcísio Fischer
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 8
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Attention: Mason Freed <mas...@chromium.org>
      Gerrit-Comment-Date: Wed, 16 Oct 2024 14:01:29 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Tarcísio Fischer (Gerrit)

      unread,
      Oct 16, 2024, 12:25:06 PMOct 16
      to Richard Townsend, Kyra Seevers, Mason Freed, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Charlie Harrison and Mason Freed

      Tarcísio Fischer added 1 comment

      File third_party/blink/web_tests/wpt_internal/preload/early_load_with_csp.html
      Line 19, Patchset 8 (Latest):/* Sync wait acts as a barrier to give the time for the image to be preloaded and avoid loading it */
      Charlie Harrison . unresolved

      Now that I'm thinking about it... I wonder if this is either flaky or not needed.
      IIUC we need the main thread free to initiate a preload request. This means if when the JS has started running we _haven't_ yet sent off the preload request, we will not while the JS is running because the JS is taking control of the main thread.

      Does the `isPreloaded` function work if we just check after the page is finished loading?

      Tarcísio Fischer

      Looks like you are right (I just tested it) - syncWait is not necessary. I started from the looped sync XHR idea and thought I'd just need any synchronous barrier, so I never tried removing it completely. `isPreloaded` works if we check after the page is finished loading, so the test passes.

      I'll remove that bit from the code. By the way, is this a good location for this test file, or should I move it to `blink/web_tests/http/tests/preload/`? (Or somewhere else?)

      Thanks for all the help so far!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Charlie Harrison
      • Mason Freed
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 8
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Attention: Mason Freed <mas...@chromium.org>
      Gerrit-Comment-Date: Wed, 16 Oct 2024 16:24:53 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Charlie Harrison <cshar...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mason Freed (Gerrit)

      unread,
      Oct 17, 2024, 11:49:55 AMOct 17
      to Tarcísio Fischer, Richard Townsend, Kyra Seevers, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Charlie Harrison and Tarcísio Fischer

      Mason Freed added 2 comments

      Patchset-level comments
      File-level comment, Patchset 8 (Latest):
      Mason Freed . resolved

      I think this LGTM, with the other test-related questions resolved. Just one more thing about the unit test.

      File third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc
      Line 1506, Patchset 8 (Latest): [this](bool enable_allow_preloading_with_csp_meta_tag) {
      Mason Freed . unresolved

      I think `INSTANTIATE_TEST_SUITE_P` might be a better (and more standard) approach here. You can have a Param that is true/false and use that to set the scoped feature flag. Here's a rough example:

      https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/css_paint_value_test.cc;l=48;drc=c0c60604ead883d24d6e9b1426b1d908a86210a5

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Charlie Harrison
      • Tarcísio Fischer
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 8
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Comment-Date: Thu, 17 Oct 2024 15:49:46 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Tarcísio Fischer (Gerrit)

      unread,
      Oct 22, 2024, 10:30:19 AMOct 22
      to Richard Townsend, Kyra Seevers, Mason Freed, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Charlie Harrison and Mason Freed

      Tarcísio Fischer added 3 comments

      Patchset-level comments
      File-level comment, Patchset 9 (Latest):
      Tarcísio Fischer . resolved

      Hey all.

      I believe this is good to go, but please feel free to further review, in case there's anything else you'd like me to fix/improve.

      Thank you for the review and discussions!

      File third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc
      Line 1506, Patchset 8: [this](bool enable_allow_preloading_with_csp_meta_tag) {
      Mason Freed . resolved

      I think `INSTANTIATE_TEST_SUITE_P` might be a better (and more standard) approach here. You can have a Param that is true/false and use that to set the scoped feature flag. Here's a rough example:

      https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/css_paint_value_test.cc;l=48;drc=c0c60604ead883d24d6e9b1426b1d908a86210a5

      Tarcísio Fischer

      Done

      File third_party/blink/web_tests/wpt_internal/preload/early_load_with_csp.html
      Line 19, Patchset 8:/* Sync wait acts as a barrier to give the time for the image to be preloaded and avoid loading it */
      Charlie Harrison . resolved

      Now that I'm thinking about it... I wonder if this is either flaky or not needed.
      IIUC we need the main thread free to initiate a preload request. This means if when the JS has started running we _haven't_ yet sent off the preload request, we will not while the JS is running because the JS is taking control of the main thread.

      Does the `isPreloaded` function work if we just check after the page is finished loading?

      Tarcísio Fischer

      Looks like you are right (I just tested it) - syncWait is not necessary. I started from the looped sync XHR idea and thought I'd just need any synchronous barrier, so I never tried removing it completely. `isPreloaded` works if we check after the page is finished loading, so the test passes.

      I'll remove that bit from the code. By the way, is this a good location for this test file, or should I move it to `blink/web_tests/http/tests/preload/`? (Or somewhere else?)

      Thanks for all the help so far!

      Tarcísio Fischer

      I've removed the syncWait and moved the file to a (IMO) more suitable place.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Charlie Harrison
      • Mason Freed
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 9
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Attention: Mason Freed <mas...@chromium.org>
      Gerrit-Comment-Date: Tue, 22 Oct 2024 14:30:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mason Freed (Gerrit)

      unread,
      Oct 22, 2024, 4:29:54 PMOct 22
      to Tarcísio Fischer, Richard Townsend, Kyra Seevers, Kouhei Ueno, Charlie Harrison, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Charlie Harrison and Tarcísio Fischer

      Mason Freed voted and added 1 comment

      Votes added by Mason Freed

      Code-Review+1

      1 comment

      Patchset-level comments
      Mason Freed . resolved

      Nice! Thanks for the test changes. LGTM from my end.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Charlie Harrison
      • Tarcísio Fischer
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 9
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Comment-Date: Tue, 22 Oct 2024 20:29:43 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Charlie Harrison (Gerrit)

      unread,
      Oct 23, 2024, 1:40:53 AMOct 23
      to Tarcísio Fischer, Mason Freed, Richard Townsend, Kyra Seevers, Kouhei Ueno, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Tarcísio Fischer

      Charlie Harrison voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Tarcísio Fischer
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 9
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      Gerrit-CC: Kyra Seevers <kyras...@chromium.org>
      Gerrit-CC: Yoav Weiss (@Shopify) <yoav...@chromium.org>
      Gerrit-Attention: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Comment-Date: Wed, 23 Oct 2024 05:40:40 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Richard Townsend (Gerrit)

      unread,
      Oct 23, 2024, 4:21:48 AMOct 23
      to Tarcísio Fischer, Charlie Harrison, Mason Freed, Kyra Seevers, Kouhei Ueno, Alex N. Jose, Chromium LUCI CQ, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org
      Attention needed from Tarcísio Fischer

      Richard Townsend voted and added 1 comment

      Votes added by Richard Townsend

      Commit-Queue+2

      1 comment

      Patchset-level comments
      Richard Townsend . resolved

      Thanks for the reviews all, great to see this one resolved. Sending to CQ on Tarcisio's behalf.

      Best
      Richard

      Gerrit-Comment-Date: Wed, 23 Oct 2024 08:21:35 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Oct 23, 2024, 4:46:00 AMOct 23
      to Tarcísio Fischer, Charlie Harrison, Mason Freed, Richard Townsend, Kyra Seevers, Kouhei Ueno, Alex N. Jose, Yoav Weiss (@Shopify), AyeAye, jmedle...@chromium.org, mkwst+w...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, prerenderi...@chromium.org, gavin...@chromium.org, tburkar...@chromium.org, blink-rev...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, loading-rev...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      Preload page contents with CSP as soon as rules have been applied

      Today, Chromium will stop preloading on the HTML document parser as soon
      as it reaches a CSP meta tag. This CL will change that to re-enable
      preloading as soon as CSP have been applied.
      Bug: 40273969
      Change-Id: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Commit-Queue: Richard Townsend <richard....@arm.com>
      Reviewed-by: Charlie Harrison <cshar...@chromium.org>
      Reviewed-by: Mason Freed <mas...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1372555}
      Files:
      • M third_party/blink/renderer/core/html/parser/html_document_parser.cc
      • M third_party/blink/renderer/core/html/parser/html_document_parser.h
      • M third_party/blink/renderer/core/html/parser/html_document_parser_state.h
      • M third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
      • M third_party/blink/renderer/core/html/parser/html_preload_scanner.h
      • M third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc
      • M third_party/blink/renderer/platform/runtime_enabled_features.json5
      • A third_party/blink/web_tests/http/tests/preload/early_load_with_csp.html
      Change size: M
      Delta: 8 files changed, 155 insertions(+), 75 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mason Freed, +1 by Charlie Harrison
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Icdf6a47ac916bdabe508128d541c727fd915efe7
      Gerrit-Change-Number: 5832754
      Gerrit-PatchSet: 10
      Gerrit-Owner: Tarcísio Fischer <tarcisio...@arm.com>
      Gerrit-Reviewer: Charlie Harrison <cshar...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Kouhei Ueno <kou...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-Reviewer: Richard Townsend <richard....@arm.com>
      Gerrit-CC: Alex N. Jose <ale...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages