Skip to content

Commit

Permalink
fix(test): make sure selection is not empty before running copy comma…
Browse files Browse the repository at this point in the history
…nd (#4772)

If current selection is empty document.execCommand('copy') may return false in some browsers (e.g. WebKit based ones).
  • Loading branch information
yury-s authored and aslushnikov committed Jul 30, 2019
1 parent 7406b18 commit 1b4a030
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/evaluation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down

0 comments on commit 1b4a030

Please sign in to comment.