fix(test): make sure selection is not empty before running copy command (#4772)
If current selection is empty document.execCommand('copy') may return false in some browsers (e.g. WebKit based ones).
This commit is contained in:
parent
7406b185d2
commit
1b4a0302fc
@ -226,7 +226,11 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
expect(error.message).toContain('JSHandles can be evaluated only in the context they were created');
|
||||
});
|
||||
it('should simulate a user gesture', async({page, server}) => {
|
||||
const result = await page.evaluate(() => document.execCommand('copy'));
|
||||
const result = await page.evaluate(() => {
|
||||
document.body.appendChild(document.createTextNode('test'));
|
||||
document.execCommand('selectAll');
|
||||
return document.execCommand('copy');
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
it('should throw a nice error after a navigation', async({page, server}) => {
|
||||
|
Loading…
Reference in New Issue
Block a user