test: add focus traversal test (#2141)

This commit is contained in:
Pavel Feldman 2020-05-07 16:10:29 -07:00 committed by GitHub
parent 7a8dd2c361
commit 755ef11691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "playwright-core",
"version": "0.17.0-post",
"version": "1.0.0-post",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
const {FFOX, CHROMIUM, LINUX, WEBKIT} = require('./utils').testOptions(browserType);
describe('Page.focus', function() {
it('should work', async function({page, server}) {
@ -44,4 +44,19 @@ describe('Page.focus', function() {
expect(focused).toBe(true);
expect(blurred).toBe(true);
});
it.fail(WEBKIT && !LINUX)('should traverse focus', async function({page, server}) {
await page.setContent(`<input id="i1"><input id="i2">`);
let focused = false;
await page.exposeFunction('focusEvent', () => focused = true);
await page.evaluate(() => i2.addEventListener('focus', focusEvent));
await page.focus('#i1');
await page.keyboard.type("First");
await page.keyboard.press("Tab");
await page.keyboard.type("Last");
expect(focused).toBe(true);
expect(await page.$eval('#i1', e => e.value)).toBe('First');
expect(await page.$eval('#i2', e => e.value)).toBe('Last');
});
});