Skip to content

Commit bdfc5aa

Browse files
fix: revert #page type change and use @ts-expect-error
Reverted the type of `#page` back to `CdpPage` and handled the `Dialog` compatibility issue locally using `@ts-expect-error` instead of a cast. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 8930eaf commit bdfc5aa

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/WaitForHelper.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {PredefinedNetworkConditions} from './third_party/index.js';
1010

1111
export class WaitForHelper {
1212
#abortController = new AbortController();
13-
#page: Page;
13+
#page: CdpPage;
1414
#stableDomTimeout: number;
1515
#stableDomFor: number;
1616
#expectNavigationIn: number;
@@ -25,7 +25,7 @@ export class WaitForHelper {
2525
this.#stableDomFor = 100 * cpuTimeoutMultiplier;
2626
this.#expectNavigationIn = 100 * cpuTimeoutMultiplier;
2727
this.#navigationTimeout = 3000 * networkTimeoutMultiplier;
28-
this.#page = page;
28+
this.#page = page as unknown as CdpPage;
2929
}
3030

3131
/**
@@ -101,11 +101,10 @@ export class WaitForHelper {
101101
resolve(true);
102102
};
103103

104-
const client = (this.#page as unknown as CdpPage)._client();
105-
client.on('Page.frameStartedNavigating', listener);
104+
this.#page._client().on('Page.frameStartedNavigating', listener);
106105
this.#abortController.signal.addEventListener('abort', () => {
107106
resolve(false);
108-
client.off('Page.frameStartedNavigating', listener);
107+
this.#page._client().off('Page.frameStartedNavigating', listener);
109108
});
110109
});
111110

@@ -137,8 +136,10 @@ export class WaitForHelper {
137136
void dialog.accept();
138137
}
139138
};
139+
// @ts-expect-error The Dialog type from CdpPage and Page are incompatible due to private properties.
140140
this.#page.on('dialog', dialogHandler);
141141
this.#abortController.signal.addEventListener('abort', () => {
142+
// @ts-expect-error The Dialog type from CdpPage and Page are incompatible due to private properties.
142143
this.#page.off('dialog', dialogHandler);
143144
});
144145
}

0 commit comments

Comments
 (0)