fix(snapshot): remove CSP meta from snapshot (#8698)
This commit is contained in:
parent
e2b092c1a0
commit
5d278db17b
|
|
@ -253,6 +253,8 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
|
|||
return;
|
||||
if (this._removeNoScript && nodeName === 'NOSCRIPT')
|
||||
return;
|
||||
if (nodeName === 'META' && (node as HTMLMetaElement).httpEquiv.toLowerCase() === 'content-security-policy')
|
||||
return;
|
||||
|
||||
const data = ensureCachedData(node);
|
||||
const values: any[] = [];
|
||||
|
|
|
|||
|
|
@ -283,6 +283,33 @@ it.describe('snapshots', () => {
|
|||
expect(await div.evaluate(div => div.scrollTop)).toBe(136);
|
||||
});
|
||||
|
||||
it('should work with meta CSP', async ({ page, showSnapshot, toImpl, snapshotter, browserName }) => {
|
||||
it.skip(browserName === 'firefox');
|
||||
|
||||
await page.setContent(`
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'none'">
|
||||
</head>
|
||||
<body>
|
||||
<div>Hello</div>
|
||||
</body>
|
||||
`);
|
||||
await page.$eval('div', div => {
|
||||
const shadow = div.attachShadow({ mode: 'open' });
|
||||
const span = document.createElement('span');
|
||||
span.textContent = 'World';
|
||||
shadow.appendChild(span);
|
||||
});
|
||||
|
||||
const snapshot = await snapshotter.captureSnapshot(toImpl(page), 'meta');
|
||||
|
||||
// Render snapshot, check expectations.
|
||||
const frame = await showSnapshot(snapshot);
|
||||
await frame.waitForSelector('div');
|
||||
// Should render shadow dom with post-processing script.
|
||||
expect(await frame.textContent('span')).toBe('World');
|
||||
});
|
||||
|
||||
it('should handle multiple headers', async ({ page, server, showSnapshot, toImpl, snapshotter, browserName }) => {
|
||||
it.skip(browserName === 'firefox');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue