This change ensure's the HAR file is saved at `recordHar.path` on the
client instead of the server.
NB: The goal was to make this change transparent to the user and NOT
introduce any new APIs. Namely, I want to leave the API open for
potential `context.har.start()` and `context.har.stop()`.
This does BREAK servers that expect the HAR to be at the `recordHar.path`
on the server, but I think that's OK since there haven't been reports
of missing HAR on client making me think not many users are getting
HAR with client and server on different hosts anyways.
Closes#8355
chore: migrate tracing to har
- `HarTracer` is used by both `HarRecorder` that implements
`recordHar` context option, and by tracing.
- We keep the `trace.network` format for now, so it is not
yet a valid har file, but it contains har entries.
This is a speculative fix that moves "background pages cleanup"
to `_didCloseInternal` so that it is only run once, but on both
context closure and browser closure.
Symptom from a flaky test:
```log
browserContext.close: page@18087c372d32819222707ca5e8fd1030 is sending "close" event after being disposed
at PageDispatcher._dispatchEvent (D:\a\playwright\playwright\src\dispatchers\dispatcher.ts:86:15)
at Page.<anonymous> (D:\a\playwright\playwright\src\dispatchers\pageDispatcher.ts:59:12)
at Page.emit (events.js:314:20)
at Page._didClose (D:\a\playwright\playwright\src\server\page.ts:220:10)
at CRPage.didClose (D:\a\playwright\playwright\src\server\chromium\crPage.ts:165:16)
at CRBrowserContext._onClosePersistent (D:\a\playwright\playwright\src\server\chromium\crBrowser.ts:476:24)
at CRBrowserContext.close (D:\a\playwright\playwright\src\server\browserContext.ts:288:20)
```
- fix#6340
- Exposes all the network related events (request, response, requestfailed, requestfinished) through the browser context to allow for managing network activity even if the is any navigations through popups or to new tabs which could result in creation of multiple page objects.
This supports `PWDEBUG=console` that:
- runs headed;
- disables timeouts;
- adds `playwright` console helper.
When using `PWDEBUG=anything-but-console`, we open inspector.
Docs keep suggesting `PWDEBUG=1`.
These methods are safe to call while the page is still open, or when it is
already closed. Works in remotely connected browser as well.
Also makes video.path() to throw for remotely connected browser.
Under the hood migrated Download and Video to use the common Artifact object.
We might not ever get the "download finished" event when closing the context:
- in Chromium, for any ongoing download;
- in all browsers, for failed downloads.
This should not prevent closing the context. Instead of waiting for the
download and then deleting it, we force delete it immediately and reject
any promises waiting for the download completion.
- Instead of capturing snapshots on demand, we now stream them
from each frame every 100ms.
- Certain actions can also force snapshots at particular moment using
"checkpoints".
- Trace viewer is able to show the page snapshot at a particular
timestamp, or using a "checkpoint" snapshot.
- Small optimization to not process stylesheets if CSSOM was not used.
There still is a lot of room for improvement.