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
test: add a failing canvas screenshot test (#11180)
Pavel Feldman328f3e265efe
diff --git a/tests/page/page-screenshot.spec.ts b/tests/page/page-screenshot.spec.tsindex 97c635dff9..06e110f64e 100644--- a/tests/page/page-screenshot.spec.ts+++ b/tests/page/page-screenshot.spec.ts@@ -321,4 +321,32 @@ it.describe('page screenshot', () => {screenshotSeveralTimes()]);});++ it('should work for text on canvas', async ({ page, headless, browserName, platform }) => {+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11177' });+ it.skip(platform !== 'darwin', 'Only test mac for font consistency');+ it.fixme(browserName === 'chromium' && !headless, 'Text is misaligned in headed vs headless Chromium');++ await page.setContent(`+ <canvas></canvas>+ <script>+ function draw() {+ const canvas = document.querySelector('canvas');+ canvas.width = 300;+ canvas.height = 150;+ canvas.style.width = '300px';+ canvas.style.height = '150px';++ const context = canvas.getContext('2d');+ context.font = 'bold 15px sans-serif';+ context.fillStyle = '#000000';+ context.textBaseline = 'middle';++ context.fillText('LOREM IPSUM', 10, 50);+ }+ </script>`);+ await page.evaluate('draw()');+ const screenshot = await page.screenshot();+ expect(screenshot).toMatchSnapshot('screenshot-canvas-text.png', { threshold: 0 });+ });});diff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-chromium.pngnew file mode 100644index 0000000000..0971000b5fBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-firefox.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-firefox.pngnew file mode 100644index 0000000000..5d10bf453dBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-firefox.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-webkit.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-webkit.pngnew file mode 100644index 0000000000..4ec99b0555Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-webkit.png differ