build(deps): bump playwright from 1.49.1 to 1.50.1

This commit is contained in:
2025-02-21 17:22:03 -07:00
parent 79c9869e65
commit dc6d9c68a9
174 changed files with 3064 additions and 1955 deletions

View File

@@ -134,7 +134,7 @@ class CRBrowser extends _browser.Browser {
return this.options.name === 'clank';
}
async _waitForAllPagesToBeInitialized() {
await Promise.all([...this._crPages.values()].map(page => page.pageOrError()));
await Promise.all([...this._crPages.values()].map(crPage => crPage._page.waitForInitializedOrError()));
}
_onAttachedToTarget({
targetInfo,
@@ -239,9 +239,9 @@ class CRBrowser extends _browser.Browser {
return;
}
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;
this._downloadCreated(originPage, payload.guid, payload.url, payload.suggestedFilename);
}
@@ -312,10 +312,10 @@ class CRBrowserContext extends _browserContext.BrowserContext {
_crPages() {
return [...this._browser._crPages.values()].filter(crPage => crPage._browserContext === this);
}
pages() {
return this._crPages().map(crPage => crPage._initializedPage).filter(Boolean);
possiblyUninitializedPages() {
return this._crPages().map(crPage => crPage._page);
}
async newPageDelegate() {
async doCreateNewPage() {
(0, _browserContext.assertBrowserContextIsNotOwned)(this);
const oldKeys = this._browser.isClank() ? new Set(this._browser._crPages.keys()) : undefined;
let {
@@ -338,7 +338,7 @@ class CRBrowserContext extends _browserContext.BrowserContext {
(0, _utils.assert)(newKeys.size === 1);
[targetId] = [...newKeys];
}
return this._browser._crPages.get(targetId);
return this._browser._crPages.get(targetId)._page;
}
async doGetCookies(urls) {
const {
@@ -372,7 +372,7 @@ class CRBrowserContext extends _browserContext.BrowserContext {
});
}
async doGrantPermissions(origin, permissions) {
const webPermissionToProtocol = new Map([['geolocation', 'geolocation'], ['midi', 'midi'], ['notifications', 'notifications'], ['camera', 'videoCapture'], ['microphone', 'audioCapture'], ['background-sync', 'backgroundSync'], ['ambient-light-sensor', 'sensors'], ['accelerometer', 'sensors'], ['gyroscope', 'sensors'], ['magnetometer', 'sensors'], ['accessibility-events', 'accessibilityEvents'], ['clipboard-read', 'clipboardReadWrite'], ['clipboard-write', 'clipboardSanitizedWrite'], ['payment-handler', 'paymentHandler'],
const webPermissionToProtocol = new Map([['geolocation', 'geolocation'], ['midi', 'midi'], ['notifications', 'notifications'], ['camera', 'videoCapture'], ['microphone', 'audioCapture'], ['background-sync', 'backgroundSync'], ['ambient-light-sensor', 'sensors'], ['accelerometer', 'sensors'], ['gyroscope', 'sensors'], ['magnetometer', 'sensors'], ['clipboard-read', 'clipboardReadWrite'], ['clipboard-write', 'clipboardSanitizedWrite'], ['payment-handler', 'paymentHandler'],
// chrome-specific permissions we have.
['midi-sysex', 'midiSysex'], ['storage-access', 'storageAccess']]);
const filtered = permissions.map(permission => {
@@ -466,7 +466,7 @@ class CRBrowserContext extends _browserContext.BrowserContext {
// When persistent context is closed, we do not necessary get Target.detachedFromTarget
// for all the background pages.
for (const [targetId, backgroundPage] of this._browser._backgroundPages.entries()) {
if (backgroundPage._browserContext === this && backgroundPage._initializedPage) {
if (backgroundPage._browserContext === this && backgroundPage._page.initializedOrUndefined()) {
backgroundPage.didClose();
this._browser._backgroundPages.delete(targetId);
}
@@ -487,7 +487,7 @@ class CRBrowserContext extends _browserContext.BrowserContext {
backgroundPages() {
const result = [];
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);
}
return result;
}

View File

@@ -100,11 +100,7 @@ class CRExecutionContext {
}
exports.CRExecutionContext = CRExecutionContext;
function rewriteError(error) {
if (error.message.includes('Object reference chain is too long')) return {
result: {
type: 'undefined'
}
};
if (error.message.includes('Object reference chain is too long')) throw new Error('Cannot serialize result: object reference chain is too long.');
if (error.message.includes('Object couldn\'t be returned by value')) return {
result: {
type: 'undefined'

View File

@@ -48,13 +48,19 @@ class RawKeyboardImpl {
// remove the trailing : to match the Chromium command names.
return commands.map(c => c.substring(0, c.length - 1));
}
async keydown(modifiers, code, keyCode, keyCodeWithoutLocation, key, location, autoRepeat, text) {
async keydown(modifiers, keyName, description, autoRepeat) {
const {
code,
key,
location,
text
} = description;
if (code === 'Escape' && (await this._dragManger.cancelDrag())) return;
const commands = this._commandsForCode(code, modifiers);
await this._client.send('Input.dispatchKeyEvent', {
type: text ? 'keyDown' : 'rawKeyDown',
modifiers: (0, _crProtocolHelper.toModifiersMask)(modifiers),
windowsVirtualKeyCode: keyCodeWithoutLocation,
windowsVirtualKeyCode: description.keyCodeWithoutLocation,
code,
commands,
key,
@@ -65,12 +71,17 @@ class RawKeyboardImpl {
isKeypad: location === input.keypadLocation
});
}
async keyup(modifiers, code, keyCode, keyCodeWithoutLocation, key, location) {
async keyup(modifiers, keyName, description) {
const {
code,
key,
location
} = description;
await this._client.send('Input.dispatchKeyEvent', {
type: 'keyUp',
modifiers: (0, _crProtocolHelper.toModifiersMask)(modifiers),
key,
windowsVirtualKeyCode: keyCodeWithoutLocation,
windowsVirtualKeyCode: description.keyCodeWithoutLocation,
code,
location
});

View File

@@ -68,8 +68,6 @@ class CRPage {
this._pdf = void 0;
this._coverage = void 0;
this._browserContext = void 0;
this._pagePromise = void 0;
this._initializedPage = null;
this._isBackgroundPage = void 0;
// Holds window features for the next popup being opened via window.open,
// until the popup target arrives. This could be racy if two oopifs
@@ -105,29 +103,15 @@ class CRPage {
screen: viewportSize
};
}
// 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) {
const frameSessions = Array.from(this._sessions.values());
await Promise.all(frameSessions.map(frameSession => {
@@ -155,9 +139,6 @@ class CRPage {
willBeginDownload() {
this._mainFrameSession._willBeginDownload();
}
async pageOrError() {
return this._pagePromise;
}
didClose() {
for (const session of this._sessions.values()) session.dispose();
this._page._didClose();
@@ -382,6 +363,9 @@ class FrameSession {
this._firstNonInitialNavigationCommittedFulfill = f;
this._firstNonInitialNavigationCommittedReject = r;
});
// The Promise is not always awaited (e.g. FrameSession._initialize can throw)
// so we catch errors here to prevent unhandled promise rejection.
this._firstNonInitialNavigationCommittedPromise.catch(() => {});
}
_isMainFrame() {
return this._targetId === this._crPage._targetId;
@@ -413,7 +397,7 @@ class FrameSession {
// Note: it is important to start video recorder before sending Page.startScreencast,
// and it is equally important to send Page.startScreencast before sending Runtime.runIfWaitingForDebugger.
await this._createVideoRecorder(screencastId, screencastOptions);
this._crPage.pageOrError().then(p => {
this._crPage._page.waitForInitializedOrError().then(p => {
if (p instanceof Error) this._stopVideoRecording().catch(() => {});
});
}
@@ -614,6 +598,9 @@ class FrameSession {
const frame = this._page._frameManager.frame(targetId);
if (!frame) return; // Subtree may be already gone due to renderer/browser race.
this._page._frameManager.removeChildFramesRecursively(frame);
for (const [contextId, context] of this._contextIdToContext) {
if (context.frame === frame) this._onExecutionContextDestroyed(contextId);
}
const frameSession = new FrameSession(this._crPage, session, targetId, this);
this._crPage._sessions.set(targetId, frameSession);
frameSession._initialize(false).catch(e => e);
@@ -704,7 +691,7 @@ class FrameSession {
this._page._addConsoleMessage(event.type, values, (0, _crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
}
async _onBindingCalled(event) {
const pageOrError = await this._crPage.pageOrError();
const pageOrError = await this._crPage._page.waitForInitializedOrError();
if (!(pageOrError instanceof Error)) {
const context = this._contextIdToContext.get(event.executionContextId);
if (context) await this._page._onBindingCalled(event.payload, context);
@@ -762,8 +749,7 @@ class FrameSession {
await this._page._onFileChooserOpened(handle);
}
_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
// after the download begins.
this._firstNonInitialNavigationCommittedReject(new Error('Starting new page download'));
@@ -802,7 +788,7 @@ class FrameSession {
});
// Wait for the first frame before reporting video to the client.
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());
});
}
async _stopVideoRecording() {