Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webkit): roll webkit to 1176 #1339

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"playwright": {
"chromium_revision": "747023",
"firefox_revision": "1041",
"webkit_revision": "1171"
"webkit_revision": "1178"
},
"scripts": {
"ctest": "cross-env BROWSER=chromium node test/test.js",
Expand Down
16 changes: 8 additions & 8 deletions src/server/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class WebKit implements BrowserType {
// We try to gracefully close to prevent crash reporting and core dumps.
// Note that it's fine to reuse the pipe transport, since
// our connection ignores kBrowserCloseMessageId.
const message = JSON.stringify({method: 'Browser.close', params: {}, id: kBrowserCloseMessageId});
const message = JSON.stringify({method: 'Playwright.close', params: {}, id: kBrowserCloseMessageId});
transport.send(message);
},
onkill: (exitCode, signal) => {
Expand Down Expand Up @@ -297,7 +297,7 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
if (pendingBrowserContextCreations.has(id)) {
transport.send(JSON.stringify({
id: ++SequenceNumberMixer._lastSequenceNumber,
method: 'Browser.deleteContext',
method: 'Playwright.deleteContext',
params: { browserContextId: parsedMessage.result.browserContextId }
}));
}
Expand Down Expand Up @@ -333,7 +333,7 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
socket.send(message);
return;
}
if (method === 'Browser.pageProxyCreated') {
if (method === 'Playwright.pageProxyCreated') {
const socket = browserContextIds.get(params.pageProxyInfo.browserContextId);
if (!socket || socket.readyState === ws.CLOSING) {
// Drop unattributed messages on the floor.
Expand All @@ -343,14 +343,14 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
socket.send(message);
return;
}
if (method === 'Browser.pageProxyDestroyed') {
if (method === 'Playwright.pageProxyDestroyed') {
const socket = pageProxyIds.get(params.pageProxyId);
pageProxyIds.delete(params.pageProxyId);
if (socket && socket.readyState !== ws.CLOSING)
socket.send(message);
return;
}
if (method === 'Browser.provisionalLoadFailed') {
if (method === 'Playwright.provisionalLoadFailed') {
const socket = pageProxyIds.get(params.pageProxyId);
if (socket && socket.readyState !== ws.CLOSING)
socket.send(message);
Expand All @@ -370,9 +370,9 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
const { id, method, params } = parsedMessage;
const seqNum = idMixer.generate({ id, socket });
transport.send(JSON.stringify({ ...parsedMessage, id: seqNum }));
if (method === 'Browser.createContext')
if (method === 'Playwright.createContext')
pendingBrowserContextCreations.add(seqNum);
if (method === 'Browser.deleteContext')
if (method === 'Playwright.deleteContext')
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
});

Expand All @@ -385,7 +385,7 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
if (s === socket) {
transport.send(JSON.stringify({
id: ++SequenceNumberMixer._lastSequenceNumber,
method: 'Browser.deleteContext',
method: 'Playwright.deleteContext',
params: { browserContextId }
}));
browserContextIds.delete(browserContextId);
Expand Down
38 changes: 19 additions & 19 deletions src/webkit/wkBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
this._defaultContext = new WKBrowserContext(this, undefined, validateBrowserContextOptions({}));

this._eventListeners = [
helper.addEventListener(this._browserSession, 'Browser.pageProxyCreated', this._onPageProxyCreated.bind(this)),
helper.addEventListener(this._browserSession, 'Browser.pageProxyDestroyed', this._onPageProxyDestroyed.bind(this)),
helper.addEventListener(this._browserSession, 'Browser.provisionalLoadFailed', event => this._onProvisionalLoadFailed(event)),
helper.addEventListener(this._browserSession, 'Playwright.pageProxyCreated', this._onPageProxyCreated.bind(this)),
helper.addEventListener(this._browserSession, 'Playwright.pageProxyDestroyed', this._onPageProxyDestroyed.bind(this)),
helper.addEventListener(this._browserSession, 'Playwright.provisionalLoadFailed', event => this._onProvisionalLoadFailed(event)),
helper.addEventListener(this._browserSession, kPageProxyMessageReceived, this._onPageProxyMessageReceived.bind(this)),
];

Expand All @@ -76,7 +76,7 @@ export class WKBrowser extends platform.EventEmitter implements Browser {

async newContext(options: BrowserContextOptions = {}): Promise<BrowserContext> {
options = validateBrowserContextOptions(options);
const { browserContextId } = await this._browserSession.send('Browser.createContext');
const { browserContextId } = await this._browserSession.send('Playwright.createContext');
options.userAgent = options.userAgent || DEFAULT_USER_AGENT;
const context = new WKBrowserContext(this, browserContextId, options);
await context._initialize();
Expand All @@ -97,7 +97,7 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
return this._firstPagePromise;
}

_onPageProxyCreated(event: Protocol.Browser.pageProxyCreatedPayload) {
_onPageProxyCreated(event: Protocol.Playwright.pageProxyCreatedPayload) {
const { pageProxyInfo } = event;
const pageProxyId = pageProxyInfo.pageProxyId;
let context: WKBrowserContext | null = null;
Expand Down Expand Up @@ -134,7 +134,7 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
});
}

_onPageProxyDestroyed(event: Protocol.Browser.pageProxyDestroyedPayload) {
_onPageProxyDestroyed(event: Protocol.Playwright.pageProxyDestroyedPayload) {
const pageProxyId = event.pageProxyId;
const wkPage = this._wkPages.get(pageProxyId);
if (!wkPage)
Expand All @@ -151,7 +151,7 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
wkPage.dispatchMessageToSession(event.message);
}

_onProvisionalLoadFailed(event: Protocol.Browser.provisionalLoadFailedPayload) {
_onProvisionalLoadFailed(event: Protocol.Playwright.provisionalLoadFailedPayload) {
const wkPage = this._wkPages.get(event.pageProxyId);
if (!wkPage)
return;
Expand Down Expand Up @@ -189,9 +189,9 @@ export class WKBrowserContext extends BrowserContextBase {

async _initialize() {
if (this._options.ignoreHTTPSErrors)
await this._browser._browserSession.send('Browser.setIgnoreCertificateErrors', { browserContextId: this._browserContextId, ignore: true });
await this._browser._browserSession.send('Playwright.setIgnoreCertificateErrors', { browserContextId: this._browserContextId, ignore: true });
if (this._options.locale)
await this._browser._browserSession.send('Browser.setLanguages', { browserContextId: this._browserContextId, languages: [this._options.locale] });
await this._browser._browserSession.send('Playwright.setLanguages', { browserContextId: this._browserContextId, languages: [this._options.locale] });
const entries = Object.entries(this._options.permissions || {});
await Promise.all(entries.map(entry => this.setPermissions(entry[0], entry[1])));
if (this._options.geolocation)
Expand All @@ -218,7 +218,7 @@ export class WKBrowserContext extends BrowserContextBase {

async newPage(): Promise<Page> {
assertBrowserContextIsNotOwned(this);
const { pageProxyId } = await this._browser._browserSession.send('Browser.createPage', { browserContextId: this._browserContextId });
const { pageProxyId } = await this._browser._browserSession.send('Playwright.createPage', { browserContextId: this._browserContextId });
const wkPage = this._browser._wkPages.get(pageProxyId)!;
const result = await wkPage.pageOrError();
if (result instanceof Page) {
Expand All @@ -230,10 +230,10 @@ export class WKBrowserContext extends BrowserContextBase {
}

async cookies(urls?: string | string[]): Promise<network.NetworkCookie[]> {
const { cookies } = await this._browser._browserSession.send('Browser.getAllCookies', { browserContextId: this._browserContextId });
const { cookies } = await this._browser._browserSession.send('Playwright.getAllCookies', { browserContextId: this._browserContextId });
return network.filterCookies(cookies.map((c: network.NetworkCookie) => {
const copy: any = { ... c };
copy.expires = c.expires === 0 ? -1 : c.expires / 1000;
copy.expires = c.expires === -1 ? -1 : c.expires / 1000;
delete copy.session;
return copy as network.NetworkCookie;
}), urls);
Expand All @@ -244,12 +244,12 @@ export class WKBrowserContext extends BrowserContextBase {
...c,
session: c.expires === -1 || c.expires === undefined,
expires: c.expires && c.expires !== -1 ? c.expires * 1000 : c.expires
})) as Protocol.Browser.SetCookieParam[];
await this._browser._browserSession.send('Browser.setCookies', { cookies: cc, browserContextId: this._browserContextId });
})) as Protocol.Playwright.SetCookieParam[];
await this._browser._browserSession.send('Playwright.setCookies', { cookies: cc, browserContextId: this._browserContextId });
}

async clearCookies() {
await this._browser._browserSession.send('Browser.deleteAllCookies', { browserContextId: this._browserContextId });
await this._browser._browserSession.send('Playwright.deleteAllCookies', { browserContextId: this._browserContextId });
}

async setPermissions(origin: string, permissions: string[]): Promise<void> {
Expand All @@ -262,19 +262,19 @@ export class WKBrowserContext extends BrowserContextBase {
throw new Error('Unknown permission: ' + permission);
return protocolPermission;
});
await this._browser._browserSession.send('Browser.grantPermissions', { origin, browserContextId: this._browserContextId, permissions: filtered });
await this._browser._browserSession.send('Playwright.grantPermissions', { origin, browserContextId: this._browserContextId, permissions: filtered });
}

async clearPermissions() {
await this._browser._browserSession.send('Browser.resetPermissions', { browserContextId: this._browserContextId });
await this._browser._browserSession.send('Playwright.resetPermissions', { browserContextId: this._browserContextId });
}

async setGeolocation(geolocation: types.Geolocation | null): Promise<void> {
if (geolocation)
geolocation = verifyGeolocation(geolocation);
this._options.geolocation = geolocation || undefined;
const payload: any = geolocation ? { ...geolocation, timestamp: Date.now() } : undefined;
await this._browser._browserSession.send('Browser.setGeolocationOverride', { browserContextId: this._browserContextId, geolocation: payload });
await this._browser._browserSession.send('Playwright.setGeolocationOverride', { browserContextId: this._browserContextId, geolocation: payload });
}

async setExtraHTTPHeaders(headers: network.Headers): Promise<void> {
Expand Down Expand Up @@ -330,7 +330,7 @@ export class WKBrowserContext extends BrowserContextBase {
await this._browser.close();
return;
}
await this._browser._browserSession.send('Browser.deleteContext', { browserContextId: this._browserContextId });
await this._browser._browserSession.send('Playwright.deleteContext', { browserContextId: this._browserContextId });
this._browser._contexts.delete(this._browserContextId);
this._didCloseInternal();
}
Expand Down
4 changes: 2 additions & 2 deletions src/webkit/wkPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class WKPage implements PageDelegate {
this._pageProxySession.dispatchMessage(message);
}

handleProvisionalLoadFailed(event: Protocol.Browser.provisionalLoadFailedPayload) {
handleProvisionalLoadFailed(event: Protocol.Playwright.provisionalLoadFailedPayload) {
if (!this._initialized || !this._provisionalPage)
return;
let errorText = event.error;
Expand Down Expand Up @@ -390,7 +390,7 @@ export class WKPage implements PageDelegate {
if (this._pageProxySession.isDisposed())
throw new Error('Target closed');
const pageProxyId = this._pageProxySession.sessionId;
const result = await this._pageProxySession.connection.browserSession.send('Browser.navigate', { url, pageProxyId, frameId: frame._id, referrer });
const result = await this._pageProxySession.connection.browserSession.send('Playwright.navigate', { url, pageProxyId, frameId: frame._id, referrer });
return { newDocumentId: result.loaderId };
}

Expand Down