Skip to content

Request interception causes blob URL cannot be loaded as a WebWorker script #6698

Description

@mstr-pezhang

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 5.5.0
  • Platform / OS version: Windows
  • URLs (if applicable):
  • Node.js version: 12.19.0

What steps will reproduce the problem?

It was not reproduced on Ubuntu or MacOS. (See the execution results in GitHub Actions https://github.com/mstr-pezhang/puppeteer-issue/actions/runs/443886088).

import puppeteer from 'puppeteer';
import compare from '../util/compareImage';

const exampleUrl = 'https://docs.mapbox.com/mapbox-gl-js/api/';
const baselinePath = 'output/mapbox-worker-normal.png';
const targetPath = 'output/mapbox-worker-request-interception.png';
const diffPath = 'output/mapbox-worker-diff.png';

let browser: puppeteer.Browser;
let page: puppeteer.Page;

test('Launch Chrome', async () => {
	browser = await puppeteer.launch();
});

test('Enable request interception', async () => {
	page = await browser.newPage();
	await page.setRequestInterception(true);
	page.on('request', (req) => {
		req.continue();
	});
});

test('Open example page', async () => {
	await page.goto(exampleUrl, { waitUntil: 'networkidle0' });
}, 30 * 1000);

test('Wait for 10s', (done) => {
	setTimeout(done, 10 * 1000);
}, 15 * 1000);

test('Take a screenshot', async () => {
	const map = await page.$('#demo');
	await map.screenshot({
		path: targetPath,
	});
	await page.close();
});

test('Open example page', async () => {
	page = await browser.newPage();
	await page.goto(exampleUrl, { waitUntil: 'networkidle0' });
}, 30 * 1000);

test('Wait for 10s', (done) => {
	setTimeout(done, 10 * 1000);
}, 15 * 1000);

test('Take a screenshot', async () => {
	const map = await page.$('#demo');
	await map.screenshot({
		path: baselinePath,
	});
	await page.close();
});

test('Compare 2 images', async () => {
	const diff = await compare(baselinePath, targetPath, diffPath);
	expect(diff.differences).toBe(0);
	expect(diff.dimension).toBeGreaterThan(0);
});

test('Close', async () => {
	await browser.close();
});
  1. Enable request interception and call request.continue() for each request.
  2. Open a new page to load Mapbox example page https://docs.mapbox.com/mapbox-gl-js/api/
  3. Wait for a while and see that all WebWorkers are not running because they are created with blob URLs.
  4. Use mapboxgl.workerUrl instead. Although this is a workaround forcontent security policy (Start web worker from static URL on startup mapbox/mapbox-gl-js#6058).
  5. See that the mapbox can be successfully rendered after workerUrl is set to https://*** or request interception is disabled.

Here's the demo project https://github.com/mstr-pezhang/chromium-issue

  1. Open the project with VS Code.
  2. Open mapbox-worker.spec.ts on a Windows machine.
  3. Click "Debug Jest".
  4. 3 images will be generated in the output folder.
  5. See the difference between mapbox-worker-normal.png and mapbox-worker-request-interception.png.

What is the expected result?
WebWorkers can be loaded via blob URLs.

What happens instead?
WebWorkers created with Blob URLs are not running and Mapbox cannot be rendered.

Activity

  1. stale commented on Jun 25, 2022

    @stale

    We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

  2. stale commented on Jul 25, 2022

    @stale

    We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions