playwright/packages/playwright-core/src/server/injected
Ross Wollman fbb364c1cd
fix: page.locator.focus() and page.locator(…).type(…) (#14267)
Fixes focus and blur management when `page.locator(…).focus()`  and  `page.locator(…).type(…)` are used which was regressed by 7a5b070 (#13510).

#13510 relied on an implicit assumption that this (conditional) [`blur`](7a5b070e95/packages/playwright-core/src/server/injected/injectedScript.ts (L672)) call would always be followed by a call that resulted in a newly focused element via this [`focus`](7a5b070e95/packages/playwright-core/src/server/injected/injectedScript.ts (L674)) call.

However, some elements are [not focusable](https://html.spec.whatwg.org/multipage/interaction.html#focusable-area), so we were blurring incorrectly, and losing focus that we should have maintained.

Two regression tests were added that pass on the commit prior to 7a5b070e95 (and match manual testing/expectations):

* `page.locator(…).focus()`: _keeps focus on element when attempting to focus a non-focusable element_
* `page.locator(…).type(…)`: _should type repeatedly in input in shadow dom_

Additionally, a third test (_should type repeatedly in input in shadow dom_) was added to check the invariant from #13510 that states:

> This affects [contenteditable] elements, but not input elements.

and allows us to introduce the targeted fix (contenteditble check before blur) without breaking FF again.

And _should type repeatedly in contenteditable in shadow dom with nested elements_ was added to ensure the above fix works with nest contenteditble detection.

Fixes #14254.
2022-05-19 14:31:56 -07:00
..
consoleApi.ts chore: do not reset internal bindings for reuse (#14019) 2022-05-09 07:44:20 -07:00
DEPS.list chore: flatten supplements (#13437) 2022-04-08 12:52:40 -07:00
domUtils.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
highlight.ts feat(api): expose locator.highlight (#12420) 2022-03-01 13:56:21 -08:00
injectedScript.ts fix: page.locator.focus() and page.locator(…).type(…) (#14267) 2022-05-19 14:31:56 -07:00
layoutSelectorUtils.ts feat(locator): layout options (leftOf, rightOf, above, below, near) (#13821) 2022-05-03 10:33:33 +01:00
reactSelectorEngine.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
README.md chore: migrate to monorepo (#9421) 2021-10-11 16:52:17 +02:00
recorder.ts chore: do not reset internal bindings for reuse (#14019) 2022-05-09 07:44:20 -07:00
roleSelectorEngine.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
roleUtils.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
selectorEngine.ts chore: migrate to monorepo (#9421) 2021-10-11 16:52:17 +02:00
selectorEvaluator.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
selectorGenerator.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
selectorUtils.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
utilityScript.ts chore: use utils via index export (6) (#13417) 2022-04-07 21:48:41 -07:00
vueSelectorEngine.ts chore: split injected utils into proper files (#14093) 2022-05-11 13:49:12 +01:00
xpathSelectorEngine.ts chore: always import type (#13365) 2022-04-06 14:57:14 -07:00

Injected

This directory contains helper sources which are injected into the page.

These sources are bundled with webpack to src/generated to be used as a compile-time source constants. See *.webpack.config.js for configs.