mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 14:11:50 +03:00
feature(webkit): roll WebKit to 1273 (#2514)
This commit is contained in:
parent
d7f867db47
commit
8ee19d53e7
@ -10,7 +10,7 @@
|
||||
},
|
||||
{
|
||||
"name": "webkit",
|
||||
"revision": "1269"
|
||||
"revision": "1273"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
||||
const pendingBrowserContextCreations = new Set<number>();
|
||||
const pendingBrowserContextDeletions = new Map<number, string>();
|
||||
const browserContextIds = new Map<string, ws>();
|
||||
const pageProxyIds = new Map<string, ws>();
|
||||
const sockets = new Set<ws>();
|
||||
|
||||
transport.onmessage = message => {
|
||||
@ -108,7 +107,7 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
||||
return;
|
||||
const { id, socket } = value;
|
||||
|
||||
if (socket.readyState === ws.CLOSING) {
|
||||
if (socket.readyState === ws.CLOSED || socket.readyState === ws.CLOSING) {
|
||||
if (pendingBrowserContextCreations.has(id)) {
|
||||
transport.send({
|
||||
id: ++SequenceNumberMixer._lastSequenceNumber,
|
||||
@ -137,40 +136,16 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
||||
return;
|
||||
}
|
||||
|
||||
// Process notification response.
|
||||
const { method, params, pageProxyId } = message;
|
||||
if (pageProxyId) {
|
||||
const socket = pageProxyIds.get(pageProxyId);
|
||||
if (!socket || socket.readyState === ws.CLOSING) {
|
||||
// Drop unattributed messages on the floor.
|
||||
return;
|
||||
}
|
||||
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));
|
||||
// Every notification either has a browserContextId top-level field or
|
||||
// has a browserContextId parameter.
|
||||
const { params, browserContextId } = message;
|
||||
const contextId = browserContextId || params.browserContextId;
|
||||
const socket = browserContextIds.get(contextId);
|
||||
if (!socket || socket.readyState === ws.CLOSING) {
|
||||
// Drop unattributed messages on the floor.
|
||||
return;
|
||||
}
|
||||
socket.send(JSON.stringify(message));
|
||||
};
|
||||
|
||||
transport.onclose = () => {
|
||||
@ -204,10 +179,6 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, logger: Inne
|
||||
socket.on('error', logError(logger));
|
||||
|
||||
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) {
|
||||
if (s === socket) {
|
||||
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}`;
|
||||
|
||||
return new WebSocketWrapper(wsEndpoint,
|
||||
[pendingBrowserContextCreations, pendingBrowserContextDeletions, browserContextIds, pageProxyIds, sockets]);
|
||||
[pendingBrowserContextCreations, pendingBrowserContextDeletions, browserContextIds, sockets]);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ export type ProtocolRequest = {
|
||||
method: string;
|
||||
params: any;
|
||||
sessionId?: string;
|
||||
pageProxyId?: string;
|
||||
};
|
||||
|
||||
export type ProtocolResponse = {
|
||||
@ -37,6 +36,7 @@ export type ProtocolResponse = {
|
||||
params?: any;
|
||||
result?: any;
|
||||
pageProxyId?: string;
|
||||
browserContextId?: string;
|
||||
};
|
||||
|
||||
export interface ConnectionTransport {
|
||||
|
@ -124,15 +124,14 @@ export class WKBrowser extends BrowserBase {
|
||||
}
|
||||
|
||||
_onPageProxyCreated(event: Protocol.Playwright.pageProxyCreatedPayload) {
|
||||
const { pageProxyInfo } = event;
|
||||
const pageProxyId = pageProxyInfo.pageProxyId;
|
||||
const pageProxyId = event.pageProxyId;
|
||||
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
|
||||
// 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
|
||||
// lifecycle events.
|
||||
context = this._contexts.get(pageProxyInfo.browserContextId) || null;
|
||||
context = this._contexts.get(event.browserContextId) || null;
|
||||
}
|
||||
if (!context)
|
||||
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) => {
|
||||
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);
|
||||
this._wkPages.set(pageProxyId, wkPage);
|
||||
|
||||
|
@ -166,7 +166,7 @@ export class WKSession extends EventEmitter {
|
||||
callback.reject(createProtocolError(callback.error, callback.method, object.error));
|
||||
else
|
||||
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.
|
||||
assert(this.isDisposed());
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user