Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/library/emulation-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,25 @@ browserTest('EM-024 should trigger hover state concurrently', async ({ browserTy
for (const page of [page1, page2, page3])
expect(await page.evaluate('window.clicked')).toBe(2);
});

browserTest('EM-028 should keep mouse drag when interacting with another page/context', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43969' },
}, async ({ contextFactory }) => {
const page1 = await (await contextFactory()).newPage();
const page2 = await (await contextFactory()).newPage();
for (const page of [page1, page2]) {
await page.setContent(`
<body style="margin: 0">
<input type="range" style="margin: 0; width: 200px; height: 20px" onchange="window.changed = true">
</body>
`);
}
await page1.mouse.move(100, 10);
await page1.mouse.down();
await page1.mouse.move(150, 10);
await page2.mouse.move(50, 50);
await page1.mouse.move(180, 10);
await page1.mouse.up();
expect(await page1.evaluate(() => !!window['changed'])).toBe(true);
expect(+await page1.locator('input').inputValue()).toBeGreaterThan(80);
});
38 changes: 25 additions & 13 deletions tests/page/page-filechooser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,32 @@ test('FC-007 should work when file input is attached to DOM', async ({ page, ser
expect(chooser).toBeTruthy();
});

test('FC-008 should work when file input is not attached to DOM', async ({ page, asset }) => {
const [, content] = await Promise.all([
page.waitForEvent('filechooser').then(chooser => chooser.setFiles(asset('file-to-upload.txt'))),
page.evaluate(async () => {
const el = document.createElement('input');
el.type = 'file';
el.click();
await new Promise(x => el.oninput = x);
const reader = new FileReader();
const promise = new Promise(fulfill => reader.onload = fulfill);
reader.readAsText(el.files[0]);
return promise.then(() => reader.result);
}),
test('FC-008 should work when file input is not attached to DOM', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43994' },
}, async ({ page, asset }) => {
await page.setContent(`<button>Open</button>`);
await page.evaluate(() => {
document.querySelector('button').onclick = () => {
const input = document.createElement('input');
input.type = 'file';
window['events'] = [];
for (const type of ['cancel', 'input', 'change'])
input.addEventListener(type, () => window['events'].push(`${type} ${input.files.length}`));
input.click();
};
});
const [chooser] = await Promise.all([
page.waitForEvent('filechooser'),
page.click('button'),
]);
await chooser.setFiles(asset('file-to-upload.txt'));
expect(await page.evaluate(() => window['events'])).toEqual(['input 1', 'change 1']);
const content = await chooser.element().evaluate(input => {
const reader = new FileReader();
const promise = new Promise(fulfill => reader.onload = fulfill);
reader.readAsText((input as HTMLInputElement).files[0]);
return promise.then(() => reader.result);
});
expect(content).toBe('contents of the file');
});

Expand Down
1 change: 1 addition & 0 deletions tests/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,7 @@ subsystem, add a row to the Subsystems table. Then update this file:
| `EM-025` | `library/emulation-coop.spec.ts` | emulation with COOP › should preserve context options |
| `EM-026` | `library/emulation-coop.spec.ts` | emulation with COOP › should preserve page.emulateMedia |
| `EM-027` | `library/emulation-coop.spec.ts` | emulation with COOP › should preserve mobile emulation |
| `EM-028` | `library/emulation-focus.spec.ts` | should keep mouse drag when interacting with another page/context |

### ER — Page errors and crashes

Expand Down
Loading