Commit 2a3f95e
committed
playwright: add a few platform-specific tests
The Git home page displays some platform-dependent behavior. With this
commit, we test that by pretending to run on the three major operating
systems: Windows, macOS and Linux. Specifically, we verify that:
- the correct download is suggested, based on the current browser
- a subset of the GUIs are shown based on the platform indicated by the
current browser
Pretending to be running on a given platform is a bit tricky because the
`navigator.userAgent`/`navigator.platform` attributes are used by the
Git home page (via `session.min.js`) to determine what operating system
the user is running.
These can be easily overridden on most browser, using the
`Object.defineProperty()` method.
However, in my tests, Chromium on Linux (and only on that operating
system) simply ignored those calls and still reported that it is running
on Linux.
To work around this, we need to use the Chrome DevTools Protocol, via
the `BrowserContext.newCDPSession()` method; For more details see
https://playwright.dev/docs/api/class-browsercontext#browser-context-new-cdp-session
Obviously, this can _only_ be used with Chromium/Chrome and won't work
on, say, Firefox or Safari. That is the reason for the somewhat ugly
`pretendPlatform()` function we need to use here.
Signed-off-by: Johannes Schindelin <[email protected]>1 parent 659dcf5 commit 2a3f95e
1 file changed
+74
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
5 | 79 | | |
6 | 80 | | |
7 | 81 | | |
| |||
0 commit comments