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