Skip to content

Commit d7bf680

Browse files
committed
Aligns Chrome for Testing version with compatible version of PuppeteerSharp
1 parent fde5b16 commit d7bf680

2 files changed

Lines changed: 8 additions & 43 deletions

File tree

Dockerfile.production

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
33

44
# Install dependencies for Puppeteer (runtime only, no Node.js needed here)
5+
# Install Chrome version 138.0.7204.101 to match PuppeteerSharp 20.2.x default.
6+
# IMPORTANT: Changing the PuppeteerSharp version or the Chrome version independently may break things. Only use compatible versions.
57
RUN apt-get update && apt-get install -y \
68
wget \
79
gnupg \
810
ca-certificates \
911
procps \
1012
libxss1 \
11-
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
12-
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
13-
&& apt-get update \
14-
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
13+
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
1514
--no-install-recommends \
15+
&& wget -q https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_138.0.6957.99-1_amd64.deb \
16+
&& apt-get install -y ./google-chrome-stable_138.0.6957.99-1_amd64.deb \
17+
&& rm google-chrome-stable_138.0.6957.99-1_amd64.deb \
1618
&& rm -rf /var/lib/apt/lists/*
1719

1820
WORKDIR /app

apps/pwabuilder/Services/ServiceWorkerAnalyzer.cs

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,9 @@ public async Task<PwaCapability> TryRunOfflineCheck(ServiceWorkerDetection? swDe
106106
// To test offline capability, we load the page in puppeteer. Then we disconnect the network and try to reload the page.
107107
// If the page loads successfully while offline, we mark the capability as passed.
108108
// NOTE: in the past we used Lighthouse's offline audit for this check. But as of summer 2025, Lighthouse has removed PWA audits including offline support audit.
109-
IPage? page = null;
110109
try
111110
{
112-
page = await puppeteerService.NavigateAsync(appUrl);
111+
using var page = await puppeteerService.NavigateAsync(appUrl);
113112
cancelToken.ThrowIfCancellationRequested();
114113

115114
// Wait for network to be idle
@@ -138,7 +137,7 @@ public async Task<PwaCapability> TryRunOfflineCheck(ServiceWorkerDetection? swDe
138137
cancelToken.ThrowIfCancellationRequested();
139138

140139
// Disconnect network
141-
page = await SetOfflineModeWithDisconnectedFallback(page, appUrl, logger);
140+
await page.SetOfflineModeAsync(true);
142141

143142
// Try to reload the page
144143
var response = await page.ReloadAsync(new NavigationOptions
@@ -166,46 +165,10 @@ public async Task<PwaCapability> TryRunOfflineCheck(ServiceWorkerDetection? swDe
166165
logger.LogWarning(ex, "Error checking offline capability for {url}", appUrl);
167166
offlineCapability.Status = PwaCapabilityCheckStatus.Failed;
168167
}
169-
finally
170-
{
171-
if (page != null)
172-
{
173-
page.Dispose();
174-
}
175-
}
176168

177169
return offlineCapability;
178170
}
179171

180-
private async Task<IPage> SetOfflineModeWithDisconnectedFallback(IPage page, Uri appUrl, ILogger logger)
181-
{
182-
try
183-
{
184-
// Try to set offline mode.
185-
await page.SetOfflineModeAsync(true);
186-
return page;
187-
}
188-
catch (TargetClosedException closedError)
189-
{
190-
// Some PWAs, such as https://belgrade.plus, have a disconnection error after waiting for service worker.
191-
// Re-navigate the page and immediately set offline mode since we've already loaded it.
192-
logger.LogWarning(closedError, "During offline detection test, the page disconnected. Reloading the page.");
193-
using var newPage = await this.puppeteerService.NavigateAsync(appUrl);
194-
await newPage.SetOfflineModeAsync(true);
195-
196-
try
197-
{
198-
page.Dispose();
199-
}
200-
catch (Exception disposeError)
201-
{
202-
logger.LogWarning(disposeError, "Error disposing Puppeteer page during offline detection fallback.");
203-
}
204-
205-
return newPage;
206-
}
207-
}
208-
209172
private PwaCapabilityCheckStatus RunCapabilityCheck(PwaCapability swCapability, ServiceWorkerDetection swDetection, string swScripts)
210173
{
211174
return swCapability.Id switch

0 commit comments

Comments
 (0)