mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
fix(snapshotter): allow rendering of & in STYLE tags (#31627)
Fixes https://github.com/microsoft/playwright/issues/31607
This commit is contained in:
parent
950875f0db
commit
d463d1f285
@ -53,12 +53,11 @@ export class SnapshotRenderer {
|
||||
const visit = (n: NodeSnapshot, snapshotIndex: number, parentTag: string | undefined, parentAttrs: [string, string][] | undefined): string => {
|
||||
// Text node.
|
||||
if (typeof n === 'string') {
|
||||
const text = escapeText(n);
|
||||
// Best-effort Electron support: rewrite custom protocol in url() links in stylesheets.
|
||||
// Old snapshotter was sending lower-case.
|
||||
if (parentTag === 'STYLE' || parentTag === 'style')
|
||||
return rewriteURLsInStyleSheetForCustomProtocol(text);
|
||||
return text;
|
||||
return rewriteURLsInStyleSheetForCustomProtocol(n);
|
||||
return escapeText(n);
|
||||
}
|
||||
|
||||
if (!(n as any)._string) {
|
||||
|
@ -429,6 +429,32 @@ test('should work with adopted style sheets and all: unset', async ({ page, runA
|
||||
}
|
||||
});
|
||||
|
||||
test('should work with nesting CSS selectors', async ({ page, runAndTrace }) => {
|
||||
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/31607' });
|
||||
|
||||
const traceViewer = await runAndTrace(async () => {
|
||||
await page.setContent(`
|
||||
<span class="foo" data-testid="green-element">Hi</span>
|
||||
<span class="foo bar" data-testid="red-element">Hello</span>
|
||||
<style>
|
||||
.foo {
|
||||
color: green;
|
||||
|
||||
&.bar {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
`);
|
||||
await page.evaluate(() => { });
|
||||
});
|
||||
{
|
||||
const frame = await traceViewer.snapshotFrame('page.evaluate', 0);
|
||||
await expect(frame.getByTestId('green-element')).toHaveCSS('color', /* green */'rgb(0, 128, 0)');
|
||||
await expect(frame.getByTestId('red-element')).toHaveCSS('color', /* red */'rgb(255, 0, 0)');
|
||||
}
|
||||
});
|
||||
|
||||
test('should restore scroll positions', async ({ page, runAndTrace }) => {
|
||||
const traceViewer = await runAndTrace(async () => {
|
||||
await page.setContent(`
|
||||
|
Loading…
Reference in New Issue
Block a user