Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(snapshot): remove CSP meta from snapshot (#8698)
Dmitry Gozman5d278db17bf3
diff --git a/src/server/snapshot/snapshotterInjected.ts b/src/server/snapshot/snapshotterInjected.tsindex 1b8ab30d5f..c169c75873 100644--- a/src/server/snapshot/snapshotterInjected.ts+++ b/src/server/snapshot/snapshotterInjected.ts@@ -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[] = [];diff --git a/tests/snapshotter.spec.ts b/tests/snapshotter.spec.tsindex f2b63958ca..947417ddc4 100644--- a/tests/snapshotter.spec.ts+++ b/tests/snapshotter.spec.ts@@ -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');