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

chore: remove nested navigation #12216

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/puppeteer-core/src/bidi/core/BrowsingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ export class BrowsingContext extends EventEmitter<{
this.#requests.delete(id);
}
}
// If the navigation hasn't finished, then this is nested navigation. The
// current navigation will handle this.
if (this.#navigation !== undefined && !this.#navigation.disposed) {
return;

if (this.#navigation !== undefined) {
this.#navigation.dispose();
}

// Note the navigation ID is null for this event.
Expand Down
18 changes: 1 addition & 17 deletions packages/puppeteer-core/src/bidi/core/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class Navigation extends EventEmitter<{

// keep-sorted start
#request: Request | undefined;
#navigation: Navigation | undefined;
readonly #browsingContext: BrowsingContext;
readonly #disposables = new DisposableStack();
#id?: string | null;
Expand Down Expand Up @@ -89,15 +88,6 @@ export class Navigation extends EventEmitter<{
const sessionEmitter = this.#disposables.use(
new EventEmitter(this.#session)
);
sessionEmitter.on('browsingContext.navigationStarted', info => {
if (
info.context !== this.#browsingContext.id ||
this.#navigation !== undefined
) {
return;
}
this.#navigation = Navigation.from(this.#browsingContext);
});

for (const eventName of [
'browsingContext.domContentLoaded',
Expand Down Expand Up @@ -141,9 +131,6 @@ export class Navigation extends EventEmitter<{
}

#matches(navigation: string | null): boolean {
if (this.#navigation !== undefined && !this.#navigation.disposed) {
return false;
}
if (this.#id === undefined) {
this.#id = navigation;
return true;
Expand All @@ -161,13 +148,10 @@ export class Navigation extends EventEmitter<{
get request(): Request | undefined {
return this.#request;
}
get navigation(): Navigation | undefined {
return this.#navigation;
}
// keep-sorted end

@inertIfDisposed
private dispose(): void {
dispose(): void {
this[disposeSymbol]();
}

Expand Down
Loading