Skip to content

feat(v2): add playwright/_impl_v2, a line-by-line port of the JS client - #3275

Closed
Pavel Feldman (pavelfeldman) wants to merge 4 commits into
microsoft:mainfrom
pavelfeldman:impl-v2-port
Closed

Pavel Feldman (pavelfeldman) wants to merge 4 commits into
microsoft:mainfrom
pavelfeldman:impl-v2-port

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • The first commit is test: port the upstream tests by registry id #3274, the ports of the upstream tests.
  • playwright/_impl_v2: a line-by-line port of the JS client at b335271c, behind PW_IMPL=v2 (async API only). The second commit is the raw port, the third has the fixes that the tests found; review commit by commit.
  • v1 (playwright/_impl) is unchanged and runs the older tests. v2 runs all of tests/async; CI runs it on Ubuntu with Chromium.

Port every test in upstream's tests/registry.md at b335271c (the tests
are those of 6bbe2475b, its parent) to tests/{async,sync}/{page,library},
named after its id and title, or list it in tests/upstream_not_ported.txt
with the reason. scripts/check_test_registry.py checks this in CI.

The test assets, the test server and the certificates are upstream's.
The older tests move to tests/{async,sync}/legacy, with the changes that
the new files need: paths, keyboard.html, consolelog.html, the
certificate, the response headers of the server, and page.pause() in
upstream's test mode.

The ports are not collected yet: they run with the line-by-line port of
the client.
Port packages/playwright-core/src/client at b335271c (the client is the
same as at 6bbe2475b) to playwright/_impl_v2, with its own ports of the
isomorphic, protocol and utils code that it uses. From playwright/_impl
it uses only the public error classes, FormData, the generated API
types, the driver location and the protocol check.
scripts/codegen/generate_protocol.py also writes its protocol channels,
types and validator.

PW_IMPL=v2 switches the async API to it, and tests/conftest.py then runs
all of tests/async on it. CI does not run it yet. The tests are not
marked: some of them fail.
- Raise the public error classes, so that `type(e) is TimeoutError`
  holds, and name the Python options in the validation errors.
- The next API call raises the error of an event listener, as in v1.
- Start the calls of the expect_*() methods eagerly, as a JS async
  function starts, and run the timers as macrotasks: a timer waits
  until the event loop is idle.
- Name the API call of a coroutine that runs in a task of its own.
- The validator sends None inside arrays as JSON null.
- Device descriptors have the Python option names; expect.soft uses the
  scope that pytest-playwright opens.
- Older tests that check v1 behavior where v2 follows upstream have a v1
  variant (@only_v1) and a v2 variant (<test>_v2, @only_v2).
- BT-046 waits for the WebSocket request as upstream does; DB-007 makes
  its internal call through the v2 client.
- ST-011 is not ported: the driver replaces lone surrogates for clients
  other than JavaScript.
- test.sh also runs v2.
…python

- CI runs v2 on Ubuntu with Chromium and Python 3.12.
- An older test that checks v1 behavior where v2 follows upstream is
  marked @only_v1 with the tests that cover v2: the port of the upstream
  test, or a Python-only test of v2 in tests/async/python, which v1 does
  not run. The v2 variants that repeated an upstream port are removed.
- ST-011 is ported again, as an expected failure: the driver replaces
  lone surrogates with U+FFFD for clients other than JavaScript.
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.

1 participant