Refresh cached map worker policy for new providers

This commit is contained in:
n30nex committed 2026-09-13 02:15:44 -04:00
1 parent 6e76937122
commit 359c04c214
2 files changed
+14 -2

No files matched your search

+11 -1
View File
@@ -106,8 +106,18 @@ test('shows matching region colors in a viewport legend only when Regions is ena
await expect(page.locator('#region-legend')).toBeHidden();
});
test('renders buildings in desktop 3D', async ({ page }, info) => {
test('renders buildings in desktop 3D after upgrading a cached map worker', async ({ page }, info) => {
test.skip(info.project.name !== 'desktop', 'desktop 3D feature; mobile controls are covered separately');
// A previous install can retain this immutable worker with the old provider
// policy. An upgraded URL must fetch the current response headers instead.
await page.route(/\/assets\/maplibre-gl-worker-[^/?]+\.js(?:\?.*)?$/, async (route) => {
const response = await route.fetch();
const headers = response.headers();
if (!new URL(route.request().url()).search) {
headers['content-security-policy'] = "connect-src 'self' https://*.basemaps.cartocdn.com https://tiles.mapterhorn.com";
}
await route.fulfill({ response, headers });
});
await visualFixture(page, 15);
await page.goto('/');
const map = page.locator('#map');
+3 -1
View File
@@ -41,7 +41,9 @@ import {
} from './trafficVisuals';
import type { EndpointV2, NodeV2, PacketView, RouteV2, StateV2 } from './types';
maplibregl.setWorkerUrl(workerURL);
// Worker responses cache their own CSP. Refresh that cache when providers change,
// even if the bundled worker bytes (and their content hash) stay identical.
maplibregl.setWorkerUrl(`${workerURL}?policy=openfreemap-v1`);
export const DEFAULT_CENTER: [number, number] = [0, 20];
export const DEFAULT_ZOOM = 1.4;