[source-phase-imports] Don't use ParkableStrings for Wasm sources [chromium/src : main]

0 views
Skip to first unread message

Luis Pardo (Gerrit)

unread,
Jun 3, 2025, 12:07:44 PMJun 3
to Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Dan Clark

Luis Pardo added 3 comments

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Luis Pardo . resolved

@dan...@microsoft.com could you take a look? I left a couple of comments in-line.

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
Line 38, Patchset 7 (Latest):class CORE_EXPORT ModuleScriptCreationParams {
Luis Pardo . unresolved

This is added just so that the linker doesn't complain about the `CopySource` method, we could probably inline it if we don't want to add this here.

File third_party/blink/renderer/core/workers/worklet_module_responses_map.cc
Line 51, Patchset 2 (Parent): *params));
Luis Pardo . unresolved

I **think** this should have always been `params_`. Seem like the correct think to pass the isolated copy to the other thread and not the original.

Open in Gerrit

Related details

Attention is currently required from:
  • Dan Clark
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 7
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Comment-Date: Tue, 03 Jun 2025 16:07:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Jun 5, 2025, 4:22:49 PMJun 5
to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Hiroshige Hayashizaki

Luis Pardo added 1 comment

Patchset-level comments
Luis Pardo . resolved

@hiro...@chromium.org Could you take a look? Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 7
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Thu, 05 Jun 2025 20:22:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Hiroshige Hayashizaki (Gerrit)

unread,
Jun 6, 2025, 12:07:56 AMJun 6
to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Luis Pardo

Hiroshige Hayashizaki added 8 comments

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
Line 155, Patchset 7 (Latest): // For Wasm modules the wire bytes are passed directly to the compiler.
Hiroshige Hayashizaki . unresolved

Could you make this comment a little more strict? e.g.

// For `ResolvedModuleType::kWasm`, the wire bytes are stored as `base::HeapArray<uint8_t>` and directly passed to the compiler.
// Otherwise, decoded text is stored as `ParkableString`.

