Skip to content

Commit

Permalink
feat(firefox): support Response.securityDetails() (#3997)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Feb 13, 2019
1 parent 57e7f12 commit 13224a7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
56 changes: 55 additions & 1 deletion experimental/puppeteer-firefox/lib/NetworkManager.js
Expand Up @@ -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};
}
Expand Down Expand Up @@ -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};
1 change: 1 addition & 0 deletions experimental/puppeteer-firefox/lib/api.js
Expand Up @@ -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,
};
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/package.json
Expand Up @@ -9,7 +9,7 @@
"node": ">=8.9.4"
},
"puppeteer": {
"firefox_revision": "167f4a537c7d87e967f5c1ce71fc9a100c347c8b"
"firefox_revision": "ac50a00d0cb3522407d3c84ec85360cbc4d14c9c"
},
"scripts": {
"install": "node install.js",
Expand Down
4 changes: 2 additions & 2 deletions test/ignorehttpserrors.spec.js
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 13224a7

Please sign in to comment.