WIP: feat(har): experiment with finish callbacks#2
Closed
Conversation
Updates in the HAR capture Log Entries: * `serverIPAddress`: (string) This now gets populated. * `_serverPort`: (number) This now gets populated. There isn't an official field according to this [w3 doc][w3] (and I didn't see a suitable field in a HAR download from Chromium DevTools). I used the field name from [WK WebInspector HARBuilder.js][wk]. * _securityDetails: non-standard info that is helpful in making assertions about cert expiries. This also introduces new APIs on `network.Response` exposing the new info. NB: At first these APIs were synchonous and populated with info that is readily available at the beginning of the Response creation, but WK does not emit IP address info until _loadingFinished, so the API's were all turned into Promise-based approaches. Closes microsoft#6624. [w3]: https://www.w3.org/community/bigdata-tools/files/2017/10/HAR_Spec_TO_HAR_Vocabulary.pdf [wk]: https://opensource.apple.com/source/WebInspectorUI/WebInspectorUI-7608.4.9.1.3/UserInterface/Controllers/HARBuilder.js.auto.html
rwoll
commented
Jun 3, 2021
|
|
||
| const detailsFoo = log.entries[0]; | ||
|
|
||
| if (browserName === 'webkit') { |
Owner
Author
There was a problem hiding this comment.
This appears to be a quirk of WK dev protocol wrt to redirects, atm. If you run the following with DEBUG="pw:protocol" you'll only see one remoteAddress in the all the logged events (corresponding to the destination, but not the intermediate redirects).
This matches what Safari shows in the Inspector tab.
// @ts-check
const http = require("http");
const pw = require("playwright");
const redirect = http.createServer((req, res) => {
res.writeHead(301, "Redirect", { Location: "http://localhost:4848"});
res.end();
});
const server = http.createServer((req, res) => {
res.setHeader("Content-Type", "text/html");
res.end("<p>OK</p>");
});
redirect.listen(4747);
server.listen(4848);
(async () => {
const browser = await pw.webkit.launch();
const context = await browser.newContext({ recordHar: { path: "record.har" }});
const page = await browser.newPage();
await page.goto("http://localhost:4747/foo");
await page.waitForSelector("text='OK'");
await context.close();
await browser.close();
redirect.close();
server.close();
})();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.