Skip to content

Commit b6d9c75

Browse files
ilonatommyCopilot
andauthored
Restore --unsafely-treat-insecure-origin-as-secure flag for Blazor WASM Lighthouse scenario (#2157)
* Restore --unsafely-treat-insecure-origin-as-secure flag for Blazor WASM Lighthouse scenario Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Also accept cached (fromCache) responses in WASM caching check The WASM caching enforcement check previously only accepted HTTP 304 (Not Modified) as proof that a .wasm resource was cached. However, browsers may serve cached resources with HTTP 200 from disk/memory cache without making a network round-trip at all. Puppeteer exposes this via response.fromCache(). Both cases indicate the resource was properly cached after the first page load, so both should be accepted. Without this fix, the 'Second page load' step fails with: Unexpected uncached wasm resource '...System.Runtime.InteropServices.JavaScript.*.wasm' even though the resource is served from the browser cache. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 38eea61 commit b6d9c75

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/BenchmarksApps/Lighthouse/src/blazor-scenario.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ logReadyStateText(); // Required by the Crank job
2424

2525
const browser = await puppeteer.launch({
2626
headless: headless === 'true',
27-
args: ['--no-sandbox']
27+
args: [
28+
'--no-sandbox',
29+
// Treat the target URL as a secure origin so that crypto.subtle is available.
30+
// This is needed because Blazor WASM requires crypto.subtle, which is only
31+
// available in secure contexts (HTTPS or localhost).
32+
`--unsafely-treat-insecure-origin-as-secure=${targetBaseUrl}`,
33+
],
2834
});
2935

3036
const pageUrl = `${targetBaseUrl}/counter`;
@@ -126,7 +132,8 @@ function throwOnFutureUncachedWasmDownloads(page) {
126132

127133
page.on('requestfinished', request => {
128134
const url = request.url();
129-
if (url.endsWith('.wasm') && request.response().status() !== 304) {
135+
const response = request.response();
136+
if (url.endsWith('.wasm') && response.status() !== 304 && !response.fromCache()) {
130137
throw new Error(`Unexpected uncached wasm resource '${url}'`);
131138
}
132139
});

0 commit comments

Comments
 (0)