Line 112, Patchset 7 (Latest): const base::HeapArray<uint8_t>& WasmSource() const {
Hiroshige Hayashizaki . unresolved

nit: name like `GetSourceForWasm()` would be clearer (it's the wasm version of `GetSourceText()`).

Line 75, Patchset 7 (Latest): ModuleScriptCreationParams(const ModuleScriptCreationParams& other)
Hiroshige Hayashizaki . unresolved

I'd like to avoid manual copy constructor because it's quite error-prone in general.

I found (pending trybot runs) ModuleScriptCreationParams can be move-only:
https://chromium-review.googlesource.com/c/chromium/src/+/6625840.

Could you check if this removes the copy constructor here?

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.cc
Line 24, Patchset 7 (Latest):ModuleScriptCreationParams::CopySource(
Hiroshige Hayashizaki . unresolved

Can we make this just `ModuleScriptCreationParams::CopySource()` and use `this` instead of `other`? (i.e. drop `other->`)?

I feel referencing both `this` and `other` seems confusing and not needed here.

File third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.h
Line 56, Patchset 7 (Latest): ResolvedModuleType module_type,
Hiroshige Hayashizaki . unresolved

Could you also add a comment to describe the type invariant, i.e.

`base::HeapArray<uint8_t>` is stored when `module_type` is `ResolvedModuleType::kWasm`, or `ParkableString` otherwise.

Maybe it would be ideal to create a new class (in module_script_creation_params.h?) containing `ResolvedModuleType` and `source` to enforce the invariant and centralize the type contract, and use the class here and `ModuleScriptCreationParams`, but probably not necessarily in this CL.

File third_party/blink/renderer/core/loader/resource/script_resource.h
Line 57, Patchset 7 (Latest):// ScriptResource is a resource representing a JavaScript classic
Hiroshige Hayashizaki . unresolved

nit: isn't this virtually the same as before?

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 246, Patchset 7 (Latest): // This method should be called only once.
Hiroshige Hayashizaki . unresolved

I doubt this assmption holds:
what if multiple wasm modules points to the same `ScriptResource`?
e.g. when we import "a.wasm" and "a.wasm#foo" in the same page. MemoryCache ignores `#foo` part and thus I expect the same ScriptResource is used.

Could you check this, and add a corresponding wpt (or wpt_internal) test (if you find the current patch set crashes here)?

---

I suspect this might be crashing or incorrectly behaving also when:

  • multiple same-origin pages import the same WASM modules
  • the `ScriptResource` is used WASM module and classic script (which anyway cause script parse error or something, but shouldn't crash or cause other internal inconsistencies)

but these might be a little harder to test/reproduce, so just checking the condition above is sufficient.

File third_party/blink/renderer/core/workers/worklet_module_responses_map.cc
Luis Pardo . unresolved

I **think** this should have always been `params_`. Seem like the correct think to pass the isolated copy to the other thread and not the original.

Hiroshige Hayashizaki

`CrossThreadBindOnce()` internally calls `IsolatedCopy`, so passing the original here is correct.
(I feel passing `*params_` is also equivalent though)

Or, did you encounter something that led this modification?

Open in Gerrit

Related details

Attention is currently required from:
  • Luis Pardo
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 7
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Comment-Date: Fri, 06 Jun 2025 04:07:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Luis Pardo <lpardo...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Jun 8, 2025, 1:40:27 PMJun 8
to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Hiroshige Hayashizaki

Luis Pardo added 9 comments

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
Line 155, Patchset 7: // For Wasm modules the wire bytes are passed directly to the compiler.
Hiroshige Hayashizaki . resolved

Could you make this comment a little more strict? e.g.

// For `ResolvedModuleType::kWasm`, the wire bytes are stored as `base::HeapArray<uint8_t>` and directly passed to the compiler.
// Otherwise, decoded text is stored as `ParkableString`.

Luis Pardo

Done

Line 112, Patchset 7: const base::HeapArray<uint8_t>& WasmSource() const {
Hiroshige Hayashizaki . resolved

nit: name like `GetSourceForWasm()` would be clearer (it's the wasm version of `GetSourceText()`).

Luis Pardo

Done

Line 75, Patchset 7: ModuleScriptCreationParams(const ModuleScriptCreationParams& other)
Hiroshige Hayashizaki . unresolved

I'd like to avoid manual copy constructor because it's quite error-prone in general.

I found (pending trybot runs) ModuleScriptCreationParams can be move-only:
https://chromium-review.googlesource.com/c/chromium/src/+/6625840.

Could you check if this removes the copy constructor here?

Luis Pardo

Yes, it works, I'll rebase after you land that patch.

Line 38, Patchset 7:class CORE_EXPORT ModuleScriptCreationParams {
Luis Pardo . resolved

This is added just so that the linker doesn't complain about the `CopySource` method, we could probably inline it if we don't want to add this here.

Luis Pardo

Acknowledged

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.cc
Line 24, Patchset 7:ModuleScriptCreationParams::CopySource(
Hiroshige Hayashizaki . resolved

Can we make this just `ModuleScriptCreationParams::CopySource()` and use `this` instead of `other`? (i.e. drop `other->`)?

I feel referencing both `this` and `other` seems confusing and not needed here.

Luis Pardo

Done

File third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.h
Line 56, Patchset 7: ResolvedModuleType module_type,
Hiroshige Hayashizaki . resolved

Could you also add a comment to describe the type invariant, i.e.

`base::HeapArray<uint8_t>` is stored when `module_type` is `ResolvedModuleType::kWasm`, or `ParkableString` otherwise.

Maybe it would be ideal to create a new class (in module_script_creation_params.h?) containing `ResolvedModuleType` and `source` to enforce the invariant and centralize the type contract, and use the class here and `ModuleScriptCreationParams`, but probably not necessarily in this CL.

Luis Pardo

Added the comment and a TODO.

File third_party/blink/renderer/core/loader/resource/script_resource.h
Line 57, Patchset 7:// ScriptResource is a resource representing a JavaScript classic
Hiroshige Hayashizaki . resolved

nit: isn't this virtually the same as before?

Luis Pardo

Expanded it more to clarify that this is also used for JSON, CSS, and Wasm module scripts.

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 246, Patchset 7: // This method should be called only once.
Hiroshige Hayashizaki . unresolved

I doubt this assmption holds:
what if multiple wasm modules points to the same `ScriptResource`?
e.g. when we import "a.wasm" and "a.wasm#foo" in the same page. MemoryCache ignores `#foo` part and thus I expect the same ScriptResource is used.

Could you check this, and add a corresponding wpt (or wpt_internal) test (if you find the current patch set crashes here)?

---

I suspect this might be crashing or incorrectly behaving also when:

  • multiple same-origin pages import the same WASM modules
  • the `ScriptResource` is used WASM module and classic script (which anyway cause script parse error or something, but shouldn't crash or cause other internal inconsistencies)

but these might be a little harder to test/reproduce, so just checking the condition above is sufficient.

Luis Pardo

You are right, we do need to keep the data around. For now, I added a new `source_bytes_` field in this class to keep it in memory, but I'm not sure if this is the right long-term approach.

If the resource is going to stay in memory for a long time it would be better to have the source in a "parkable" object, but using a `ParkableString` for a non-string buffer seems hacky. WDYT?

File third_party/blink/renderer/core/workers/worklet_module_responses_map.cc
Luis Pardo . resolved

I **think** this should have always been `params_`. Seem like the correct think to pass the isolated copy to the other thread and not the original.

Hiroshige Hayashizaki

`CrossThreadBindOnce()` internally calls `IsolatedCopy`, so passing the original here is correct.
(I feel passing `*params_` is also equivalent though)

Or, did you encounter something that led this modification?

Luis Pardo

Or, did you encounter something that led this modification?

No, I don't know why I thought this was calling the copy constructor instead of IsolatedCopy.

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 8
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Sun, 08 Jun 2025 17:40:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hiroshige Hayashizaki <hiro...@chromium.org>
Comment-In-Reply-To: Luis Pardo <lpardo...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Jun 9, 2025, 2:38:44 PMJun 9
to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Hiroshige Hayashizaki

Luis Pardo added 1 comment

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
Line 75, Patchset 7: ModuleScriptCreationParams(const ModuleScriptCreationParams& other)
Hiroshige Hayashizaki . resolved

I'd like to avoid manual copy constructor because it's quite error-prone in general.

I found (pending trybot runs) ModuleScriptCreationParams can be move-only:
https://chromium-review.googlesource.com/c/chromium/src/+/6625840.

Could you check if this removes the copy constructor here?

Luis Pardo

Yes, it works, I'll rebase after you land that patch.

Luis Pardo

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 9
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Mon, 09 Jun 2025 18:38:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Luis Pardo <lpardo...@microsoft.com>
Comment-In-Reply-To: Hiroshige Hayashizaki <hiro...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Hiroshige Hayashizaki (Gerrit)

unread,
Jun 17, 2025, 1:00:30 AMJun 17
to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Luis Pardo

Hiroshige Hayashizaki added 2 comments

Commit Message
Line 14, Patchset 10 (Latest):corrupting the Wasm source.
Hiroshige Hayashizaki . unresolved

Do you have tests? (i.e. to confirm the wasm source is not decoded as UTF-8)

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 246, Patchset 7: // This method should be called only once.
Hiroshige Hayashizaki . unresolved

I doubt this assmption holds:
what if multiple wasm modules points to the same `ScriptResource`?
e.g. when we import "a.wasm" and "a.wasm#foo" in the same page. MemoryCache ignores `#foo` part and thus I expect the same ScriptResource is used.

Could you check this, and add a corresponding wpt (or wpt_internal) test (if you find the current patch set crashes here)?

---

I suspect this might be crashing or incorrectly behaving also when:

  • multiple same-origin pages import the same WASM modules
  • the `ScriptResource` is used WASM module and classic script (which anyway cause script parse error or something, but shouldn't crash or cause other internal inconsistencies)

but these might be a little harder to test/reproduce, so just checking the condition above is sufficient.

Luis Pardo

You are right, we do need to keep the data around. For now, I added a new `source_bytes_` field in this class to keep it in memory, but I'm not sure if this is the right long-term approach.

If the resource is going to stay in memory for a long time it would be better to have the source in a "parkable" object, but using a `ParkableString` for a non-string buffer seems hacky. WDYT?

Hiroshige Hayashizaki

At least we shouldn't call `ClearData();` because it would invalidate the data that would be otherwise

Open in Gerrit

Related details

Attention is currently required from:
  • Luis Pardo
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • 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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 10
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Comment-Date: Tue, 17 Jun 2025 04:58:49 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Hiroshige Hayashizaki (Gerrit)

unread,
Jun 17, 2025, 2:51:14 AMJun 17
to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Luis Pardo

Hiroshige Hayashizaki added 2 comments

Commit Message
Line 9, Patchset 10 (Latest):Support for Wasm modules was already added, but the sources are
Hiroshige Hayashizaki . unresolved

I've figured out an underlying issue for this: when a `ScriptResource` is used both as a text JavaScript and WASM, users can observe unexpected empty bytes (or probably other inconsistent states).

Background (root cause):

`ScriptResource` (when used for ordinal text classic/module scripts) usually clears its underlying bytes as soon as possible.

Problem:

Reproducing case (to be placed under `virtual/javascript-source-phase-imports/external/wpt/wasm/webapi/esm-integration/`):

```
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true, allow_uncaught_exception : true });
</script>
<script crossorigin src="./resources/exported-names.wasm"></script>
<script type=module>
import source exportedNamesSource from "./resources/exported-names.wasm";
done();
</script>
```

1. A `ScriptResource` is used as a classic script. This grabs the loaded body (which is WASM) and causes `CONSOLE ERROR: Uncaught SyntaxError: Invalid or unexpected token` as expected (not JavaScript at all, of course). `crossorigin` attribute is used to make the `ScriptResource` shared between classic script here and module WASM below.
2. The same `ScriptResource` is used as WASM (via Blink MemoryCache). The body (`ScriptResource::Data()`) is already gone at this time, and causes `CONSOLE ERROR: Uncaught CompileError: WasmModuleObject::Compile(): expected 4 bytes, fell off end @+0`,
i.e. unexpected empty body is observed.

Anyway almost always at most one of them can be successful and there are no valid use cases for this scenario, but something wrong shouldn't be observed / shouldn't be used as attack vector.

Solutions...?

So ... what we should do? I'm not confident at all, brainstorming...

Given that we switch JavaScript/WASM compilation sorely based on Content-Type response header, anyway we need to use `ScriptResource` that can potentially shared with text module scripts.

So ... for example, we might want to keep raw bytes when Content-Type is `application/wasm`, but this anyway needs more careful design.

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 251, Patchset 10 (Latest): source_bytes_ = std::move(data_array);
Hiroshige Hayashizaki . unresolved

Do we need `source_bytes_` here?
Can we always get bytes directly from `Data()` without `ClearData()`?

Gerrit-Comment-Date: Tue, 17 Jun 2025 06:49:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Jun 17, 2025, 6:54:15 PMJun 17
to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Hiroshige Hayashizaki

Luis Pardo voted and added 4 comments

Votes added by Luis Pardo

Commit-Queue+1

4 comments

Commit Message
Line 9, Patchset 10:Support for Wasm modules was already added, but the sources are
Hiroshige Hayashizaki . resolved

I've figured out an underlying issue for this: when a `ScriptResource` is used both as a text JavaScript and WASM, users can observe unexpected empty bytes (or probably other inconsistent states).

Background (root cause):

`ScriptResource` (when used for ordinal text classic/module scripts) usually clears its underlying bytes as soon as possible.

Problem:

Reproducing case (to be placed under `virtual/javascript-source-phase-imports/external/wpt/wasm/webapi/esm-integration/`):

```
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true, allow_uncaught_exception : true });
</script>
<script crossorigin src="./resources/exported-names.wasm"></script>
<script type=module>
import source exportedNamesSource from "./resources/exported-names.wasm";
done();
</script>
```

1. A `ScriptResource` is used as a classic script. This grabs the loaded body (which is WASM) and causes `CONSOLE ERROR: Uncaught SyntaxError: Invalid or unexpected token` as expected (not JavaScript at all, of course). `crossorigin` attribute is used to make the `ScriptResource` shared between classic script here and module WASM below.
2. The same `ScriptResource` is used as WASM (via Blink MemoryCache). The body (`ScriptResource::Data()`) is already gone at this time, and causes `CONSOLE ERROR: Uncaught CompileError: WasmModuleObject::Compile(): expected 4 bytes, fell off end @+0`,
i.e. unexpected empty body is observed.

Anyway almost always at most one of them can be successful and there are no valid use cases for this scenario, but something wrong shouldn't be observed / shouldn't be used as attack vector.

Solutions...?

So ... what we should do? I'm not confident at all, brainstorming...

Given that we switch JavaScript/WASM compilation sorely based on Content-Type response header, anyway we need to use `ScriptResource` that can potentially shared with text module scripts.

So ... for example, we might want to keep raw bytes when Content-Type is `application/wasm`, but this anyway needs more careful design.

Luis Pardo

I think think it should be enough to do this check before clearing the raw bytes. I'll follow up in another CL, opened another issue (blocking the feature) to track this: https://issues.chromium.org/issues/425682456.

Line 14, Patchset 10:corrupting the Wasm source.
Hiroshige Hayashizaki . resolved

Do you have tests? (i.e. to confirm the wasm source is not decoded as UTF-8)

Luis Pardo

Added the test.

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 246, Patchset 7: // This method should be called only once.
Hiroshige Hayashizaki . resolved

I doubt this assmption holds:
what if multiple wasm modules points to the same `ScriptResource`?
e.g. when we import "a.wasm" and "a.wasm#foo" in the same page. MemoryCache ignores `#foo` part and thus I expect the same ScriptResource is used.

Could you check this, and add a corresponding wpt (or wpt_internal) test (if you find the current patch set crashes here)?

---

I suspect this might be crashing or incorrectly behaving also when:

  • multiple same-origin pages import the same WASM modules
  • the `ScriptResource` is used WASM module and classic script (which anyway cause script parse error or something, but shouldn't crash or cause other internal inconsistencies)

but these might be a little harder to test/reproduce, so just checking the condition above is sufficient.

Luis Pardo

You are right, we do need to keep the data around. For now, I added a new `source_bytes_` field in this class to keep it in memory, but I'm not sure if this is the right long-term approach.

If the resource is going to stay in memory for a long time it would be better to have the source in a "parkable" object, but using a `ParkableString` for a non-string buffer seems hacky. WDYT?

Hiroshige Hayashizaki

At least we shouldn't call `ClearData();` because it would invalidate the data that would be otherwise

Luis Pardo

Done

Line 251, Patchset 10: source_bytes_ = std::move(data_array);
Hiroshige Hayashizaki . resolved

Do we need `source_bytes_` here?
Can we always get bytes directly from `Data()` without `ClearData()`?

Luis Pardo

Implemented this suggestion.

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
Gerrit-Change-Number: 6612586
Gerrit-PatchSet: 11
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-CC: Dan Clark <dan...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Jun 2025 22:54:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hiroshige Hayashizaki (Gerrit)

unread,
Jun 18, 2025, 3:37:31 AMJun 18
to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
Attention needed from Luis Pardo

Hiroshige Hayashizaki added 14 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Hiroshige Hayashizaki . resolved

Leaning toward landing this CL with a separate follow-up for crbug.com/425682456.

I added comments to make the contract/semantics more strict, as a preparation for the follow-up.

Commit Message
Line 9, Patchset 10:Support for Wasm modules was already added, but the sources are
Hiroshige Hayashizaki . unresolved
Hiroshige Hayashizaki

The code isn't executed in the wild (unless developers explicitly enable the feature), right?
i.e. The feature kJavaScriptSourcePhaseImports is disabled and not enabled by any experiments etc.

If so, it's fine to discuss on the follow-up CL.
I basically expect selectively keeping raw bytes would work, while we should be careful.

(In other words, the fix should be applied before the code can run in the wild, because the `FlatData()` check could crash the Chromium in the wild at non-negligible rate)

File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
Line 155, Patchset 11 (Latest): // Cannot be const to support the move constructor.
Hiroshige Hayashizaki . unresolved

Is this still true? I feel this can be still const just like other const fields.

File third_party/blink/renderer/core/loader/modulescript/module_script_loader_test.cc
Line 598, Patchset 11 (Latest): TestFetchURL(ModuleScriptCustomFetchType::kNone, client,
Hiroshige Hayashizaki . unresolved

Can this non-ASCII test be a WPT?
Not blocking this CL, but for the long term adding as WPT is better.

(very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

File third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.h
Line 55, Patchset 11 (Latest): // `ResolvedModuleType::kWasm`, and `ParkableString` otherwise.
Hiroshige Hayashizaki . unresolved

nit: we can also add the same TODO as `module_script_creation_params.h`:

```
// TODO(https://crbug.com/42204365): Wrap this and the module type in a
// new class.
```

File third_party/blink/renderer/core/loader/resource/script_resource.h
Line 290, Patchset 11 (Latest): base::HeapArray<uint8_t> FlatData();
Hiroshige Hayashizaki . unresolved

Could you rename this to `GetWasmSource()`?
Also add "for Wasm sources" in the comment.

Line 289, Patchset 11 (Latest): // The buffer is not stored within this class.
Hiroshige Hayashizaki . unresolved

"The returned buffer is not stored within this class." is clearer.

Line 288, Patchset 11 (Latest): // Returns a flattened representation of the Data and clears the buffer.
Hiroshige Hayashizaki . unresolved

" and clears the buffer" part is obsolete.

Line 125, Patchset 11 (Latest): ResolvedModuleType module_type);
Hiroshige Hayashizaki . unresolved

Could you rename this to `GetSourceTextOrWasmSource()`?
(Assuming FlatData() is renamed to GetWasmSource())

So that the name directly corresponds to underlying GetWasmSource() and SourceText().

Line 124, Patchset 11 (Latest): std::variant<ParkableString, base::HeapArray<uint8_t>> GetBytesOrTextSource(
Hiroshige Hayashizaki . unresolved

Could you add comments:

About return type:

```
For module purposes.
Returns the wire bytes for Wasm modules, or otherwise, the decoded text.
See `ModuleScriptCreationParams::source_`.
```

About module_type:

```
`module_type` should be from `ModuleScriptFetcher::WasModuleLoadSuccessful(this,...)`.
Particularly, if `module_type` is `kWasm`, then the Content Type of `this` should be a WASM MIME type (See the corresponding `CHECK()` in `FlatData()`).
```

Line 120, Patchset 11 (Latest): // If needed, decode the source buffer into a ParkableString.
Hiroshige Hayashizaki . unresolved

This is a little confusing, because even without calling `SourceText`, the source buffer can be decoded.

So maybe this should be:

```
// Returns the decoded source text as a ParkableString.
```

File third_party/blink/renderer/core/loader/resource/script_resource.cc
Line 247, Patchset 11 (Latest): // Data is not cleared for Wasm resources.
Hiroshige Hayashizaki . unresolved

Could you add a TODO? like

```
TODO(https://crbug.com/425682456): Currently this assumption doesn't hold.
```

Line 248, Patchset 11 (Latest): CHECK(Data());
Hiroshige Hayashizaki . unresolved

Could you add

```
CHECK(IsLoaded());
CHECK(base::FeatureList::IsEnabled(
blink::features::kJavaScriptSourcePhaseImports));
CHECK(MIMETypeRegistry::IsWasmMIMEType(GetResponse().HttpContentType()));
```
Line 270, Patchset 11 (Latest): // Wasm resources are not decoded, so we return an empty string.
Hiroshige Hayashizaki . unresolved

nit: Creating a separate paragraph + adding a word "also" might be easier to read.

```
// ... or we either haven't started loading and haven't received data yet, or
// we finished loading with an error/cancellation, and thus don't have data.
// In both cases, we can treat the resource as empty.
  // Also Wasm resources are not decoded, so we return an empty string.
// TODO(https://crbug.com/42204365): Investigate if we need inspector support.
```
Open in Gerrit

Related details

Attention is currently required from:
  • Luis Pardo
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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 11
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Comment-Date: Wed, 18 Jun 2025 07:37:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hiroshige Hayashizaki (Gerrit)

    unread,
    Jun 18, 2025, 3:38:04 AMJun 18
    to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
    Attention needed from Luis Pardo

    Hiroshige Hayashizaki added 1 comment

    Commit Message
    Line 29, Patchset 11 (Latest):Bug: 42204365
    Hiroshige Hayashizaki . unresolved

    Could you also add `425682456`? (Because this CL introduces the behavior of crbug.com/425682456)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Luis Pardo
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 11
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Comment-Date: Wed, 18 Jun 2025 07:37:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Luis Pardo (Gerrit)

    unread,
    Jun 18, 2025, 7:04:11 PMJun 18
    to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
    Attention needed from Hiroshige Hayashizaki

    Luis Pardo added 14 comments

    Commit Message

    Could you also add `425682456`? (Because this CL introduces the behavior of crbug.com/425682456)

    Luis Pardo

    Done

    File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
    Line 155, Patchset 11: // Cannot be const to support the move constructor.
    Hiroshige Hayashizaki . unresolved

    Is this still true? I feel this can be still const just like other const fields.

    Luis Pardo

    It's still true. The move constructor defaults to the copy constructor for the const members, all the other members are trivial or have a copy constructor (like KURL), but the new variant doesn't because `HeapArray` is move only, and even if it had, we wouldn't like to be copying this memory instead of moving it.

    File third_party/blink/renderer/core/loader/modulescript/module_script_loader_test.cc
    Line 598, Patchset 11: TestFetchURL(ModuleScriptCustomFetchType::kNone, client,
    Hiroshige Hayashizaki . unresolved

    Can this non-ASCII test be a WPT?
    Not blocking this CL, but for the long term adding as WPT is better.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Luis Pardo

    Can this non-ASCII test be a WPT?

    I'll add it in a follow-up CL. Would you prefer it as a WPT internal or external test? I'm trying to understand if this would be a Chomium-specific bug or is general enough to be relevant to other browsers.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Updated it

    File third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.h
    Line 55, Patchset 11: // `ResolvedModuleType::kWasm`, and `ParkableString` otherwise.
    Hiroshige Hayashizaki . resolved

    nit: we can also add the same TODO as `module_script_creation_params.h`:

    ```
    // TODO(https://crbug.com/42204365): Wrap this and the module type in a
    // new class.
    ```

    Luis Pardo

    Done

    File third_party/blink/renderer/core/loader/resource/script_resource.h
    Line 290, Patchset 11: base::HeapArray<uint8_t> FlatData();
    Hiroshige Hayashizaki . resolved

    Could you rename this to `GetWasmSource()`?
    Also add "for Wasm sources" in the comment.

    Luis Pardo

    Done

    Line 289, Patchset 11: // The buffer is not stored within this class.
    Hiroshige Hayashizaki . resolved

    "The returned buffer is not stored within this class." is clearer.

    Luis Pardo

    Done

    Line 288, Patchset 11: // Returns a flattened representation of the Data and clears the buffer.
    Hiroshige Hayashizaki . resolved

    " and clears the buffer" part is obsolete.

    Luis Pardo

    Done

    Line 125, Patchset 11: ResolvedModuleType module_type);
    Hiroshige Hayashizaki . resolved

    Could you rename this to `GetSourceTextOrWasmSource()`?
    (Assuming FlatData() is renamed to GetWasmSource())

    So that the name directly corresponds to underlying GetWasmSource() and SourceText().

    Luis Pardo

    Done

    Line 124, Patchset 11: std::variant<ParkableString, base::HeapArray<uint8_t>> GetBytesOrTextSource(
    Hiroshige Hayashizaki . resolved

    Could you add comments:

    About return type:

    ```
    For module purposes.
    Returns the wire bytes for Wasm modules, or otherwise, the decoded text.
    See `ModuleScriptCreationParams::source_`.
    ```

    About module_type:

    ```
    `module_type` should be from `ModuleScriptFetcher::WasModuleLoadSuccessful(this,...)`.
    Particularly, if `module_type` is `kWasm`, then the Content Type of `this` should be a WASM MIME type (See the corresponding `CHECK()` in `FlatData()`).
    ```

    Luis Pardo

    Done

    Line 120, Patchset 11: // If needed, decode the source buffer into a ParkableString.
    Hiroshige Hayashizaki . resolved

    This is a little confusing, because even without calling `SourceText`, the source buffer can be decoded.

    So maybe this should be:

    ```
    // Returns the decoded source text as a ParkableString.
    ```

    Luis Pardo

    Done

    File third_party/blink/renderer/core/loader/resource/script_resource.cc
    Line 247, Patchset 11: // Data is not cleared for Wasm resources.
    Hiroshige Hayashizaki . resolved

    Could you add a TODO? like

    ```
    TODO(https://crbug.com/425682456): Currently this assumption doesn't hold.
    ```

    Luis Pardo

    Done

    Line 248, Patchset 11: CHECK(Data());
    Hiroshige Hayashizaki . resolved

    Could you add

    ```
    CHECK(IsLoaded());
    CHECK(base::FeatureList::IsEnabled(
    blink::features::kJavaScriptSourcePhaseImports));
    CHECK(MIMETypeRegistry::IsWasmMIMEType(GetResponse().HttpContentType()));
    ```
    Luis Pardo

    Done

    Line 270, Patchset 11: // Wasm resources are not decoded, so we return an empty string.
    Hiroshige Hayashizaki . resolved

    nit: Creating a separate paragraph + adding a word "also" might be easier to read.

    ```
    // ... or we either haven't started loading and haven't received data yet, or
    // we finished loading with an error/cancellation, and thus don't have data.
    // In both cases, we can treat the resource as empty.
      // Also Wasm resources are not decoded, so we return an empty string.
    // TODO(https://crbug.com/42204365): Investigate if we need inspector support.
    ```
    Luis Pardo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Hiroshige Hayashizaki
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Comment-Date: Wed, 18 Jun 2025 23:04:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hiroshige Hayashizaki (Gerrit)

    unread,
    Jun 18, 2025, 11:17:43 PMJun 18
    to Luis Pardo, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
    Attention needed from Luis Pardo

    Hiroshige Hayashizaki voted and added 4 comments

    Votes added by Hiroshige Hayashizaki

    Code-Review+1

    4 comments

    Patchset-level comments
    File-level comment, Patchset 12 (Latest):
    Hiroshige Hayashizaki . resolved

    LGTM

    Commit Message
    Line 9, Patchset 10:Support for Wasm modules was already added, but the sources are
    Hiroshige Hayashizaki . resolved
    Hiroshige Hayashizaki

    sg. I wanted to just confirm the `JavaScriptSourcePhaseImports` feature isn't enabled by any experiments.

    File third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
    Line 155, Patchset 11: // Cannot be const to support the move constructor.
    Hiroshige Hayashizaki . resolved

    Is this still true? I feel this can be still const just like other const fields.

    Luis Pardo

    It's still true. The move constructor defaults to the copy constructor for the const members, all the other members are trivial or have a copy constructor (like KURL), but the new variant doesn't because `HeapArray` is move only, and even if it had, we wouldn't like to be copying this memory instead of moving it.

    Hiroshige Hayashizaki

    Er, I see, we have to move out. Thank you for clarification.

    File third_party/blink/renderer/core/loader/modulescript/module_script_loader_test.cc
    Line 598, Patchset 11: TestFetchURL(ModuleScriptCustomFetchType::kNone, client,
    Hiroshige Hayashizaki . unresolved

    Can this non-ASCII test be a WPT?
    Not blocking this CL, but for the long term adding as WPT is better.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Luis Pardo

    Can this non-ASCII test be a WPT?

    I'll add it in a follow-up CL. Would you prefer it as a WPT internal or external test? I'm trying to understand if this would be a Chomium-specific bug or is general enough to be relevant to other browsers.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Updated it

    Hiroshige Hayashizaki

    sg.

    Would you prefer it as a WPT internal or external test?

    I basically prefer external WPT, to make internal tests really internal-only (those with Chromium-specific behavior expectations or Chromium-specific test infra).
    The test might be specific to Chromium bug, but anyway other browsers should still pass the test without any bugs (and it's also theoretically possible to catch bugs in other browsers e.g. Safari due to the common code between Blink/WebKit).

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Luis Pardo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 03:17:15 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Luis Pardo (Gerrit)

    unread,
    Jun 18, 2025, 11:56:35 PMJun 18
    to Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org

    Luis Pardo added 1 comment

    File third_party/blink/renderer/core/loader/modulescript/module_script_loader_test.cc
    Line 598, Patchset 11: TestFetchURL(ModuleScriptCustomFetchType::kNone, client,
    Hiroshige Hayashizaki . resolved

    Can this non-ASCII test be a WPT?
    Not blocking this CL, but for the long term adding as WPT is better.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Luis Pardo

    Can this non-ASCII test be a WPT?

    I'll add it in a follow-up CL. Would you prefer it as a WPT internal or external test? I'm trying to understand if this would be a Chomium-specific bug or is general enough to be relevant to other browsers.

    (very nit: maybe this is more like non-UTF8 rather than non-ASCII?)

    Updated it

    Hiroshige Hayashizaki

    sg.

    Would you prefer it as a WPT internal or external test?

    I basically prefer external WPT, to make internal tests really internal-only (those with Chromium-specific behavior expectations or Chromium-specific test infra).
    The test might be specific to Chromium bug, but anyway other browsers should still pass the test without any bugs (and it's also theoretically possible to catch bugs in other browsers e.g. Safari due to the common code between Blink/WebKit).

    Luis Pardo

    Acknowledged

    Open in Gerrit

    Related details

    Attention set is empty
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 03:56:25 +0000
    satisfied_requirement
    open
    diffy

    Luis Pardo (Gerrit)

    unread,
    Jun 18, 2025, 11:58:39 PMJun 18
    to Dominic Farolino, Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
    Attention needed from Dominic Farolino

    Luis Pardo added 1 comment

    Patchset-level comments
    Luis Pardo . resolved

    @d...@chromium.org can you take a look at VirtualTestSuites? Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Dominic Farolino
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Dominic Farolino <d...@chromium.org>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 03:58:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    open
    diffy

    Dominic Farolino (Gerrit)

    unread,
    Jun 19, 2025, 7:54:14 AMJun 19
    to Luis Pardo, Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org
    Attention needed from Luis Pardo

    Dominic Farolino voted and added 1 comment

    Votes added by Dominic Farolino

    Code-Review+1

    1 comment

    Patchset-level comments
    Dominic Farolino . resolved

    VTS LGTM

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Luis Pardo
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 11:54:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Luis Pardo (Gerrit)

    unread,
    Jun 19, 2025, 12:15:31 PMJun 19
    to Dominic Farolino, Hiroshige Hayashizaki, Dan Clark, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org

    Luis Pardo voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 12
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-CC: Dan Clark <dan...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Comment-Date: Thu, 19 Jun 2025 16:15:18 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Chromium LUCI CQ (Gerrit)

    unread,
    Jun 19, 2025, 12:18:59 PMJun 19
    to Luis Pardo, Dominic Farolino, Hiroshige Hayashizaki, Dan Clark, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, blink-work...@chromium.org, dom+...@chromium.org, gavinp...@chromium.org, hiroshig...@chromium.org, horo+...@chromium.org, kinuko...@chromium.org, kouhei...@chromium.org, loading...@chromium.org, shimazu...@chromium.org

    Chromium LUCI CQ submitted the change

    Change information

    Commit message:
    [source-phase-imports] Don't use ParkableStrings for Wasm sources


    Support for Wasm modules was already added, but the sources are
    currently stored in ParkableStrings and going through the same decoding
    as text sources. This is wrong because the Wasm compiler works directly
    with the wire bytes; and it's buggy because the presence of non-UTF8
    "characters" in the sources will lift the string to 16-bit storage,
    corrupting the Wasm source.

    Main changes:
    - Replace the source_text_ ParkableString class member in
    ModuleScriptCreationParams with a variant holding either a HeapArray
    (for wasm) or a ParkableString (otherwise).
    - Add a GetBytesOrTextSource method to ScriptResource to retrieve the
    variant with the source.
    - Add a wpt internal to test that the same resource can be requested
    twice in the same module.

    Drive by:
    - WasmModuleScript: spanify the empty wasm byte sequence constant.
    - Update outdated comments in ScriptResource.
    Bug: 42204365, 425682456
    Change-Id: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Reviewed-by: Dominic Farolino <d...@chromium.org>
    Reviewed-by: Hiroshige Hayashizaki <hiro...@chromium.org>
    Commit-Queue: Luis Pardo <lpardo...@microsoft.com>
    Cr-Commit-Position: refs/heads/main@{#1476191}
    Files:
    • M third_party/blink/renderer/core/loader/modulescript/document_module_script_fetcher.cc
    • M third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.cc
    • M third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h
    • M third_party/blink/renderer/core/loader/modulescript/module_script_loader_test.cc
    • M third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.cc
    • M third_party/blink/renderer/core/loader/modulescript/worker_module_script_fetcher.h
    • M third_party/blink/renderer/core/loader/modulescript/worklet_module_script_fetcher.cc
    • M third_party/blink/renderer/core/loader/resource/script_resource.cc
    • M third_party/blink/renderer/core/loader/resource/script_resource.h
    • M third_party/blink/renderer/core/script/module_map_test.cc
    • M third_party/blink/renderer/core/script/wasm_module_script.cc
    • M third_party/blink/renderer/core/script/wasm_module_script.h
    • M third_party/blink/renderer/core/testing/data/core_test_bundle_data.filelist
    • A third_party/blink/renderer/core/testing/data/non_UTF8.wasm
    • M third_party/blink/web_tests/VirtualTestSuites
    • A third_party/blink/web_tests/virtual/javascript-source-phase-imports/wpt_internal/js/source-phase-imports/import-same-wasm-resource-twice-expected.txt
    • A third_party/blink/web_tests/wpt_internal/js/source-phase-imports/import-same-wasm-resource-twice-expected.txt
    • A third_party/blink/web_tests/wpt_internal/js/source-phase-imports/import-same-wasm-resource-twice.html
    • A third_party/blink/web_tests/wpt_internal/js/source-phase-imports/resources/exported-names.wasm
    Change size: M
    Delta: 19 files changed, 171 insertions(+), 40 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Dominic Farolino, +1 by Hiroshige Hayashizaki
    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: If62f7d842042579927d3cca48b8c03a1a4be5a22
    Gerrit-Change-Number: 6612586
    Gerrit-PatchSet: 13
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
    Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages