mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
feature(webkit): roll WebKit to 1273 (#2514)
This commit is contained in:
parent
d7f867db47
commit
8ee19d53e7
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webkit",
|
"name": "webkit",
|
||||||
"revision": "1269"
|
"revision": "1273"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,6 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
|||||||
const pendingBrowserContextCreations = new Set<number>();
|
const pendingBrowserContextCreations = new Set<number>();
|
||||||
const pendingBrowserContextDeletions = new Map<number, string>();
|
const pendingBrowserContextDeletions = new Map<number, string>();
|
||||||
const browserContextIds = new Map<string, ws>();
|
const browserContextIds = new Map<string, ws>();
|
||||||
const pageProxyIds = new Map<string, ws>();
|
|
||||||
const sockets = new Set<ws>();
|
const sockets = new Set<ws>();
|
||||||
|
|
||||||
transport.onmessage = message => {
|
transport.onmessage = message => {
|
||||||
@ -108,7 +107,7 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
|||||||
return;
|
return;
|
||||||
const { id, socket } = value;
|
const { id, socket } = value;
|
||||||
|
|
||||||
if (socket.readyState === ws.CLOSING) {
|
if (socket.readyState === ws.CLOSED || socket.readyState === ws.CLOSING) {
|
||||||
if (pendingBrowserContextCreations.has(id)) {
|
if (pendingBrowserContextCreations.has(id)) {
|
||||||
transport.send({
|
transport.send({
|
||||||
id: ++SequenceNumberMixer._lastSequenceNumber,
|
id: ++SequenceNumberMixer._lastSequenceNumber,
|
||||||
@ -137,40 +136,16 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process notification response.
|
// Every notification either has a browserContextId top-level field or
|
||||||
const { method, params, pageProxyId } = message;
|
// has a browserContextId parameter.
|
||||||
if (pageProxyId) {
|
const { params, browserContextId } = message;
|
||||||
const socket = pageProxyIds.get(pageProxyId);
|
const contextId = browserContextId || params.browserContextId;
|
||||||
if (!socket || socket.readyState === ws.CLOSING) {
|
const socket = browserContextIds.get(contextId);
|
||||||
// Drop unattributed messages on the floor.
|
if (!socket || socket.readyState === ws.CLOSING) {
|
||||||
return;
|
// Drop unattributed messages on the floor.
|
||||||
}
|
|
||||||
socket.send(JSON.stringify(message));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (method === 'Playwright.pageProxyCreated') {
|
|
||||||
const socket = browserContextIds.get(params.pageProxyInfo.browserContextId);
|
|
||||||
if (!socket || socket.readyState === ws.CLOSING) {
|
|
||||||
// Drop unattributed messages on the floor.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pageProxyIds.set(params.pageProxyInfo.pageProxyId, socket);
|
|
||||||
socket.send(JSON.stringify(message));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (method === 'Playwright.pageProxyDestroyed') {
|
|
||||||
const socket = pageProxyIds.get(params.pageProxyId);
|
|
||||||
pageProxyIds.delete(params.pageProxyId);
|
|
||||||
if (socket && socket.readyState !== ws.CLOSING)
|
|
||||||
socket.send(JSON.stringify(message));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (method === 'Playwright.provisionalLoadFailed') {
|
|
||||||
const socket = pageProxyIds.get(params.pageProxyId);
|
|
||||||
if (socket && socket.readyState !== ws.CLOSING)
|
|
||||||
socket.send(JSON.stringify(message));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
socket.send(JSON.stringify(message));
|
||||||
};
|
};
|
||||||
|
|
||||||
transport.onclose = () => {
|
transport.onclose = () => {
|
||||||
@ -204,10 +179,6 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
|||||||
socket.on('error', logError(logger));
|
socket.on('error', logError(logger));
|
||||||
|
|
||||||
socket.on('close', (socket as any).__closeListener = () => {
|
socket.on('close', (socket as any).__closeListener = () => {
|
||||||
for (const [pageProxyId, s] of pageProxyIds) {
|
|
||||||
if (s === socket)
|
|
||||||
pageProxyIds.delete(pageProxyId);
|
|
||||||
}
|
|
||||||
for (const [browserContextId, s] of browserContextIds) {
|
for (const [browserContextId, s] of browserContextIds) {
|
||||||
if (s === socket) {
|
if (s === socket) {
|
||||||
transport.send({
|
transport.send({
|
||||||
@ -226,5 +197,5 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
|||||||
const wsEndpoint = typeof address === 'string' ? `${address}/${guid}` : `ws://127.0.0.1:${address.port}/${guid}`;
|
const wsEndpoint = typeof address === 'string' ? `${address}/${guid}` : `ws://127.0.0.1:${address.port}/${guid}`;
|
||||||
|
|
||||||
return new WebSocketWrapper(wsEndpoint,
|
return new WebSocketWrapper(wsEndpoint,
|
||||||
[pendingBrowserContextCreations, pendingBrowserContextDeletions, browserContextIds, pageProxyIds, sockets]);
|
[pendingBrowserContextCreations, pendingBrowserContextDeletions, browserContextIds, sockets]);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ export type ProtocolRequest = {
|
|||||||
method: string;
|
method: string;
|
||||||
params: any;
|
params: any;
|
||||||
sessionId?: string;
|
sessionId?: string;
|
||||||
pageProxyId?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProtocolResponse = {
|
export type ProtocolResponse = {
|
||||||
@ -37,6 +36,7 @@ export type ProtocolResponse = {
|
|||||||
params?: any;
|
params?: any;
|
||||||
result?: any;
|
result?: any;
|
||||||
pageProxyId?: string;
|
pageProxyId?: string;
|
||||||
|
browserContextId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ConnectionTransport {
|
export interface ConnectionTransport {
|
||||||
|
@ -124,15 +124,14 @@ export class WKBrowser extends BrowserBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onPageProxyCreated(event: Protocol.Playwright.pageProxyCreatedPayload) {
|
_onPageProxyCreated(event: Protocol.Playwright.pageProxyCreatedPayload) {
|
||||||
const { pageProxyInfo } = event;
|
const pageProxyId = event.pageProxyId;
|
||||||
const pageProxyId = pageProxyInfo.pageProxyId;
|
|
||||||
let context: WKBrowserContext | null = null;
|
let context: WKBrowserContext | null = null;
|
||||||
if (pageProxyInfo.browserContextId) {
|
if (event.browserContextId) {
|
||||||
// FIXME: we don't know about the default context id, so assume that all targets from
|
// FIXME: we don't know about the default context id, so assume that all targets from
|
||||||
// unknown contexts are created in the 'default' context which can in practice be represented
|
// unknown contexts are created in the 'default' context which can in practice be represented
|
||||||
// by multiple actual contexts in WebKit. Solving this properly will require adding context
|
// by multiple actual contexts in WebKit. Solving this properly will require adding context
|
||||||
// lifecycle events.
|
// lifecycle events.
|
||||||
context = this._contexts.get(pageProxyInfo.browserContextId) || null;
|
context = this._contexts.get(event.browserContextId) || null;
|
||||||
}
|
}
|
||||||
if (!context)
|
if (!context)
|
||||||
context = this._defaultContext as WKBrowserContext;
|
context = this._defaultContext as WKBrowserContext;
|
||||||
@ -141,7 +140,7 @@ export class WKBrowser extends BrowserBase {
|
|||||||
const pageProxySession = new WKSession(this._connection, pageProxyId, `The page has been closed.`, (message: any) => {
|
const pageProxySession = new WKSession(this._connection, pageProxyId, `The page has been closed.`, (message: any) => {
|
||||||
this._connection.rawSend({ ...message, pageProxyId });
|
this._connection.rawSend({ ...message, pageProxyId });
|
||||||
});
|
});
|
||||||
const opener = pageProxyInfo.openerId ? this._wkPages.get(pageProxyInfo.openerId) : undefined;
|
const opener = event.openerId ? this._wkPages.get(event.openerId) : undefined;
|
||||||
const wkPage = new WKPage(context, pageProxySession, opener || null);
|
const wkPage = new WKPage(context, pageProxySession, opener || null);
|
||||||
this._wkPages.set(pageProxyId, wkPage);
|
this._wkPages.set(pageProxyId, wkPage);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ export class WKSession extends EventEmitter {
|
|||||||
callback.reject(createProtocolError(callback.error, callback.method, object.error));
|
callback.reject(createProtocolError(callback.error, callback.method, object.error));
|
||||||
else
|
else
|
||||||
callback.resolve(object.result);
|
callback.resolve(object.result);
|
||||||
} else if (object.id) {
|
} else if (object.id && !object.error) {
|
||||||
// Response might come after session has been disposed and rejected all callbacks.
|
// Response might come after session has been disposed and rejected all callbacks.
|
||||||
assert(this.isDisposed());
|
assert(this.isDisposed());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user