Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
soundofspace committed Aug 5, 2024
1 parent ac883b2 commit ec912ae
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions plugins/default-browser-emulator/test/detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1269,52 +1269,61 @@ it('should emulate in a blob shared worker', async () => {
if (req.url === '/test.html') {
res.end(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
const { hardwareConcurrency, userAgent, deviceMemory } = navigator;
const results = [{ hardwareConcurrency, userAgent, deviceMemory }];
const results = [{ hardwareConcurrency, userAgent, deviceMemory }];
(async () => {
async function check() {
const { port } = new SharedWorker(URL.createObjectURL(new Blob([
"const { hardwareConcurrency, userAgent, deviceMemory } = navigator;",
"onconnect = e => {",
" const port = e.ports[0];",
" port.postMessage({ hardwareConcurrency, userAgent, deviceMemory });",
" port.close();",
"};"
], { type: 'application/javascript' })));
const { port } = new SharedWorker(
URL.createObjectURL(
new Blob(
[
"const { hardwareConcurrency, userAgent, deviceMemory } = navigator;",
"onconnect = e => {",
" const port = e.ports[0];",
" port.postMessage({ hardwareConcurrency, userAgent, deviceMemory });",
" port.close();",
"};",
],
{ type: "application/javascript" }
)
)
);
port.start();
await new Promise(resolve => {
port.addEventListener("message", e => {
await new Promise((resolve) => {
port.addEventListener("message", (e) => {
port.close();
results.push(e.data);
resolve();
});
})
});
}
const checks = [];
for (let index = 0; index < 20; index++) {
checks.push(check());
}
await Promise.all(checks)
await fetch('/worker-result', {
method: 'POST',
await Promise.all(checks);
await fetch("/worker-result", {
method: "POST",
body: JSON.stringify(results),
});
})();
</script>
</body></html>`);
})();
</script>
</body>
</html>
`);
} else if (req.url.includes('worker-result')) {
const result = await Helpers.readableToBuffer(req);
jsonResults.push(result.toString());
Expand Down Expand Up @@ -1346,7 +1355,7 @@ it('should emulate in a blob shared worker', async () => {
resultWithUnmasked.push({ hardware: [...hardware], ua: [...ua] });
}
expect(resultWithUnmasked).toHaveLength(0);
});
}, 120e3);

test('should not trigger stack for unhandled error', async () => {
const agent = pool.createAgent({
Expand Down

0 comments on commit ec912ae

Please sign in to comment.