-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiag-shadow-text.test.ts
More file actions
34 lines (29 loc) · 1.25 KB
/
diag-shadow-text.test.ts
File metadata and controls
34 lines (29 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { test } from '@playwright/test';
import { fileURLToPath, pathToFileURL } from 'node:url';
import * as path from 'node:path';
import type { IRNode } from '../../src/types.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const demosDir = path.resolve(__dirname, '..', 'demos');
test('verify shadow DOM text quads fixed', async ({ page }) => {
const fileUrl = pathToFileURL(path.join(demosDir, 'text.html')).href;
await page.goto(fileUrl, { waitUntil: 'load' });
const { injectBoxQuadsPolyfill, injectLibrary } = await import('../helpers.js');
await injectBoxQuadsPolyfill(page);
await injectLibrary(page);
const ir: IRNode[] = await page.evaluate(() => {
const root = document.getElementById('root') || document.body;
return (window as any).__HC.extractIR(root, {
boxType: 'border',
includeText: true,
includeImages: true,
});
});
const textNodes = ir.filter(n => n.type === 'text');
for (const t of textNodes) {
if (t.type === 'text') {
const q = t.quad;
console.log('TEXT: "' + t.text.substring(0, 30) + '" quad[0]=(' + Math.round(q[0].x) + ',' + Math.round(q[0].y) + ') quad[3]=(' + Math.round(q[3].x) + ',' + Math.round(q[3].y) + ')');
}
}
});