Skip to content

Conversation

@rwoll
Copy link
Owner

@rwoll rwoll commented Jun 2, 2021

No description provided.

rwoll added 10 commits May 20, 2021 14:13
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

const detailsFoo = log.entries[0];

if (browserName === 'webkit') {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
})();

@rwoll rwoll changed the base branch from feature/har-ip-and-ssl to master June 3, 2021 16:26
@rwoll rwoll closed this Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants