Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop parsing unreachable webview names #900

Merged
23 changes: 15 additions & 8 deletions lib/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export interface WebviewsMapping {
/**
* Webview pages list as it is retrieved by `/json/list` CDP endpoint
*/
pages: StringRecord[];
pages?: StringRecord[];
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
/**
* An actual webview name for switching context.
*
Expand Down Expand Up @@ -1081,7 +1081,7 @@ export type SwipeAction = [
NonReleaseTouchAction,
NonReleaseTouchAction,
NonReleaseTouchAction,
ReleaseTouchAction
ReleaseTouchAction,
];

export type TouchDragAction = [NonReleaseTouchAction, NonReleaseTouchAction, ReleaseTouchAction];
Expand All @@ -1096,16 +1096,23 @@ export interface LockOpts {

export interface DeviceidleOpts {
/** The action name to execute */
action: 'whitelistAdd'|'whitelistRemove';
action: 'whitelistAdd' | 'whitelistRemove';
/** Either a single package or multiple packages to add or remove from the idle whitelist */
packages?: string|string[];
packages?: string | string[];
}

export interface SendTrimMemoryOpts {
/** The package name to send the `trimMemory` event to */
pkg: string;
/** The actual memory trim level to be sent */
level: 'COMPLETE' | 'MODERATE' | 'BACKGROUND' | 'UI_HIDDEN' | 'RUNNING_CRITICAL' | 'RUNNING_LOW' | 'RUNNING_MODERATE';
level:
| 'COMPLETE'
| 'MODERATE'
| 'BACKGROUND'
| 'UI_HIDDEN'
| 'RUNNING_CRITICAL'
| 'RUNNING_LOW'
| 'RUNNING_MODERATE';
}

export interface SetUiModeOpts {
Expand Down Expand Up @@ -1134,14 +1141,14 @@ export interface GetUiModeOpts {
export interface SmsListResultItem {
id: string;
address: string;
person: string|null;
person: string | null;
date: string;
read: string;
status: string;
type: string;
subject: string|null;
subject: string | null;
body: string;
serviceCenter: string|null;
serviceCenter: string | null;
}

export interface SmsListResult {
Expand Down
22 changes: 14 additions & 8 deletions lib/helpers/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ async function collectWebviewsDetails(
for (const item of webviewsMapping) {
detailCollectors.push(
(async () => {
let port: number|undefined;
let host: string|undefined;
let port: number | undefined;
let host: string | undefined;
try {
[host, port] = await allocateDevtoolsChannel(adb, item.proc, webviewDevtoolsPort);
if (enableWebviewDetailsCollection) {
Expand Down Expand Up @@ -396,12 +396,18 @@ const WebviewHelpers: WebviewHelpers = {

const result: string[] = [];
for (const {webview, pages, proc, webviewName} of webviewsMapping) {
if (ensureWebviewsHavePages && pages?.length === 0) {
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
logger.info(
`Skipping the webview '${webview}' at '${proc}' ` +
`since it has reported having zero pages`,
);
continue;
if (ensureWebviewsHavePages) {
if (_.isUndefined(pages)) {
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
logger.info(`Skipping the webview '${webview}' at '${proc}' since it is unreachable`);
continue;
}
if (pages.length === 0) {
logger.info(
`Skipping the webview '${webview}' at '${proc}' ` +
`since it has reported having zero pages`,
);
continue;
}
}
if (webviewName) {
result.push(webviewName);
Expand Down