Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(webkit): support ignoreHTTPSErrors launcher option (#243)
Yury Semikhatskyf539afa2a710
diff --git a/package.json b/package.jsonindex 0c941e9f58..59a02a40ce 100644--- a/package.json+++ b/package.json@@ -10,7 +10,7 @@"playwright": {"chromium_revision": "724623","firefox_revision": "1005",- "webkit_revision": "1032"+ "webkit_revision": "1036"},"scripts": {"unit": "node test/test.js",diff --git a/src/webkit/Browser.ts b/src/webkit/Browser.tsindex c4af04008a..2dea19cc41 100644--- a/src/webkit/Browser.ts+++ b/src/webkit/Browser.ts@@ -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 = {diff --git a/src/webkit/Launcher.ts b/src/webkit/Launcher.tsindex 226cb89adc..7f520bb6f8 100644--- a/src/webkit/Launcher.ts+++ b/src/webkit/Launcher.ts@@ -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;diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.jsindex d929de2ab3..1c5e82247f 100644--- a/test/ignorehttpserrors.spec.js+++ b/test/ignorehttpserrors.spec.js@@ -19,7 +19,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, pconst {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, pexpect(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>`);});