Skip to content

Commit

Permalink
fix: Page.waitForDevicePrompt crash
Browse files Browse the repository at this point in the history
Only call `deviceRequestPromptManager()` if the parent frame is not
null.

Bug: #11072
Follow-up-of: #9299
  • Loading branch information
thiagowfx committed Oct 13, 2023
1 parent 8290dc9 commit 284e4c3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/puppeteer-core/src/cdp/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {Frame, FrameEvent, throwIfDetached} from '../api/Frame.js';
import type {HTTPResponse} from '../api/HTTPResponse.js';
import type {Page, WaitTimeoutOptions} from '../api/Page.js';
import {setPageContent} from '../common/util.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {disposeSymbol} from '../util/disposable.js';
import {isErrorLike} from '../util/ErrorLike.js';
Expand Down Expand Up @@ -292,12 +291,12 @@ export class CdpFrame extends Frame {
}

#deviceRequestPromptManager(): DeviceRequestPromptManager {
if (this.isOOPFrame()) {
const parentFrame = this.parentFrame();
if (this.isOOPFrame() || parentFrame === null) {
return this._frameManager._deviceRequestPromptManager(this.#client);
} else {
return parentFrame.#deviceRequestPromptManager();
}
const parentFrame = this.parentFrame();
assert(parentFrame !== null);
return parentFrame.#deviceRequestPromptManager();
}

@throwIfDetached
Expand Down

0 comments on commit 284e4c3

Please sign in to comment.