feat(firefox): support Response.securityDetails() (#3997)

This commit is contained in:
Andrey Lushnikov 2019-02-13 11:56:51 -08:00 committed by GitHub
parent 57e7f12fbc
commit 13224a761e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 4 deletions

View File

@ -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};

View File

@ -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,
};

View File

@ -9,7 +9,7 @@
"node": ">=8.9.4"
},
"puppeteer": {
"firefox_revision": "167f4a537c7d87e967f5c1ce71fc9a100c347c8b"
"firefox_revision": "ac50a00d0cb3522407d3c84ec85360cbc4d14c9c"
},
"scripts": {
"install": "node install.js",

View File

@ -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);