refactor: remove unnecessary return await in content-security and read-commands

Remove 6 redundant return-await patterns where there's no enclosing
try block. Eliminates all defensive.async-noise findings from these files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-09 04:41:46 -10:00
parent 11e56e9a10
commit 1ea3e44931
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ const ARIA_INJECTION_PATTERNS = [
* - ARIA labels with injection patterns
*/
export async function markHiddenElements(page: Page | Frame): Promise<string[]> {
return await page.evaluate((ariaPatterns: string[]) => {
return page.evaluate((ariaPatterns: string[]) => {
const found: string[] = [];
const elements = document.querySelectorAll('body *');
@@ -167,7 +167,7 @@ export async function markHiddenElements(page: Page | Frame): Promise<string[]>
* Uses clone + remove approach: clones body, removes marked elements, returns innerText.
*/
export async function getCleanTextWithStripping(page: Page | Frame): Promise<string> {
return await page.evaluate(() => {
return page.evaluate(() => {
const body = document.body;
if (!body) return '';
const clone = body.cloneNode(true) as HTMLElement;
+4 -4
View File
@@ -49,7 +49,7 @@ function wrapForEvaluate(code: string): string {
* Exported for DRY reuse in meta-commands (diff).
*/
export async function getCleanText(page: Page | Frame): Promise<string> {
return await page.evaluate(() => {
return page.evaluate(() => {
const body = document.body;
if (!body) return '';
const clone = body.cloneNode(true) as HTMLElement;
@@ -73,7 +73,7 @@ export async function handleReadCommand(
switch (command) {
case 'text': {
return await getCleanText(target);
return getCleanText(target);
}
case 'html': {
@@ -81,9 +81,9 @@ export async function handleReadCommand(
if (selector) {
const resolved = await session.resolveRef(selector);
if ('locator' in resolved) {
return await resolved.locator.innerHTML({ timeout: 5000 });
return resolved.locator.innerHTML({ timeout: 5000 });
}
return await target.locator(resolved.selector).innerHTML({ timeout: 5000 });
return target.locator(resolved.selector).innerHTML({ timeout: 5000 });
}
// page.content() is page-only; use evaluate for frame compat
const doctype = await target.evaluate(() => {