mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
fix: do not report errored pages after context closure (#4346)
Consider the following sequence: - page opens a popup; - popup target is attached, we start initializing it; - user calls browser.close(); - browser is closed, and popup initialization fails; - we report "errored page" on the already closed context; - RPC client cannot make sense of this: "Cannot find parent object BrowserContext@guid to create Frame@guid" This issue was revealed during Firefox pipe migration.
This commit is contained in:
parent
4cb52144b5
commit
e942138913
@ -267,6 +267,10 @@ export abstract class BrowserContext extends EventEmitter {
|
||||
await this._doUpdateRequestInterception();
|
||||
}
|
||||
|
||||
isClosingOrClosed() {
|
||||
return this._closedStatus !== 'open';
|
||||
}
|
||||
|
||||
async close() {
|
||||
if (this._closedStatus === 'open') {
|
||||
this._closedStatus = 'closing';
|
||||
|
@ -164,8 +164,13 @@ export class CRBrowser extends Browser {
|
||||
this._crPages.set(targetInfo.targetId, crPage);
|
||||
crPage.pageOrError().then(pageOrError => {
|
||||
const page = crPage._page;
|
||||
if (pageOrError instanceof Error)
|
||||
if (pageOrError instanceof Error) {
|
||||
// Initialization error could have happened because of
|
||||
// context/browser closure. Just ignore the page.
|
||||
if (context!.isClosingOrClosed())
|
||||
return;
|
||||
page._setIsError();
|
||||
}
|
||||
context!.emit(BrowserContext.Events.Page, page);
|
||||
if (opener) {
|
||||
opener.pageOrError().then(openerPage => {
|
||||
|
@ -108,8 +108,13 @@ export class FFBrowser extends Browser {
|
||||
|
||||
ffPage.pageOrError().then(async pageOrError => {
|
||||
const page = ffPage._page;
|
||||
if (pageOrError instanceof Error)
|
||||
if (pageOrError instanceof Error) {
|
||||
// Initialization error could have happened because of
|
||||
// context/browser closure. Just ignore the page.
|
||||
if (context.isClosingOrClosed())
|
||||
return;
|
||||
page._setIsError();
|
||||
}
|
||||
context.emit(BrowserContext.Events.Page, page);
|
||||
if (!opener)
|
||||
return;
|
||||
|
@ -156,8 +156,13 @@ export class WKBrowser extends Browser {
|
||||
|
||||
wkPage.pageOrError().then(async pageOrError => {
|
||||
const page = wkPage._page;
|
||||
if (pageOrError instanceof Error)
|
||||
if (pageOrError instanceof Error) {
|
||||
// Initialization error could have happened because of
|
||||
// context/browser closure. Just ignore the page.
|
||||
if (context!.isClosingOrClosed())
|
||||
return;
|
||||
page._setIsError();
|
||||
}
|
||||
context!.emit(BrowserContext.Events.Page, page);
|
||||
if (!opener)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user