Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion experimental/puppeteer-firefox/lib/NetworkManager.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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