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(input): emit change events upon page.setInputFiles (#1028)
Pavel Feldmanf2b2d7269326
diff --git a/src/dom.ts b/src/dom.tsindex ab2c3a05fa..b8f7ecc693 100644--- a/src/dom.ts+++ b/src/dom.ts@@ -571,4 +571,5 @@ export const setFileInputFunction = async (element: HTMLInputElement, payloads:dt.items.add(file);element.files = dt.files;element.dispatchEvent(new Event('input', { 'bubbles': true }));+ element.dispatchEvent(new Event('change', { 'bubbles': true }));};diff --git a/test/input.spec.js b/test/input.spec.jsindex 4a78afa06a..6889632391 100644--- a/test/input.spec.js+++ b/test/input.spec.js@@ -193,17 +193,19 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMIpath.relative(process.cwd(), __dirname + '/assets/pptr.png')).catch(e => error = e);expect(error).not.toBe(null);});- it('should emit input change event', async({page, server}) => {+ it('should emit input and change events', async({page, server}) => {const events = [];await page.exposeFunction('eventHandled', e => events.push(e));await page.setContent(`<input id=input type=file></input><script>input.addEventListener('input', e => eventHandled({ type: e.type }));+ input.addEventListener('change', e => eventHandled({ type: e.type }));</script>`);await (await page.$('input')).setInputFiles(FILE_TO_UPLOAD);- expect(events.length).toBe(1);+ expect(events.length).toBe(2);expect(events[0].type).toBe('input');+ expect(events[1].type).toBe('change');});});