Previously, we always saved the trace for each context until the
very end of the test, and then either repacked them or abandoned
depending on the `trace` mode.
However, this could result in downloading large traces from the
remote server when the tests succeeded but trace was set to
`retain-on-failure`. This slows down remote operations quite a lot.
The fix is to carefully consider whether the trace should be
saved or abandoned, based on whether the test and afterEach hooks
have finished successfully.
This could be a minor regression, where the trace will not be saved
if one of the fixture teardowns fails after the context has been
already closed, and trace mode was `retain-on-failure` or
`retain-on-first-failure`.
Retaining traces in the following scenarios:
- browser crash;
- manual `browser.close()`;
- implicit `browser.close()` from the `browser` fixture upon test end.
This does not affect the library, where `browser.close()` will not
retain the trace and will close the browser as fast as possible.
References #31541, #31535, #31537.
`x-playwright-debug-log: value` headers are printed to `pw:browser`
debug log.
`x-playwright-attachment: name=value` headers are attached to each test.
Fixes#21619.
- Always show a fixture that was running during timeout.
- Give custom titles to built-in fixtures.
- Specify setup/teardown fixture phase in the message.
- Split connect vs launch browser fixtures for better naming.
Example timeout message:
```log
Timeout of 2000ms exceeded while running fixture "built-in playwright configuration" teardown.
```