From 13224a761ece560124ad630b85bf0e5151fa3759 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 13 Feb 2019 11:56:51 -0800 Subject: [PATCH] feat(firefox): support Response.securityDetails() (#3997) --- .../puppeteer-firefox/lib/NetworkManager.js | 56 ++++++++++++++++++- experimental/puppeteer-firefox/lib/api.js | 1 + experimental/puppeteer-firefox/package.json | 2 +- test/ignorehttpserrors.spec.js | 4 +- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/experimental/puppeteer-firefox/lib/NetworkManager.js b/experimental/puppeteer-firefox/lib/NetworkManager.js index 9b10a869..0d983e00 100644 --- a/experimental/puppeteer-firefox/lib/NetworkManager.js +++ b/experimental/puppeteer-firefox/lib/NetworkManager.js @@ -149,10 +149,15 @@ class Response { this._status = payload.status; this._statusText = payload.statusText; this._headers = {}; + this._securityDetails = payload.securityDetails ? new SecurityDetails(payload.securityDetails) : null; for (const {name, value} of payload.headers) this._headers[name.toLowerCase()] = value; } + securityDetails() { + return this._securityDetails; + } + headers() { return {...this._headers}; } @@ -189,4 +194,53 @@ class Response { } } -module.exports = {NetworkManager, Request, Response}; +class SecurityDetails { + /** + * @param {!Protocol.Network.SecurityDetails} securityPayload + */ + constructor(securityPayload) { + this._subjectName = securityPayload['subjectName']; + this._issuer = securityPayload['issuer']; + this._validFrom = securityPayload['validFrom']; + this._validTo = securityPayload['validTo']; + this._protocol = securityPayload['protocol']; + } + + /** + * @return {string} + */ + subjectName() { + return this._subjectName; + } + + /** + * @return {string} + */ + issuer() { + return this._issuer; + } + + /** + * @return {number} + */ + validFrom() { + return this._validFrom; + } + + /** + * @return {number} + */ + validTo() { + return this._validTo; + } + + /** + * @return {string} + */ + protocol() { + return this._protocol; + } +} + + +module.exports = {NetworkManager, Request, Response, SecurityDetails}; diff --git a/experimental/puppeteer-firefox/lib/api.js b/experimental/puppeteer-firefox/lib/api.js index 1f01e99c..f1e97f37 100644 --- a/experimental/puppeteer-firefox/lib/api.js +++ b/experimental/puppeteer-firefox/lib/api.js @@ -14,6 +14,7 @@ module.exports = { Puppeteer: require('./Puppeteer').Puppeteer, Request: require('./NetworkManager').Request, Response: require('./NetworkManager').Response, + SecurityDetails: require('./NetworkManager').SecurityDetails, Target: require('./Browser').Target, TimeoutError: require('./Errors').TimeoutError, }; diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json index 1b99f287..12a4a6ed 100644 --- a/experimental/puppeteer-firefox/package.json +++ b/experimental/puppeteer-firefox/package.json @@ -9,7 +9,7 @@ "node": ">=8.9.4" }, "puppeteer": { - "firefox_revision": "167f4a537c7d87e967f5c1ce71fc9a100c347c8b" + "firefox_revision": "ac50a00d0cb3522407d3c84ec85360cbc4d14c9c" }, "scripts": { "install": "node install.js", diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.js index 38358913..98761930 100644 --- a/test/ignorehttpserrors.spec.js +++ b/test/ignorehttpserrors.spec.js @@ -37,7 +37,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p delete state.page; }); - describe_fails_ffox('Response.securityDetails', function() { + describe('Response.securityDetails', function() { it('should work', async({page, httpsServer}) => { const response = await page.goto(httpsServer.EMPTY_PAGE); const securityDetails = response.securityDetails(); @@ -63,7 +63,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p }); }); - it_fails_ffox('should work', async({page, httpsServer}) => { + it('should work', async({page, httpsServer}) => { let error = null; const response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e); expect(error).toBe(null);