From 691667e4447422851e8f3afb4180ce18396be894 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 14 Feb 2020 20:50:44 -0800 Subject: [PATCH] fix(input): emit change events upon page.setInputFiles --- src/dom.ts | 1 + test/input.spec.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dom.ts b/src/dom.ts index ab2c3a05faf33..b8f7ecc693724 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.js index 4a78afa06a7a3..68896323912ba 100644 --- a/test/input.spec.js +++ b/test/input.spec.js @@ -193,17 +193,19 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI path.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(` `); 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'); }); });