Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit change event on uploadFile calls #5389

Merged
merged 1 commit into from Mar 12, 2020

Conversation

phihag
Copy link
Contributor

@phihag phihag commented Feb 5, 2020

In puppeteer 1.20.0, the following code emitted an alert:

const puppeteer = require('puppeteer');

(async () => {
	const browser = await puppeteer.launch({args: ['--no-sandbox'], headless: false});
	const page = (await browser.pages())[0];

	await page.setContent(`
		<input type=file>
		<script>
		document.querySelector('input').addEventListener('change', () => {
			alert('Uploaded a file');
		});
		</script>
		`);
	const input = await page.waitForSelector('input[type="file"]');
	await input.uploadFile(__filename);
})();

This is broken in puppeteer 2.0.0 and 2.1.0.
A bisection yielded 6091a34 as the commit that broke this.

Emitting the change event as well seems to fix the problem.

@mathiasbynens
Copy link
Member

Thanks for the patch! Could you add a test for this as well please?

@heikkipora
Copy link

This PR (and bug) is related to the same file upload changeset: #5358 (and should be merged at the same time with this PR I think)

@phihag
Copy link
Contributor Author

phihag commented Feb 6, 2020

Updated to include tests for the input and change events.

In puppeteer 1.20.0, the following code emitted an alert:
```
const puppeteer = require('puppeteer');

(async () => {
	const browser = await puppeteer.launch({args: ['--no-sandbox'], headless: false});
	const page = (await browser.pages())[0];

	await page.setContent(`
		<input type=file>
		<script>
		document.querySelector('input').addEventListener('change', () => {
			alert('Uploaded a file');
		});
		</script>
		`);
	const input = await page.waitForSelector('input[type="file"]');
	await input.uploadFile(__filename);
})();
```

A bisection yielded 6091a34 as the commit that broke this.

Emitting the change event as well seems to fix the problem.
@SimonSchick
Copy link

Test failures seem unrelated to code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants