Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/kind-schools-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@web/test-runner-chrome': patch
---

This changeset removes the Puppeteer/Chrome focus browser patches that shouldn't
be needed anymore, and can cause instability.

The patches were added quite a while ago, and the upstream issues should
be resolved in Chromium. See: https://issues.chromium.org/issues/40272146.

Also see:
https://github.com/puppeteer/puppeteer/issues/10350#issuecomment-1586858101.

The patches are currently also resulting some instability of web test
runner. That is because the patch calls an exposed function from inside
the browser, while navigation later on during `stopSession` can happen;
breaking the handle for retrieving function call arguments passed to the
exposed function.

Puppeteer team found this issue and also landed a fix to improve the
failure mode here. See:
https://github.com/puppeteer/puppeteer/pull/13759
10 changes: 10 additions & 0 deletions .changeset/shaggy-chefs-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@web/test-runner-core': patch
---

Improve debug message for test runner uncaught exceptions

This should make debugging easier. It wasn't very easy to figure out
where the errors originated from (because of how the actual uncaught
exception only happened with many concurrent builds inside a sandbox
environment that is hard to debug).
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/test-runner-chrome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"dependencies": {
"@web/test-runner-core": "^0.13.0",
"@web/test-runner-coverage-v8": "^0.8.0",
"async-mutex": "0.4.0",
"chrome-launcher": "^0.15.0",
"puppeteer-core": "^24.0.0"
},
Expand Down
40 changes: 0 additions & 40 deletions packages/test-runner-chrome/src/ChromeLauncherPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { Page, JSCoverageEntry } from 'puppeteer-core';
import { TestRunnerCoreConfig } from '@web/test-runner-core';
import { v8ToIstanbul } from '@web/test-runner-coverage-v8';
import { SessionResult } from '@web/test-runner-core';
import { Mutex } from 'async-mutex';

const mutex = new Mutex();

declare global {
interface Window {
Expand Down Expand Up @@ -49,43 +46,6 @@ export class ChromeLauncherPage {
});
}

// Patching the browser page to workaround an issue in the new headless mode of Chrome where some functions
// with callbacks (requestAnimationFrame and requestIdleCallback) are not executing their callbacks.
// https://github.com/puppeteer/puppeteer/issues/10350
if (!this.patchAdded) {
await this.puppeteerPage.exposeFunction('__bringTabToFront', (id: string) => {
const promise = new Promise(resolve => {
this.resolvers[id] = resolve as () => void;
});
return mutex.runExclusive(async () => {
await this.puppeteerPage.bringToFront();
await promise;
});
});
await this.puppeteerPage.exposeFunction('__releaseLock', (id: string) => {
this.resolvers[id]?.();
});
await this.puppeteerPage.evaluateOnNewDocument(() => {
// eslint-disable-next-line @typescript-eslint/ban-types
function patchFunction(name: string, fn: Function) {
(window as any)[name] = (...args: unknown[]) => {
const result = fn.call(window, ...args);
const id = Math.random().toString().substring(2);
// Make sure that the tab running the test code is brought back to the front.
window.__bringTabToFront(id);
fn.call(window, () => {
window.__releaseLock(id);
});
return result;
};
}

patchFunction('requestAnimationFrame', window.requestAnimationFrame);
patchFunction('requestIdleCallback', window.requestIdleCallback);
});
this.patchAdded = true;
}

await this.puppeteerPage.setViewport({ height: 600, width: 800 });
await this.puppeteerPage.goto(url);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/test-runner/src/startTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function startTestRunner(options: StartTestRunnerParams = {}) {
if (autoExitProcess) {
process.on('uncaughtException', error => {
/* eslint-disable-next-line no-console */
console.error(error);
console.error(`Uncaught exception, stopping test runner..\n`, error);
stop();
});
}
Expand Down
Loading