playwright-core
Advanced tools
Comparing version 1.50.0-alpha-2024-12-14 to 1.50.0-alpha-2024-12-15
@@ -83,4 +83,4 @@ "use strict"; | ||
// Create default page as we cannot get access to the existing one. | ||
const pageDelegate = await browser._defaultContext.newPageDelegate(); | ||
await pageDelegate.pageOrError(); | ||
const page = await browser._defaultContext.doCreateNewPage(); | ||
await page.waitForInitializedOrError(); | ||
} | ||
@@ -177,9 +177,6 @@ return browser; | ||
} | ||
pages() { | ||
return this._bidiPages().map(bidiPage => bidiPage._initializedPage).filter(Boolean); | ||
possiblyUninitializedPages() { | ||
return this._bidiPages().map(bidiPage => bidiPage._page); | ||
} | ||
pagesOrErrors() { | ||
return this._bidiPages().map(bidiPage => bidiPage.pageOrError()); | ||
} | ||
async newPageDelegate() { | ||
async doCreateNewPage() { | ||
(0, _browserContext.assertBrowserContextIsNotOwned)(this); | ||
@@ -192,3 +189,3 @@ const { | ||
}); | ||
return this._browser._bidiPages.get(context); | ||
return this._browser._bidiPages.get(context)._page; | ||
} | ||
@@ -195,0 +192,0 @@ async doGetCookies(urls) { |
@@ -44,3 +44,2 @@ "use strict"; | ||
this._page = void 0; | ||
this._pagePromise = void 0; | ||
this._session = void 0; | ||
@@ -53,3 +52,2 @@ this._opener = void 0; | ||
this._pdf = void 0; | ||
this._initializedPage = null; | ||
this._initScriptIds = []; | ||
@@ -70,11 +68,9 @@ this._session = bidiSession; | ||
// Initialize main frame. | ||
this._pagePromise = this._initialize().finally(async () => { | ||
await this._page.initOpener(this._opener); | ||
}).then(() => { | ||
this._initializedPage = this._page; | ||
this._page.reportAsNew(); | ||
return this._page; | ||
}).catch(e => { | ||
this._page.reportAsNew(e); | ||
return e; | ||
// TODO: Wait for first execution context to be created and maybe about:blank navigated. | ||
this._initialize().then(() => { | ||
var _this$_opener; | ||
return this._page.reportAsNew((_this$_opener = this._opener) === null || _this$_opener === void 0 ? void 0 : _this$_opener._page); | ||
}, error => { | ||
var _this$_opener2; | ||
return this._page.reportAsNew((_this$_opener2 = this._opener) === null || _this$_opener2 === void 0 ? void 0 : _this$_opener2._page, error); | ||
}); | ||
@@ -90,5 +86,2 @@ } | ||
} | ||
potentiallyUninitializedPage() { | ||
return this._page; | ||
} | ||
didClose() { | ||
@@ -99,6 +92,2 @@ this._session.dispose(); | ||
} | ||
async pageOrError() { | ||
// TODO: Wait for first execution context to be created and maybe about:blank navigated. | ||
return this._pagePromise; | ||
} | ||
_onFrameAttached(frameId, parentFrameId) { | ||
@@ -319,3 +308,3 @@ return this._page._frameManager.frameAttached(frameId, parentFrameId); | ||
if (event.channel !== kPlaywrightBindingChannel) return; | ||
const pageOrError = await this.pageOrError(); | ||
const pageOrError = await this._page.waitForInitializedOrError(); | ||
if (pageOrError instanceof Error) return; | ||
@@ -322,0 +311,0 @@ const context = this._realmToContext.get(event.source.realm); |
@@ -204,2 +204,5 @@ "use strict"; | ||
} | ||
pages() { | ||
return this.possiblyUninitializedPages().filter(page => page.initializedOrUndefined()); | ||
} | ||
@@ -270,19 +273,18 @@ // BrowserContext methods. | ||
async _loadDefaultContextAsIs(progress) { | ||
let pageOrError; | ||
if (!this.pagesOrErrors().length) { | ||
if (!this.possiblyUninitializedPages().length) { | ||
const waitForEvent = _helper.helper.waitForEvent(progress, this, BrowserContext.Events.Page); | ||
progress.cleanupWhenAborted(() => waitForEvent.dispose); | ||
// Race against BrowserContext.close | ||
pageOrError = await Promise.race([waitForEvent.promise, this._closePromise]); | ||
// Consider Page initialization errors | ||
if (pageOrError instanceof _page6.Page) pageOrError = await pageOrError._delegate.pageOrError(); | ||
} else { | ||
pageOrError = await this.pagesOrErrors()[0]; | ||
await Promise.race([waitForEvent.promise, this._closePromise]); | ||
} | ||
const page = this.possiblyUninitializedPages()[0]; | ||
if (!page) return; | ||
const pageOrError = await page.waitForInitializedOrError(); | ||
if (pageOrError instanceof Error) throw pageOrError; | ||
await pageOrError.mainFrame()._waitForLoadState(progress, 'load'); | ||
return pageOrError; | ||
await page.mainFrame()._waitForLoadState(progress, 'load'); | ||
return page; | ||
} | ||
async _loadDefaultContext(progress) { | ||
const defaultPage = await this._loadDefaultContextAsIs(progress); | ||
if (!defaultPage) return; | ||
const browserName = this._browser.options.name; | ||
@@ -293,5 +295,4 @@ if (this._options.isMobile && browserName === 'chromium' || this._options.locale && browserName === 'webkit') { | ||
// - webkit fails to change locale for existing page. | ||
const oldPage = defaultPage; | ||
await this.newPage(progress.metadata); | ||
await oldPage.close(progress.metadata); | ||
await defaultPage.close(progress.metadata); | ||
} | ||
@@ -390,5 +391,5 @@ } | ||
async newPage(metadata) { | ||
const pageDelegate = await this.newPageDelegate(); | ||
if (metadata.isServerSide) pageDelegate.potentiallyUninitializedPage().markAsServerSideOnly(); | ||
const pageOrError = await pageDelegate.pageOrError(); | ||
const page = await this.doCreateNewPage(); | ||
if (metadata.isServerSide) page.markAsServerSideOnly(); | ||
const pageOrError = await page.waitForInitializedOrError(); | ||
if (pageOrError instanceof _page6.Page) { | ||
@@ -395,0 +396,0 @@ if (pageOrError.isClosed()) throw new Error('Page has been closed.'); |
@@ -137,3 +137,3 @@ "use strict"; | ||
async _waitForAllPagesToBeInitialized() { | ||
await Promise.all([...this._crPages.values()].map(page => page.pageOrError())); | ||
await Promise.all([...this._crPages.values()].map(crPage => crPage._page.waitForInitializedOrError())); | ||
} | ||
@@ -243,5 +243,5 @@ _onAttachedToTarget({ | ||
page.willBeginDownload(); | ||
let originPage = page._initializedPage; | ||
let originPage = page._page.initializedOrUndefined(); | ||
// If it's a new window download, report it on the opener page. | ||
if (!originPage && page._opener) originPage = page._opener._initializedPage; | ||
if (!originPage && page._opener) originPage = page._opener._page.initializedOrUndefined(); | ||
if (!originPage) return; | ||
@@ -317,9 +317,6 @@ this._downloadCreated(originPage, payload.guid, payload.url, payload.suggestedFilename); | ||
} | ||
pages() { | ||
return this._crPages().map(crPage => crPage._initializedPage).filter(Boolean); | ||
possiblyUninitializedPages() { | ||
return this._crPages().map(crPage => crPage._page); | ||
} | ||
pagesOrErrors() { | ||
return this._crPages().map(crPage => crPage.pageOrError()); | ||
} | ||
async newPageDelegate() { | ||
async doCreateNewPage() { | ||
(0, _browserContext.assertBrowserContextIsNotOwned)(this); | ||
@@ -347,3 +344,3 @@ const oldKeys = this._browser.isClank() ? new Set(this._browser._crPages.keys()) : undefined; | ||
} | ||
return this._browser._crPages.get(targetId); | ||
return this._browser._crPages.get(targetId)._page; | ||
} | ||
@@ -476,3 +473,3 @@ async doGetCookies(urls) { | ||
for (const [targetId, backgroundPage] of this._browser._backgroundPages.entries()) { | ||
if (backgroundPage._browserContext === this && backgroundPage._initializedPage) { | ||
if (backgroundPage._browserContext === this && backgroundPage._page.initializedOrUndefined()) { | ||
backgroundPage.didClose(); | ||
@@ -498,3 +495,3 @@ this._browser._backgroundPages.delete(targetId); | ||
for (const backgroundPage of this._browser._backgroundPages.values()) { | ||
if (backgroundPage._browserContext === this && backgroundPage._initializedPage) result.push(backgroundPage._initializedPage); | ||
if (backgroundPage._browserContext === this && backgroundPage._page.initializedOrUndefined()) result.push(backgroundPage._page); | ||
} | ||
@@ -501,0 +498,0 @@ return result; |
@@ -71,4 +71,2 @@ "use strict"; | ||
this._browserContext = void 0; | ||
this._pagePromise = void 0; | ||
this._initializedPage = null; | ||
this._isBackgroundPage = void 0; | ||
@@ -109,25 +107,11 @@ // Holds window features for the next popup being opened via window.open, | ||
} | ||
// Note: it is important to call |reportAsNew| before resolving pageOrError promise, | ||
// so that anyone who awaits pageOrError got a ready and reported page. | ||
this._pagePromise = this._mainFrameSession._initialize(bits.hasUIWindow).then(async r => { | ||
await this._page.initOpener(this._opener); | ||
return r; | ||
}).catch(async e => { | ||
await this._page.initOpener(this._opener); | ||
throw e; | ||
}).then(() => { | ||
this._initializedPage = this._page; | ||
this._reportAsNew(); | ||
return this._page; | ||
}).catch(e => { | ||
this._reportAsNew(e); | ||
return e; | ||
const createdEvent = this._isBackgroundPage ? _crBrowser.CRBrowserContext.CREvents.BackgroundPage : _browserContext.BrowserContext.Events.Page; | ||
this._mainFrameSession._initialize(bits.hasUIWindow).then(() => { | ||
var _this$_opener; | ||
return this._page.reportAsNew((_this$_opener = this._opener) === null || _this$_opener === void 0 ? void 0 : _this$_opener._page, undefined, createdEvent); | ||
}, error => { | ||
var _this$_opener2; | ||
return this._page.reportAsNew((_this$_opener2 = this._opener) === null || _this$_opener2 === void 0 ? void 0 : _this$_opener2._page, error, createdEvent); | ||
}); | ||
} | ||
potentiallyUninitializedPage() { | ||
return this._page; | ||
} | ||
_reportAsNew(error) { | ||
this._page.reportAsNew(error, this._isBackgroundPage ? _crBrowser.CRBrowserContext.CREvents.BackgroundPage : _browserContext.BrowserContext.Events.Page); | ||
} | ||
async _forAllFrameSessions(cb) { | ||
@@ -160,5 +144,2 @@ const frameSessions = Array.from(this._sessions.values()); | ||
} | ||
async pageOrError() { | ||
return this._pagePromise; | ||
} | ||
didClose() { | ||
@@ -422,3 +403,3 @@ for (const session of this._sessions.values()) session.dispose(); | ||
await this._createVideoRecorder(screencastId, screencastOptions); | ||
this._crPage.pageOrError().then(p => { | ||
this._crPage._page.waitForInitializedOrError().then(p => { | ||
if (p instanceof Error) this._stopVideoRecording().catch(() => {}); | ||
@@ -717,3 +698,3 @@ }); | ||
async _onBindingCalled(event) { | ||
const pageOrError = await this._crPage.pageOrError(); | ||
const pageOrError = await this._crPage._page.waitForInitializedOrError(); | ||
if (!(pageOrError instanceof Error)) { | ||
@@ -776,4 +757,3 @@ const context = this._contextIdToContext.get(event.executionContextId); | ||
_willBeginDownload() { | ||
const originPage = this._crPage._initializedPage; | ||
if (!originPage) { | ||
if (!this._crPage._page.initializedOrUndefined()) { | ||
// Resume the page creation with an error. The page will automatically close right | ||
@@ -817,3 +797,3 @@ // after the download begins. | ||
gotFirstFrame.then(() => { | ||
this._crPage._browserContext._browser._videoStarted(this._crPage._browserContext, screencastId, options.outputFile, this._crPage.pageOrError()); | ||
this._crPage._browserContext._browser._videoStarted(this._crPage._browserContext, screencastId, options.outputFile, this._crPage._page.waitForInitializedOrError()); | ||
}); | ||
@@ -820,0 +800,0 @@ } |
@@ -135,3 +135,3 @@ "use strict"; | ||
ffPage._page._frameManager.frameAbortedNavigation(payload.frameId, 'Download is starting'); | ||
let originPage = ffPage._initializedPage; | ||
let originPage = ffPage._page.initializedOrUndefined(); | ||
// If it's a new window download, report it on the opener page. | ||
@@ -142,3 +142,3 @@ if (!originPage) { | ||
ffPage._markAsError(new Error('Starting new page download')); | ||
if (ffPage._opener) originPage = ffPage._opener._initializedPage; | ||
if (ffPage._opener) originPage = ffPage._opener._page.initializedOrUndefined(); | ||
} | ||
@@ -273,9 +273,6 @@ if (!originPage) return; | ||
} | ||
pages() { | ||
return this._ffPages().map(ffPage => ffPage._initializedPage).filter(pageOrNull => !!pageOrNull); | ||
possiblyUninitializedPages() { | ||
return this._ffPages().map(ffPage => ffPage._page); | ||
} | ||
pagesOrErrors() { | ||
return this._ffPages().map(ffPage => ffPage.pageOrError()); | ||
} | ||
async newPageDelegate() { | ||
async doCreateNewPage() { | ||
(0, _browserContext.assertBrowserContextIsNotOwned)(this); | ||
@@ -290,3 +287,3 @@ const { | ||
}); | ||
return this._browser._ffPages.get(targetId); | ||
return this._browser._ffPages.get(targetId)._page; | ||
} | ||
@@ -293,0 +290,0 @@ async doGetCookies(urls) { |
@@ -18,3 +18,2 @@ "use strict"; | ||
var _debugLogger = require("../../utils/debugLogger"); | ||
var _manualPromise = require("../../utils/manualPromise"); | ||
var _browserContext = require("../browserContext"); | ||
@@ -52,5 +51,3 @@ var _errors = require("../errors"); | ||
this._browserContext = void 0; | ||
this._pagePromise = new _manualPromise.ManualPromise(); | ||
this._initializedPage = null; | ||
this._initializationFailed = false; | ||
this._reportedAsNew = false; | ||
this._opener = void 0; | ||
@@ -75,10 +72,7 @@ this._contextIdToContext = void 0; | ||
this._eventListeners = [_eventsHelper.eventsHelper.addEventListener(this._session, 'Page.eventFired', this._onEventFired.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.frameAttached', this._onFrameAttached.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.frameDetached', this._onFrameDetached.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.navigationAborted', this._onNavigationAborted.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.navigationCommitted', this._onNavigationCommitted.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.navigationStarted', this._onNavigationStarted.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.sameDocumentNavigation', this._onSameDocumentNavigation.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Runtime.executionContextCreated', this._onExecutionContextCreated.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Runtime.executionContextDestroyed', this._onExecutionContextDestroyed.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Runtime.executionContextsCleared', this._onExecutionContextsCleared.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.linkClicked', event => this._onLinkClicked(event.phase)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.uncaughtError', this._onUncaughtError.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Runtime.console', this._onConsole.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.dialogOpened', this._onDialogOpened.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.bindingCalled', this._onBindingCalled.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.fileChooserOpened', this._onFileChooserOpened.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.workerCreated', this._onWorkerCreated.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.workerDestroyed', this._onWorkerDestroyed.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.dispatchMessageFromWorker', this._onDispatchMessageFromWorker.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.crashed', this._onCrashed.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.videoRecordingStarted', this._onVideoRecordingStarted.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.webSocketCreated', this._onWebSocketCreated.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.webSocketClosed', this._onWebSocketClosed.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.webSocketFrameReceived', this._onWebSocketFrameReceived.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.webSocketFrameSent', this._onWebSocketFrameSent.bind(this)), _eventsHelper.eventsHelper.addEventListener(this._session, 'Page.screencastFrame', this._onScreencastFrame.bind(this))]; | ||
this._session.once('Page.ready', async () => { | ||
await this._page.initOpener(this._opener); | ||
if (this._initializationFailed) return; | ||
// Note: it is important to call |reportAsNew| before resolving pageOrError promise, | ||
// so that anyone who awaits pageOrError got a ready and reported page. | ||
this._initializedPage = this._page; | ||
this._page.reportAsNew(); | ||
this._pagePromise.resolve(this._page); | ||
this._session.once('Page.ready', () => { | ||
var _this$_opener; | ||
if (this._reportedAsNew) return; | ||
this._reportedAsNew = true; | ||
this._page.reportAsNew((_this$_opener = this._opener) === null || _this$_opener === void 0 ? void 0 : _this$_opener._page); | ||
}); | ||
@@ -89,18 +83,9 @@ // Ideally, we somehow ensure that utility world is created before Page.ready arrives, but currently it is racy. | ||
} | ||
potentiallyUninitializedPage() { | ||
return this._page; | ||
} | ||
async _markAsError(error) { | ||
// Same error may be report twice: channer disconnected and session.send fails. | ||
if (this._initializationFailed) return; | ||
this._initializationFailed = true; | ||
if (!this._initializedPage) { | ||
await this._page.initOpener(this._opener); | ||
this._page.reportAsNew(error); | ||
this._pagePromise.resolve(error); | ||
} | ||
var _this$_opener2; | ||
// Same error may be reported twice: channel disconnected and session.send fails. | ||
if (this._reportedAsNew) return; | ||
this._reportedAsNew = true; | ||
this._page.reportAsNew((_this$_opener2 = this._opener) === null || _this$_opener2 === void 0 ? void 0 : _this$_opener2._page, error); | ||
} | ||
async pageOrError() { | ||
return this._pagePromise; | ||
} | ||
_onWebSocketCreated(event) { | ||
@@ -220,3 +205,3 @@ this._page._frameManager.onWebSocketCreated(webSocketId(event.frameId, event.wsid), event.requestURL); | ||
async _onBindingCalled(event) { | ||
const pageOrError = await this.pageOrError(); | ||
const pageOrError = await this._page.waitForInitializedOrError(); | ||
if (!(pageOrError instanceof Error)) { | ||
@@ -294,3 +279,3 @@ const context = this._contextIdToContext.get(event.executionContextId); | ||
_onVideoRecordingStarted(event) { | ||
this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this.pageOrError()); | ||
this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this._page.waitForInitializedOrError()); | ||
} | ||
@@ -297,0 +282,0 @@ didClose() { |
@@ -50,3 +50,4 @@ "use strict"; | ||
this._closedPromise = new _manualPromise.ManualPromise(); | ||
this._initialized = false; | ||
this._initialized = void 0; | ||
this._initializedPromise = new _manualPromise.ManualPromise(); | ||
this._eventsToEmitAfterInitialized = []; | ||
@@ -99,8 +100,10 @@ this._crashed = false; | ||
} | ||
async initOpener(opener) { | ||
if (!opener) return; | ||
const openerPage = await opener.pageOrError(); | ||
if (openerPage instanceof Page && !openerPage.isClosed()) this._opener = openerPage; | ||
async reportAsNew(opener, error = undefined, contextEvent = _browserContext.BrowserContext.Events.Page) { | ||
if (opener) { | ||
const openerPageOrError = await opener.waitForInitializedOrError(); | ||
if (openerPageOrError instanceof Page && !openerPageOrError.isClosed()) this._opener = openerPageOrError; | ||
} | ||
this._markInitialized(error, contextEvent); | ||
} | ||
reportAsNew(error = undefined, contextEvent = _browserContext.BrowserContext.Events.Page) { | ||
_markInitialized(error = undefined, contextEvent = _browserContext.BrowserContext.Events.Page) { | ||
if (error) { | ||
@@ -112,3 +115,3 @@ // Initialization error could have happened because of | ||
} | ||
this._initialized = true; | ||
this._initialized = error || this; | ||
this.emitOnContext(contextEvent, this); | ||
@@ -125,2 +128,6 @@ for (const { | ||
if (this.isClosed()) this.emit(Page.Events.Close);else this.instrumentation.onPageOpen(this); | ||
// Note: it is important to resolve _initializedPromise at the end, | ||
// so that anyone who awaits waitForInitializedOrError got a ready and reported page. | ||
this._initializedPromise.resolve(this._initialized); | ||
} | ||
@@ -130,2 +137,5 @@ initializedOrUndefined() { | ||
} | ||
waitForInitializedOrError() { | ||
return this._initializedPromise; | ||
} | ||
emitOnContext(event, ...args) { | ||
@@ -132,0 +142,0 @@ if (this._isServerSideOnly) return; |
@@ -111,3 +111,3 @@ "use strict"; | ||
page._page._frameManager.frameAbortedNavigation(payload.frameId, 'Download is starting'); | ||
let originPage = page._initializedPage; | ||
let originPage = page._page.initializedOrUndefined(); | ||
// If it's a new window download, report it on the opener page. | ||
@@ -118,3 +118,3 @@ if (!originPage) { | ||
page._firstNonInitialNavigationCommittedReject(new Error('Starting new page download')); | ||
if (page._opener) originPage = page._opener._initializedPage; | ||
if (page._opener) originPage = page._opener._page.initializedOrUndefined(); | ||
} | ||
@@ -214,9 +214,6 @@ if (!originPage) return; | ||
} | ||
pages() { | ||
return this._wkPages().map(wkPage => wkPage._initializedPage).filter(pageOrNull => !!pageOrNull); | ||
possiblyUninitializedPages() { | ||
return this._wkPages().map(wkPage => wkPage._page); | ||
} | ||
pagesOrErrors() { | ||
return this._wkPages().map(wkPage => wkPage.pageOrError()); | ||
} | ||
async newPageDelegate() { | ||
async doCreateNewPage() { | ||
(0, _browserContext.assertBrowserContextIsNotOwned)(this); | ||
@@ -228,3 +225,3 @@ const { | ||
}); | ||
return this._browser._wkPages.get(pageProxyId); | ||
return this._browser._wkPages.get(pageProxyId)._page; | ||
} | ||
@@ -231,0 +228,0 @@ async doGetCookies(urls) { |
@@ -26,3 +26,2 @@ "use strict"; | ||
var _debugLogger = require("../../utils/debugLogger"); | ||
var _manualPromise = require("../../utils/manualPromise"); | ||
var _browserContext = require("../browserContext"); | ||
@@ -59,3 +58,2 @@ var _errors = require("../errors"); | ||
this._page = void 0; | ||
this._pagePromise = new _manualPromise.ManualPromise(); | ||
this._pageProxySession = void 0; | ||
@@ -70,3 +68,2 @@ this._opener = void 0; | ||
this._browserContext = void 0; | ||
this._initializedPage = null; | ||
this._firstNonInitialNavigationCommittedPromise = void 0; | ||
@@ -108,5 +105,2 @@ this._firstNonInitialNavigationCommittedFulfill = () => {}; | ||
} | ||
potentiallyUninitializedPage() { | ||
return this._page; | ||
} | ||
async _initializePageProxySession() { | ||
@@ -309,3 +303,3 @@ if (this._page._browserContext.isSettingStorageState()) return; | ||
handleProvisionalLoadFailed(event) { | ||
if (!this._initializedPage) { | ||
if (!this._page.initializedOrUndefined()) { | ||
this._firstNonInitialNavigationCommittedReject(new Error('Initial load failed')); | ||
@@ -323,5 +317,2 @@ return; | ||
} | ||
async pageOrError() { | ||
return this._pagePromise; | ||
} | ||
async _onTargetCreated(event) { | ||
@@ -346,3 +337,4 @@ const { | ||
if (!targetInfo.isProvisional) { | ||
(0, _utils.assert)(!this._initializedPage); | ||
var _this$_opener; | ||
(0, _utils.assert)(!this._page.initializedOrUndefined()); | ||
let pageOrError; | ||
@@ -374,8 +366,3 @@ try { | ||
} | ||
await this._page.initOpener(this._opener); | ||
// Note: it is important to call |reportAsNew| before resolving pageOrError promise, | ||
// so that anyone who awaits pageOrError got a ready and reported page. | ||
this._initializedPage = pageOrError instanceof _page.Page ? pageOrError : null; | ||
this._page.reportAsNew(pageOrError instanceof _page.Page ? undefined : pageOrError); | ||
this._pagePromise.resolve(pageOrError); | ||
this._page.reportAsNew((_this$_opener = this._opener) === null || _this$_opener === void 0 ? void 0 : _this$_opener._page, pageOrError instanceof _page.Page ? undefined : pageOrError); | ||
} else { | ||
@@ -483,3 +470,3 @@ (0, _utils.assert)(targetInfo.isProvisional); | ||
async _onBindingCalled(contextId, argument) { | ||
const pageOrError = await this.pageOrError(); | ||
const pageOrError = await this._page.waitForInitializedOrError(); | ||
if (!(pageOrError instanceof Error)) { | ||
@@ -813,3 +800,3 @@ const context = this._contextIdToContext.get(contextId); | ||
this._recordingVideoFile = options.outputFile; | ||
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this.pageOrError()); | ||
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this._page.waitForInitializedOrError()); | ||
} | ||
@@ -816,0 +803,0 @@ async _stopVideo() { |
{ | ||
"name": "playwright-core", | ||
"version": "1.50.0-alpha-2024-12-14", | ||
"version": "1.50.0-alpha-2024-12-15", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7987742
109274