mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-03 07:51:12 +03:00
feat(webkit): support ignoreHTTPSErrors launcher option (#243)
Also roll webkit to 1036
This commit is contained in:
parent
4fd241e4ae
commit
f539afa2a7
@ -10,7 +10,7 @@
|
|||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "724623",
|
"chromium_revision": "724623",
|
||||||
"firefox_revision": "1005",
|
"firefox_revision": "1005",
|
||||||
"webkit_revision": "1032"
|
"webkit_revision": "1036"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"unit": "node test/test.js",
|
"unit": "node test/test.js",
|
||||||
|
@ -37,16 +37,19 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||||||
_targets = new Map<string, Target>();
|
_targets = new Map<string, Target>();
|
||||||
private _eventListeners: RegisteredListener[];
|
private _eventListeners: RegisteredListener[];
|
||||||
private _privateEvents = new EventEmitter();
|
private _privateEvents = new EventEmitter();
|
||||||
|
private readonly _ignoreHTTPSErrors: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
|
ignoreHTTPSErrors: boolean,
|
||||||
defaultViewport: types.Viewport | null,
|
defaultViewport: types.Viewport | null,
|
||||||
process: childProcess.ChildProcess | null,
|
process: childProcess.ChildProcess | null,
|
||||||
closeCallback?: (() => Promise<void>)) {
|
closeCallback?: (() => Promise<void>)) {
|
||||||
super();
|
super();
|
||||||
|
this._connection = connection;
|
||||||
|
this._ignoreHTTPSErrors = ignoreHTTPSErrors;
|
||||||
this._defaultViewport = defaultViewport;
|
this._defaultViewport = defaultViewport;
|
||||||
this._process = process;
|
this._process = process;
|
||||||
this._connection = connection;
|
|
||||||
this._closeCallback = closeCallback || (() => Promise.resolve());
|
this._closeCallback = closeCallback || (() => Promise.resolve());
|
||||||
|
|
||||||
/** @type {!Map<string, !Target>} */
|
/** @type {!Map<string, !Target>} */
|
||||||
@ -67,6 +70,9 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||||||
debugError(e);
|
debugError(e);
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this._ignoreHTTPSErrors)
|
||||||
|
this._setIgnoreTLSFailures(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
async userAgent(): Promise<string> {
|
async userAgent(): Promise<string> {
|
||||||
@ -88,6 +94,8 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||||||
|
|
||||||
async newContext(): Promise<BrowserContext> {
|
async newContext(): Promise<BrowserContext> {
|
||||||
const {browserContextId} = await this._connection.send('Browser.createContext');
|
const {browserContextId} = await this._connection.send('Browser.createContext');
|
||||||
|
if (this._ignoreHTTPSErrors)
|
||||||
|
await this._setIgnoreTLSFailures(browserContextId);
|
||||||
const context = this._createBrowserContext(browserContextId);
|
const context = this._createBrowserContext(browserContextId);
|
||||||
this._contexts.set(browserContextId, context);
|
this._contexts.set(browserContextId, context);
|
||||||
return context;
|
return context;
|
||||||
@ -250,6 +258,10 @@ export class Browser extends EventEmitter implements BrowserInterface {
|
|||||||
}, this, isIncognito);
|
}, this, isIncognito);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _setIgnoreTLSFailures(browserContextId: string | undefined) {
|
||||||
|
await this._connection.send('Browser.setIgnoreCertificateErrors', { browserContextId, ignore: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BrowserEvents = {
|
const BrowserEvents = {
|
||||||
|
@ -59,7 +59,8 @@ export class Launcher {
|
|||||||
handleSIGTERM = true,
|
handleSIGTERM = true,
|
||||||
handleSIGHUP = true,
|
handleSIGHUP = true,
|
||||||
defaultViewport = {width: 800, height: 600},
|
defaultViewport = {width: 800, height: 600},
|
||||||
slowMo = 0
|
slowMo = 0,
|
||||||
|
ignoreHTTPSErrors = false
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const webkitArguments = [];
|
const webkitArguments = [];
|
||||||
@ -103,7 +104,7 @@ export class Launcher {
|
|||||||
try {
|
try {
|
||||||
const transport = new PipeTransport(launched.process.stdio[3] as NodeJS.WritableStream, launched.process.stdio[4] as NodeJS.ReadableStream);
|
const transport = new PipeTransport(launched.process.stdio[3] as NodeJS.WritableStream, launched.process.stdio[4] as NodeJS.ReadableStream);
|
||||||
connection = new Connection(transport, slowMo);
|
connection = new Connection(transport, slowMo);
|
||||||
const browser = new Browser(connection, defaultViewport, launched.process, launched.gracefullyClose);
|
const browser = new Browser(connection, ignoreHTTPSErrors, defaultViewport, launched.process, launched.gracefullyClose);
|
||||||
await browser._waitForTarget(t => t._type === 'page');
|
await browser._waitForTarget(t => t._type === 'page');
|
||||||
return browser;
|
return browser;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -137,6 +138,7 @@ export type LauncherLaunchOptions = {
|
|||||||
env?: {[key: string]: string} | undefined,
|
env?: {[key: string]: string} | undefined,
|
||||||
defaultViewport?: types.Viewport | null,
|
defaultViewport?: types.Viewport | null,
|
||||||
slowMo?: number,
|
slowMo?: number,
|
||||||
|
ignoreHTTPSErrors?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
let cachedMacVersion = undefined;
|
let cachedMacVersion = undefined;
|
||||||
|
@ -19,7 +19,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
const {describe, xdescribe, fdescribe} = testRunner;
|
const {describe, xdescribe, fdescribe} = testRunner;
|
||||||
const {it, fit, xit} = testRunner;
|
const {it, fit, xit} = testRunner;
|
||||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||||
describe.skip(WEBKIT)('ignoreHTTPSErrors', function() {
|
describe('ignoreHTTPSErrors', function() {
|
||||||
beforeAll(async state => {
|
beforeAll(async state => {
|
||||||
state.browser = await playwright.launch({...defaultBrowserOptions, ignoreHTTPSErrors: true});
|
state.browser = await playwright.launch({...defaultBrowserOptions, ignoreHTTPSErrors: true});
|
||||||
});
|
});
|
||||||
@ -43,13 +43,13 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
expect(error).toBe(null);
|
expect(error).toBe(null);
|
||||||
expect(response.ok()).toBe(true);
|
expect(response.ok()).toBe(true);
|
||||||
});
|
});
|
||||||
it('should work with request interception', async({page, server, httpsServer}) => {
|
it.skip(WEBKIT)('should work with request interception', async({page, server, httpsServer}) => {
|
||||||
await page.interception.enable();
|
await page.interception.enable();
|
||||||
page.on('request', request => page.interception.continue(request));
|
page.on('request', request => page.interception.continue(request));
|
||||||
const response = await page.goto(httpsServer.EMPTY_PAGE);
|
const response = await page.goto(httpsServer.EMPTY_PAGE);
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
});
|
});
|
||||||
it('should work with mixed content', async({page, server, httpsServer}) => {
|
it.skip(WEBKIT)('should work with mixed content', async({page, server, httpsServer}) => {
|
||||||
httpsServer.setRoute('/mixedcontent.html', (req, res) => {
|
httpsServer.setRoute('/mixedcontent.html', (req, res) => {
|
||||||
res.end(`<iframe src=${server.EMPTY_PAGE}></iframe>`);
|
res.end(`<iframe src=${server.EMPTY_PAGE}></iframe>`);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user