Skip to content

Commit

Permalink
feat(browser): roll WebKit to r1370 (#4257)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Oct 28, 2020
1 parent ece84ec commit 7bedbb2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
{
"name": "webkit",
"revision": "1364",
"revision": "1370",
"download": true
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/server/chromium/crNetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class CRNetworkManager {
_onRequestWillBeSentExtraInfo(event: Protocol.Network.requestWillBeSentExtraInfoPayload) {
const request = this._requestIdToRequest.get(event.requestId);
if (request) {
request.request._updateWithRawHeaders(headersObjectToArray(event.headers));
request.request.updateWithRawHeaders(headersObjectToArray(event.headers));
this._requestIdToExtraInfo.delete(event.requestId);
} else {
this._requestIdToExtraInfo.set(event.requestId, event);
Expand Down
2 changes: 1 addition & 1 deletion src/server/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class Request {
return new Route(this, this._routeDelegate);
}

_updateWithRawHeaders(headers: types.HeadersArray) {
updateWithRawHeaders(headers: types.HeadersArray) {
this._headers = headers;
this._headersMap.clear();
for (const { name, value } of this._headers)
Expand Down
28 changes: 17 additions & 11 deletions src/server/webkit/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6564,6 +6564,21 @@ the top of the viewport and Y increases as it proceeds towards the bottom of the
*/
data: string;
}
/**
* Overrides screen size exposed to DOM and used in media queries for testing with provided values.
*/
export type setScreenSizeOverrideParameters = {
/**
* Screen width
*/
width?: number;
/**
* Screen height
*/
height?: number;
}
export type setScreenSizeOverrideReturnValue = {
}
/**
* Insert text into the current selection of the page.
*/
Expand Down Expand Up @@ -6641,15 +6656,6 @@ the top of the viewport and Y increases as it proceeds towards the bottom of the
}
export type crashReturnValue = {
}
/**
* Overrides screen size with provided values.
*/
export type setScreenSizeOverrideParameters = {
width: number;
height: number;
}
export type setScreenSizeOverrideReturnValue = {
}
/**
* Overrides window.orientation with provided value.
*/
Expand Down Expand Up @@ -8682,14 +8688,14 @@ the top of the viewport and Y increases as it proceeds towards the bottom of the
"Page.snapshotNode": Page.snapshotNodeParameters;
"Page.snapshotRect": Page.snapshotRectParameters;
"Page.archive": Page.archiveParameters;
"Page.setScreenSizeOverride": Page.setScreenSizeOverrideParameters;
"Page.insertText": Page.insertTextParameters;
"Page.accessibilitySnapshot": Page.accessibilitySnapshotParameters;
"Page.setInterceptFileChooserDialog": Page.setInterceptFileChooserDialogParameters;
"Page.setDefaultBackgroundColorOverride": Page.setDefaultBackgroundColorOverrideParameters;
"Page.createUserWorld": Page.createUserWorldParameters;
"Page.setBypassCSP": Page.setBypassCSPParameters;
"Page.crash": Page.crashParameters;
"Page.setScreenSizeOverride": Page.setScreenSizeOverrideParameters;
"Page.setOrientationOverride": Page.setOrientationOverrideParameters;
"Playwright.enable": Playwright.enableParameters;
"Playwright.disable": Playwright.disableParameters;
Expand Down Expand Up @@ -8966,14 +8972,14 @@ the top of the viewport and Y increases as it proceeds towards the bottom of the
"Page.snapshotNode": Page.snapshotNodeReturnValue;
"Page.snapshotRect": Page.snapshotRectReturnValue;
"Page.archive": Page.archiveReturnValue;
"Page.setScreenSizeOverride": Page.setScreenSizeOverrideReturnValue;
"Page.insertText": Page.insertTextReturnValue;
"Page.accessibilitySnapshot": Page.accessibilitySnapshotReturnValue;
"Page.setInterceptFileChooserDialog": Page.setInterceptFileChooserDialogReturnValue;
"Page.setDefaultBackgroundColorOverride": Page.setDefaultBackgroundColorOverrideReturnValue;
"Page.createUserWorld": Page.createUserWorldReturnValue;
"Page.setBypassCSP": Page.setBypassCSPReturnValue;
"Page.crash": Page.crashReturnValue;
"Page.setScreenSizeOverride": Page.setScreenSizeOverrideReturnValue;
"Page.setOrientationOverride": Page.setOrientationOverrideReturnValue;
"Playwright.enable": Playwright.enableReturnValue;
"Playwright.disable": Playwright.disableReturnValue;
Expand Down
4 changes: 3 additions & 1 deletion src/server/webkit/wkPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import * as jpeg from 'jpeg-js';
import * as path from 'path';
import * as png from 'pngjs';
import { assert, createGuid, debugAssert, headersArrayToObject } from '../../utils/utils';
import { assert, createGuid, debugAssert, headersArrayToObject, headersObjectToArray } from '../../utils/utils';
import * as accessibility from '../accessibility';
import * as dialog from '../dialog';
import * as dom from '../dom';
Expand Down Expand Up @@ -927,6 +927,8 @@ export class WKPage implements PageDelegate {
if (!request)
return;
const response = request.createResponse(event.response);
if (event.response.requestHeaders && Object.keys(event.response.requestHeaders).length)
request.request.updateWithRawHeaders(headersObjectToArray(event.response.requestHeaders));
this._page._frameManager.requestReceivedResponse(response);

if (response.status() === 204) {
Expand Down
4 changes: 1 addition & 3 deletions src/trace/harTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ type HarOptions = {

class HarContextTracer {
private _options: HarOptions;
private _browserName: string;
private _log: har.Log;
private _pageEntries = new Map<Page, har.Page>();
private _entries = new Map<network.Request, har.Entry>();
private _lastPage = 0;
private _barrierPromises = new Map<Promise<void>, Page>();

constructor(context: BrowserContext, options: HarOptions) {
this._browserName = context._browser._options.name;
this._options = options;
this._log = {
version: '1.2',
Expand Down Expand Up @@ -204,7 +202,7 @@ class HarContextTracer {
status: response.status(),
statusText: response.statusText(),
httpVersion: 'HTTP/1.1',
cookies: cookiesForHar(response.headerValue('set-cookie'), this._browserName === 'webkit' ? ',' : '\n'),
cookies: cookiesForHar(response.headerValue('set-cookie'), '\n'),
headers: response.headers().map(header => ({ name: header.name, value: header.value })),
content: {
size: -1,
Expand Down
12 changes: 5 additions & 7 deletions test/har.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ it('should include form params', async ({ pageWithHar, server }) => {
});
});

it('should include cookies', (test, { browserName }) => {
test.fail(browserName === 'webkit', 'WebKit is lacking raw headers w/ cookies on WebCore side');
}, async ({ pageWithHar, server }) => {
it('should include cookies', async ({ pageWithHar, server }) => {
const { page, context } = pageWithHar;
await context.addCookies([
{ name: 'name1', value: '"value1"', domain: 'localhost', path: '/', httpOnly: true },
Expand All @@ -184,7 +182,9 @@ it('should include cookies', (test, { browserName }) => {
]);
});

it('should include set-cookies', async ({ pageWithHar, server }) => {
it('should include set-cookies', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform === 'darwin', 'Does not work yet');
}, async ({ pageWithHar, server }) => {
const { page } = pageWithHar;
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', [
Expand All @@ -202,9 +202,7 @@ it('should include set-cookies', async ({ pageWithHar, server }) => {
expect(new Date(cookies[2].expires).valueOf()).toBeGreaterThan(Date.now());
});

it('should include set-cookies with comma', (test, { browserName }) => {
test.fail(browserName === 'webkit', 'WebKit concatenates headers poorly');
}, async ({ pageWithHar, server }) => {
it('should include set-cookies with comma', async ({ pageWithHar, server }) => {
const { page } = pageWithHar;
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', [
Expand Down
8 changes: 4 additions & 4 deletions test/network-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ it('should return headers', async ({page, server, isChromium, isFirefox, isWebKi
expect(response.request().headers()['user-agent']).toContain('WebKit');
});

it('should get the same headers as the server', (test, { browserName }) => {
test.fail(browserName === 'webkit', 'Provisional headers differ from those in network stack');
it('should get the same headers as the server', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform !== 'darwin', 'Provisional headers differ from those in network stack');
}, async ({ page, server }) => {
let serverRequest;
server.setRoute('/empty.html', (request, response) => {
Expand All @@ -93,8 +93,8 @@ it('should get the same headers as the server', (test, { browserName }) => {
expect(response.request().headers()).toEqual(serverRequest.headers);
});

it('should get the same headers as the server CORP', (test, { browserName }) => {
test.fail(browserName === 'webkit', 'Provisional headers differ from those in network stack');
it('should get the same headers as the server CORP', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform !== 'darwin', 'Provisional headers differ from those in network stack');
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/empty.html');
let serverRequest;
Expand Down

0 comments on commit 7bedbb2

Please sign in to comment.