cherry-pick(#20998): fix: stricter condition for Firefox codegen tests workaround

This patch fixes the following tests on WebKit @ Darwin:
- library/inspector/cli-codegen-2.spec.ts:197:7 › cli codegen › should
download files
- library/inspector/cli-codegen-2.spec.ts:428:7 › cli codegen › should
update hover model on action
This commit is contained in:
Andrey Lushnikov 2023-02-17 12:19:46 -08:00 committed by Andrey Lushnikov
parent 31ace756d8
commit d32d466f2f

View file

@ -254,7 +254,7 @@ class Recorder {
const activeElement = this._deepActiveElement(document);
// Firefox dispatches "focus" event to body when clicking on a backgrounded headed browser window.
// We'd like to ignore this stray event.
if (activeElement === document.body)
if (userGesture && activeElement === document.body)
return;
const result = activeElement ? generateSelector(this._injectedScript, activeElement, this._testIdAttributeName) : null;
this._activeModel = result && result.selector ? result : null;