Skip to content

Commit

Permalink
chore: remove nested navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Apr 5, 2024
1 parent 17e9fee commit 116f483
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
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

0 comments on commit 116f483

Please sign in to comment.