Skip to content

Commit 86768b9

Browse files
authored
test: add test for consistent hyphen rendering in headless/headed (#34159)
1 parent 372d419 commit 86768b9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/library/headful.spec.ts

+43
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,46 @@ it('headless and headful should use same default fonts', async ({ page, browserN
313313
}
314314
await headlessBrowser.close();
315315
});
316+
317+
it('should have the same hyphen rendering on headless and headed', {
318+
annotation: {
319+
type: 'issue',
320+
description: 'https://github.com/microsoft/playwright/issues/33590'
321+
}
322+
}, async ({ browserType, page, headless, server }) => {
323+
const content = `
324+
<!DOCTYPE html>
325+
<html lang="en">
326+
<head>
327+
<style>
328+
.hyphenated {
329+
width: 100px;
330+
hyphens: auto;
331+
text-align: justify;
332+
border: 1px solid black;
333+
}
334+
</style>
335+
</head>
336+
<body>
337+
<div class="hyphenated">
338+
supercalifragilisticexpialidocious
339+
</div>
340+
</body>
341+
</html>
342+
`;
343+
server.setRoute('/hyphenated.html', (req, res) => {
344+
res.writeHead(200, { 'Content-Type': 'text/html' });
345+
res.end(content);
346+
});
347+
const oppositeBrowser = await browserType.launch({ headless: !headless });
348+
const oppositePage = await oppositeBrowser.newPage();
349+
await oppositePage.goto(server.PREFIX + '/hyphenated.html');
350+
await page.goto(server.PREFIX + '/hyphenated.html');
351+
352+
const [divHeight1, divHeight2] = await Promise.all([
353+
page.evaluate(() => document.querySelector('.hyphenated').getBoundingClientRect().height),
354+
oppositePage.evaluate(() => document.querySelector('.hyphenated').getBoundingClientRect().height),
355+
]);
356+
expect(divHeight1).toBe(divHeight2);
357+
await oppositeBrowser.close();
358+
});

0 commit comments

Comments
 (0)