mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +02:00
Merge pull request #18401 from timvandermeij/test-orphaned-browsers
Fix orphaned browser processes due to uncaught exceptions in the tests
This commit is contained in:
commit
fe692435d3
1 changed files with 23 additions and 17 deletions
|
@ -970,8 +970,6 @@ async function startBrowsers({ baseUrl, initializeSession }) {
|
||||||
await puppeteer.trimCache();
|
await puppeteer.trimCache();
|
||||||
|
|
||||||
const browserNames = options.noChrome ? ["firefox"] : ["firefox", "chrome"];
|
const browserNames = options.noChrome ? ["firefox"] : ["firefox", "chrome"];
|
||||||
|
|
||||||
sessions = [];
|
|
||||||
for (const browserName of browserNames) {
|
for (const browserName of browserNames) {
|
||||||
// The session must be pushed first and augmented with the browser once
|
// The session must be pushed first and augmented with the browser once
|
||||||
// it's initialized. The reason for this is that browser initialization
|
// it's initialized. The reason for this is that browser initialization
|
||||||
|
@ -1078,25 +1076,33 @@ async function main() {
|
||||||
stats = [];
|
stats = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.downloadOnly) {
|
try {
|
||||||
await ensurePDFsDownloaded();
|
if (options.downloadOnly) {
|
||||||
} else if (options.unitTest) {
|
await ensurePDFsDownloaded();
|
||||||
// Allows linked PDF files in unit-tests as well.
|
} else if (options.unitTest) {
|
||||||
await ensurePDFsDownloaded();
|
// Allows linked PDF files in unit-tests as well.
|
||||||
startUnitTest("/test/unit/unit_test.html", "unit");
|
await ensurePDFsDownloaded();
|
||||||
} else if (options.fontTest) {
|
await startUnitTest("/test/unit/unit_test.html", "unit");
|
||||||
startUnitTest("/test/font/font_test.html", "font");
|
} else if (options.fontTest) {
|
||||||
} else if (options.integration) {
|
await startUnitTest("/test/font/font_test.html", "font");
|
||||||
// Allows linked PDF files in integration-tests as well.
|
} else if (options.integration) {
|
||||||
await ensurePDFsDownloaded();
|
// Allows linked PDF files in integration-tests as well.
|
||||||
startIntegrationTest();
|
await ensurePDFsDownloaded();
|
||||||
} else {
|
await startIntegrationTest();
|
||||||
startRefTest(options.masterMode, options.reftest);
|
} else {
|
||||||
|
await startRefTest(options.masterMode, options.reftest);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Close the browsers if uncaught exceptions occur, otherwise the spawned
|
||||||
|
// processes can become orphaned and keep running after `test.mjs` exits
|
||||||
|
// because the teardown logic of the tests did not get a chance to run.
|
||||||
|
console.error(e);
|
||||||
|
await Promise.all(sessions.map(session => closeSession(session.name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
var sessions;
|
var sessions = [];
|
||||||
var onAllSessionsClosed;
|
var onAllSessionsClosed;
|
||||||
var host = "127.0.0.1";
|
var host = "127.0.0.1";
|
||||||
var options = parseOptions();
|
var options = parseOptions();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue