fix(highlight): drive-by fixes to selector highlight (#12083)

This commit is contained in:
Andrey Lushnikov 2022-02-14 11:32:18 -07:00 committed by GitHub
parent 5ea79c2ffa
commit 6c89f160e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -1144,7 +1144,7 @@ export class Frame extends SdkObject {
const pair = await this.resolveFrameForSelectorNoWait(selector);
if (!pair)
return;
const context = await this._utilityContext();
const context = await pair.frame._utilityContext();
const injectedScript = await context.injectedScript();
return await injectedScript.evaluate((injected, { parsed }) => {
return injected.highlight(parsed);

View File

@ -882,8 +882,9 @@ export class InjectedScript {
}
_runHighlightOnRaf(selector: ParsedSelector) {
if (this._highlight)
this._highlight.updateHighlight(this.querySelectorAll(selector, document.documentElement), stringifySelector(selector), false);
if (!this._highlight)
return;
this._highlight.updateHighlight(this.querySelectorAll(selector, document.documentElement), stringifySelector(selector), false);
requestAnimationFrame(() => this._runHighlightOnRaf(selector));
}