Compare commits
151
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ec829cd8c | ||
|
|
0069d2fd96 | ||
|
|
303adbecf8 | ||
|
|
47e67680de | ||
|
|
b1bae5e3fd | ||
|
|
ea3f372b3a | ||
|
|
ac866325d9 | ||
|
|
24a1e7c33b | ||
|
|
84bfdec0d4 | ||
|
|
c5605964e1 | ||
|
|
a1bbafbeaa | ||
|
|
88d285d303 | ||
|
|
a2d48d33be | ||
|
|
feb43f03a3 | ||
|
|
6aad4b3edb | ||
|
|
03834f3a66 | ||
|
|
e52f2dda30 | ||
|
|
8641484dbd | ||
|
|
f09ff6adf5 | ||
|
|
81741026c9 | ||
|
|
b91e18db21 | ||
|
|
8c698e9421 | ||
|
|
12a8233a98 | ||
|
|
8de65f8284 | ||
|
|
3caafc8b6e | ||
|
|
5d2200d6f2 | ||
|
|
58794fc460 | ||
|
|
95c3a17e28 | ||
|
|
b88f5e3a4d | ||
|
|
61219b606f | ||
|
|
61950b9f08 | ||
|
|
de6f23cab3 | ||
|
|
64ca7b6858 | ||
|
|
d52ce6b0c5 | ||
|
|
60047974cc | ||
|
|
abb0fec604 | ||
|
|
e6425ed823 | ||
|
|
4ae82c636f | ||
|
|
11c81a7d18 | ||
|
|
72a88e9bef | ||
|
|
de98485983 | ||
|
|
af7a5ea507 | ||
|
|
6366bd5779 | ||
|
|
a64c1bb591 | ||
|
|
ad78730b09 | ||
|
|
abcc56e5b5 | ||
|
|
11de43a1fc | ||
|
|
912bf0c685 | ||
|
|
8de974db6f | ||
|
|
4fe36b40ab | ||
|
|
f6aee7f595 | ||
|
|
6fc18b3d09 | ||
|
|
10c54bc1fc | ||
|
|
e11d7d0699 | ||
|
|
e42c1b1788 | ||
|
|
49fd6fc7c1 | ||
|
|
b6405aed5c | ||
|
|
bccaba8b8e | ||
|
|
584e7b4ef2 | ||
|
|
7477275f43 | ||
|
|
5dc9a8d0d8 | ||
|
|
106658e3b7 | ||
|
|
6a3b564e29 | ||
|
|
5f1d9526ec | ||
|
|
3e6ac4462c | ||
|
|
dc0bf4dcd3 | ||
|
|
deace90f7a | ||
|
|
d5ae243725 | ||
|
|
a82d3e40d7 | ||
|
|
0388d00f45 | ||
|
|
beca4a5856 | ||
|
|
b685183552 | ||
|
|
9878cad989 | ||
|
|
cebb7f8cb0 | ||
|
|
4aecaf0043 | ||
|
|
c09cf08c17 | ||
|
|
b9c9139695 | ||
|
|
52bffd7fe3 | ||
|
|
270e7a799d | ||
|
|
dd4e9b5d95 | ||
|
|
5c1f6a5cc4 | ||
|
|
57cfc78bb0 | ||
|
|
b763a8320c | ||
|
|
e384f731ac | ||
|
|
edab7112f6 | ||
|
|
91bccd23fa | ||
|
|
e82320fd52 | ||
|
|
b1091c9ebb | ||
|
|
7bb5ae076e | ||
|
|
36da827fa3 | ||
|
|
1dbf33ac0a | ||
|
|
6c73012fd4 | ||
|
|
4a6317ec41 | ||
|
|
e8ffdf8a2a | ||
|
|
08b32a8004 | ||
|
|
cec6e28767 | ||
|
|
50dd052f4a | ||
|
|
9f2c21662e | ||
|
|
26e4fe6b1c | ||
|
|
c3bca774b6 | ||
|
|
7b8f1e70b2 | ||
|
|
1d3d149cb6 | ||
|
|
5ee935268a | ||
|
|
4416b088d7 | ||
|
|
8516470e95 | ||
|
|
f0c60c0f0c | ||
|
|
5994a6cfd8 | ||
|
|
e7f1c85225 | ||
|
|
5d3ac3bc7c | ||
|
|
39128592a4 | ||
|
|
a973088192 | ||
|
|
b2d424925a | ||
|
|
c489db7937 | ||
|
|
0706164f58 | ||
|
|
a09233152c | ||
|
|
7cd92712ab | ||
|
|
2be9b6046a | ||
|
|
c43d787ce9 | ||
|
|
f094102fab | ||
|
|
aa53d6ea06 | ||
|
|
4b2fb63fe6 | ||
|
|
83afc6c8d5 | ||
|
|
163315c114 | ||
|
|
578763389d | ||
|
|
3a97b05708 | ||
|
|
91e69710eb | ||
|
|
cf328bf481 | ||
|
|
65b7a3c3bc | ||
|
|
5fda215266 | ||
|
|
05190ed5e9 | ||
|
|
cfbf1889a8 | ||
|
|
2d2204898e | ||
|
|
384351d4a3 | ||
|
|
a14da2127e | ||
|
|
b60b5c5e8c | ||
|
|
252036e2fc | ||
|
|
0f7a9a2905 | ||
|
|
112467f5ad | ||
|
|
22d8abc9ba | ||
|
|
a743dbbbf7 | ||
|
|
f7873501e2 | ||
|
|
bcf47c7dde | ||
|
|
fcfbed215e | ||
|
|
b0b4f02d7c | ||
|
|
d842a35ffa | ||
|
|
1832ea6323 | ||
|
|
b3eb6c3733 | ||
|
|
1d7204ffe6 | ||
|
|
1b974cd964 | ||
|
|
2c8bfa12da | ||
|
|
8d48c4a472 |
No files matched your search
@@ -0,0 +1,156 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# control-a-trace-hunt.yml - a MEASUREMENT, not a gate: the Control+A file of the
|
||||
# e2e (tests/test_control_a_selects_all_in_a_field_e2e.py, 20 tests: 5 ways to press
|
||||
# the shortcut x 2 fields x the in-process browser and the stock client), run again
|
||||
# and again with the protocol trace of scripts/hunt_trace_plugin.py, to find the cause
|
||||
# of a rare red: `Page.set_content: the caller's world never appeared for frame
|
||||
# mainframe-N - did you call install()? Worlds seen: ['']`.
|
||||
#
|
||||
# What it records, per test run, in one JSON: the events the engine sends about
|
||||
# navigations, frames and contexts (executionContextsCleared / Created / Destroyed with
|
||||
# the world), the commands the server sends (Page.setInitScripts, which is what
|
||||
# declares the caller's world; Runtime.evaluate with its context), and the marks of
|
||||
# install(), caller_context() and set_content, all with their time. scripts/
|
||||
# hunt_ctrla_summary.py then puts the red runs and the green ones side by side.
|
||||
#
|
||||
# ROUNDS OF FOUR COPIES, not `-n 4`: four pytest processes at once, each on the whole
|
||||
# file (what a `--dist loadfile` worker of the gate does), so that every browser lives
|
||||
# the same 10 tests per mode, in the same order, as in the gate and four browsers are
|
||||
# up together (scripts/hunt_ctrla_rounds.py says why). Rounds follow until 300 test
|
||||
# runs per system are recorded (4 rounds = 320). A red copy never stops the others,
|
||||
# and the verdict of the job is only that the files are there.
|
||||
#
|
||||
# It runs on a push to its own branch only.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
name: control-a-trace-hunt
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [hunt/control-a-trace]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A hunt has a group of its own, unique to the run: a newer push never cancels
|
||||
# a measurement that is half done (tests/test_ci_runs_once_per_commit.py).
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.run_id }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
# the core of main, not the pinned one: the pair is mismatched on purpose (as the core's wrapper-on-this-core job does)
|
||||
INVISIBLE_CORE_PIN: allow
|
||||
INVISIBLE_CORE_AUTOFIX: "off"
|
||||
|
||||
jobs:
|
||||
control-a-trace-linux:
|
||||
name: control-a-trace (linux)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install --no-deps --force-reinstall "git+https://github.com/oss-invisible/core@65307f59f1245e214c8357593950d5ec929536ac"
|
||||
python -c "import invisible_core; from invisible_core.testing import e2e; c = e2e.command('4', [], junit='x.xml'); print('core', invisible_core.__version__, c); assert not any(a.startswith('--rerun') for a in c) and 'no:rerunfailures' in c, c"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
- name: System deps (xvfb + Firefox runtime libs)
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb
|
||||
sudo "$(which python)" -m playwright install-deps firefox
|
||||
- name: Fetch the published firefox binary
|
||||
run: echo "FF=$(python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
|
||||
- name: The GeoIP database (made by the repository, same bytes every run)
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
- name: The Control+A file in rounds of four copies, with the protocol trace
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: xvfb-run -a python -u scripts/hunt_ctrla_rounds.py --binary "$FF" --out-dir "$RUNNER_TEMP/ctrla-hunt" --min-runs 300 --copies 4 --budget-min 18
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
run: |
|
||||
pkill -f firefox || true
|
||||
echo "left: $(pgrep -fc firefox || true)"
|
||||
- name: The summary of the red and the green runs
|
||||
if: always()
|
||||
run: python scripts/hunt_ctrla_summary.py "$RUNNER_TEMP/ctrla-hunt/trace" --max-reds 30 | tee "$RUNNER_TEMP/ctrla-hunt/summary.txt" || true
|
||||
- name: Upload the traces, the junit and the logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: control-a-trace-linux-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: ${{ runner.temp }}/ctrla-hunt
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
# The verdict is only that the files are there: a red test is what the hunt is for.
|
||||
- name: Verdict (the files are there)
|
||||
if: always()
|
||||
run: |
|
||||
traces=$(ls "$RUNNER_TEMP/ctrla-hunt/trace"/*.json 2>/dev/null | wc -l)
|
||||
junits=$(ls "$RUNNER_TEMP/ctrla-hunt/junit"/*.xml 2>/dev/null | wc -l)
|
||||
echo "trace files: $traces, junit files: $junits"
|
||||
if [ "$traces" -lt 300 ]; then echo "::warning::only $traces test runs were recorded (300 were wanted)"; fi
|
||||
[ "$traces" -gt 0 ] && [ "$junits" -gt 0 ]
|
||||
|
||||
control-a-trace-windows:
|
||||
name: control-a-trace (windows)
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 40
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: Install wrapper + test deps
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install --no-deps --force-reinstall "git+https://github.com/oss-invisible/core@65307f59f1245e214c8357593950d5ec929536ac"
|
||||
python -c "import invisible_core; from invisible_core.testing import e2e; c = e2e.command('4', [], junit='x.xml'); print('core', invisible_core.__version__, c); assert not any(a.startswith('--rerun') for a in c) and 'no:rerunfailures' in c, c"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
- name: Fetch the published firefox binary
|
||||
run: echo "FF=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
|
||||
- name: The GeoIP database (made by the repository, same bytes every run)
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
- name: The Control+A file in rounds of four copies, with the protocol trace
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: python -u scripts/hunt_ctrla_rounds.py --binary "$FF" --out-dir "$RUNNER_TEMP/ctrla-hunt" --min-runs 300 --copies 4 --budget-min 18
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: The summary of the red and the green runs
|
||||
if: always()
|
||||
run: python scripts/hunt_ctrla_summary.py "$RUNNER_TEMP/ctrla-hunt/trace" --max-reds 30 | tee "$RUNNER_TEMP/ctrla-hunt/summary.txt" || true
|
||||
- name: Upload the traces, the junit and the logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: control-a-trace-windows-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: ${{ runner.temp }}/ctrla-hunt
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
# The verdict is only that the files are there: a red test is what the hunt is for.
|
||||
- name: Verdict (the files are there)
|
||||
if: always()
|
||||
run: |
|
||||
traces=$(ls "$RUNNER_TEMP/ctrla-hunt/trace"/*.json 2>/dev/null | wc -l)
|
||||
junits=$(ls "$RUNNER_TEMP/ctrla-hunt/junit"/*.xml 2>/dev/null | wc -l)
|
||||
echo "trace files: $traces, junit files: $junits"
|
||||
if [ "$traces" -lt 300 ]; then echo "::warning::only $traces test runs were recorded (300 were wanted)"; fi
|
||||
[ "$traces" -gt 0 ] && [ "$junits" -gt 0 ]
|
||||
@@ -131,6 +131,8 @@ jobs:
|
||||
shell: bash
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
|
||||
# test_release_e2e.py and test_upgrade_e2e.py (pip, uv, PyPI, the GitHub release) are NOT in this run or in the Windows legs below: tests/conftest.py leaves
|
||||
# them out of every run that does not name their file, and user-install.yml (the round after the publication) names it. tests/_post_publication.py.
|
||||
- name: Run the full e2e suite under a virtual display, without the root ones
|
||||
# PYTHONUNBUFFERED, and it is not a nicety. Without it Python block-buffers
|
||||
# stdout when it is a pipe, and this step printed NOTHING for 39 minutes
|
||||
|
||||
@@ -186,6 +186,12 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# main, for the tests that compare a list of this change with the list of main (tests/test_the_e2e_tests_do_not_wait_on_clocks.py: the debt of
|
||||
# the e2e tests only shrinks). The checkout is one commit deep; without this the comparison has nothing to read and the test says so.
|
||||
- name: main, to compare the lists that may only shrink
|
||||
shell: bash
|
||||
run: git fetch --no-tags --depth=1 origin main:refs/remotes/origin/main
|
||||
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
|
||||
@@ -6,6 +6,35 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.52.1] - 2026-11-15
|
||||
|
||||
### Changed
|
||||
- Pins invisible-core 64.73.0 (same engine, firefox-64). The compositor is now declared in software on every machine, as a
|
||||
retail Firefox reports on a machine without a usable GPU, and never read from the host. Before, the hardware compositor
|
||||
was declared over a software adapter, which cost about 6x the CPU in the GPU process.
|
||||
- Windows: the engine is created inside a job of its own, so a launch no longer scans every process of the machine to bind
|
||||
the engine's tree. (#498)
|
||||
- Several browsers in one async program no longer slow one another down:
|
||||
- `connect()` starts no thread on the event loop (#497).
|
||||
- The virtual display of `headless=True` starts off the event loop (#499).
|
||||
- Closing a browser waits for its processes and removes its profile without holding the loop that serves the others:
|
||||
with four browsers in one process the loop was held for up to about 0.5 s per close, and is not held now (#503).
|
||||
- Comments, the fork notes and one test message no longer point at scripts that were deleted (the transport comparison scripts and the prefs byte-parity gate: no round ran them). No behaviour changes. (#458)
|
||||
|
||||
### Added
|
||||
- `page.expose_function`, `page.expose_binding`, `context.expose_function` and `context.expose_binding`, as in Playwright: the page calls a Python function and gets a promise (the value, a rejection when the function raised, an await when it is async). The page sees the function and nothing else (no name of ours on the window, no init script); an engine without `Page.addBinding` is refused with a clear sentence. Arguments and results cross as JSON. (#471)
|
||||
- `Locator.screenshot()` and `ElementHandle.screenshot()`: a picture of the element, as in Playwright, in the page, in a frame of another site and in a frame nested in it. (#470)
|
||||
|
||||
### Fixed
|
||||
- A context init script added after a page exists runs once in it, not twice. (#469)
|
||||
- A CORS preflight (an OPTIONS request that no route holds) is no longer reported to the client, as in Playwright's own server: `page.on("request")`, `route` and a request counter hear of one request fewer for each preflighted fetch of the page. (#467)
|
||||
|
||||
### Tests
|
||||
- Every test module is checked to leave no browser open (a census of the connection threads, which needs no package to run). (#497, #500)
|
||||
- Software compositing is declared: the compositor in use, the CPU of the GPU process, and the bytes a page reads compared
|
||||
against a recorded reference, on Linux and Windows. (#501)
|
||||
- The UDP bench survives a loaded Windows machine, and its verdict says what it saw. (#502)
|
||||
|
||||
## [0.52.0] - 2026-11-14
|
||||
|
||||
### Changed
|
||||
|
||||
+632
@@ -39031,6 +39031,638 @@
|
||||
}
|
||||
},
|
||||
"wheel_filename": "invisible_playwright-0.52.0-py3-none-any.whl"
|
||||
},
|
||||
{
|
||||
"published_at": "2026-11-15T12:54:33Z",
|
||||
"requires_dist": [
|
||||
"greenlet<4.0.0,>=3.1.1",
|
||||
"invisible-core==64.73.0",
|
||||
"psutil>=5.9",
|
||||
"pyee<14,>=13",
|
||||
"aioquic>=1.2; extra == 'dev'",
|
||||
"build>=1; extra == 'dev'",
|
||||
"cryptography>=41; extra == 'dev'",
|
||||
"h2<5,>=4; extra == 'dev'",
|
||||
"playwright==1.61.0; extra == 'dev'",
|
||||
"pytest-rerunfailures>=14; extra == 'dev'",
|
||||
"pytest-timeout>=2; extra == 'dev'",
|
||||
"pytest-xdist>=3; extra == 'dev'",
|
||||
"pytest>=7; extra == 'dev'",
|
||||
"ruff>=0.6; extra == 'dev'",
|
||||
"websockets>=13; extra == 'dev'",
|
||||
"websockets>=13; extra == 'remote'"
|
||||
],
|
||||
"sdist": {
|
||||
"digest": "6486cc02c6448e3ba9e85eb8bccd1b6cfb395940bed7c8a21ffdf7aa1a0fa200",
|
||||
"files": {
|
||||
"LICENSE": "2abb03e63a96918967f383cbc36e3faefe10a47ae20b2cab43212ef965e02f96",
|
||||
"PKG-INFO": "6aa4d5d50e856b09540458a077cca457e2716c25f3a3afda745136e0236cd74e",
|
||||
"README.md": "9759da65973562f5b720d9ff20e76355c554494e597094b05f4d51eace298366",
|
||||
"docs/README.md": "ae694f21758d2b80d1dc8eb4d13867d7241ca80fb4137c0ead03e7af799b7192",
|
||||
"docs/integrations/README.md": "d9d4a01c5ce0b3a94123653bf8e78283113cae0a6ec22ba0bc2a2a77baf8ea19",
|
||||
"pyproject.toml": "048fc3fabbcd0edc5b777ff37f985a6a5f180c2e4343eb5c0a088b5a44fb5339",
|
||||
"src/invisible_playwright/THIRD_PARTY_FORK.md": "59e4e355bac554cf7c6ed078f7cd66f053b0e2122ca97107b5a39928a25f9a36",
|
||||
"src/invisible_playwright/__init__.py": "4516af737fdbaa0967a359a97b01aa7a3e3d57dae7283ebe5e6ac2381285f3ee",
|
||||
"src/invisible_playwright/__main__.py": "c6cd277050ead2d11c98b7cbab91ada7d19e495c95e4c86de1f9aaf2b2051d38",
|
||||
"src/invisible_playwright/_cursor.py": "12975e06bcd6c162f4c38298966f9adaa8d9d2eeb225df3a4984af2c9d29672f",
|
||||
"src/invisible_playwright/_engine.py": "fabcbd037b52294a5b5201c22382f56714e94aa1edfb834ee2fc8fd7cbf2b3b0",
|
||||
"src/invisible_playwright/_fpforge/__init__.py": "3e1338f0bac8ce7c61c0b20c87d7824af5d14e3254b8984f5fc811e6c8500681",
|
||||
"src/invisible_playwright/_geo.py": "6cb7a453ae392bd4724f2d508a7f697d1189d9e05b833cc4b36d70069d18225f",
|
||||
"src/invisible_playwright/_headless.py": "ceaf85c0a32f92c8c8489fa11756b538feddecc021d4ae22782927171429c2b9",
|
||||
"src/invisible_playwright/_juggler/__init__.py": "96d6d06dad40f3c5112ab2bf9852c9d273ca891647baaf86e9913a06112db829",
|
||||
"src/invisible_playwright/_juggler/_bindings.py": "3ccfc601acdee9fe67c6de693892ff90d53b60729df1be29f091493a4a3e0c9c",
|
||||
"src/invisible_playwright/_juggler/_marshal.py": "11da69c3de627bd809a1d5b5371874f4aab3356d95ed602a4dfe4d53230245df",
|
||||
"src/invisible_playwright/_juggler/_threads.py": "a790d60fae3815169f2692af3377e62add5ac3ec240fa0dc7e6b52a88c7fa5c0",
|
||||
"src/invisible_playwright/_juggler/dialogs.py": "5541004829d2484526fc93f11338bfdf9f63f3319e17fc95ea51f61e1b429220",
|
||||
"src/invisible_playwright/_juggler/dispatcher.py": "dbe6a309766850eadd6176ce5fdc69865f4be9b8efa308248017a0c07bcf3ad6",
|
||||
"src/invisible_playwright/_juggler/memprobe.py": "b970afd7f877ac3ed631bd8b069000798034e32c1df497ce8102928aa29277d7",
|
||||
"src/invisible_playwright/_juggler/perimeter.py": "6c453ccb00624a40d222ae8887c93aed688a108199d17e18e0791109c2686535",
|
||||
"src/invisible_playwright/_juggler/pointer.py": "cc38686ae60d08613b70d5898cec14ba62b67de218748963263a877c057b7ca9",
|
||||
"src/invisible_playwright/_juggler/remote.py": "8835469f4a3d902d60858327ab95e183eded7373d02e4aa92fa67e0369e752d2",
|
||||
"src/invisible_playwright/_juggler/server.py": "acacc1bf28f13f793f98f9429cc4f485d1f96566b7798bde2f96d48092f8bf13",
|
||||
"src/invisible_playwright/_juggler/transport.py": "b03b1b5367f89915dcaa02366957cfdac00a77aa695f8aa86e71fb9955e39ee2",
|
||||
"src/invisible_playwright/_juggler/variants.py": "0ad98874f892ba1527be16230160166230aa846c5665bbf02fc0a643279a99c8",
|
||||
"src/invisible_playwright/_juggler/wire.py": "fbe0399da9896031a104bdbe83a7c24a42dd6c264a23bd65d83e8e5f2be9e840",
|
||||
"src/invisible_playwright/_pin.py": "34840d65c3ce32aa856f55344358a84cf47904471039a0a28d510166c6feda4b",
|
||||
"src/invisible_playwright/_proxy.py": "dadfd7ad17246521c78c2e67bc60e31e3fc854dcb0924c4067f5d49a9662722e",
|
||||
"src/invisible_playwright/_pw/LICENSE": "7fab1461b41970ff376f1c9303a637076bfaaeb71cd12dd3a1c44aaf59a1a2b9",
|
||||
"src/invisible_playwright/_pw/README.md": "3ff2819bfde496151299983c4db167171e3e49933e7cf75613239893b2530570",
|
||||
"src/invisible_playwright/_pw/__init__.py": "06c3acdadd13e2813fcb95ad91d53ee3885c2b5f473beccc45a579d9ceead70b",
|
||||
"src/invisible_playwright/_pw/__main__.py": "dcc8e224337e54bb2febd50cc2e3c6db6ad345c2e148fe64612ca64c4dbea469",
|
||||
"src/invisible_playwright/_pw/_impl/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"src/invisible_playwright/_pw/_impl/__pyinstaller/__init__.py": "5a8c0cfeb2d84ed4287afdec24ffcec60d1ed827b92afdfbd82b2351ffae1c15",
|
||||
"src/invisible_playwright/_pw/_impl/__pyinstaller/hook-playwright.async_api.py": "d4a8c45554b3ba55e8102f03f576bab6ea4abfb70cdc60095471d504e34a1014",
|
||||
"src/invisible_playwright/_pw/_impl/__pyinstaller/hook-playwright.sync_api.py": "d4a8c45554b3ba55e8102f03f576bab6ea4abfb70cdc60095471d504e34a1014",
|
||||
"src/invisible_playwright/_pw/_impl/_api_structures.py": "7117217bc28b93311e0ded2232935bbb3e71cd36a69ace95faa5b5f019b6186d",
|
||||
"src/invisible_playwright/_pw/_impl/_artifact.py": "3f06f56db387ad34194b9287291843e32ee6b2fbd06417872085ba5cdf58c3d0",
|
||||
"src/invisible_playwright/_pw/_impl/_assertions.py": "ebfe537ce1c118606f256cf431d8acc55dbf45cec0ff8ce80b7d08189372d584",
|
||||
"src/invisible_playwright/_pw/_impl/_async_base.py": "411bdbf2019879b7338bfd11291dab77662c4de8c029ce233f6c8c173845e440",
|
||||
"src/invisible_playwright/_pw/_impl/_browser.py": "96af02910c9bd02ed3747049e4dc83f792b18ab363257bea5bb63e81335b5098",
|
||||
"src/invisible_playwright/_pw/_impl/_browser_context.py": "c91c6e44a0dbc4e9c0430807561d9b92a73a3b33c406792a71a1362ccf995e46",
|
||||
"src/invisible_playwright/_pw/_impl/_browser_type.py": "8e8fab1f8253952f971ea941948292e49fa08038e6566e6164ba1db927f16017",
|
||||
"src/invisible_playwright/_pw/_impl/_cdp_session.py": "da1f31e66ee6a1a47a77412f6efa3e72670835a81d20a42a939cc6043f4c3357",
|
||||
"src/invisible_playwright/_pw/_impl/_clock.py": "c3868a4cfdad993d99a554e58742f8c1e9f6806d51199e2870916e6c8b2eea2c",
|
||||
"src/invisible_playwright/_pw/_impl/_connection.py": "0c345f8afd418c42c9722126b4562009922135df050c076ce279481cc9ae2534",
|
||||
"src/invisible_playwright/_pw/_impl/_console_message.py": "4adcc1921c9ad348a2f796848b2ce92ab625b3f328ed611ac42d6576fe16ac66",
|
||||
"src/invisible_playwright/_pw/_impl/_credentials.py": "0d5e2ea044d6a0861de54aae29de5f0da8ef871635384f57a111e2d70cd9843e",
|
||||
"src/invisible_playwright/_pw/_impl/_debugger.py": "17a425f2c82a798098fe08a0a1b92be5fd7ccce0d56af25a6795e80d33aee2bd",
|
||||
"src/invisible_playwright/_pw/_impl/_dialog.py": "2061f36b8952cd8fcb74c9a9cc9930c3a600eb1e7f6fa4ef1867867f353d14a6",
|
||||
"src/invisible_playwright/_pw/_impl/_disposable.py": "564a3c3e3e2c5dc8db07727d682e2fb40c0e113e8489cf7fc179ed4aaea2ac87",
|
||||
"src/invisible_playwright/_pw/_impl/_download.py": "5349c613615cc690593537acbedc83e5a53fd056521358cacaf2a355238efdd4",
|
||||
"src/invisible_playwright/_pw/_impl/_element_handle.py": "b922cf771522209192727547185c922e9617f94fe55ae7c37ffa99cadf410a45",
|
||||
"src/invisible_playwright/_pw/_impl/_errors.py": "49407bd6164ab563f82b2bf37863a265555071544dcabedbf7beba8be1b618cd",
|
||||
"src/invisible_playwright/_pw/_impl/_event_context_manager.py": "55ea0fab5a17acbb3f6f797610cf20a77efcbc7b62e8c19bac53a138f39c7127",
|
||||
"src/invisible_playwright/_pw/_impl/_fetch.py": "2756ee00ffb7cf8e178af4d9f8d56ab7d06828fce431faa9318e54a2ade55e1f",
|
||||
"src/invisible_playwright/_pw/_impl/_file_chooser.py": "3efbf6c96f36cb906508330cb09ef5b5e1843e2b1aa95b27a5f85ec4376c8522",
|
||||
"src/invisible_playwright/_pw/_impl/_form_data.py": "a9ce4cb4f77a06d24d31ea0e81a0e007a965bf33ad848ebed7cf0ad2f40f36b7",
|
||||
"src/invisible_playwright/_pw/_impl/_frame.py": "0f974f94f52be86e510552900469c219007ba7a5ec05f3fe3a0d5cb78ff42b81",
|
||||
"src/invisible_playwright/_pw/_impl/_glob.py": "af927c1cc1a33e12094224ca96158964ce2c7ad9f4b4de3ac60e16e0baf9f887",
|
||||
"src/invisible_playwright/_pw/_impl/_greenlets.py": "27456c0ecfc181a04a6a1245e0f72549129e3af0b611e60607cb5d29f4fe2634",
|
||||
"src/invisible_playwright/_pw/_impl/_har_router.py": "24fe3134253de1b71a3738348444dea88b78bdd250851ac7cfdac2ffcdef68b8",
|
||||
"src/invisible_playwright/_pw/_impl/_helper.py": "c866f0dde846d84856404d7b6c72c5fbd5ac41302b1f6ac043016956256c2812",
|
||||
"src/invisible_playwright/_pw/_impl/_impl_to_api_mapping.py": "ea1e5b8ea94f344a18a6c049e465d45044cfd61c2ef779887f076e675dffa655",
|
||||
"src/invisible_playwright/_pw/_impl/_input.py": "14ed52c5e5bda7f5d8bde6b67fd651dee8c368344e13d652178d04e975ea1801",
|
||||
"src/invisible_playwright/_pw/_impl/_js_handle.py": "cbb76fdf29d5087e2f2d04bac5e729bf7905238a9b386f3be9e01a4e2a95406a",
|
||||
"src/invisible_playwright/_pw/_impl/_json_pipe.py": "c738956081dee483bbc032707553a9f9b3be38750f2ee7916390fa47fb1b19e8",
|
||||
"src/invisible_playwright/_pw/_impl/_local_utils.py": "93677e1277ef74efcf52630d98a8857c1ea847b6e16757538040ce49e2758490",
|
||||
"src/invisible_playwright/_pw/_impl/_locator.py": "c4457bbae669d98530a5bfd717619f8fc801a20c35e2e52e39b4f96193fba708",
|
||||
"src/invisible_playwright/_pw/_impl/_map.py": "606086b53edc29605a5ff0b22147dfc640e38c65089df790063aed9cb89bfaa7",
|
||||
"src/invisible_playwright/_pw/_impl/_network.py": "6af15cca7afa486ddb3edcea9ed2fdd2104f6ec268612dedf6707453a0c9433d",
|
||||
"src/invisible_playwright/_pw/_impl/_object_factory.py": "16cf089afe2a37a18c397ac6cc9aebd296db731b6e6fac2a1248cae09585f26e",
|
||||
"src/invisible_playwright/_pw/_impl/_page.py": "187b110afac50f94766b0b5b40a82c02b895e723c0000fbee7233deb0e08d11e",
|
||||
"src/invisible_playwright/_pw/_impl/_path_utils.py": "2c0c34e8c14e04d350044e5ecca4d804b4c5f9191a94c450f58e6a3f9d8bcd1c",
|
||||
"src/invisible_playwright/_pw/_impl/_playwright.py": "7f1771a504561f108c9e0faa9a44f4e4ab8cc13116bbf2686ea1a3b03ede7d52",
|
||||
"src/invisible_playwright/_pw/_impl/_screencast.py": "3bbef5e66981e9216f27f83428207f61d33d2e371ce2121d195c9ed646d1001f",
|
||||
"src/invisible_playwright/_pw/_impl/_selectors.py": "8f480ab03977b1d1d703a5519d195e3f3335e0e644cd559501167f39318db354",
|
||||
"src/invisible_playwright/_pw/_impl/_set_input_files_helpers.py": "a8863bbe7d98520c8770f51b130c69c259ae629a829e1286588da6b16950377e",
|
||||
"src/invisible_playwright/_pw/_impl/_str_utils.py": "0ff1b72ae6d0dfefc92939fca4cc0c2dcb7efe4fd8e520c72c630a6bd94b0fe3",
|
||||
"src/invisible_playwright/_pw/_impl/_stream.py": "0f05ac6e14aa97ae37b68986bee03d656e3b1f92944b8aa42b9ad927df1803fa",
|
||||
"src/invisible_playwright/_pw/_impl/_sync_base.py": "0bfe9eee479bad5295d7b281f20bb306ed652ef74a5053b14c320995a3187af5",
|
||||
"src/invisible_playwright/_pw/_impl/_tracing.py": "d88db6cdfedaa54ee6435fb7dd5e89b2906ad409374ec0177d17a2bf344d694b",
|
||||
"src/invisible_playwright/_pw/_impl/_transport.py": "93fd10d3b610df26bce681e7e85d2511a62701a2b5ba1fa3e56eac62c6a564da",
|
||||
"src/invisible_playwright/_pw/_impl/_video.py": "f7002004b2c26d072bd108f9539b8e1b698f917be7b17cd30cc7eb3fb373d6d6",
|
||||
"src/invisible_playwright/_pw/_impl/_waiter.py": "d8cda0d02e1e92674c4c0a3127229ff87ca4ef214c1682daf3b64ad4268240e0",
|
||||
"src/invisible_playwright/_pw/_impl/_web_error.py": "238b060de72bdf92b54f771622e9e9739b64240d73e7d573c9125f68a28b64a8",
|
||||
"src/invisible_playwright/_pw/_impl/_web_storage.py": "7f942aee8cc96bd82ea59b3d0839e8b20e4f44f066343e8640e3180fe001ab70",
|
||||
"src/invisible_playwright/_pw/_impl/_writable_stream.py": "4a4936a37ee5c783f88d7f6c7bfda2850bcc18867a420581ca16c90e1248047e",
|
||||
"src/invisible_playwright/_pw/_repo_version.py": "d53af84ac37b99e382129383cbd4ae8f2c78798801ced917b9c0b0e23b34f58e",
|
||||
"src/invisible_playwright/_pw/async_api/__init__.py": "77bbd2c48813238c42211e1470f66bcf82ec31373f89fbe0670b8cba52aae7d6",
|
||||
"src/invisible_playwright/_pw/async_api/_context_manager.py": "3bc5660a721ccc9cce317c8b4a15074b88dbbffeddf860b01ca187dbe16d8ad3",
|
||||
"src/invisible_playwright/_pw/async_api/_generated.py": "b0a5713e9b560387b04bf6410c56b231ec90f0dd7e571f58d2af50013d977f18",
|
||||
"src/invisible_playwright/_pw/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"src/invisible_playwright/_pw/sync_api/__init__.py": "a99ad0ce7f8511de29e3661e9e2c8b2dd5e8c4a0cfe7731de4428367df00c15e",
|
||||
"src/invisible_playwright/_pw/sync_api/_context_manager.py": "d6300f64c2961ae4d115fac87869b7837f4f17d697d8cf843fd58592530e5c5d",
|
||||
"src/invisible_playwright/_pw/sync_api/_generated.py": "7881f3918cdeadd2909f82d36cfd993a54664638adf289cb9eb2e3dbd139f045",
|
||||
"src/invisible_playwright/_reaper.py": "4e87bd00b81805fa3e242ae8c1162c32fa78da4dbc515a9de0647209fab7533c",
|
||||
"src/invisible_playwright/_session.py": "6b9c441e1cf056fbc113dc30105faa189b062a835cda8c692d5652512da549bb",
|
||||
"src/invisible_playwright/_version.py": "101d9ed902fb1a3a806f99f220eb10dd73ca656bd8b02f0c507ec338ef14890b",
|
||||
"src/invisible_playwright/_webgl_personas.py": "bdb1c0d79297f9dc3177f8f530a655bd77b473a1838c4829dc48283e30c380a8",
|
||||
"src/invisible_playwright/async_api.py": "bc5d240d93e7fd995b1014fde23c2a7c739c9fd44fabdf68c508d100bcef8798",
|
||||
"src/invisible_playwright/cli.py": "bd742a8f8ce7961ab3f3ee100398f0247a1e0289563d60be56c33ccd17215f87",
|
||||
"src/invisible_playwright/config.py": "5f48dfcd4cb757787af5c8ff37f2c7a6683ee3f2b4500182dd4c2dd0722a38f3",
|
||||
"src/invisible_playwright/constants.py": "6be639754df221f5c41fdbe343ae35e9ea4c83297e98f6566250549f19d6c121",
|
||||
"src/invisible_playwright/download.py": "416db5d579525d7f0802064d8a6929126c6b085dbe0f1c298f02a7a349f000d9",
|
||||
"src/invisible_playwright/launcher.py": "4cf58482e8468693c80e46a626098ff7f46badb81e945810729a8945e17801cc",
|
||||
"src/invisible_playwright/prefs.py": "3fabf6f07d9f85cd5ea5bb901dfeedc2c3a41b8e199acd0dc25a11c473004298",
|
||||
"src/invisible_playwright/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"src/invisible_playwright/sync_api.py": "4c42eacfdd306f1b610a54bb54fcd1cbaef3c20dd525e584d3c587c4a846ea6b",
|
||||
"tests/_bfcache_evidence.py": "49085e45eb21eb0c3cef0fcb39c2d82d936b5532277c7fa1c2ecbc38c0a93e25",
|
||||
"tests/_browser_census.py": "cf91f249e8e098366c59148ffd62aa10e1847675da6748e3d0e8a93e95b229ec",
|
||||
"tests/_canvas_text.py": "46dfb266b5c6f66698f6bc49cb7211e4e8ef81114da2efd9ae3b6d8c8b861c68",
|
||||
"tests/_cpu_by_type.py": "f11f00712c3476b27d6e28d721d7ba6794298a491a060cf303819626b43292ec",
|
||||
"tests/_doh_servers.py": "5458970c4fececd22f133f1534efee9d0b35d80f1a83156a831e160bbe55c320",
|
||||
"tests/_doh_support.py": "172caeae4992a91b57fa9866430cdb6bb4df53609c6c6646304b22dfa14b3941",
|
||||
"tests/_egress_sink.py": "57669610c5601b9fc351e86072db8092a403f6dac18e6b7b72e2c6a840a6b1df",
|
||||
"tests/_fission_frames.py": "ffe8c96183509d0c645fd4db9b502e2701cf0e7e4e412a7117a4b9ca5185d537",
|
||||
"tests/_h3_server.py": "0e1e8ff0458a84cbd3d441a142a3981c143f52467cda4153cd24c08de32a3272",
|
||||
"tests/_host_address.py": "f2dd658654b7735b8fb2455c4c0a00abcaffaa7d019942923ac3d9dc91a00694",
|
||||
"tests/_http_proxy.py": "6ef54a2b12f0ae768dea0a8e5acb285a5dd624506c9f263980c4172930e30006",
|
||||
"tests/_lab_pki.py": "6a5e87f3b5fee314e65dde231a54ad3ed28a0971431fdfcab081f5efafa5eb57",
|
||||
"tests/_leaks.py": "cbe026e0bef8cd4d6458fab6688a1c7a678f5c4db4b8820712c900d07a9a0b22",
|
||||
"tests/_page_bytes.py": "8ac51b3966e77c52905b4442a14ca7cefaa162b0b7c63f4e8635a656fdc0e3f2",
|
||||
"tests/_page_work.py": "88fc590ca508a4c5ee37e1a40892083dbfb82e2ae0cff0635cc67a579d0a73d0",
|
||||
"tests/_pointer_fakes.py": "a9bbb87d7f3df93749d728870ac886c177afb2f6274dd506ebca6bca1e4c32ca",
|
||||
"tests/_ports.py": "377d3f2abefc98814cfb0557a43c0ac0b46f4bcc623e91d69d55fce90511e24b",
|
||||
"tests/_processes.py": "4193b1cea8f43dfa85e998e70246188c482a6e3f8b5fa0e9517c272ce9fa7846",
|
||||
"tests/_realness_support.py": "19025f06ab74d4ecfbaf4017e4844d611666815401492a4f472f88373d805bc4",
|
||||
"tests/_screencast_evidence.py": "8cdd5137003f2aaa4caf08165a2f9fe16cb3b9f01681cb75bc200288ae962476",
|
||||
"tests/_servers.py": "d3e2668c7e4c3d4a2c54304dda334381012e6327838381279fd3d9802e73dd7d",
|
||||
"tests/_socks_servers.py": "43c6e8ee767f5256ed807d45c4bf228dcd0bfd1a40b9004cefae3299bc855562",
|
||||
"tests/_trap_policy.py": "b71592501c795a14396a4dd2dcd4396ef54377d87a011af9475dbb3bb7d6cfcf",
|
||||
"tests/_turn_chain.py": "d7c69cc1eb6891e14dddac6c844245d3ea9d7f9db41092471e8ee9375ff246f9",
|
||||
"tests/_udp_line.py": "ecfda9d25cf81e2cb270040f54eecd89576ceadadea78eb6b43b3fda501086e2",
|
||||
"tests/_witness.py": "7cb8d923b970cdff0ec2d9eacdebf1030e583226a6e68bbba7e354c8bacb7225",
|
||||
"tests/conftest.py": "12e8bc1ee5f0c9d56ff86133ac6dcf4b96c6769c7c8ef91295b8c78c7d54dffb",
|
||||
"tests/data/canvas_icc_ref/gen_images.py": "b6624a1197289fb69c3383f3c960f1b27a1703c604c5db4415d9bd09fcb204bf",
|
||||
"tests/data/canvas_icc_ref/index.html": "8927658dd8820b5d9fd11640a86c831ec043831649dc36e4df026b2d8f6228f5",
|
||||
"tests/data/canvas_icc_ref/refs.json": "c3956caaa578890f24131882440ed94ad9334dc9c2315f94cb7625a388dfb8a7",
|
||||
"tests/data/canvas_text_ref/index.html": "7da3e2c1349f1c2c7b3aaab9c5055007a571e0e4ab310b28d5691df4ea01ed5e",
|
||||
"tests/data/canvas_text_ref/refs.json": "2fbe5d5bbe4b9b0ca74d59496395d14c02068ab80cee2f5b3311440a41ce794d",
|
||||
"tests/data/canvas_text_ref_colors/index.html": "eb0b5bbf8712826bf1ef6e0f466105c31fc3087cae67daae567085d92ae47a0b",
|
||||
"tests/data/canvas_text_ref_colors/refs.json": "b7da9d351433ee7c1432142eea9751b6ecf910ad76e7a4b7cfaeab17d4d301a6",
|
||||
"tests/data/page_bytes_linux.json": "50ee0f624eec21cc311efc92ae80f35163d287a8b90b426a136d048b05b3ad29",
|
||||
"tests/data/page_bytes_windows.json": "344d335caee6c446dec67a6a2a85bab24051ea1901c1d4704dc4d1681e2f09f9",
|
||||
"tests/data/pointer_golden.json": "1c1da4b1a064d5266b602623c7297712803fb0615d6bcf9927a4a335721a7498",
|
||||
"tests/data/pointer_golden_origin.py": "41e2bc0f0317d67d24f12155cadf5cb9a219b84b5fd9c5185083040cbb753c0f",
|
||||
"tests/data/retail_159_system_theme.json": "2446b904294f6f4d342bd1b64942c345f4d45b8dbc58bfefdf41e45a75fc0f10",
|
||||
"tests/data/ucrt_css_calc.txt": "9f5e011cb6676f577c0011ad568f20c4fc53e9bc8a2891a1163385d48fb81666",
|
||||
"tests/data/ucrt_sin_cos_tan.txt": "0f4cf31fa9dad2aafec3554d5f47666b69c0c099b261fcff4b9a410b869ccdfa",
|
||||
"tests/data/webcodecs_h264.annexb": "6d2bf6221fdf47cc2d0232c8631a74832ce0058098e314ebffdf0ca70347c101",
|
||||
"tests/data/webcodecs_h264_1080p_bframes.annexb": "04da8f4dcbb8bc0f72749c0170d0684591aa10b9f8d04486a199dff84e0d51be",
|
||||
"tests/data/webcodecs_h264_1080p_bframes_rgba_sha256.json": "746640ce00911252e3aef486b9981412a2d2b652728220025f1a7fe538a8a8ca",
|
||||
"tests/engine_process_tree.py": "e949fb5898c9d14cfb76c49507004168585af463a12722296ca6876c7815408a",
|
||||
"tests/engine_refusal.py": "6ccefd8c51d767a289d908e6aa70b2a194de82ec50f9286440763e5fa77f63cc",
|
||||
"tests/gates/upstream_baseline.json": "d87ea58e2ea92b24b8d5d6f3451f1fc0055825c53e315555d522aed7fa6d273a",
|
||||
"tests/geoip_used.py": "59641c6c282016d36ed69254df2e3d571b81a4347537ed50da252161ec17a999",
|
||||
"tests/page_bytes_probe.js": "1a6a264dbaced1a9adf362194cda72db24f60734d9e8c057ca7895ee1492db05",
|
||||
"tests/stroke_shape.py": "f4bb1315338dc4d1b402e2feff1b40ee8cb46358c2d66934c7456a183c5384e3",
|
||||
"tests/test_a_162_message_is_read_like_a_161_one.py": "793ffb99c62be438f17308e99541f1053378b5aebd4f936d8ae3c48445e1efec",
|
||||
"tests/test_a_click_makes_one_mousemove_at_its_point.py": "16685cfe4a40fc00d94168c8640478f48ec1943310c280a55a55e0f9459775c9",
|
||||
"tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py": "1325b13b438f819883f1aed5daa06cd4e6305c05eb8ceb01b844f5d4bed92970",
|
||||
"tests/test_a_closed_browser_leaves_the_others_alone_e2e.py": "f8454227ff36dc9413eab6cbe7203f4df15c83df6a8c372fcb6274a5085bf0f3",
|
||||
"tests/test_a_closed_context_leaves_nothing_in_the_registry.py": "7d8da81271cbd2fcba9ba40ba800ef07c47a02059e7edfbeddfdeeb3d0acfa5b",
|
||||
"tests/test_a_closed_page_says_nothing.py": "f21c0f2ca50c24f282d448b6eba299d98037820bccb5853f5e584a7eb3cb0723",
|
||||
"tests/test_a_closed_pipe_is_a_closed_target.py": "55e821fb6b1ffc0479f2c627e96e56484c51d3f4a7af39f735922149137e8885",
|
||||
"tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py": "d4c647ebb0ce8eb904f36c72b4bebe6ec3dd3b84cf3806f8c48d539c485c476d",
|
||||
"tests/test_a_context_init_script_runs_once_e2e.py": "670e2466cbce855fd1a83f0eb8568a3bbe4b5ce32e67ee795896da5c512e8711",
|
||||
"tests/test_a_context_proxy_carries_its_measured_udp_exit.py": "dfb741b73b04ccfd7393479e1bf19e1eefa47bc71251281f4d147acef86e392e",
|
||||
"tests/test_a_context_route_disables_the_cache.py": "da73964c3228320438a631d3a623e1c2dee748302d35b07cc37d2c52227614f4",
|
||||
"tests/test_a_context_that_ends_leaves_no_process_e2e.py": "1997be72e35d445126c1c7eae740d7eee8d898aeaaaa5363da2be778c9eb20b0",
|
||||
"tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py": "8997146fad3ad4113e4d72d7d928f5d74f8ffb497303bfa012bc344ef16f28cd",
|
||||
"tests/test_a_declared_webgl_extension_survives_its_use_e2e.py": "955e14cf9ab2a0d4774dc77db317d0766be7dc92a32eeaa5b411130ab66ac478",
|
||||
"tests/test_a_detached_frame_answers_detached.py": "b4f7f6e825d4183eb3b5a07f57a78abe96885757e821d1fab24c36e9ce69c883",
|
||||
"tests/test_a_dialog_is_a_protocol_object.py": "23b67e1e0b26053407a0c37c8e08aff526c8e83bf62a667e12783b325c7ff4fd",
|
||||
"tests/test_a_dialog_is_answered_after_a_pause.py": "a9a50b2ec40b3a87a0088f82e1d71a1432c2fc4c84e3cd0029ee83fd640893bc",
|
||||
"tests/test_a_download_finished_before_it_was_announced_is_finished.py": "5d3be1aa70190287d020657b25b41600b691971c9f492d8ad51fc6ab85f82a58",
|
||||
"tests/test_a_failed_expect_carries_its_call_log.py": "00c085fc57f814958c3ef49827a2c2bb3a8de7e8c72a551dac191b3073adb9f9",
|
||||
"tests/test_a_failed_launch_stops_the_display.py": "ca1ef419e238981c1a3a49991b64b91234b2844289cd6cca7d9ab73ab9702e0c",
|
||||
"tests/test_a_field_is_typed_after_a_pause.py": "2cb0980e356557b970cd1c01a3e88133840d13eb8a93c1f11b261cc4df40ce8f",
|
||||
"tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py": "4064e99f54ef25dba062e9dbc987f2ac3cab5a22d16c2a579d778af702a84e7d",
|
||||
"tests/test_a_keepalive_request_reaches_the_client_e2e.py": "5148c7f3730a1876408febbb15f235506528694d017d78333d3e21ceabf1831e",
|
||||
"tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py": "ef8e2f386d6dd55a191118811708944c7a61364d5c97ba0f31083c4338aaf4c5",
|
||||
"tests/test_a_launch_has_one_deadline.py": "5754beba9d57035c43bb86203afb5e2c5c064ff58b0aeb58a55f6c7ea904d3ba",
|
||||
"tests/test_a_launch_without_a_session_gets_one.py": "d85c4ca388fdcd65f8a5742e094ee17c1e4deaa43645a508b936aba7ad7ef05a",
|
||||
"tests/test_a_launch_without_a_session_gets_one_e2e.py": "8079a0aad8de7f8ebe3d68d9498d01234753b8c25adbedf2cd2a153a7241b773",
|
||||
"tests/test_a_left_documents_body_is_evicted_e2e.py": "b687d3ec5be57f6598d751a8a08f8d968f30908b437df52ff2bd10ef1ba11ac2",
|
||||
"tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py": "e78091bad22bf3d9e7669fc4f236abc34605f113dff55ce5bffb6f2f480756c9",
|
||||
"tests/test_a_missing_system_theme_pref_refuses_the_launch_e2e.py": "46c70e961789f415c7fdd0473ce77818c70a13bbb7279ed11bb60494f9632dda",
|
||||
"tests/test_a_module_that_leaves_a_browser_open_fails.py": "a7075810abe82226ece71465bbe4521708d20243ac2bd41ac3d2877ae2d82d95",
|
||||
"tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py": "0ec5339f580d33c5cdc80e1c2b586378895c96c4babd7cbe0435a7e47b930bc2",
|
||||
"tests/test_a_new_page_waits_for_the_engine.py": "87d60be3ca55fb2e79accf35aa3c81bf97601a11045ce8fc52b57ad61f0edac4",
|
||||
"tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py": "cbb23cb5b6df948bb93f60375df27dbffc274e5c4f227502498f66edb32c2a40",
|
||||
"tests/test_a_page_cannot_probe_the_juggler_e2e.py": "2af4046d7c737e87b2435f334055eb92ed1de817e6b9a8946506814e96376745",
|
||||
"tests/test_a_page_closed_before_its_announcement_is_not_announced.py": "e953ebd2671a4d8f560a1cc42488d4282ccb523f78292e1ad6011ea9fbaf1631",
|
||||
"tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py": "bb6e640169994bf68730ddbf26bd1ce99c98d734baadd67ee0de991749752c8f",
|
||||
"tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py": "bb47a24a706d3d49e90a3fc9390f0afd21230af6887fad1381049b61c22fed07",
|
||||
"tests/test_a_page_that_moves_on_e2e.py": "2b9f5fc96675ffc4cafc13d95a131a02e3d5c724a15e10303f3b751ef954b23f",
|
||||
"tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py": "140fc72d3573a73ee9aba40a26b760e45f1a96070efad3cf23fbb300549d492f",
|
||||
"tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py": "7ada9fc12b6bb64390ce60c0220ddd870fbfb02e5e70d160c38126ddc784dc84",
|
||||
"tests/test_a_popup_of_a_link_reaches_the_client_e2e.py": "f8170d43749df340ef5447343fbb89a35684df726d6c909d60708a60ca47dc4a",
|
||||
"tests/test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py": "3044b213bb3921b0c9a68a0ee089e8a01b7f3a624fc59c27acd88ca9d637334e",
|
||||
"tests/test_a_request_and_a_response_are_light.py": "0a0c731037f9b1fbd8868721550f49a113da5e1cfc2f71fff5e75d5e474fe5a1",
|
||||
"tests/test_a_request_says_what_it_is.py": "e586459542963cc4f20617848f22b3eb4fd45b83d4bef73acc8cf1666b9a4a7d",
|
||||
"tests/test_a_request_says_what_it_is_e2e.py": "914b3da82c1d1427b4b0edd8dd2c8e4b251d35cfa046537987aee3a275e83465",
|
||||
"tests/test_a_served_browser_answers_a_plain_client_e2e.py": "b5147129eba86f91d10c6631615ba5f6153e66b405bb499081aa7c24e33c6799",
|
||||
"tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py": "5e7c7028beaefeb73a9419656d8b9074d438383e05baa7fadc77b00615ff78f9",
|
||||
"tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py": "cef5a089a79a859be2a1bc8fec2c1dbfc115501af8069a23d4971ab70c391297",
|
||||
"tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py": "e35980664b18bf19d973a396340e06f21920282c3b0e81bf0cf6c9171ca4080e",
|
||||
"tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py": "2b146d2d01ae8a2f17e2cb2d1a1c109d0cf6c944167d3a9ae33c59a24c71b66c",
|
||||
"tests/test_accept_language_on_the_wire_e2e.py": "3ec7d9da9207a5dc543b898d6bb2bd6c7a5a98d38959a3465447b214873c0c60",
|
||||
"tests/test_actions_without_a_point.py": "dfd5bff76af799b4d705cec2177c16bd2faf521ccf7ff52b8057a9df4bfc0fa1",
|
||||
"tests/test_add_script_tag.py": "660393717fd30819a9e673827ebd284e642c95dfe78b4621d84f8aa26f7c7d51",
|
||||
"tests/test_an_expect_reads_its_value_once.py": "d23d6005eb6bf20307b010afce91b8b6f2128d3743dc76b264ef47ed5a3c3d43",
|
||||
"tests/test_an_isolated_page_and_the_next_e2e.py": "b8877ce754bb5eb2a67023ab963705bbfc9cf146a0d5bc0e22edca860f30cad9",
|
||||
"tests/test_async_api.py": "bc23db7f37b4f3616c95ac531e10b5e269dae3dae4badfbc8ab64b1260d11fb9",
|
||||
"tests/test_backcompat.py": "d283cb213019a76953e65dd451c9f9dfaafb7625ddc38b68d806be49ba8545b1",
|
||||
"tests/test_browser_output_is_drained.py": "f450c8f6df7c74f5f96bbced7dcaf8b10a02df8500018897bfad36cffb26d4d2",
|
||||
"tests/test_build.py": "30fff1ce6fd17c1d81874fc6db7253a745a403d30e536cf6ed7186533584e13a",
|
||||
"tests/test_bypass_csp_e2e.py": "8cfae28f4acdd2d6e7bed95a8117bbac00064cb9d3cee2c39ebf9b7d16099078",
|
||||
"tests/test_caller_world_handles_e2e.py": "815c1c6b472c0554f9d5c6a6977f62e53bf76218d82972b92834535eeec0e291",
|
||||
"tests/test_canvas_icc_readback_is_windows_e2e.py": "166c7756e5e75b300882ba322d56373b7b5703e05a70fd0f8a924ead054367b4",
|
||||
"tests/test_canvas_reads_as_drawn.py": "95444935965f00f7db3668e1b61ceb2be74a864b16b6288283c877e7fc68c0bf",
|
||||
"tests/test_canvas_render_stealth.py": "fb43cfd2cf77c91fdb836d1b9cce874c16486df9ceae0ba89e999fdd8ad2c14e",
|
||||
"tests/test_canvas_text_colors_and_cleartype_is_windows_e2e.py": "cab6924c63e26d878a6f054385f6ca975644f5decbfb2ea276c0f805bbe639cc",
|
||||
"tests/test_canvas_text_is_windows_e2e.py": "3aa8604959d70d849535b725019700a87cd91dfae8d312ffa52b89b1026f716d",
|
||||
"tests/test_ci_downloads_are_authenticated.py": "04bef9dcb53092d2bff696c8ebc77dd9238e66ae80b204b707944fe82da547fb",
|
||||
"tests/test_ci_drive_gate_goes_through_the_core.py": "51a00b9ca3480f2df187a137467e16f6891850862e4c79671a3ef5ba898ebcc8",
|
||||
"tests/test_ci_host_gate.py": "328cf30c2dcd45fa7ef8349981952d530c9d448883a370a4f4e8611b54e24adf",
|
||||
"tests/test_ci_lab_geoip.py": "9bdae7f75db538cadc674df931522578f3e222a5fdb0eb3a006550f8e23d07e5",
|
||||
"tests/test_ci_lab_geoip_verify.py": "754081f6b6d01d877043d3511377c641e2aacb4fe751033f1c6633ef66f68037",
|
||||
"tests/test_ci_real_geoip_check.py": "e1a150e28fc786e44f858e678dd6ab88886890892854edef1bd1117b6bb3d7da",
|
||||
"tests/test_ci_real_geoip_exit_code.py": "e5acaa5829ccea2a930a0c7310c9aa3ddc725c16bf883095bcad8125b5014fa9",
|
||||
"tests/test_ci_runs_once_per_commit.py": "6c92c16d6914db249e88937a06bd81fc0a3bd124f1adbeda0852e70b21437ea1",
|
||||
"tests/test_ci_verdict.py": "86c60a98027cbb0b529f253b71e3505a58a855f44b480db34f988b19029e9e84",
|
||||
"tests/test_ci_workflows_build_the_geoip_database.py": "c232cb4e994e5c45b9563b13be811254fda5d63c427292216eaf6f4a45351ba5",
|
||||
"tests/test_cli.py": "5c9ab4707b35d99deeb0b3af8735ad8ab38bd79588729b251e32684c210fb9eb",
|
||||
"tests/test_click_rhythm.py": "ad3850f11e5ed2a66c2b65caee3f48931cff406c30b8ab1a24b59617a298fa95",
|
||||
"tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py": "06e2e90a8ec1107fdaab97241a631f44ac806cc9a1d1175da85701360df75f71",
|
||||
"tests/test_connect_does_not_start_threads_on_the_loop.py": "5dfd9a5acb175536e222f6d11ca19c9c3c481cd5088cce297e0b85cfcddabdcb",
|
||||
"tests/test_context_locale_e2e.py": "f53d5227bf3feed7577c2b5c9303d0e602c38af704cfbcd4d3784197d6420719",
|
||||
"tests/test_context_locale_is_a_list.py": "31d2c45f8c6bfd3609f57b5b7cf33c954affac2ab3f272d8c8457e58ec8c5764",
|
||||
"tests/test_context_proxy_only_resolves_by_doh_e2e.py": "7200b081c443cb559a6e5cd40028f42509ce0832057a9fe9ae81db17e83be928",
|
||||
"tests/test_control_a_selects_all_in_a_field_e2e.py": "a10bd2c68c975bbfe8eb55e37c3f22626428608d177e803e1a9dfaabf1bbdbd8",
|
||||
"tests/test_core_pin.py": "85c4baf6afef4f3df928547d82e651c8bc8f5262717adc82a8bcce341d00bc46",
|
||||
"tests/test_cross_origin_iframe.py": "fcfd2bf2a56e96c0c43ef32f6c3108a4004b827ff9ac54fccafdb45bbfd6eaf8",
|
||||
"tests/test_css_calc_is_windows_e2e.py": "40b613d180c571aaf384afb4c19ba2ee70791872e82653c0a1a6d804033f271f",
|
||||
"tests/test_cursor_dispatch.py": "9d55a333f175c38d0005d183c72eddaa68d64ca5e2689f69af732b06700b2b7f",
|
||||
"tests/test_cursor_wiring.py": "9e4118f5b959fb705c49c2be02d23c5c752127fd87c3e3f9902047a03942f553",
|
||||
"tests/test_declared_host_network_e2e.py": "a02475f562987ac104199cdfd92b54e39f12818e299169e18a928b881eede76d",
|
||||
"tests/test_detectors_e2e.py": "476fa9fd40bfb3d1e544a950efa7251f70a5eb650598ffc7912015d438cbf6e4",
|
||||
"tests/test_docs_name_the_mcp_repo_as_it_is.py": "c6563d16a9c56fc80b6edee8b82de09288a939afbc3fa97b0c3d43bfbd9da4fa",
|
||||
"tests/test_doh_session_prefs_unit.py": "802e51996616c044858add5df6b5e831879354b643326112e6faafa91f4e4f08",
|
||||
"tests/test_doh_through_the_proxy_e2e.py": "d0a08c97a8bb2193baa920c3bac12de6f85679e351dc7df2d49547d63e84cd5b",
|
||||
"tests/test_doh_under_stress_e2e.py": "d0d7d2c402e851bd2cb5221ba0267701044c6a2697331b1ff7dfe6d1d5718827",
|
||||
"tests/test_download_is_intercepted_e2e.py": "f31c8aceb14f8f9aaf194bb3a81ea77b305fa712361befc090d643cd66522f63",
|
||||
"tests/test_drag_motion.py": "8c7e2c00f35c3f6018d5c621f52677af53331fbae89bf18be1f0b84c0e38ece8",
|
||||
"tests/test_e2e.py": "60fe4aad2e8fb6b146f09c590eb18037bcd8dfd009e2c29cacb217c882b001d6",
|
||||
"tests/test_e2e_hermetic.py": "6ff72fb72345fc1f766edc63f741818c708a805b1041d18cc1bf7bddfce3dc91",
|
||||
"tests/test_element_handle_actions.py": "a32fcaed7ebbed8a0e67477460c847084a05cca8bfd7e93072f8c5be371068b3",
|
||||
"tests/test_element_screenshot_e2e.py": "42d9b82c856bd86140c64a959ab552d4391866916a2c59b0303c681a6e18a9f2",
|
||||
"tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py": "3a7e3cd3ffeb285843d1e457a52199c9490851a5756ad307f2a5b076a91c5f1d",
|
||||
"tests/test_every_page_draws_its_own_acts.py": "3a1f821d191e9c92b25e95f293094315cf9218f7e7083d08c0301a5824c2472f",
|
||||
"tests/test_every_refusal_is_declared.py": "07d0669781c9576a76c1090731f6906708e72bdf65371384c5ade362d574694a",
|
||||
"tests/test_every_route_command_is_answered_may_fail.py": "15359fc307e1dfdfb73e74bd1965b72a7d7de53dc9b07b7f5e10d0bc6ea820e2",
|
||||
"tests/test_every_suite_runs_on_linux_and_windows.py": "a616e16da5ccf67de622085d2821ce702bee343fb8caec99a3e81956a06c9f94",
|
||||
"tests/test_expose_binding_e2e.py": "4b8fed3557ebd61b856ce650146eb9cfb8539e1d90de17565fa7651a6b7fd0c2",
|
||||
"tests/test_expose_binding_refusal.py": "830fa5b68be646ca2e51d187b2dd9ef1401ef6231aa648bec501e6992f19f24e",
|
||||
"tests/test_file_chooser.py": "a5d759ebd1dce310ba25f7b1d76de26dd34f7df0ec7ac98414aad886e6637a31",
|
||||
"tests/test_fingerprint_consistency.py": "aaf372f742cc251e38635eb89be662436616a75aacd17602328cc933397ca0e8",
|
||||
"tests/test_fingerprint_surface.py": "20d2d936f925610a448a74d8b47cf6ecded48532e99ae9ad6d490bc016fab816",
|
||||
"tests/test_first_launch_from_a_new_path.py": "e3d61cc2a8fc893a34058cf05204f9bfd8cbc93fa7544733b5aa5cafd044a45d",
|
||||
"tests/test_fission_frames_dialogs_downloads_popups_e2e.py": "f206299cf493f63b4ebbb8b4c11fad5b657ef4ee0699675dcfd9e832547e5eb5",
|
||||
"tests/test_fission_frames_history_and_processes_e2e.py": "79942b5a07598772c78b2aa6a9933ba7a1ece6049cbba989d444127d01056415",
|
||||
"tests/test_fission_frames_route_and_bindings_e2e.py": "5c665717848c934bf634bf648577a43e63a68e7560798029fd067f4da5ae7453",
|
||||
"tests/test_fission_frames_tree_input_and_pixels_e2e.py": "7c7ba8fc64bac1fcd9f4e94334dd7f0c5fe7b1c94c0460b5fbadc39878683bae",
|
||||
"tests/test_fission_frames_workers_storage_and_special_frames_e2e.py": "73fb09cb0728f5f79e7b0ab13ce8aeff4a1648adf4562263207f7369aca1d878",
|
||||
"tests/test_fission_identity_parity_e2e.py": "3e78b149e6f8c366a7ac6442bfbeddde2f0190c906315055e2702df350abbbe4",
|
||||
"tests/test_fission_iframe_crash_e2e.py": "faa39a6c7b2437534b9fb0a3f5cd17c8afa4f15a93283be327dea2f7235760d5",
|
||||
"tests/test_fission_strategy1_bench.py": "7d27a4bbc0429c346e3a435130b7af1caea61474593c164f381cd549df069059",
|
||||
"tests/test_fixtures_name_why_the_package_is_missing.py": "acaa7120c5d8d411c14b3c533fe424f10c4cf4c3af481f4966d64f1dcf97a221",
|
||||
"tests/test_fontconfig_reads_nothing_of_the_host_linux_e2e.py": "daf9b0ee5873edbc08238748505030e9257531a5da01382f1b1cd88f4027f2ee",
|
||||
"tests/test_fork.py": "61ec15a3a4d98d68a16a09f2654cb8383a842b8432c5a24c2d1eb4f26dc7e573",
|
||||
"tests/test_frame_dispatch.py": "04ca6dcba6e13064d201531ed14c23b1212fee14e3c1aa6027badd30699aa598",
|
||||
"tests/test_frames_outlive_the_back_forward_cache_e2e.py": "75409e7e4b7d4259db5ece525042f6507884e05e1d2306ed7e33e39d8c904e7b",
|
||||
"tests/test_geoip_used.py": "0ad66c33f98711bd00d909c3f421f4b02bfef0aae141f01751238cc88448b3e7",
|
||||
"tests/test_goto_and_every_way_it_is_stopped_e2e.py": "9e0f04f8cc9e4860405348c5ae7ebe8f9478aaf9753db62b6b0f2c9971b53e60",
|
||||
"tests/test_goto_follows_the_base_url.py": "bd4867905bbf341333d6d84927452276a0c5595e96f4ce192251796fb13677a0",
|
||||
"tests/test_goto_networkidle_after_spa_e2e.py": "cb925e058d74d9f2fe660fdb39a29ddcc6bf6fd3cd3c32a7c774b85ba0435ec5",
|
||||
"tests/test_goto_script_redirect_e2e.py": "285b39f4b2a90e306496a4a4b88d4a5cbd741c5399a3464e85853f24aa138596",
|
||||
"tests/test_goto_to_the_same_url_e2e.py": "c92e12718ce10d27cbe7ac31ed91ceca74055f55520c3925823690e52ac645fd",
|
||||
"tests/test_hidden_desktop.py": "5d6386f77d65b73cfdd4baff73c6dce28a69d3d93622fd4c7e642b0e57c8b173",
|
||||
"tests/test_hidden_display_linux.py": "101be6358fd7dcc2fea46fe992c2d12cf08b0ec99513ef76a0cfdad0c89314e6",
|
||||
"tests/test_hook_wiring.py": "b06a8d0c747c695987086128cc4946e6baf2afbdd953f340cb1d0270c8bd88cd",
|
||||
"tests/test_http3_through_the_proxy_e2e.py": "fb84f5cc6b3b6afe81645bb1bbf6efcf7409ac13f2dc7797a9b35e1f13e9bfa1",
|
||||
"tests/test_ice_names_by_the_context_proxy_e2e.py": "53a43690b2e23a38484757c85a8dc13464f136cd63e9e7c0fda0b9f3cd3718ae",
|
||||
"tests/test_ignore_https_errors_e2e.py": "3a2371e70076ab1ae8a7f0ad5785a641870637138579e8cf82118adb4e5b3904",
|
||||
"tests/test_imports.py": "75a5c1f77d26fe675e4ef3f75df3aa6b2fbce516d32cd9f5764ea5370b3f6d7c",
|
||||
"tests/test_injected_node_surface.py": "679ffa5115456351c7d9fade457ddc30a66e9d238e5cefe38b8ad152d69702ae",
|
||||
"tests/test_input_is_born_before_the_page_sees_it_e2e.py": "899a83fedaac86d972f0bacf620695b84eab85b0a2937a431d48a22e09ce6350",
|
||||
"tests/test_integration.py": "6b8f1c6f0f511adeb817fbbc9244230f2f3f543483409b3dcc8e6d6b1b4d6ed3",
|
||||
"tests/test_juggler_actions.py": "b3aea4e372c0c1d62372c3ab54958b7c5e4e60f81aff17ac5977a2cdf1bc34f4",
|
||||
"tests/test_juggler_connection.py": "aa2bb990598281dcf1da2a7b3e220b023bd1dac644d76e4231c7fcb402dad571",
|
||||
"tests/test_juggler_event_buffer.py": "3b67fee3ecc8b806e1cf4dd1d6b644617b3f67537133e598a126757120108bb8",
|
||||
"tests/test_juggler_event_listeners.py": "47b8c44423c8d250f465656b70264004102115d84e3b02863c63ef6b23469e85",
|
||||
"tests/test_juggler_injected.py": "765e7974f840fb5d692b86de90fe653d71f176065c8206129ee6dfc1053b2c2e",
|
||||
"tests/test_juggler_lifecycle_e2e.py": "9747facee2130bfef0b3b013c9732029f9cdc49bca7f224341433cb75a906fc5",
|
||||
"tests/test_juggler_lives_in_the_core.py": "e14acc31eb3c31499f4270b5eb5e06ffbd89bd97892b4b5e796fd80b4d5e1885",
|
||||
"tests/test_juggler_posix_pipe.py": "e26156bc3ee89d9c8213ce88ea45402a4c084b78212e735cea0a818885d423ed",
|
||||
"tests/test_juggler_transport.py": "60cfc2bbef1c3b69a908f81bca91c50751237189712b942a8e8545440dafb29d",
|
||||
"tests/test_key_delay_reaches_the_keyboard.py": "64c6d61fb89af183c3656fc7a0e3dc98110490e156c1372ed9c86fe72f45306f",
|
||||
"tests/test_keyboard_rhythm.py": "432cc602ce9625fc0fbddf767093d68d4ad3382c0ff5558d5947df7f699d3427",
|
||||
"tests/test_launch_counters_run_on_github.py": "b36040ceacf6add9606be1aef2e18579ad0488dd9ec4981f5e6eb460577a79b9",
|
||||
"tests/test_launcher_config.py": "2006cbac5f4a485033bb857c755f535eda3bf01a8dd1c551069e3d96335e9bb3",
|
||||
"tests/test_launcher_helpers.py": "4a6b7bbed4f0b82ce96c71fd04c15c519cb488d24475f212bb454aab5826c560",
|
||||
"tests/test_long_session_e2e.py": "96cd8fd6bb5ec76d56574d9bfb1bea0a3803dde55f7ed261f91ff6922f5e064a",
|
||||
"tests/test_math_sin_cos_tan_are_windows_e2e.py": "ddf7ec5161a6aace727306d634d61acf38203784a02e19474cf58590c4b1b848",
|
||||
"tests/test_mouse.py": "3e9a9e98210a07d3f84a01ff3680f80725d5854f306817b71c95af8380cc77a6",
|
||||
"tests/test_mouse_events_keep_their_values_e2e.py": "0d7f76724da0802b96598084ed997fdeac17edbd4e9e38631e646325eb43f0c1",
|
||||
"tests/test_navigation_across_processes_e2e.py": "7fb8ee5fa2e8575bcdd8a8f3775ee04e36bfb6afb6a5da093448be2ecd027e71",
|
||||
"tests/test_navigation_response.py": "0f8db0fde9a1a98108397275ca04ab6c95da9fb73acf5c52cab81ab37156f6bb",
|
||||
"tests/test_nested_frame_actions.py": "ba8a9a15c21ffdd8e23f24f76c1749e08a52e1f14a0efc23c1833a42bfd28c7b",
|
||||
"tests/test_networkidle_reaches_the_client_e2e.py": "bdbaa90dfde6c5f3dcb6e6f87b84adf88d0a4ac55ec7f4aae76251586d3c2f18",
|
||||
"tests/test_networkidle_through_a_served_browser_with_routes_e2e.py": "334b98349c88b0df798a0b57fc6f8d18d6b58c6e12e96f4a9876121e07357302",
|
||||
"tests/test_new_page_defaults.py": "e74367f3e008e5345c8391070bce0ac857395a47b2aa69ca69d6376926d3c4ce",
|
||||
"tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py": "48e8f6401d729269ff0d60f6a5e6f673b44339da49066420b5f14e4d6145b537",
|
||||
"tests/test_no_override_leaves_the_persona_scheme.py": "d46a4c66359afafdac275ac1ef6994018de990e061d5a2d1d22c18b1e89a14f1",
|
||||
"tests/test_no_thread_is_started_on_the_reader.py": "f882ec09a53c4d4541ecdaffe5a263523c355470109dd3f53c517cc8e8eb2e16",
|
||||
"tests/test_nothing_leaves_but_the_proxy_e2e.py": "ab7522048596207c346d02c863a75e08df8a9e4428922810bfbe9a2131d16a08",
|
||||
"tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py": "526dcdc059ecd0993c51e3e4a7a77c61d81fd8505cc180ae7939444040d89b7c",
|
||||
"tests/test_oop_frame_element.py": "dbb8ada9914f0a275eadef034dad6d2b47f3fa72ceba51b8cedbd7fea808650e",
|
||||
"tests/test_oop_frame_geometry.py": "983ffa905815068dae15b72bc846e0e6280f6663412ab03272fea4b800476a35",
|
||||
"tests/test_page_number_follows_the_call.py": "5d6fd7d1b2cf4a2cd904e851ee0c12b05ac2ff386f90b9cbd38919f0cd23dff5",
|
||||
"tests/test_persistent_profile_keeps_state.py": "c6d11fde906d4a0d8c94c124c7b7fdb436420efc7460a51a4cfbc31ceb911059",
|
||||
"tests/test_pin.py": "e297f630a7c281d951c536cd7e683ce9daaefed78afafbeb6c9f91410f6a7a85",
|
||||
"tests/test_pin_dicts_are_valid.py": "a6bbc441942cd5772a1a0d3a0b3b69540c2ae1b9f955fcd70b052e47cb68a0eb",
|
||||
"tests/test_pinning_doc.py": "50a620a3b9fd9077eeda7806bf891f8a138aa5f9ba3dba7fd5f9d12b1b4fbd48",
|
||||
"tests/test_pointer_position.py": "c2132d7ea8b1b8f628d262d2df2246d70d213723adc5a1f8ab5be91482041d1a",
|
||||
"tests/test_pointer_server.py": "465bea4cc589cd7fbe2ab3bbe9e743c12605eb8c70fe9e71a4d3e7cfd78d33bf",
|
||||
"tests/test_popup_adoption_unit.py": "ee9c2b940346cc0ab71151bdbb0b0ab988983df961847d3c548996c7e03ce4ab",
|
||||
"tests/test_popup_destinations_e2e.py": "b76ac4561f9e4f36ef5d61ae80cc1fc1b8e4a3cfdb48464b6f810e072712cee8",
|
||||
"tests/test_popup_pages.py": "77565b4e39dc9fdcd61a85aa6be8b693aede93abde93a6fbab49bd0a3d9a87e2",
|
||||
"tests/test_popups_reach_the_client_e2e.py": "79fbfbf81ddf44723509f97bf0dc30ee4fe7027781ce2615e86c1a20f106aff0",
|
||||
"tests/test_prefs_composition_arm.py": "46b1cbe17704554c32069ef5d4ddf0c47a1b9a0890ead4d35db63303ee6ae2f2",
|
||||
"tests/test_preload_newtab_reaches_the_core_only_when_asked.py": "fbac9599093d0b92a72773b24fa8be91b5f0c900efdcd56f00991c17a28e6c8a",
|
||||
"tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py": "90542bb44009ab68e356ea7d0881b86b1b35271fc9b00b153fd3e30feaade0c5",
|
||||
"tests/test_protocol_names_are_declared.py": "d9fb8913d290c8a61bf461a2198a3e6fbe2c1a81f6a6f6384280595c97ee290e",
|
||||
"tests/test_proxy_http_auth_e2e.py": "884f978221e7f968c43b2bf7261da93aac37049572aa563a27af153722701b0a",
|
||||
"tests/test_proxy_reaches_the_browser.py": "b9fd7bde8fd419834c5171daab0de4d4b9865eb05739a2dad323abb323d6d04b",
|
||||
"tests/test_proxy_socks_auth_e2e.py": "c3445d5fb0ad1cf0bfac31b768d29ee4698a51f3b816e6c7019f6b14ec2c01c0",
|
||||
"tests/test_publish_gate_wiring.py": "d5792ca9aac04cf9df42c592ed09c625e5cc68962c797e1d3621831eba290d3e",
|
||||
"tests/test_pyproject_names_real_paths.py": "a142fd2737ac94e3f965ad7d9bb40297fb3a9016379baf1b756a62b72be92bf1",
|
||||
"tests/test_readme_claims.py": "0407f77f5c08c66a55a0f8fcac0857881c55c04cea8163ae1482018df5aa9e11",
|
||||
"tests/test_realness_behind_a_declared_exit_e2e.py": "42ec863ef8ccead03cf665b7311b6424dde6e7caa681c26b0fd9f530a43195a6",
|
||||
"tests/test_reaper.py": "000e4639d86868f05a7f6be4abc38d2eb59d74045a73aceb5c0aca2a6d29dd93",
|
||||
"tests/test_release_e2e.py": "a921e0758f62e07894a3c5084b270d74d407a4fcfdec32898b799b3aaa2d9850",
|
||||
"tests/test_release_notes_install.py": "e0a6024ef78995e9650bccf0bcc7a72727b6bb6fb32f21f38b467c105f37e5fa",
|
||||
"tests/test_request_gc_uses_the_page_session.py": "1a574bf6aa857a139548142211b05b34705fa15fa08fe0abe6e4be7a194ac3aa",
|
||||
"tests/test_requestless_navigation.py": "7768a47cb3e0ef51a2112dc19f7ba3e980e681e10150cef9258476b67f6fbd7b",
|
||||
"tests/test_resolver_race_e2e.py": "0432c40229c4038dff9e439b990dd021c63a0f8b354135b324b8a83723e69c90",
|
||||
"tests/test_resource_types_match_the_pinned_driver.py": "d7f2bfb2e8eb31deefcb283ccbc0c19401ebb36ef5369877a786fb1dd3493ec4",
|
||||
"tests/test_route_abort_code.py": "6ec26ec73dce79161a7b2446955ef4c6d1697d1431a8402c3027fe1c5ef28209",
|
||||
"tests/test_route_e2e.py": "2662f2a0bd11b7e18e1bd09abca905316afbdec04d1ef8734c7cbfbd57602cd3",
|
||||
"tests/test_route_header_order_e2e.py": "a5e58720c0dddd3a1090b565064170b1213bdc9061484e5eb9193a94fba8e1ea",
|
||||
"tests/test_route_post_data_e2e.py": "3f1e478dc6a339a1cf372f3179c8f3a9403add5d80a1117a09e2740b1942a7a1",
|
||||
"tests/test_route_sends_a_navigation_elsewhere_e2e.py": "278fb9fa637586066c7352bafbab7c0ab0a6482e387e9fac2ee5a24053d1f8af",
|
||||
"tests/test_route_superseded_e2e.py": "733e6f8f478fd9d9fa8a045ed42625eb600881fc68d3d9ba16eaa4d234ce96b8",
|
||||
"tests/test_same_document_goto_e2e.py": "5b9d613098a7d1e78e475bdc95da03ee0d89f2835aca2adb31944bc302238d9f",
|
||||
"tests/test_same_document_navigation.py": "0e3b55bcb481126810cddf9f085200363e23fc087296b5fed7c935db57a854c0",
|
||||
"tests/test_screencast.py": "f5366c60da60606c7c8413a51b684eb18ddb26e8d5183a2ebd6f7c5e4647c37a",
|
||||
"tests/test_screencast_ack_race.py": "b66e8fa467fa41b48222f83809737e51a828e9adbc7479d1a53645cf5ba2b045",
|
||||
"tests/test_screencast_stop_e2e.py": "a6b96377db6bc6476de8b1b0c598c6d312a77fef27d2f9706fddd736cd9d1592",
|
||||
"tests/test_screenshot_looks_where_you_are.py": "1ba51fad0e1f44e9a52a2fa479f970a213762b275802f98c2f6a714e47f7aaa0",
|
||||
"tests/test_screenshot_of_text_returns_linux_e2e.py": "dd910029cc5c70c2c85d64576fa12fe4767070ef0c0f03189ec398f131901e93",
|
||||
"tests/test_scroll_into_view.py": "d5c91487c90f2252470986f7efc8fc7bd01b85fb40b45fddc597dc191fa75b09",
|
||||
"tests/test_scroll_only_if_needed_e2e.py": "b78ed5fcb9a596d63c68ceecb77ecdf92e744a6a64b16dc7b17b88dde9929125",
|
||||
"tests/test_seal_binary_path.py": "364e418085eee9568e7fd0381a579296c151495932c1101f3b41c8c728188656",
|
||||
"tests/test_seal_floor.py": "8271836753ac6351ee8746b93b1f3e3f222c13c19800e46ffd8cc40d08384acf",
|
||||
"tests/test_seal_playwright_range.py": "34f818aa423ca30c24534ae27e1dcfaa34e7167a840ccf92e614cf3632735ff5",
|
||||
"tests/test_seal_wire_version.py": "ce208cb450ba067a07e0eb7eceb3c0677a6037b499b5e8abde67c438a1c62fb2",
|
||||
"tests/test_service_worker.py": "994c7d80a60dd60d8fa2f0d3b48e851e80e7ad1bed2ca3c9aeb30edc5470de09",
|
||||
"tests/test_service_worker_controller_e2e.py": "0255a83cb1a507203def00e673250fbd9e61ad4bbadf6f77a2112ba734c7d94f",
|
||||
"tests/test_service_worker_options.py": "40e70e6ec5744024ee280466924c10159b43c74a6a079085de84b7aadac4800f",
|
||||
"tests/test_service_workers_blocked.py": "e1b3abbcad571d821e26e60a0bf316ec212b22547b5874a7e0d2a9e4529d407c",
|
||||
"tests/test_session_transport.py": "60c413770e0ea78bd01bae528818c0cb51dcf262ca9712a4a0bf87aac3620675",
|
||||
"tests/test_set_input_files_payloads.py": "2653c2e20f6bf7bc86c9575c4a05ac402581753bd771a02da212e420bdf51dcb",
|
||||
"tests/test_set_offline_e2e.py": "d2c1dd8d673be53a4042a20263737163a4a26b9ed1d551203fa7f19d966eae69",
|
||||
"tests/test_shadow_trusted_input.py": "97a46078aef6b23f9496c41b023dd7af1e034091be705aaa805b42804c13e1df",
|
||||
"tests/test_software_compositing_is_declared_e2e.py": "19c909412ef946211a0ad99ceab21a753891f393d38f0412db6fde4a85cbe48b",
|
||||
"tests/test_strict_and_force.py": "a3586ad41f4260a0f016a93838cda2e45b6eb4b2b488c3a0af95ab429eaa4d68",
|
||||
"tests/test_suite_boundaries.py": "9e554a4fe13c1475bd879b342e6f92780819614faf02dc884e4cc04bb734bae6",
|
||||
"tests/test_system_fonts_and_colors_are_windows_e2e.py": "ba98e9c4cd56bf914c4ef2e4fed1a871bd59bd04a37c4424d340ef725ce120b7",
|
||||
"tests/test_the_argument_does_not_rewrite_the_expression.py": "bfd094b08582355c60d6e2d8df8b2cf39a5f3134f7dc492d06f1fed8b24b9c69",
|
||||
"tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py": "5c8e72bca1059edcf9db3289e0a8be9199b5c2f086d0243b69ef97b7bdf7bb35",
|
||||
"tests/test_the_callers_code_is_not_counted_e2e.py": "94649ee17fa7fab96cf88c98a4d5f8829077009daf95b0fc9fbc1ec140109375",
|
||||
"tests/test_the_callers_code_runs_once.py": "5a3d86180bd11ab1e9433905c2f99485269c7dfe6cf3c75a5530cf7d94384a01",
|
||||
"tests/test_the_callers_code_runs_once_e2e.py": "8e5c57cd2eb1c619657caeee567cdf86d52cf755c86496b7d0f69631bbf299ef",
|
||||
"tests/test_the_census_needs_no_package.py": "225e8c1821085da1f18da20d45c83997411e000632e3d6537f4017f5674e692b",
|
||||
"tests/test_the_changelog_covers_this_version.py": "3cfd227ac69901ab7cfe5a3286d5c3dbfdc1322b15279521253b1b733c159af3",
|
||||
"tests/test_the_consecutive_port_tests_run_serially.py": "186412cc691a7b12b46d13fa3accbac1902d1e6ef5ff3e1615901abd411ed2db",
|
||||
"tests/test_the_device_enumeration_takes_the_declared_time_e2e.py": "41703d9174483ef2d36885ed41ea20b06a7122f842f9f1e2ab4abf024c724965",
|
||||
"tests/test_the_doh_e2e_launch_on_a_virtual_display.py": "33ae300b61cf37a8cce81adb14711ca870d1dcdf11d66ebd3377c10c526f910c",
|
||||
"tests/test_the_e2e_run_stops_at_the_first_engine_refusal.py": "0f29e035ee261be18d2d7d2250c6da072e7a35ea024525be4eeb6716d0dd0772",
|
||||
"tests/test_the_egress_sink_helpers.py": "09850f08f767e5634b9b820c5671acd4f422b076d878b740c64d45b7f51cd526",
|
||||
"tests/test_the_engine_is_born_in_the_job_e2e.py": "9415ba90848b12747a302b4ef098e7bff1064fc4db6060da08cd41f8fef0af24",
|
||||
"tests/test_the_engine_processes_of_a_test_come_from_its_tree.py": "32f45d4e7af16761dec0257fae360f9fa241fc5f37b3ff8d9453318c6f40c693",
|
||||
"tests/test_the_exit_of_a_context_is_discovered_through_its_own_gateway.py": "a07027f344b531a9c6d047af0131a35a9b0811d03430f4c638ddf9de5e723b8b",
|
||||
"tests/test_the_fake_doh_answers.py": "eee1db51996881388c3d3cbbabe66a97ae6a1317fb61892f0ccecfa8c40e9d72",
|
||||
"tests/test_the_fake_doh_delays_and_refuses.py": "e3d8737e872039decb8d9dc876d37d5c4d621f09dbf897b602382d42e487f0f4",
|
||||
"tests/test_the_fake_doh_tells_a_refused_certificate_from_a_dropped_connection.py": "4fa9aa72435612edd665719d82ca725925fd0722e049e49044256d7c36463009",
|
||||
"tests/test_the_favicon_stays_out_of_sight_e2e.py": "f43b3228799188db000834c28e43e2abe25ebdc7cef1caf3463beb22b1e6ea0a",
|
||||
"tests/test_the_floor_says_the_installer_of_this_environment.py": "baa238883691235250b426537e95e9da6bd68749073bd980b392bd050d83536a",
|
||||
"tests/test_the_h3_line_helpers.py": "c11e7b2fc8b4af439af0ca273b2426b6faafc88874c3504c6f8d054875da763a",
|
||||
"tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py": "ea075622ed1dbc8f3ad58a5a5606ef94ce94711f3440c53280882b8bcc6c6f1e",
|
||||
"tests/test_the_host_address_helper.py": "e104c158686333a80603ba838e6b5210ceb99570b2772d859523e6fd7f6c5905",
|
||||
"tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py": "6dff62aaf9b926f78bd682a5e0e352534bf4dfe53bf5403ecd6f59314d55ebed",
|
||||
"tests/test_the_http_proxy_helper_asks_for_credentials.py": "e2c16386e7c356a61c13bd307695b35f2bf579cc1766bc3718964d34bb2e0023",
|
||||
"tests/test_the_install_job_waits_for_the_index.py": "21050e537f8249918326f796ffdc135bb615c3a6d7b2f8b3336055ede0e6d17d",
|
||||
"tests/test_the_keyboard_follows_the_session_language.py": "a745ec07a7020f4df8a6f1d3101b3efaccd9937a7f7abb573b6d349e2af86f95",
|
||||
"tests/test_the_lab_ca_and_its_ocsp_leaf.py": "723e542175fcc9156869d0e43759acab1bce2b91028938d78f65ed31c32b31b8",
|
||||
"tests/test_the_leak_watcher_sees_a_direct_connection.py": "688a8315f6357fc7fa1080d8069fe94997c7754457ee320cdc0a9a2205a0c7ec",
|
||||
"tests/test_the_names_of_a_permission_are_the_engines.py": "e59caecfc07bbbd7fa574e098e730dfa28baacca7d5a0180709cd9d6bb72b9da",
|
||||
"tests/test_the_network_declaration_reaches_the_engine.py": "31c11a5d6527ac341b8ad602f3343c17b50afe620769b61d5c058b9e21dbcfe7",
|
||||
"tests/test_the_page_bytes_reference_compares_decoded_pixels.py": "c0c51dff5add67fdff1076d6fc6b8a955f10cea8e374cdeced366ab385470004",
|
||||
"tests/test_the_ports_are_one_sequence.py": "01387abfe344e3e3212dd27c8f25583cf5519aacbe21d0dbe25f0dc09a70c6d3",
|
||||
"tests/test_the_realness_helpers.py": "3211aaf9a1f01e03a4efbf9c64c81f183fdfa51d20a157a4976f30945af78fe8",
|
||||
"tests/test_the_registry_collects_the_oldest_like_playwright.py": "188e319115e0c441a7075c342bc30e22378b7f70e889cce09cf1967cf85c1b09",
|
||||
"tests/test_the_remote_server_memory_probe_and_trim.py": "501fcae728a3bee087094493a785872584f20b41b894f984bb4cbd9fb56557de",
|
||||
"tests/test_the_remote_server_serves_the_protocol.py": "8e9f36d9783c015133d12f614d5e97d994d654e1548ffec245e008cded349e1a",
|
||||
"tests/test_the_resolver_trap_counts_its_own_users.py": "74189c33495ca93a33cc6479a77f6c035511ebb77f936169735da6b479c73399",
|
||||
"tests/test_the_resolver_trap_is_required_by_the_gate.py": "862c3da5f21f192c297be545c23eb3c2cf4dfcfea934a286124f08904f221653",
|
||||
"tests/test_the_root_e2e_run_in_the_root_step_and_nowhere_else.py": "10421f0802257983be343e78dd9e1cb2c2d2c45759cf9065240c412e944c0fc4",
|
||||
"tests/test_the_sandbox_e2e_runs_where_user_namespaces_are_on.py": "3fb2e5b18caa40339f346d0662654ce4d611a7c7a6557b26eb85d3e3ade31bbb",
|
||||
"tests/test_the_scheme_is_the_personas_e2e.py": "63143d88c1ee6e368bb7dc302d27a5a19bd39a2faa8dd5e1326582ef5c86939a",
|
||||
"tests/test_the_server_is_exported_and_the_readme_shows_it.py": "fb666592d1574036c6a3d1536f43605a906eddeb094537064de6b46dcb780df5",
|
||||
"tests/test_the_server_says_nothing_about_the_launch_counter.py": "8132a7c996fee1d93a7680db238dd53e538f2fe30b78b877a2623da68e7a17f4",
|
||||
"tests/test_the_session_position_reaches_every_context.py": "2164f0dd6d46260fe7a351c9307833abd255ddcc3261225ddb0905f7e33c6194",
|
||||
"tests/test_the_socket_process_is_sandboxed_e2e.py": "f76dec5e43ad7ba531d1de5a6e365c35d33c7bd6d1400e167a6e1d80f6ffdcc8",
|
||||
"tests/test_the_timing_comparisons_run_serially.py": "151842c510566ccce8b129af4f823bad674d72e6511eff70696ea66202e0eb79",
|
||||
"tests/test_the_udp_bench_survives_what_a_loaded_machine_does_to_it.py": "80ac6642fe813508e3da272d7d29bfee2e922710ec20f0cf1f1415038fc59b8f",
|
||||
"tests/test_the_udp_chain_helper.py": "144ea82e740f92e17e615d515b4d40ed7b0088470af89e4ad9bca7f635e26d45",
|
||||
"tests/test_the_udp_line_helpers.py": "153c45b09e56b744f2a61816f1429cab4f69ae7c32b2e7e09cb9049eb82cb5ef",
|
||||
"tests/test_the_version_describes_the_code.py": "6db64fe0b6d59c073f5b64ffb0c175260f7552bdb89f61abd70ca6c7b46a9fa5",
|
||||
"tests/test_the_whole_udp_chain_by_name_e2e.py": "ed88486115554e6b572a4cc023cf75842142427dc845ba7c6037967a4bd51257",
|
||||
"tests/test_the_wire_is_json.py": "48f89523b0d83f49876cd3eb1f92b50dd36ecf7eb91a939575f9e795d2a6c306",
|
||||
"tests/test_the_witness_hears_a_direct_send.py": "efc12a4f7a4d7381b42448ca2efdfc4fe44158d8cd2a5ce6833a96314b06be4e",
|
||||
"tests/test_the_witness_picks_a_port_both_sockets_bind.py": "acc056c825c07eeb71b55af526e4ab7bd40301bfbf0d32c980ba2bd09fff06da",
|
||||
"tests/test_timeout_zero_is_no_limit.py": "f4b7dc56a2b5840fc6daf0ea1dea22a8d9798d20febf8261a46a5b6e70d1ebaf",
|
||||
"tests/test_trial_does_not_act.py": "5b836b82b7cf3e6f41814d9c6505cba637da2f1740f140eb64a24997826d429a",
|
||||
"tests/test_turn_over_tcp_is_tried_for_real_e2e.py": "cb1eeba1ced50bc456fe8fb3eee83efefccf4f241707849cb02bae9a47fe18f4",
|
||||
"tests/test_typing_a_character_without_a_key_e2e.py": "2018dec5589d58ce1cbb320bd2fc2e7372d5bebf092fa24ef6e8c782b3f4f4f4",
|
||||
"tests/test_ua_widget_not_selectable.py": "564e389fe06bdcbeedebb27352b2b705d60428463120619f96b6b59ce322d794",
|
||||
"tests/test_upgrade_e2e.py": "d7bca38e4d6a0e839490563727fab2f2b76c5b5f64bd10b7e07517f34d72933a",
|
||||
"tests/test_version.py": "b22609f731743835f3f681ed3227aa2e5d8462a166dfd9934440b744344914a6",
|
||||
"tests/test_version_is_not_taken.py": "254661fd419fc5df2957c01238e333e9be32391ff719b9a11292a864f232d8be",
|
||||
"tests/test_virtual_display_start_off_the_loop.py": "882b2d10347a998b1d32b9df70fe1be225c58573d1bf7d93ce5ce5819ec312a8",
|
||||
"tests/test_voices_e2e.py": "87fd3347584b42f4ebaa33343d1ac57aa9965484005d025aa6173cf2e58d7c61",
|
||||
"tests/test_wait_for_function.py": "c819e5dff8c0b2d60d503b61027dfac4c602ea9f429eaad9b8f46cd8feebcceb",
|
||||
"tests/test_wait_for_timeout.py": "9f1ee4b14e315532f4e0e2c113d537ef943ca0a11587b347ccde4f4a33fa9373",
|
||||
"tests/test_web_fonts_of_closed_contexts_e2e.py": "6f0733b723e6a68d11804fe6ad2de7e18bdc97c19ebbbb17c3ee3bcc90b4c531",
|
||||
"tests/test_webcodecs_h264_bframe_pts_order_e2e.py": "7214e2c6ec627c9ccb7b77d98a25d64aa4aea13a2719cb4b935a2856ca9ffdd3",
|
||||
"tests/test_webcodecs_h264_software_decode_ignores_hardware_request_e2e.py": "1b5b1ee7d29e97cdd45a3e810a7a825568335ce039c9aad63130905dc05aa26e",
|
||||
"tests/test_webcodecs_h264_without_host_libavcodec_linux_e2e.py": "3bcf78b6347a287052cfa8259fe505a005733cfb6cac9f13d409d263709ed9ab",
|
||||
"tests/test_webgl2_exists_without_host_mesa_linux_e2e.py": "0e5755c047109b7edb76b6153969213f6246942790c4b017a0b7e5c7c95f704a",
|
||||
"tests/test_webgl_blending_rounds_once_e2e.py": "921ad34f63882c53705845e96b20da90f1680a2cbe76748cd7d4a6653f55fae1",
|
||||
"tests/test_webgl_dot_has_the_declared_gpu_s_bits_e2e.py": "2a60334a3febc9945eeebef4cb8ef869f4fc16a7f954c3cf03952e0e25a35d9b",
|
||||
"tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py": "9b8c284e2f49d0a83ee2d76fe95ab0773a075d9cb8f0fb4ca80ba6da9027adf2",
|
||||
"tests/test_webgl_mediump_is_full_precision_e2e.py": "0444e8fa9db6759c83d72e141ab52aadcde979ac8e4bea0f8550cd5e0ac45601",
|
||||
"tests/test_webgl_noise_active.py": "1a820cb9dd67e9fa4c909beab8ce2eeefb0da3eb81b178275dac017afdcb83e6",
|
||||
"tests/test_webrtc_realness.py": "7ddda2e379dc363e58562ede791fdca007684731afdff6c8f4689a242bc9df21",
|
||||
"tests/unit/test_bfcache_evidence.py": "aac37eae30b4140a84593973486b784b0f48771d4a08ed91bee102ea972f5a7e",
|
||||
"tests/unit/test_canvas_icc_refs.py": "1ce5972836116263ddf12057e07f131a01f9b324582137a857738c792ae8e025",
|
||||
"tests/unit/test_canvas_text_colors_refs.py": "42c32ec2f231e28d91f58cef9a7fdbd229e1bf40767b2e00cfa62e56cbaec2ed",
|
||||
"tests/unit/test_canvas_text_refs.py": "f7b792d6bfda02ec0f3c0c880a99cc693f8413b1a135912f545134417d56a554",
|
||||
"tests/unit/test_compare_canvas_text_runs.py": "908d9f26343d90af081eb18957d2b16a158415d0340c9dfcb48b8c2d45f129b0",
|
||||
"tests/unit/test_config_public.py": "83e065e991a542c7937df190c9467ac4fc177e50e15a3a75d06701f4aa1f1254",
|
||||
"tests/unit/test_engine_at_least.py": "cce6f5301096fe1c30e57c64b2f0a3c688f7f90f5e1a92d0018a099170a7514d",
|
||||
"tests/unit/test_fontconfig_criterion.py": "d730e744f26aa3826f6a7ac02f3f4f37f7513b70ce1440b9c1e2c79505287041",
|
||||
"tests/unit/test_processes_counts_sites.py": "960541d1e102c8c1ea1b6aacad0a2ddf98083ba4daba720db8b58f8c11ec2a39",
|
||||
"tests/unit/test_theme_refusal_drop.py": "b00cf36b87df2c09760ee031fc2013d8edeaeb48796a5b8a7dcf9d5fcc9169bc",
|
||||
"tests/vendor/README.md": "551b2c2337690f908914ef1a7a1ed2385bdde5ddf444ae1410d9cee464403681",
|
||||
"tests/vendor/botd-2.0.0.esm.js": "f438ed251dc7414ece9d4a2b6941441ad9ffae1a1905817f5f0c7366e701dd86",
|
||||
"tests/vendor/creepjs-10aa672.js": "80f43f364bd973bc03cb5b82de033ce28b2bbb145cb04237632a46ef040a92be",
|
||||
"tests/vendor/fingerprintjs-5.2.0.umd.min.js": "a8de5ead580c42d2e2b01a5752aa08da510852230971aa18554d67cd5de5775b",
|
||||
"tests/vendor/fpscanner-1.0.6.es.js": "5680b88e6075fceab5343d31b43dcb1892a98cff072d37084efdd244fd2cb809",
|
||||
"tests/webfont_probe.py": "0e4e8997343de023d288ff0adeac0bb4f88c940f7e55c24585f187e3823da10c"
|
||||
}
|
||||
},
|
||||
"sdist_filename": "invisible_playwright-0.52.1.tar.gz",
|
||||
"seal_tag": "",
|
||||
"version": "0.52.1",
|
||||
"wheel": {
|
||||
"digest": "0d55445c4b879a16fa68546901e5a59372a05ed71b4a3d0ae223bf059374abb8",
|
||||
"files": {
|
||||
"<dist-info>/METADATA": "6aa4d5d50e856b09540458a077cca457e2716c25f3a3afda745136e0236cd74e",
|
||||
"<dist-info>/WHEEL": "da266b2640c891e0e1d24f528a428ca85b913feb9aea66f822bd40b04478044c",
|
||||
"<dist-info>/entry_points.txt": "f07941bc791c2c31375755627886bfe11ba2d83df7b2522064f84be8299ee3a3",
|
||||
"<dist-info>/licenses/LICENSE": "2abb03e63a96918967f383cbc36e3faefe10a47ae20b2cab43212ef965e02f96",
|
||||
"invisible_playwright/THIRD_PARTY_FORK.md": "59e4e355bac554cf7c6ed078f7cd66f053b0e2122ca97107b5a39928a25f9a36",
|
||||
"invisible_playwright/__init__.py": "4516af737fdbaa0967a359a97b01aa7a3e3d57dae7283ebe5e6ac2381285f3ee",
|
||||
"invisible_playwright/__main__.py": "c6cd277050ead2d11c98b7cbab91ada7d19e495c95e4c86de1f9aaf2b2051d38",
|
||||
"invisible_playwright/_cursor.py": "12975e06bcd6c162f4c38298966f9adaa8d9d2eeb225df3a4984af2c9d29672f",
|
||||
"invisible_playwright/_engine.py": "fabcbd037b52294a5b5201c22382f56714e94aa1edfb834ee2fc8fd7cbf2b3b0",
|
||||
"invisible_playwright/_fpforge/__init__.py": "3e1338f0bac8ce7c61c0b20c87d7824af5d14e3254b8984f5fc811e6c8500681",
|
||||
"invisible_playwright/_geo.py": "6cb7a453ae392bd4724f2d508a7f697d1189d9e05b833cc4b36d70069d18225f",
|
||||
"invisible_playwright/_headless.py": "ceaf85c0a32f92c8c8489fa11756b538feddecc021d4ae22782927171429c2b9",
|
||||
"invisible_playwright/_juggler/__init__.py": "96d6d06dad40f3c5112ab2bf9852c9d273ca891647baaf86e9913a06112db829",
|
||||
"invisible_playwright/_juggler/_bindings.py": "3ccfc601acdee9fe67c6de693892ff90d53b60729df1be29f091493a4a3e0c9c",
|
||||
"invisible_playwright/_juggler/_marshal.py": "11da69c3de627bd809a1d5b5371874f4aab3356d95ed602a4dfe4d53230245df",
|
||||
"invisible_playwright/_juggler/_threads.py": "a790d60fae3815169f2692af3377e62add5ac3ec240fa0dc7e6b52a88c7fa5c0",
|
||||
"invisible_playwright/_juggler/dialogs.py": "5541004829d2484526fc93f11338bfdf9f63f3319e17fc95ea51f61e1b429220",
|
||||
"invisible_playwright/_juggler/dispatcher.py": "dbe6a309766850eadd6176ce5fdc69865f4be9b8efa308248017a0c07bcf3ad6",
|
||||
"invisible_playwright/_juggler/memprobe.py": "b970afd7f877ac3ed631bd8b069000798034e32c1df497ce8102928aa29277d7",
|
||||
"invisible_playwright/_juggler/perimeter.py": "6c453ccb00624a40d222ae8887c93aed688a108199d17e18e0791109c2686535",
|
||||
"invisible_playwright/_juggler/pointer.py": "cc38686ae60d08613b70d5898cec14ba62b67de218748963263a877c057b7ca9",
|
||||
"invisible_playwright/_juggler/remote.py": "8835469f4a3d902d60858327ab95e183eded7373d02e4aa92fa67e0369e752d2",
|
||||
"invisible_playwright/_juggler/server.py": "acacc1bf28f13f793f98f9429cc4f485d1f96566b7798bde2f96d48092f8bf13",
|
||||
"invisible_playwright/_juggler/transport.py": "b03b1b5367f89915dcaa02366957cfdac00a77aa695f8aa86e71fb9955e39ee2",
|
||||
"invisible_playwright/_juggler/variants.py": "0ad98874f892ba1527be16230160166230aa846c5665bbf02fc0a643279a99c8",
|
||||
"invisible_playwright/_juggler/wire.py": "fbe0399da9896031a104bdbe83a7c24a42dd6c264a23bd65d83e8e5f2be9e840",
|
||||
"invisible_playwright/_pin.py": "34840d65c3ce32aa856f55344358a84cf47904471039a0a28d510166c6feda4b",
|
||||
"invisible_playwright/_proxy.py": "dadfd7ad17246521c78c2e67bc60e31e3fc854dcb0924c4067f5d49a9662722e",
|
||||
"invisible_playwright/_pw/LICENSE": "7fab1461b41970ff376f1c9303a637076bfaaeb71cd12dd3a1c44aaf59a1a2b9",
|
||||
"invisible_playwright/_pw/README.md": "3ff2819bfde496151299983c4db167171e3e49933e7cf75613239893b2530570",
|
||||
"invisible_playwright/_pw/__init__.py": "06c3acdadd13e2813fcb95ad91d53ee3885c2b5f473beccc45a579d9ceead70b",
|
||||
"invisible_playwright/_pw/__main__.py": "dcc8e224337e54bb2febd50cc2e3c6db6ad345c2e148fe64612ca64c4dbea469",
|
||||
"invisible_playwright/_pw/_impl/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"invisible_playwright/_pw/_impl/__pyinstaller/__init__.py": "5a8c0cfeb2d84ed4287afdec24ffcec60d1ed827b92afdfbd82b2351ffae1c15",
|
||||
"invisible_playwright/_pw/_impl/__pyinstaller/hook-playwright.async_api.py": "d4a8c45554b3ba55e8102f03f576bab6ea4abfb70cdc60095471d504e34a1014",
|
||||
"invisible_playwright/_pw/_impl/__pyinstaller/hook-playwright.sync_api.py": "d4a8c45554b3ba55e8102f03f576bab6ea4abfb70cdc60095471d504e34a1014",
|
||||
"invisible_playwright/_pw/_impl/_api_structures.py": "7117217bc28b93311e0ded2232935bbb3e71cd36a69ace95faa5b5f019b6186d",
|
||||
"invisible_playwright/_pw/_impl/_artifact.py": "3f06f56db387ad34194b9287291843e32ee6b2fbd06417872085ba5cdf58c3d0",
|
||||
"invisible_playwright/_pw/_impl/_assertions.py": "ebfe537ce1c118606f256cf431d8acc55dbf45cec0ff8ce80b7d08189372d584",
|
||||
"invisible_playwright/_pw/_impl/_async_base.py": "411bdbf2019879b7338bfd11291dab77662c4de8c029ce233f6c8c173845e440",
|
||||
"invisible_playwright/_pw/_impl/_browser.py": "96af02910c9bd02ed3747049e4dc83f792b18ab363257bea5bb63e81335b5098",
|
||||
"invisible_playwright/_pw/_impl/_browser_context.py": "c91c6e44a0dbc4e9c0430807561d9b92a73a3b33c406792a71a1362ccf995e46",
|
||||
"invisible_playwright/_pw/_impl/_browser_type.py": "8e8fab1f8253952f971ea941948292e49fa08038e6566e6164ba1db927f16017",
|
||||
"invisible_playwright/_pw/_impl/_cdp_session.py": "da1f31e66ee6a1a47a77412f6efa3e72670835a81d20a42a939cc6043f4c3357",
|
||||
"invisible_playwright/_pw/_impl/_clock.py": "c3868a4cfdad993d99a554e58742f8c1e9f6806d51199e2870916e6c8b2eea2c",
|
||||
"invisible_playwright/_pw/_impl/_connection.py": "0c345f8afd418c42c9722126b4562009922135df050c076ce279481cc9ae2534",
|
||||
"invisible_playwright/_pw/_impl/_console_message.py": "4adcc1921c9ad348a2f796848b2ce92ab625b3f328ed611ac42d6576fe16ac66",
|
||||
"invisible_playwright/_pw/_impl/_credentials.py": "0d5e2ea044d6a0861de54aae29de5f0da8ef871635384f57a111e2d70cd9843e",
|
||||
"invisible_playwright/_pw/_impl/_debugger.py": "17a425f2c82a798098fe08a0a1b92be5fd7ccce0d56af25a6795e80d33aee2bd",
|
||||
"invisible_playwright/_pw/_impl/_dialog.py": "2061f36b8952cd8fcb74c9a9cc9930c3a600eb1e7f6fa4ef1867867f353d14a6",
|
||||
"invisible_playwright/_pw/_impl/_disposable.py": "564a3c3e3e2c5dc8db07727d682e2fb40c0e113e8489cf7fc179ed4aaea2ac87",
|
||||
"invisible_playwright/_pw/_impl/_download.py": "5349c613615cc690593537acbedc83e5a53fd056521358cacaf2a355238efdd4",
|
||||
"invisible_playwright/_pw/_impl/_element_handle.py": "b922cf771522209192727547185c922e9617f94fe55ae7c37ffa99cadf410a45",
|
||||
"invisible_playwright/_pw/_impl/_errors.py": "49407bd6164ab563f82b2bf37863a265555071544dcabedbf7beba8be1b618cd",
|
||||
"invisible_playwright/_pw/_impl/_event_context_manager.py": "55ea0fab5a17acbb3f6f797610cf20a77efcbc7b62e8c19bac53a138f39c7127",
|
||||
"invisible_playwright/_pw/_impl/_fetch.py": "2756ee00ffb7cf8e178af4d9f8d56ab7d06828fce431faa9318e54a2ade55e1f",
|
||||
"invisible_playwright/_pw/_impl/_file_chooser.py": "3efbf6c96f36cb906508330cb09ef5b5e1843e2b1aa95b27a5f85ec4376c8522",
|
||||
"invisible_playwright/_pw/_impl/_form_data.py": "a9ce4cb4f77a06d24d31ea0e81a0e007a965bf33ad848ebed7cf0ad2f40f36b7",
|
||||
"invisible_playwright/_pw/_impl/_frame.py": "0f974f94f52be86e510552900469c219007ba7a5ec05f3fe3a0d5cb78ff42b81",
|
||||
"invisible_playwright/_pw/_impl/_glob.py": "af927c1cc1a33e12094224ca96158964ce2c7ad9f4b4de3ac60e16e0baf9f887",
|
||||
"invisible_playwright/_pw/_impl/_greenlets.py": "27456c0ecfc181a04a6a1245e0f72549129e3af0b611e60607cb5d29f4fe2634",
|
||||
"invisible_playwright/_pw/_impl/_har_router.py": "24fe3134253de1b71a3738348444dea88b78bdd250851ac7cfdac2ffcdef68b8",
|
||||
"invisible_playwright/_pw/_impl/_helper.py": "c866f0dde846d84856404d7b6c72c5fbd5ac41302b1f6ac043016956256c2812",
|
||||
"invisible_playwright/_pw/_impl/_impl_to_api_mapping.py": "ea1e5b8ea94f344a18a6c049e465d45044cfd61c2ef779887f076e675dffa655",
|
||||
"invisible_playwright/_pw/_impl/_input.py": "14ed52c5e5bda7f5d8bde6b67fd651dee8c368344e13d652178d04e975ea1801",
|
||||
"invisible_playwright/_pw/_impl/_js_handle.py": "cbb76fdf29d5087e2f2d04bac5e729bf7905238a9b386f3be9e01a4e2a95406a",
|
||||
"invisible_playwright/_pw/_impl/_json_pipe.py": "c738956081dee483bbc032707553a9f9b3be38750f2ee7916390fa47fb1b19e8",
|
||||
"invisible_playwright/_pw/_impl/_local_utils.py": "93677e1277ef74efcf52630d98a8857c1ea847b6e16757538040ce49e2758490",
|
||||
"invisible_playwright/_pw/_impl/_locator.py": "c4457bbae669d98530a5bfd717619f8fc801a20c35e2e52e39b4f96193fba708",
|
||||
"invisible_playwright/_pw/_impl/_map.py": "606086b53edc29605a5ff0b22147dfc640e38c65089df790063aed9cb89bfaa7",
|
||||
"invisible_playwright/_pw/_impl/_network.py": "6af15cca7afa486ddb3edcea9ed2fdd2104f6ec268612dedf6707453a0c9433d",
|
||||
"invisible_playwright/_pw/_impl/_object_factory.py": "16cf089afe2a37a18c397ac6cc9aebd296db731b6e6fac2a1248cae09585f26e",
|
||||
"invisible_playwright/_pw/_impl/_page.py": "187b110afac50f94766b0b5b40a82c02b895e723c0000fbee7233deb0e08d11e",
|
||||
"invisible_playwright/_pw/_impl/_path_utils.py": "2c0c34e8c14e04d350044e5ecca4d804b4c5f9191a94c450f58e6a3f9d8bcd1c",
|
||||
"invisible_playwright/_pw/_impl/_playwright.py": "7f1771a504561f108c9e0faa9a44f4e4ab8cc13116bbf2686ea1a3b03ede7d52",
|
||||
"invisible_playwright/_pw/_impl/_screencast.py": "3bbef5e66981e9216f27f83428207f61d33d2e371ce2121d195c9ed646d1001f",
|
||||
"invisible_playwright/_pw/_impl/_selectors.py": "8f480ab03977b1d1d703a5519d195e3f3335e0e644cd559501167f39318db354",
|
||||
"invisible_playwright/_pw/_impl/_set_input_files_helpers.py": "a8863bbe7d98520c8770f51b130c69c259ae629a829e1286588da6b16950377e",
|
||||
"invisible_playwright/_pw/_impl/_str_utils.py": "0ff1b72ae6d0dfefc92939fca4cc0c2dcb7efe4fd8e520c72c630a6bd94b0fe3",
|
||||
"invisible_playwright/_pw/_impl/_stream.py": "0f05ac6e14aa97ae37b68986bee03d656e3b1f92944b8aa42b9ad927df1803fa",
|
||||
"invisible_playwright/_pw/_impl/_sync_base.py": "0bfe9eee479bad5295d7b281f20bb306ed652ef74a5053b14c320995a3187af5",
|
||||
"invisible_playwright/_pw/_impl/_tracing.py": "d88db6cdfedaa54ee6435fb7dd5e89b2906ad409374ec0177d17a2bf344d694b",
|
||||
"invisible_playwright/_pw/_impl/_transport.py": "93fd10d3b610df26bce681e7e85d2511a62701a2b5ba1fa3e56eac62c6a564da",
|
||||
"invisible_playwright/_pw/_impl/_video.py": "f7002004b2c26d072bd108f9539b8e1b698f917be7b17cd30cc7eb3fb373d6d6",
|
||||
"invisible_playwright/_pw/_impl/_waiter.py": "d8cda0d02e1e92674c4c0a3127229ff87ca4ef214c1682daf3b64ad4268240e0",
|
||||
"invisible_playwright/_pw/_impl/_web_error.py": "238b060de72bdf92b54f771622e9e9739b64240d73e7d573c9125f68a28b64a8",
|
||||
"invisible_playwright/_pw/_impl/_web_storage.py": "7f942aee8cc96bd82ea59b3d0839e8b20e4f44f066343e8640e3180fe001ab70",
|
||||
"invisible_playwright/_pw/_impl/_writable_stream.py": "4a4936a37ee5c783f88d7f6c7bfda2850bcc18867a420581ca16c90e1248047e",
|
||||
"invisible_playwright/_pw/_repo_version.py": "d53af84ac37b99e382129383cbd4ae8f2c78798801ced917b9c0b0e23b34f58e",
|
||||
"invisible_playwright/_pw/async_api/__init__.py": "77bbd2c48813238c42211e1470f66bcf82ec31373f89fbe0670b8cba52aae7d6",
|
||||
"invisible_playwright/_pw/async_api/_context_manager.py": "3bc5660a721ccc9cce317c8b4a15074b88dbbffeddf860b01ca187dbe16d8ad3",
|
||||
"invisible_playwright/_pw/async_api/_generated.py": "b0a5713e9b560387b04bf6410c56b231ec90f0dd7e571f58d2af50013d977f18",
|
||||
"invisible_playwright/_pw/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"invisible_playwright/_pw/sync_api/__init__.py": "a99ad0ce7f8511de29e3661e9e2c8b2dd5e8c4a0cfe7731de4428367df00c15e",
|
||||
"invisible_playwright/_pw/sync_api/_context_manager.py": "d6300f64c2961ae4d115fac87869b7837f4f17d697d8cf843fd58592530e5c5d",
|
||||
"invisible_playwright/_pw/sync_api/_generated.py": "7881f3918cdeadd2909f82d36cfd993a54664638adf289cb9eb2e3dbd139f045",
|
||||
"invisible_playwright/_reaper.py": "4e87bd00b81805fa3e242ae8c1162c32fa78da4dbc515a9de0647209fab7533c",
|
||||
"invisible_playwright/_session.py": "6b9c441e1cf056fbc113dc30105faa189b062a835cda8c692d5652512da549bb",
|
||||
"invisible_playwright/_version.py": "101d9ed902fb1a3a806f99f220eb10dd73ca656bd8b02f0c507ec338ef14890b",
|
||||
"invisible_playwright/_webgl_personas.py": "bdb1c0d79297f9dc3177f8f530a655bd77b473a1838c4829dc48283e30c380a8",
|
||||
"invisible_playwright/async_api.py": "bc5d240d93e7fd995b1014fde23c2a7c739c9fd44fabdf68c508d100bcef8798",
|
||||
"invisible_playwright/cli.py": "bd742a8f8ce7961ab3f3ee100398f0247a1e0289563d60be56c33ccd17215f87",
|
||||
"invisible_playwright/config.py": "5f48dfcd4cb757787af5c8ff37f2c7a6683ee3f2b4500182dd4c2dd0722a38f3",
|
||||
"invisible_playwright/constants.py": "6be639754df221f5c41fdbe343ae35e9ea4c83297e98f6566250549f19d6c121",
|
||||
"invisible_playwright/download.py": "416db5d579525d7f0802064d8a6929126c6b085dbe0f1c298f02a7a349f000d9",
|
||||
"invisible_playwright/launcher.py": "4cf58482e8468693c80e46a626098ff7f46badb81e945810729a8945e17801cc",
|
||||
"invisible_playwright/prefs.py": "3fabf6f07d9f85cd5ea5bb901dfeedc2c3a41b8e199acd0dc25a11c473004298",
|
||||
"invisible_playwright/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"invisible_playwright/sync_api.py": "4c42eacfdd306f1b610a54bb54fcd1cbaef3c20dd525e584d3c587c4a846ea6b"
|
||||
}
|
||||
},
|
||||
"wheel_filename": "invisible_playwright-0.52.1-py3-none-any.whl"
|
||||
}
|
||||
],
|
||||
"schema": 1
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
{"id": "wrapper.e2e.context.egress", "giro": "G2", "os": ["linux", "windows"], "min_tests": 14, "exact": true, "tests": ["tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "Taken from the minimal-engine port (branch tests/minimal-port) unchanged but for the removed engine gate: 12 = 6 kinds of page work (hints, image/fetch/WebSocket/EventSource, WebRTC STUN and TURN-udp by name, geolocation, a service worker with push, a page still loading when its context closes) x 2 schemes (no proxy at launch and a gateway on the context; a launch gateway and a different one on the context), and 2 = the TURN server named over TCP in those two schemes. EXPECTED RED on the published firefox-63: the 2 TURN-by-name cases (the lookup of the TCP socket takes user context 0; fixed by commits ac0214bff4 and 058edd6cc6 of firefox-64). The 12 have not run on any engine yet. Like wrapper.e2e.doh: the Linux leg runs as root for the resolver trap (INVPW_REQUIRE_TRAP=1); on Windows the DoH log and the gateway's CONNECTs are the sink."},
|
||||
{"id": "wrapper.e2e.context.sink", "giro": "G2", "os": ["linux", "windows"], "min_tests": 35, "exact": true, "tests": ["tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "The behavioural half of the class gate 'nothing of a context leaves but through its proxy', with a witness at an address of this host (no root, no address on lo) and the engine's own resolver log as the native-lookup sink. 35 = 31 + the 4 OCSP cases; the 31 are 19 probes (fetch, WebSocket, stun, turn over UDP, turn and turns over TCP, each by name, by IP and by a .local name, behind SOCKS5 and behind an HTTP proxy where the road differs) + 3 controls (the same probe by IP with no proxy IS heard by the witness) + 1 control of the native sink. + 4 PeerConnections built from a torn-down window (a detached iframe, a closed popup; behind SOCKS5 and behind HTTP; defect B3: EXPECTED RED on firefox-63, green on firefox-64) + 2 controls of them (the same PeerConnection from an attached iframe, green on both). + 2 cases of two contexts alive at once (each with its own proxy and DoH, a TURN server over TCP by a different name in each; behind SOCKS5 EXPECTED RED on firefox-63 like turn_tcp-name-socks5, behind HTTP green on both). EXPECTED RED on firefox-63: turn_tcp-name-socks5, turns_tcp-name-socks5 (user context 0, fixed in firefox-64) and the three .local cases fetch-local-socks5, stun-local-socks5, stun-local-http (audit B4, also red on firefox-64 until decided). The Linux leg runs as root so the resolver trap is a second sink. Windows reads the same engine log (its getaddrinfo lines are in the parent process file under the sandbox: run 43574494194), with the no-proxy native control as its positive control. THE OCSP CASES (4): a TLS page whose leaf, signed by a lab CA the engine trusts (put in the profile by the engine's xpcshell, no ignore_https_errors), names its OCSP responder by a NAME (ocsp-<nonce>.lab.test) and by an IP; a context behind the gateway loads it and the request must go through the gateway, never be looked up natively, in user context 0, or reach the responder (2 cases, EXPECTED RED on firefox-63, green on firefox-64); the same page in a context with no proxy IS asked of the responder (control); a page of an issuer the engine does not trust makes no OCSP request (negative control)."},
|
||||
{"id": "wrapper.e2e.realness", "giro": "G2", "os": ["linux", "windows"], "min_tests": 32, "exact": true, "tests": ["tests/test_realness_behind_a_declared_exit_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "The realness check without a real proxy: six declared exits, the values a page reads, and the roads. Linux runs as root without xdist like the DoH suite (the resolver trap); on Windows the trap does not exist and the assertion on the system resolver is the only one omitted."},
|
||||
{"id": "wrapper.unit.udp", "giro": "G1", "os": ["linux", "windows"], "min_tests": 249, "exact": true, "tests": ["tests/test_the_server_says_nothing_about_the_launch_counter.py", "tests/test_the_witness_picks_a_port_both_sockets_bind.py", "tests/test_preload_newtab_reaches_the_core_only_when_asked.py", "tests/test_the_resolver_trap_counts_its_own_users.py", "tests/test_the_doh_e2e_launch_on_a_virtual_display.py", "tests/test_the_realness_helpers.py", "tests/test_the_h3_line_helpers.py", "tests/test_the_fake_doh_delays_and_refuses.py", "tests/test_the_host_address_helper.py", "tests/test_the_udp_chain_helper.py", "tests/test_the_fake_doh_answers.py", "tests/test_doh_session_prefs_unit.py", "tests/test_the_leak_watcher_sees_a_direct_connection.py", "tests/test_the_http_proxy_helper_asks_for_credentials.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_the_network_declaration_reaches_the_engine.py", "tests/test_the_resolver_trap_is_required_by_the_gate.py", "tests/test_the_exit_of_a_context_is_discovered_through_its_own_gateway.py", "tests/test_the_witness_hears_a_direct_send.py", "tests/test_the_egress_sink_helpers.py", "tests/test_the_lab_ca_and_its_ocsp_leaf.py"], "marker": "unit", "needs_root": false, "note": "92 = 6+32+21+7+8+3+9+6. The leak watcher file defines exactly one of its two resolver-trap tests per host (7 everywhere), so no test is skipped. `exact`: min_tests is raised by hand when a test is added. The sink of the egress gate (tests/test_the_egress_sink_helpers.py, 20): the engine's log (the same on Linux and Windows) and the witness read on known inputs, and a blind log that must raise, never answer 'nothing'. The lab CA of its OCSP case (tests/test_the_lab_ca_and_its_ocsp_leaf.py, 17; tests/test_the_fake_doh_answers.py +1, the DoH serving a lab-CA leaf): the leaf's AIA, trusted and untrusted issuers, the responder, the xpcshell step."},
|
||||
{"id": "wrapper.e2e.page", "giro": "G2", "os": ["linux", "windows"], "min_tests": 115, "exact": true, "tests": ["tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_popup_destinations_e2e.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_route_superseded_e2e.py"], "marker": "e2e", "needs_root": false, "note": "114 = 100 + the 14 of test_a_page_that_moves_on_e2e.py (a navigation the page overtook with location.replace ends; the engine fix 860ef8a6d9 is proved by it). 100 counted at the collection; was 96 = 10+32+16+34+4 before the popup tests of 6200bc2). A page is handed over when the engine says Page.ready; a popup reaches the client (link, noopener, window.open; own site and another; with and without a route; in-process and over launch_server) as Playwright's does; a superseded route. Needs the candidate binary, and the stock Playwright client of the dev extra."},
|
||||
{"id": "wrapper.unit.page", "giro": "G1", "os": ["linux", "windows"], "min_tests": 72, "exact": true, "tests": ["tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_page_number_follows_the_call.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py"], "marker": "unit", "needs_root": false, "note": "72 = 44 + 3+9+5+1+10 of the popup hand-over (24 counted at the collection before; was 20 = 3+8+1+8 before 6200bc2). The page dispatcher's wait for Page.ready and what it hands over; the drive gate goes through the core (the engine waits for the session's road)."}
|
||||
{"id": "wrapper.unit.udp", "giro": "G1", "os": ["linux", "windows"], "min_tests": 258, "exact": true, "tests": ["tests/test_the_server_says_nothing_about_the_launch_counter.py", "tests/test_the_witness_picks_a_port_both_sockets_bind.py", "tests/test_preload_newtab_reaches_the_core_only_when_asked.py", "tests/test_the_resolver_trap_counts_its_own_users.py", "tests/test_the_doh_e2e_launch_on_a_virtual_display.py", "tests/test_the_realness_helpers.py", "tests/test_the_h3_line_helpers.py", "tests/test_the_fake_doh_delays_and_refuses.py", "tests/test_the_host_address_helper.py", "tests/test_the_udp_chain_helper.py", "tests/test_the_fake_doh_answers.py", "tests/test_doh_session_prefs_unit.py", "tests/test_the_leak_watcher_sees_a_direct_connection.py", "tests/test_the_http_proxy_helper_asks_for_credentials.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_the_network_declaration_reaches_the_engine.py", "tests/test_the_resolver_trap_is_required_by_the_gate.py", "tests/test_the_exit_of_a_context_is_discovered_through_its_own_gateway.py", "tests/test_the_witness_hears_a_direct_send.py", "tests/test_the_egress_sink_helpers.py", "tests/test_the_lab_ca_and_its_ocsp_leaf.py", "tests/test_the_udp_bench_survives_what_a_loaded_machine_does_to_it.py"], "marker": "unit", "needs_root": false, "note": "92 = 6+32+21+7+8+3+9+6. The leak watcher file defines exactly one of its two resolver-trap tests per host (7 everywhere), so no test is skipped. `exact`: min_tests is raised by hand when a test is added. The sink of the egress gate (tests/test_the_egress_sink_helpers.py, 20): the engine's log (the same on Linux and Windows) and the witness read on known inputs, and a blind log that must raise, never answer 'nothing'. The lab CA of its OCSP case (tests/test_the_lab_ca_and_its_ocsp_leaf.py, 17; tests/test_the_fake_doh_answers.py +1, the DoH serving a lab-CA leaf): the leaf's AIA, trusted and untrusted issuers, the responder, the xpcshell step."},
|
||||
{"id": "wrapper.e2e.page", "giro": "G2", "os": ["linux", "windows"], "min_tests": 121, "exact": true, "tests": ["tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_popup_destinations_e2e.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py"], "marker": "e2e", "needs_root": false, "note": "114 + the 6 of test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py (four browsers in one process, one closes: the loop is held less than 50 ms by the clock of its own thread, the other three keep answering; one control holds the loop on purpose, the other leaves it late in its selector and must not be charged). 114 = 100 + the 14 of test_a_page_that_moves_on_e2e.py (a navigation the page overtook with location.replace ends; the engine fix 860ef8a6d9 is proved by it). 100 counted at the collection; was 96 = 10+32+16+34+4 before the popup tests of 6200bc2). A page is handed over when the engine says Page.ready; a popup reaches the client (link, noopener, window.open; own site and another; with and without a route; in-process and over launch_server) as Playwright's does; a superseded route. Needs the candidate binary, and the stock Playwright client of the dev extra."},
|
||||
{"id": "wrapper.unit.page", "giro": "G1", "os": ["linux", "windows"], "min_tests": 72, "exact": true, "tests": ["tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_page_number_follows_the_call.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py"], "marker": "unit", "needs_root": false, "note": "72 = 44 + 3+9+5+1+10 of the popup hand-over (24 counted at the collection before; was 20 = 3+8+1+8 before 6200bc2). The page dispatcher's wait for Page.ready and what it hands over; the drive gate goes through the core (the engine waits for the session's road)."},
|
||||
{"id": "wrapper.e2e.compositing", "giro": "G2", "os": ["linux", "windows"], "min_tests": 3, "exact": true, "tests": ["tests/test_software_compositing_is_declared_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The engine DECLARES software compositing on every machine (core: the compositing entries of zoom.stealth.gfx.feature_status carry the VM decision, and on Windows gfx.webrender.software=true, gfx.webrender.software.d3d11=false). 3 = (1) the compositor read from a privileged context is 'WebRender (Software)' on Windows and on Linux (windowUtils.layerManagerType of each window: Troubleshoot.snapshot().graphics throws on this engine, `ext is null`, so it is not the route); (2) the GPU process uses under 1.5 s of CPU on the fixed 10-scene loop of one browser (Windows runner: 0.32 s declared, 2.7-4.2 s not, runs 43652292533 and 43642744101; on Linux it is held to the bound if a GPU process exists); (3) the 86 keys of the page-bytes probe plus the canvas 2D scenes (drawImage scaled with smoothing off/low/medium/high, text with linear/radial/conic gradients) equal tests/data/page_bytes_<os>.json, PNGs on decoded pixels. EXPECTED RED on the core 64.71.0 (tests 1 and 2 on Windows). The reference of Windows holds the 75 stable keys and 6 of the 11 PNG keys of run 43652292533; the five other PNG keys and the new canvas keys, and all of Linux, are written from the first run on the engine of the reference (the failure of test 3 prints RECORD-BEGIN ... RECORD-END with the entries to merge): a reference that is not complete is red, never skipped."},
|
||||
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 19, "exact": true, "tests": ["tests/test_the_page_bytes_reference_compares_decoded_pixels.py"], "marker": "unit", "needs_root": false, "note": "The helpers of wrapper.e2e.compositing on known inputs, no browser: the PNG compared on decoded pixels (another deBG chunk and compression are the same, one pixel is not, every scanline filter), the comparison with a reference (changed, missing and extra keys named, the entry to record), the type of an engine process, an engine process known by its executable and not by the name it gives itself (Linux), and the CPU of a window, and the shape of the committed Windows reference."}
|
||||
]
|
||||
+2
-2
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "invisible_playwright"
|
||||
version = "0.52.0"
|
||||
version = "0.52.1"
|
||||
description = "Playwright wrapper for a patched Firefox with deterministic stealth profile."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
@@ -69,7 +69,7 @@ dependencies = [
|
||||
# metadata; nothing in src/ hardcodes a second copy (tests/test_core_pin.py
|
||||
# fails if one appears). What stays invisible to install-time machinery is the
|
||||
# --no-deps / lockfile residue, and _pin.py is the only layer that sees it.
|
||||
"invisible_core==64.71.0",
|
||||
"invisible_core==64.73.0",
|
||||
# ⛔ playwright is NO LONGER a dependency: since the full fork, the Python
|
||||
# client lives in src/invisible_playwright/_pw/ and its server in
|
||||
# src/invisible_playwright/_juggler/ (no Node driver). Reintroducing it would not visibly
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
"""How much does answering the protocol IN PROCESS actually cost?
|
||||
|
||||
⛔ THE QUESTION IS NARROW ON PURPOSE. Not "is the Python path faster than the
|
||||
Node driver" - that comparison is dominated by the browser and would answer a
|
||||
different question. This measures ONLY the machinery this package adds between
|
||||
`Channel.send` and the code that talks to Juggler: building the message dict,
|
||||
the queue, the worker-thread hop, the reply, and `call_soon_threadsafe` back
|
||||
onto the loop.
|
||||
|
||||
That is the thing the owner asked about on 2026-08-28: inside one process,
|
||||
serialising to yourself looks like waste. Whether it IS waste depends on how it
|
||||
compares to the round trip it wraps, and this project decides that kind of
|
||||
question with a number.
|
||||
|
||||
⛔ NO BROWSER, and that is what makes this trustworthy. A fake server answers
|
||||
instantly, so what is left in the measurement is the transport and nothing
|
||||
else. It also means the result does not depend on the machine being quiet in
|
||||
the way a browser measurement does - though a loaded machine still widens the
|
||||
tail, which is why the median is reported next to the mean.
|
||||
|
||||
python scripts/bench_transport.py
|
||||
python scripts/bench_transport.py --giri 20000
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import pathlib
|
||||
import statistics
|
||||
import sys
|
||||
import time
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "src"))
|
||||
|
||||
#: What a real Juggler round trip costs, measured on 2026-08-27 with the
|
||||
#: shipped binary. It is the denominator: the transport's cost only means
|
||||
#: something as a fraction of the work it wraps.
|
||||
#: ⛔ `Runtime.evaluate("1")` and NOT `Heap.collectGarbage`, which was used once
|
||||
#: as a "bare command" and actually collects garbage - 26,8 ms of browser work
|
||||
#: attributed to the transport.
|
||||
JUGGLER_ROUND_TRIP_MS = 2.4
|
||||
|
||||
|
||||
class FakeServer:
|
||||
"""Answers instantly, so only the transport is being timed."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.transport = None
|
||||
|
||||
def attach(self, transport) -> None:
|
||||
self.transport = transport
|
||||
|
||||
def shutdown(self) -> None:
|
||||
pass
|
||||
|
||||
def handle(self, message):
|
||||
return {"value": message["params"].get("n")}
|
||||
|
||||
|
||||
async def run(rounds: int) -> int:
|
||||
from invisible_playwright._juggler.transport import InProcessTransport
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
transport = InProcessTransport(loop, FakeServer())
|
||||
await transport.connect()
|
||||
|
||||
pending = {}
|
||||
|
||||
def on_message(message):
|
||||
future = pending.pop(message.get("id"), None)
|
||||
if future is not None and not future.done():
|
||||
future.set_result(message)
|
||||
|
||||
transport.on_message = on_message
|
||||
|
||||
async def one(index: int):
|
||||
future = loop.create_future()
|
||||
pending[index] = future
|
||||
transport.send({"id": index, "guid": "x", "method": "noop",
|
||||
"params": {"n": index},
|
||||
"metadata": {"apiName": "bench"}})
|
||||
return await future
|
||||
|
||||
# ⛔ A warm-up that is DISCARDED: the first calls pay for thread start-up
|
||||
# and for the first allocation of every structure, and folding those into
|
||||
# the average is how a microbenchmark reports a number nobody can reproduce.
|
||||
for i in range(200):
|
||||
await one(i)
|
||||
|
||||
samples = []
|
||||
for i in range(rounds):
|
||||
start = time.perf_counter()
|
||||
await one(200 + i)
|
||||
samples.append((time.perf_counter() - start) * 1000.0)
|
||||
|
||||
transport.request_stop()
|
||||
await transport.wait_until_stopped()
|
||||
|
||||
samples.sort()
|
||||
media = statistics.fmean(samples)
|
||||
mediana = samples[len(samples) // 2]
|
||||
p95 = samples[int(len(samples) * 0.95)]
|
||||
print("giri utili %d" % len(samples))
|
||||
print("media %.4f ms" % media)
|
||||
print("mediana %.4f ms" % mediana)
|
||||
print("p95 %.4f ms" % p95)
|
||||
print("p99 %.4f ms" % samples[int(len(samples) * 0.99)])
|
||||
print()
|
||||
print("un giro Juggler vero %.2f ms (misurato 2026-08-27)"
|
||||
% JUGGLER_ROUND_TRIP_MS)
|
||||
quota = 100.0 * mediana / JUGGLER_ROUND_TRIP_MS
|
||||
print("il transport pesa %.1f%% di una chiamata vera" % quota)
|
||||
print()
|
||||
if quota < 10:
|
||||
print("VERDETTO: il transport NON e' il costo. Togliere thread e coda "
|
||||
"andrebbe fatto per semplicita', se mai, non per velocita'.")
|
||||
else:
|
||||
print("VERDETTO: il transport pesa abbastanza da giustificare il "
|
||||
"refactor asincrono.")
|
||||
return 0
|
||||
|
||||
|
||||
def main() -> int:
|
||||
p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
p.add_argument("--giri", type=int, default=5000)
|
||||
a = p.parse_args()
|
||||
return asyncio.run(run(a.giri))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -100,8 +100,8 @@ def _classes(tree: ast.AST) -> dict:
|
||||
#: next step. The failure it would cause is silent and backwards: an `async
|
||||
#: def` operation is absent from `_methods`, so `reachable` returns an EMPTY
|
||||
#: known-set for it, and every field that operation legitimately reads gets
|
||||
#: reported as ignored. Same tuple as `check_unresolved_names.py`'s
|
||||
#: `_FUNCTIONS`, for the same reason.
|
||||
#: reported as ignored. Both function kinds are listed for the same reason as in any
|
||||
#: AST walk over operations.
|
||||
_FUNCTIONS = (ast.FunctionDef, ast.AsyncFunctionDef)
|
||||
|
||||
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
"""A method that uses a name it never has: the NameError nobody ran into yet.
|
||||
|
||||
⛔ IT CAUGHT TWO REAL DEFECTS THE MOMENT IT WAS WRITTEN, both of the same shape
|
||||
and both invisible to every other check in this repo:
|
||||
|
||||
* `Actions._set_checked` passed `frame_id` to its retry loop without ever
|
||||
taking it as a parameter, while `check()` and `uncheck()` accepted the
|
||||
argument and dropped it. Every `page.check()` on the Python transport died
|
||||
with `Page.check: name 'frame_id' is not defined` - and the transport judge
|
||||
reported it as an ENGINE defect, because the test that exercises it pins the
|
||||
transport itself and therefore fails identically on both arms.
|
||||
* `Actions.drag_and_drop` did the same thing twice in one function.
|
||||
|
||||
⛔ WHY THE SUITE DID NOT SEE IT. A `NameError` inside a method is not a syntax
|
||||
error and not an import error: the module loads, the class builds, the name
|
||||
resolves at CALL time. So the whole file is green until somebody calls that one
|
||||
method, and the two above sat in a package with 500 passing tests.
|
||||
|
||||
**What it does NOT do.** It does not type-check, it does not follow
|
||||
`globals()`, `exec`, or a name injected by a decorator, and it deliberately
|
||||
treats every module-level assignment and import as available. The question it
|
||||
asks is the narrowest one that catches this: *does this function use a bare
|
||||
name that is neither its parameter, nor assigned in it, nor defined at module
|
||||
level?*
|
||||
|
||||
python scripts/check_unresolved_names.py
|
||||
python scripts/check_unresolved_names.py --selftest
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import builtins
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
#: ⛔ `scripts/` IS IN THE PERIMETER SINCE 2026-08-29, and leaving it out was
|
||||
#: not a scoping decision - it was a hole this gate exists to close. On that
|
||||
#: date `upstream_baseline.py:_per_file` was found returning `1 if morti else
|
||||
#: 0` with `morti` assigned nowhere: a guaranteed NameError, sitting in the
|
||||
#: repository, while this gate reported "none in 102 file(s)". Pointed at that
|
||||
#: one file by hand it named the fault correctly, so the LOGIC was never
|
||||
#: wrong; only the perimeter was.
|
||||
#:
|
||||
#: And the argument for scanning `scripts/` is STRONGER than for the package,
|
||||
#: not weaker. The reason this class of defect survives is that a NameError
|
||||
#: inside a function is invisible until someone calls it - and the package has
|
||||
#: 529 unit tests calling into it, while these scripts have none. `_per_file`
|
||||
#: is reached only by `--per-file`, on the async arm, forty minutes into a run
|
||||
#: nobody makes twice.
|
||||
#:
|
||||
#: Measured before widening: 22 files, zero findings besides the real one - so
|
||||
#: this costs no false positives to keep.
|
||||
SCANNED = [ROOT / "src" / "invisible_playwright", ROOT / "scripts"]
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
|
||||
_FUNCTIONS = (ast.FunctionDef, ast.AsyncFunctionDef)
|
||||
|
||||
|
||||
def _module_names(tree: ast.AST) -> set:
|
||||
known = {n.name for n in ast.walk(tree)
|
||||
if isinstance(n, _FUNCTIONS + (ast.ClassDef,))}
|
||||
known |= {t.id for n in ast.walk(tree) if isinstance(n, ast.Assign)
|
||||
for t in n.targets if isinstance(t, ast.Name)}
|
||||
known |= {n.target.id for n in ast.walk(tree)
|
||||
if isinstance(n, ast.AnnAssign) and isinstance(n.target, ast.Name)}
|
||||
known |= {a.asname or a.name.split(".")[0]
|
||||
for n in ast.walk(tree) if isinstance(n, (ast.Import, ast.ImportFrom))
|
||||
for a in n.names}
|
||||
# ⛔ THE MODULE DUNDERS, which are not builtins and are not imports:
|
||||
# Python puts them in the module namespace itself. They only became
|
||||
# reachable when this gate started walking module-level functions, and
|
||||
# `__file__` in a plain function is the commonest of them by far - it was
|
||||
# the first false positive the widening produced.
|
||||
known |= {"__file__", "__name__", "__doc__", "__package__", "__spec__",
|
||||
"__loader__", "__builtins__", "__path__"}
|
||||
return known | set(dir(builtins))
|
||||
|
||||
|
||||
def _bound_in(fn: ast.AST) -> set:
|
||||
"""Every name that exists inside this function by the time it runs.
|
||||
|
||||
⛔ Nested functions and lambdas contribute their PARAMETERS, because the
|
||||
outer body legitimately refers to them; comprehension targets and `except
|
||||
... as` names too. Leaving any of those out turns ordinary code into a
|
||||
fault, and a check that cries wolf is switched off after the third time.
|
||||
"""
|
||||
args = fn.args
|
||||
bound = {a.arg for a in list(args.args) + list(args.kwonlyargs)
|
||||
+ list(getattr(args, "posonlyargs", []))}
|
||||
if args.vararg:
|
||||
bound.add(args.vararg.arg)
|
||||
if args.kwarg:
|
||||
bound.add(args.kwarg.arg)
|
||||
for n in ast.walk(fn):
|
||||
if isinstance(n, ast.Name) and isinstance(n.ctx, ast.Store):
|
||||
bound.add(n.id)
|
||||
elif isinstance(n, _FUNCTIONS + (ast.Lambda,)) and n is not fn:
|
||||
inner = n.args
|
||||
for a in (list(inner.args) + list(inner.kwonlyargs)
|
||||
+ list(getattr(inner, "posonlyargs", []))):
|
||||
bound.add(a.arg)
|
||||
# ⛔ `*args` and `**kw` OF THE NESTED FUNCTION TOO. Leaving these
|
||||
# out is not a small gap: the first run of this checker over the
|
||||
# real package reported 10 faults and every one of them was this -
|
||||
# `def patched(**kw)` inside a wrapper, which is the single most
|
||||
# common shape in the file it was scanning. A checker that is
|
||||
# wrong ten times out of ten teaches people to ignore it, and the
|
||||
# two REAL defects it had just found would have been ignored with
|
||||
# the rest.
|
||||
if inner.vararg:
|
||||
bound.add(inner.vararg.arg)
|
||||
if inner.kwarg:
|
||||
bound.add(inner.kwarg.arg)
|
||||
if not isinstance(n, ast.Lambda):
|
||||
bound.add(n.name)
|
||||
elif isinstance(n, ast.comprehension):
|
||||
for t in ast.walk(n.target):
|
||||
if isinstance(t, ast.Name):
|
||||
bound.add(t.id)
|
||||
elif isinstance(n, ast.ExceptHandler) and n.name:
|
||||
bound.add(n.name)
|
||||
elif isinstance(n, ast.Global):
|
||||
bound.update(n.names)
|
||||
elif isinstance(n, ast.Nonlocal):
|
||||
bound.update(n.names)
|
||||
return bound
|
||||
|
||||
|
||||
def unresolved(source: str, where: str = "<source>") -> list:
|
||||
tree = ast.parse(source)
|
||||
known = _module_names(tree)
|
||||
out = []
|
||||
|
||||
def scan(fn, owner):
|
||||
bound = _bound_in(fn)
|
||||
for n in ast.walk(fn):
|
||||
if isinstance(n, ast.Name) and isinstance(n.ctx, ast.Load):
|
||||
if n.id not in bound and n.id not in known:
|
||||
out.append((where, owner, fn.name, n.id, n.lineno))
|
||||
|
||||
for cls in [n for n in ast.walk(tree) if isinstance(n, ast.ClassDef)]:
|
||||
for fn in [n for n in cls.body if isinstance(n, _FUNCTIONS)]:
|
||||
scan(fn, cls.name)
|
||||
# ⛔ MODULE-LEVEL FUNCTIONS TOO, and they were invisible until
|
||||
# 2026-08-29. This gate was written against a file of dispatcher classes,
|
||||
# so it walked classes and nothing else; a plain function was never looked
|
||||
# at. It cost a real defect the day a refactor moved seventeen leaf helpers
|
||||
# into two new modules with no classes at all: one of them used `json`
|
||||
# without importing it, this gate reported "none in 103 files", and the
|
||||
# failure surfaced as a NameError out of one test - which is the exact
|
||||
# shape it exists to catch before a caller does.
|
||||
for fn in [n for n in tree.body if isinstance(n, _FUNCTIONS)]:
|
||||
scan(fn, "<module>")
|
||||
return out
|
||||
|
||||
|
||||
SELFTEST = [
|
||||
("the defect itself: used, never taken",
|
||||
"class A:\n def op(self, x):\n return self.go(frame_id)\n", 1),
|
||||
("a parameter is not a fault",
|
||||
"class A:\n def op(self, frame_id):\n return frame_id\n", 0),
|
||||
("a keyword-only parameter is not a fault",
|
||||
"class A:\n def op(self, *, frame_id=None):\n return frame_id\n", 0),
|
||||
("something assigned in the body is not a fault",
|
||||
"class A:\n def op(self):\n v = 1\n return v\n", 0),
|
||||
("a module-level name is not a fault",
|
||||
"H = 1\nclass A:\n def op(self):\n return H\n", 0),
|
||||
("a MODULE-LEVEL FUNCTION using a name nobody imported",
|
||||
"def helper(x):\n return json.dumps(x)\n", 1),
|
||||
("the same module-level function with the import present",
|
||||
"import json\ndef helper(x):\n return json.dumps(x)\n", 0),
|
||||
("__file__ in a module-level function is not a fault",
|
||||
"def where():\n return __file__\n", 0),
|
||||
("an import is not a fault",
|
||||
"import json\nclass A:\n def op(self):\n return json\n", 0),
|
||||
("a builtin is not a fault",
|
||||
"class A:\n def op(self):\n return len([])\n", 0),
|
||||
("a nested function's parameter is not a fault",
|
||||
"class A:\n def op(self):\n def run(p):\n return p\n"
|
||||
" return run\n", 0),
|
||||
("a comprehension target is not a fault",
|
||||
"class A:\n def op(self):\n return [i for i in range(3)]\n", 0),
|
||||
("an except-as name is not a fault",
|
||||
"class A:\n def op(self):\n try:\n pass\n"
|
||||
" except ValueError as e:\n return e\n", 0),
|
||||
("two in one function are both reported",
|
||||
"class A:\n def op(self):\n return (a_missing, b_missing)\n", 2),
|
||||
# ⛔ The two below are the shape that produced 10 false alarms on the first
|
||||
# real run. They are here so the next person who tightens `_bound_in` finds
|
||||
# out immediately instead of from a wall of noise.
|
||||
("a nested function's **kwargs is not a fault",
|
||||
"class A:\n def op(self):\n def patched(**kw):\n"
|
||||
" return kw\n return patched\n", 0),
|
||||
("a lambda's *args is not a fault",
|
||||
"class A:\n def op(self):\n return lambda *args: args\n", 0),
|
||||
]
|
||||
|
||||
|
||||
def selftest() -> int:
|
||||
bad = 0
|
||||
for name, source, expected in SELFTEST:
|
||||
got = len(unresolved(source))
|
||||
ok = got == expected
|
||||
bad += 0 if ok else 1
|
||||
print(" %-48s %s (%d, expected %d)"
|
||||
% (name, "ok" if ok else "BROKEN", got, expected))
|
||||
print("selftest: %d cases, %d broken" % (len(SELFTEST), bad))
|
||||
return 1 if bad else 0
|
||||
|
||||
|
||||
def main() -> int:
|
||||
p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
p.add_argument("--selftest", action="store_true")
|
||||
p.add_argument("paths", nargs="*",
|
||||
help="default: the package's own source, plus scripts/")
|
||||
a = p.parse_args()
|
||||
if a.selftest:
|
||||
return selftest()
|
||||
|
||||
files = ([pathlib.Path(x) for x in a.paths]
|
||||
or sorted(f for root in SCANNED for f in root.rglob("*.py")))
|
||||
faults = []
|
||||
for f in files:
|
||||
try:
|
||||
faults += unresolved(f.read_text(encoding="utf-8"), str(f))
|
||||
except SyntaxError as bad:
|
||||
print(" %s: cannot be parsed (%s)" % (f, bad))
|
||||
return 2
|
||||
for where, cls, fn, name, line in faults:
|
||||
print(" %s :: %s.%s uses %r at line %d and never has it"
|
||||
% (pathlib.Path(where).name, cls, fn, name, line))
|
||||
if faults:
|
||||
print("UNRESOLVED NAMES: %d. Each one is a NameError waiting for the "
|
||||
"first caller of that method." % len(faults))
|
||||
return 1
|
||||
print("UNRESOLVED NAMES: none in %d file(s)." % len(files))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,318 +0,0 @@
|
||||
"""Do the two servers receive the same thing, and answer the same thing?
|
||||
|
||||
⛔ THIS IS THE QUESTION THAT DECIDES WHETHER THE NODE DRIVER CAN BE DELETED, and
|
||||
it is not the same question `judge_both_transports.py` answers. That one runs
|
||||
tests and reports which arm goes red - a behavioural check, and a coarse one: a
|
||||
field the client does not happen to read today is missing in complete silence,
|
||||
and shows up as a bug months later in a code path nobody exercised. This one
|
||||
compares the WIRE.
|
||||
|
||||
**What it compares, and why at this level.**
|
||||
|
||||
* **input**: every method the client SENDS, and the set of PARAMETER NAMES it
|
||||
sends with each. Both servers must accept the same vocabulary. A method
|
||||
present on one side and absent on the other is a hole; a method present on
|
||||
both but reached with different fields means the client is being driven
|
||||
differently, which makes the rest of the comparison meaningless.
|
||||
* **output**: every object TYPE the server creates, and the set of INITIALIZER
|
||||
FIELD NAMES for each; plus every EVENT name the server emits, per type. This
|
||||
is the half that reading `_impl` cannot give you: it tells you which fields
|
||||
are CONSUMED today, never which are SENT, and the difference is exactly the
|
||||
set a future code path will want.
|
||||
|
||||
⛔ **FIELD NAMES, NOT VALUES.** guids are allocated by whoever allocates them,
|
||||
ports are ephemeral, versions and build ids differ by construction. Comparing
|
||||
values would drown the real differences in noise that is not a difference at
|
||||
all. Where a VALUE matters it belongs in a test, not here.
|
||||
|
||||
⛔ **AND IT RUNS THE SAME SESSION TWICE, IN TWO SUBPROCESSES.** The transport is
|
||||
chosen once, at import time, from the environment: two transports in one process
|
||||
would mean one of the two arms was not the thing it claims to be.
|
||||
|
||||
python scripts/diff_protocol.py <firefox-binary>
|
||||
python scripts/diff_protocol.py <firefox-binary> --keep (leave the traces)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "src"))
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
|
||||
#: Fields whose ABSENCE on one side is not a finding, because the two paths
|
||||
#: legitimately disagree about them. Kept short and each one argued: a long
|
||||
#: list here is how a comparison stops comparing.
|
||||
EXPECTED_DIFFERENCES = {
|
||||
# The driver reports the bundled Playwright's version string; we report the
|
||||
# engine's. Neither is wrong and no client behaviour depends on the text.
|
||||
("Playwright", "initializer", "preLaunchedBrowser"),
|
||||
# ⛔ `previewUpdated` is a REAL gap, listed here because it is argued and
|
||||
# not because it is small. The driver pushes a new preview string every
|
||||
# time a handle's value changes, and `_js_handle.py` does listen for it -
|
||||
# so on this server `repr(handle)` keeps the preview it was born with.
|
||||
# That is the whole consequence: it reaches error messages and the REPL,
|
||||
# never a page, never a decision, never a byte on the wire. Implementing it
|
||||
# would mean re-serialising every handle after every evaluation, which is
|
||||
# protocol traffic and parent-process work for a string a human reads.
|
||||
# If it ever stops being cosmetic - a client that BRANCHES on the preview -
|
||||
# this line is where to start.
|
||||
("ElementHandle", "event", "previewUpdated"),
|
||||
("JSHandle", "event", "previewUpdated"),
|
||||
}
|
||||
|
||||
|
||||
#: A checkout that still carries the Node driver, for the day this one does not.
|
||||
#: Same contract and same reason as in `judge_both_transports.py`: a worktree,
|
||||
#: not an installed release, because a published wrapper pins a published core
|
||||
#: and a sealed engine and cannot drive a locally built binary.
|
||||
#:
|
||||
#: git worktree add /tmp/judge <the last commit that carried _driver/>
|
||||
#: INVPW_DRIVER_TREE=/tmp/judge python scripts/diff_protocol.py <binary>
|
||||
DRIVER_TREE_ENV = "INVPW_DRIVER_TREE"
|
||||
|
||||
|
||||
def capture(binary: str, transport: str, out: pathlib.Path) -> None:
|
||||
"""Run the scripted session under one transport, writing its trace."""
|
||||
env = dict(os.environ)
|
||||
env["INVPW_TRANSPORT"] = transport
|
||||
env["INVPW_TRACE_OUT"] = str(out)
|
||||
tree = os.environ.get(DRIVER_TREE_ENV)
|
||||
if transport == "driver" and tree:
|
||||
# ⛔ The driver comes from the older tree; the RECORDER does not. The
|
||||
# capture script has to be this one, or the two traces are produced by
|
||||
# two different instruments and every difference between them measures
|
||||
# the instruments - which is the mistake this whole comparison exists
|
||||
# to avoid.
|
||||
src = str(pathlib.Path(tree) / "src")
|
||||
env["PYTHONPATH"] = os.pathsep.join(
|
||||
[src] + ([env["PYTHONPATH"]] if env.get("PYTHONPATH") else []))
|
||||
script = ROOT / "scripts" / "capture_protocol.py"
|
||||
r = subprocess.run([sys.executable, str(script), binary, "-o", str(out)],
|
||||
env=env, capture_output=True, text=True)
|
||||
if r.returncode != 0 or not out.exists():
|
||||
raise RuntimeError("the %s arm did not produce a trace:\n%s\n%s"
|
||||
% (transport, r.stdout[-2000:], r.stderr[-2000:]))
|
||||
|
||||
|
||||
def sent_vocabulary(trace: list) -> dict:
|
||||
"""method -> the set of parameter names ever sent with it."""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "send":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
method = message.get("method")
|
||||
if not method:
|
||||
continue
|
||||
params = message.get("params") or {}
|
||||
out.setdefault(method, set()).update(params.keys())
|
||||
return out
|
||||
|
||||
|
||||
def created_shapes(trace: list) -> dict:
|
||||
"""type -> the set of initializer field names ever seen for it."""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "recv":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
if message.get("method") != "__create__":
|
||||
continue
|
||||
params = message.get("params") or {}
|
||||
kind = params.get("type")
|
||||
if not kind:
|
||||
continue
|
||||
out.setdefault(kind, set()).update(
|
||||
(params.get("initializer") or {}).keys())
|
||||
return out
|
||||
|
||||
|
||||
def events_by_owner(trace: list, shapes_of_guid: dict) -> dict:
|
||||
"""type -> the set of event names the server emitted on objects of it."""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "recv":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
method = message.get("method")
|
||||
if not method or method.startswith("__"):
|
||||
continue
|
||||
kind = shapes_of_guid.get(message.get("guid"), "?")
|
||||
out.setdefault(kind, set()).add(method)
|
||||
return out
|
||||
|
||||
|
||||
def parentage(trace: list, types: dict) -> dict:
|
||||
"""child TYPE -> the set of parent TYPES it was ever created under.
|
||||
|
||||
⛔ A FOURTH DIMENSION, ADDED BECAUSE ITS ABSENCE LET A REAL DEFECT
|
||||
THROUGH. This server created `ElementHandle` as a child of `Page`; the
|
||||
driver creates it under `Frame`. Types matched, initializer fields matched,
|
||||
events matched - and every call that reads a timeout off the handle's frame
|
||||
died with `'Page' object has no attribute '_timeout'`, because
|
||||
`_element_handle.py` learns its frame from the guid TREE and from nothing
|
||||
else. Parentage is protocol, not bookkeeping.
|
||||
"""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "recv":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
if message.get("method") != "__create__":
|
||||
continue
|
||||
params = message.get("params") or {}
|
||||
kind = params.get("type")
|
||||
if not kind:
|
||||
continue
|
||||
out.setdefault(kind, set()).add(types.get(message.get("guid"), "root"))
|
||||
return out
|
||||
|
||||
|
||||
def disposed_types(trace: list, types: dict) -> dict:
|
||||
"""type -> whether an object of it was ever disposed ("yes" or nothing).
|
||||
|
||||
⛔ A FIFTH DIMENSION, AND THE FOUR ABOVE ARE BLIND TO IT BY CONSTRUCTION:
|
||||
`events_by_owner` skips every method starting with `__`, so `__dispose__`
|
||||
was invisible to this comparison no matter how far the two servers drifted.
|
||||
It is not bookkeeping either - the client ACTS on it, dropping the object
|
||||
from its registry - so a server that never disposes anything grows the
|
||||
client's registry for the life of the browser, and a server that disposes
|
||||
something the client still holds hands back a dead reference.
|
||||
|
||||
It was added on 2026-08-28 to answer a question the PARITY verdict could
|
||||
not: this server never disposed a closed page, and the count of live
|
||||
objects grew by one per page (9 at page 0, 508 at page 499). Whether that
|
||||
is a defect or a difference depends entirely on what the driver does, and
|
||||
nothing here could see it.
|
||||
|
||||
The value is a one-element set rather than a bool so `report` can compare
|
||||
it like every other dimension.
|
||||
"""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "recv":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
if message.get("method") != "__dispose__":
|
||||
continue
|
||||
kind = types.get(message.get("guid"))
|
||||
if kind:
|
||||
out.setdefault(kind, set()).add("disposed")
|
||||
return out
|
||||
|
||||
|
||||
def guid_types(trace: list) -> dict:
|
||||
"""guid -> its type, so an event can be attributed to a KIND of object."""
|
||||
out: dict = {}
|
||||
for entry in trace:
|
||||
if entry["dir"] != "recv":
|
||||
continue
|
||||
message = entry["msg"]
|
||||
if message.get("method") != "__create__":
|
||||
continue
|
||||
params = message.get("params") or {}
|
||||
if params.get("guid"):
|
||||
out[params["guid"]] = params.get("type")
|
||||
return out
|
||||
|
||||
|
||||
def report(label: str, ours: dict, theirs: dict, kind: str) -> list:
|
||||
"""Differences in one dimension, as lines. Empty means parity."""
|
||||
faults = []
|
||||
|
||||
def kept(name, fields):
|
||||
"""⛔ The argued differences are filtered HERE TOO, and they were not.
|
||||
A field can be missing two ways: the key exists on both sides and one
|
||||
set is short, or the key is absent entirely. The first version only
|
||||
filtered the first, so an event type that appears on the driver and
|
||||
nowhere on ours stayed red forever no matter what was written about
|
||||
it - and a gate with a permanent red is a gate people stop reading."""
|
||||
return sorted(f for f in fields
|
||||
if (name, kind, f) not in EXPECTED_DIFFERENCES)
|
||||
|
||||
for name in sorted(set(theirs) - set(ours)):
|
||||
rest = kept(name, theirs[name])
|
||||
if rest:
|
||||
faults.append("%s %r reaches the DRIVER and not us: %s"
|
||||
% (label, name, rest))
|
||||
for name in sorted(set(ours) - set(theirs)):
|
||||
rest = kept(name, ours[name])
|
||||
if rest:
|
||||
faults.append("%s %r reaches US and not the driver: %s"
|
||||
% (label, name, rest))
|
||||
for name in sorted(set(ours) & set(theirs)):
|
||||
missing = theirs[name] - ours[name]
|
||||
extra = ours[name] - theirs[name]
|
||||
missing = {f for f in missing
|
||||
if (name, kind, f) not in EXPECTED_DIFFERENCES}
|
||||
extra = {f for f in extra
|
||||
if (name, kind, f) not in EXPECTED_DIFFERENCES}
|
||||
if missing:
|
||||
faults.append("%s %r: the driver carries %s and we do not"
|
||||
% (label, name, sorted(missing)))
|
||||
if extra:
|
||||
faults.append("%s %r: we carry %s and the driver does not"
|
||||
% (label, name, sorted(extra)))
|
||||
return faults
|
||||
|
||||
|
||||
def main() -> int:
|
||||
p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
p.add_argument("binary")
|
||||
p.add_argument("--keep", action="store_true",
|
||||
help="leave the two traces on disk for inspection")
|
||||
a = p.parse_args()
|
||||
|
||||
work = pathlib.Path(tempfile.mkdtemp(prefix="protocol_diff_"))
|
||||
driver_trace = work / "driver.json"
|
||||
ours_trace = work / "juggler.json"
|
||||
|
||||
print("recording the DRIVER arm ...", flush=True)
|
||||
capture(a.binary, "driver", driver_trace)
|
||||
print("recording the PYTHON arm ...", flush=True)
|
||||
capture(a.binary, "juggler", ours_trace)
|
||||
|
||||
driver = json.loads(driver_trace.read_text(encoding="utf-8"))
|
||||
ours = json.loads(ours_trace.read_text(encoding="utf-8"))
|
||||
print()
|
||||
print(" driver: %d messages python: %d messages"
|
||||
% (len(driver), len(ours)))
|
||||
|
||||
faults = []
|
||||
faults += report("method", sent_vocabulary(ours), sent_vocabulary(driver),
|
||||
"params")
|
||||
faults += report("object", created_shapes(ours), created_shapes(driver),
|
||||
"initializer")
|
||||
faults += report("events on", events_by_owner(ours, guid_types(ours)),
|
||||
events_by_owner(driver, guid_types(driver)), "event")
|
||||
faults += report("parent of", parentage(ours, guid_types(ours)),
|
||||
parentage(driver, guid_types(driver)), "parent")
|
||||
faults += report("disposal of", disposed_types(ours, guid_types(ours)),
|
||||
disposed_types(driver, guid_types(driver)), "dispose")
|
||||
|
||||
print()
|
||||
for line in faults:
|
||||
print(" " + line)
|
||||
if a.keep or faults:
|
||||
print()
|
||||
print(" traces: %s" % work)
|
||||
if faults:
|
||||
print("PROTOCOL DIFF: %d difference(s). The Node driver cannot be "
|
||||
"deleted while any of these stand, or a caller who reaches one "
|
||||
"gets silence instead of a browser." % len(faults))
|
||||
return 1
|
||||
print("PROTOCOL DIFF: PARITY - same methods with the same parameters in, "
|
||||
"same object types with the same initializer fields, the same "
|
||||
"events, the same parentage and the same disposals out.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The reviewed list of the check that keeps third parties out of the verdict of the e2e tests (``tests/gates/e2e_clock_exceptions.json``).
|
||||
|
||||
python scripts/e2e_clock_exceptions.py # what the list says and what the sources say: counts by class, and every difference
|
||||
python scripts/e2e_clock_exceptions.py --write # make the ``debt`` again: every occurrence no ``entries`` item covers (a correction removed some)
|
||||
python scripts/e2e_clock_exceptions.py --write --prune # and drop the ``entries`` that match nothing any more
|
||||
|
||||
``entries`` are the occurrences a person reviewed and decided are deliberate (each has a closed ``kind`` and a ``reason``); ``--write`` never adds one. ``debt`` is every
|
||||
other occurrence: the dangerous ones, not yet corrected. It is made from the sources, so it is regenerated, not edited: when a branch that corrects tests merges, run
|
||||
``--write`` and the corrected occurrences leave the list. A list that grows is refused by ``tests/test_the_e2e_tests_do_not_wait_on_clocks.py`` (against main).
|
||||
Exit 1 when the file on disk is not what ``--write`` would write.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
|
||||
import _e2e_clocks as clocks # noqa: E402
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n", 1)[0])
|
||||
ap.add_argument("--write", action="store_true", help="write the file with the debt made again")
|
||||
ap.add_argument("--prune", action="store_true", help="with --write: drop the entries that match no occurrence")
|
||||
ns = ap.parse_args(argv)
|
||||
found = clocks.scan()
|
||||
path = clocks.GATE_FILE
|
||||
document = clocks.load(path) if path.is_file() else clocks.empty_document()
|
||||
made = clocks.regenerate(document, found, prune_entries=ns.prune)
|
||||
text = clocks.dump(made)
|
||||
differences = clocks.compare(found, document)
|
||||
by_class = collections.Counter(i["class"] for i in made["debt"]) # type: ignore[index, union-attr]
|
||||
kinds = collections.Counter(i["kind"] for i in made["entries"]) # type: ignore[index, union-attr]
|
||||
print("entries: %d %s" % (len(made["entries"]), dict(sorted(kinds.items())))) # type: ignore[arg-type]
|
||||
print("debt: %d %s" % (len(made["debt"]), dict(sorted(by_class.items())))) # type: ignore[arg-type]
|
||||
for name in ("new", "stale_entries", "stale_debt", "both"):
|
||||
for key in differences[name]:
|
||||
print(" %-13s %s" % (name, key))
|
||||
if ns.write:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("written: %s" % path.relative_to(ROOT))
|
||||
return 0
|
||||
if not path.is_file() or path.read_text(encoding="utf-8") != text:
|
||||
print("%s is not what --write makes" % path.relative_to(ROOT), file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""A MEASUREMENT, not a gate: the Control+A file, run again and again with the protocol trace, until there are enough runs.
|
||||
|
||||
python scripts/hunt_ctrla_rounds.py --binary "$FF" --out-dir out [--min-runs 300] [--copies 4] [--budget-min 28]
|
||||
|
||||
One ROUND starts COPIES pytest processes at once, each on the whole file tests/test_control_a_selects_all_in_a_field_e2e.py (20 tests: 10 for
|
||||
the in-process browser, 10 for the stock client), each with its own junit, its own log and its own tag (`r<round>c<copy>`), loaded with
|
||||
`-p scripts.hunt_trace_plugin` (one JSON per test in `<out-dir>/trace`). Rounds follow each other until `--min-runs` test runs have been
|
||||
recorded or the time budget is spent (no round is started after it). No round ever stops the others: a copy that is red, hangs or dies is
|
||||
only a copy that wrote what it wrote, and the exit code is non-zero only when the hunt could not start (no binary) or recorded nothing.
|
||||
|
||||
Why COPIES in parallel and not `-n 4 --dist loadfile` or `-n 4 --dist load`: under `loadfile` a file goes to ONE worker, so a single file
|
||||
would run on one worker and the other three would be idle, which is not four at once; under `load` the 20 tests of the file are scattered
|
||||
over four workers and each builds the module-scoped `browser` fixture for itself, so every browser sees about 5 tests instead of the 10 it
|
||||
sees in the gate, in another order: the question of this hunt (what a browser that has served pages before does with the next one) would
|
||||
be asked of a different browser. A copy is what a `loadfile` worker is in the gate: the whole file, in file order, one browser per mode;
|
||||
four copies are the four browsers at once of the gate (the cap of this project is four browsers).
|
||||
|
||||
Layout of `--out-dir`: `trace/` (the JSON of the plugin), `junit/` (one XML per copy), `logs/` (the output of each copy).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
TEST_FILE = "tests/test_control_a_selects_all_in_a_field_e2e.py"
|
||||
#: A test that hangs ends its copy at this many seconds (pytest-timeout, thread method as in the gate), not the job.
|
||||
TEST_DEADLINE_S = 300
|
||||
#: A copy that is still alive after this long is killed: a whole file takes a couple of minutes.
|
||||
COPY_DEADLINE_S = 15 * 60
|
||||
|
||||
|
||||
def command(junit):
|
||||
return [
|
||||
sys.executable, "-u", "-m", "pytest",
|
||||
"-m", "e2e", "-o", "addopts=",
|
||||
"-p", "no:rerunfailures", "-p", "no:cacheprovider",
|
||||
"-p", "scripts.hunt_trace_plugin",
|
||||
"-o", "junit_family=xunit2", "--junitxml=%s" % junit,
|
||||
"--timeout", str(TEST_DEADLINE_S), "--timeout-method", "thread",
|
||||
"-v", "--tb=short",
|
||||
TEST_FILE,
|
||||
]
|
||||
|
||||
|
||||
def environment(binary, trace_dir, tag):
|
||||
env = {k: v for k, v in os.environ.items() if k != "PYTEST_ADDOPTS"}
|
||||
env.update({
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
"INVPW_BINARY_PATH": binary,
|
||||
"STEALTHFOX_E2E_BINARY": binary,
|
||||
"HUNT_TRACE_DIR": str(trace_dir),
|
||||
"HUNT_TRACE_TAG": tag,
|
||||
})
|
||||
return env
|
||||
|
||||
|
||||
def recorded(trace_dir):
|
||||
return sum(1 for _ in Path(trace_dir).glob("*.json"))
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0], formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--binary", default=os.environ.get("INVPW_BINARY_PATH") or os.environ.get("FF"),
|
||||
help="the engine of invisible_playwright (default: $INVPW_BINARY_PATH, then $FF)")
|
||||
parser.add_argument("--out-dir", default="ctrla-hunt", help="where trace/, junit/ and logs/ are written")
|
||||
parser.add_argument("--min-runs", type=int, default=300, help="stop after the round that reaches this many test runs (default 300)")
|
||||
parser.add_argument("--copies", type=int, default=4, help="pytest processes at once in a round (default 4: the browsers of the gate)")
|
||||
parser.add_argument("--budget-min", type=float, default=28.0, help="no new round after this many minutes (default 28)")
|
||||
args = parser.parse_args(argv)
|
||||
if not args.binary or not Path(args.binary).exists():
|
||||
print("::error::the engine is needed: --binary, or $INVPW_BINARY_PATH / $FF (%r)" % args.binary, flush=True)
|
||||
return 2
|
||||
|
||||
out = Path(args.out_dir).resolve()
|
||||
trace, junit, logs = out / "trace", out / "junit", out / "logs"
|
||||
for directory in (trace, junit, logs):
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
started = time.monotonic()
|
||||
number = 0
|
||||
while recorded(trace) < args.min_runs:
|
||||
if number and time.monotonic() - started > args.budget_min * 60:
|
||||
print("budget of %.0f min spent: no new round" % args.budget_min, flush=True)
|
||||
break
|
||||
number += 1
|
||||
round_started = time.monotonic()
|
||||
procs = []
|
||||
for copy in range(1, args.copies + 1):
|
||||
tag = "r%02dc%d" % (number, copy)
|
||||
log = open(logs / (tag + ".log"), "w", encoding="utf-8", newline="\n")
|
||||
proc = subprocess.Popen(command(junit / (tag + ".xml")), cwd=str(ROOT), env=environment(args.binary, trace, tag),
|
||||
stdout=log, stderr=subprocess.STDOUT)
|
||||
procs.append((tag, proc, log))
|
||||
codes = {}
|
||||
for tag, proc, log in procs:
|
||||
try:
|
||||
codes[tag] = proc.wait(timeout=max(1.0, COPY_DEADLINE_S - (time.monotonic() - round_started)))
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
codes[tag] = "killed"
|
||||
log.close()
|
||||
print("round %d: %.0f s, %d run(s) recorded so far, exit codes %s" % (
|
||||
number, time.monotonic() - round_started, recorded(trace), codes), flush=True)
|
||||
total = recorded(trace)
|
||||
print("%d round(s), %d test run(s) recorded in %s" % (number, total, trace), flush=True)
|
||||
return 0 if total else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,224 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The summary of a Control+A hunt: the JSON of scripts/hunt_trace_plugin.py, read and put in two piles, red and green.
|
||||
|
||||
python scripts/hunt_ctrla_summary.py DIR [DIR ...] [--around MS] [--top N] [--max-reds N]
|
||||
|
||||
DIR is a folder (or several: the artefact of each job) holding the files the plugin wrote, however deep. It prints
|
||||
|
||||
* the count per system and mode of the browser fixture (in-process, stock-client): how many passed and how many were red;
|
||||
* for each red (up to --max-reds): the test, the first line of its failure and the sequence of events of the world, the context and the
|
||||
navigation of ITS page around `set_content`: what the engine said (event), what the server sent (send / reply / error) and the marks of
|
||||
the plugin (install, caller_context, set_content), with the ms counted from the start of `set_content` (negative: before it). A context is
|
||||
named by its world: main (the page's own, empty name), aux (`__ctx_aux__`, the utility world) and caller (`__ctx_caller__`, the one
|
||||
`set_content` waits for); an id is resolved to its world from the creation event;
|
||||
* the sequence that is typical of the greens, per mode (the most frequent ones, --top), in the same words and with the times of the first
|
||||
test that had it, so that a red is read against what a green does.
|
||||
|
||||
Nothing here decides: the exit code is 1 only when no JSON is found. The red ones are the ones whose outcome is `failed` or `error`.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
|
||||
#: What the sequence is made of: the events of the worlds, the contexts, the frames and the navigations; the commands that make a world or run
|
||||
#: in one; the marks of the plugin.
|
||||
_EVENT = {
|
||||
"Page.navigationStarted", "Page.navigationCommitted", "Page.navigationAborted", "Page.sameDocumentNavigation", "Page.eventFired",
|
||||
"Page.frameAttached", "Page.frameDetached", "Runtime.executionContextsCleared", "Runtime.executionContextCreated",
|
||||
"Runtime.executionContextDestroyed", "Browser.attachedToTarget", "Browser.detachedFromTarget",
|
||||
}
|
||||
_COMMAND = {"Page.setInitScripts", "Runtime.evaluate", "Runtime.callFunction", "Page.navigate", "Page.close", "Browser.newPage"}
|
||||
_WORLD = {"": "main", "__ctx_aux__": "aux", "__ctx_caller__": "caller"}
|
||||
_RED = ("failed", "error")
|
||||
|
||||
|
||||
def load(directories):
|
||||
tests = []
|
||||
for directory in directories:
|
||||
for path in sorted(Path(directory).rglob("*.json")):
|
||||
try:
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
if isinstance(data, dict) and "events" in data and "nodeid" in data:
|
||||
data["_file"] = path.name
|
||||
tests.append(data)
|
||||
return tests
|
||||
|
||||
|
||||
def _session_of(row):
|
||||
"""The session a row belongs to: its own, or for a target that attaches the one it announces."""
|
||||
_, _, method, detail, _, session = row
|
||||
if method in ("Browser.attachedToTarget", "Browser.detachedFromTarget"):
|
||||
return (detail or {}).get("sessionId") or session
|
||||
return session
|
||||
|
||||
|
||||
def _world_names(rows):
|
||||
"""executionContextId -> world, from the creation events of this test (every connection: the ids are unique to a session)."""
|
||||
out = {}
|
||||
for _, kind, method, detail, _, _ in rows:
|
||||
if kind == "event" and method == "Runtime.executionContextCreated":
|
||||
out[str(detail.get("executionContextId"))] = _WORLD.get(detail.get("world"), detail.get("world"))
|
||||
return out
|
||||
|
||||
|
||||
def _word(row, worlds):
|
||||
"""One row as a short word: what it is and what tells it apart (the world, the frame is left out: the session is already one page)."""
|
||||
_, kind, method, detail, _, _ = row
|
||||
detail = detail or {}
|
||||
short = method.replace("Page.", "").replace("Runtime.", "").replace("Browser.", "")
|
||||
parts = []
|
||||
if method == "Runtime.executionContextCreated":
|
||||
parts.append(_WORLD.get(detail.get("world"), detail.get("world")))
|
||||
elif method == "Runtime.executionContextDestroyed":
|
||||
parts.append(worlds.get(str(detail.get("executionContextId")), "unknown ctx"))
|
||||
elif method in ("Runtime.evaluate", "Runtime.callFunction"):
|
||||
parts.append("in " + worlds.get(str(detail.get("executionContextId")), "?"))
|
||||
if detail.get("expression"):
|
||||
parts.append(detail["expression"][:40])
|
||||
elif method == "Page.setInitScripts" and kind == "send":
|
||||
parts.append("+".join(_WORLD.get(w[0], str(w[0])) for w in detail.get("worlds") or []) or "none")
|
||||
elif method.startswith("Page.navigation") and detail.get("url"):
|
||||
parts.append(detail["url"][:40])
|
||||
elif method == "Page.eventFired":
|
||||
parts.append(detail.get("name"))
|
||||
elif method in ("caller_context.start", "caller_context.error", "set_content.start", "install.start"):
|
||||
if detail.get("worlds") is not None:
|
||||
parts.append("worlds known: [%s]" % ", ".join(w.split("=")[0] for w in detail["worlds"]))
|
||||
if detail.get("error"):
|
||||
parts.append(detail["error"][:60])
|
||||
elif method == "set_content.error" and detail.get("error"):
|
||||
parts.append(detail["error"][:60])
|
||||
prefix = {"send": "-> ", "reply": "<- ", "error": "<-ERR ", "event": "", "mark": "## "}[kind]
|
||||
word = prefix + short
|
||||
if kind == "event" and detail.get("replay"):
|
||||
word += " (replayed)"
|
||||
if kind == "error":
|
||||
parts.append(str(detail.get("error", ""))[:60])
|
||||
elif kind == "reply" and detail.get("ms") is not None:
|
||||
parts.append("%s ms" % detail["ms"])
|
||||
return "%s(%s)" % (word, " ".join(str(p) for p in parts if p is not None and p != "")) if parts else word
|
||||
|
||||
|
||||
def _interesting(row):
|
||||
_, kind, method, _, _, _ = row
|
||||
if kind == "event":
|
||||
return method in _EVENT
|
||||
if kind in ("send", "reply", "error"):
|
||||
return method in _COMMAND
|
||||
return kind == "mark" and (method.startswith(("install.", "caller_context.", "set_content.")))
|
||||
|
||||
|
||||
def _sequence(test):
|
||||
"""(session, rows of that page that matter, anchor ms): the page is the one of the `set_content` mark; the anchor is its start."""
|
||||
rows = test["events"]
|
||||
anchor_row = next((r for r in rows if r[1] == "mark" and r[2] == "set_content.start"), None) or next((r for r in rows if r[1] == "mark" and r[2] == "caller_context.start"), None) # the world is asked for by others too
|
||||
if anchor_row is None:
|
||||
return None, [], None, {}
|
||||
session = anchor_row[5]
|
||||
worlds = _world_names(rows)
|
||||
mine = [r for r in rows if _interesting(r) and (_session_of(r) == session or r[1] == "mark" and r[5] == session)]
|
||||
return session, mine, anchor_row[0], worlds
|
||||
|
||||
|
||||
def _fold(words):
|
||||
"""Consecutive repeats collapse: [word, ms of the first, count]."""
|
||||
folded = []
|
||||
for word, ms in words:
|
||||
if folded and folded[-1][0] == word:
|
||||
folded[-1][2] += 1
|
||||
else:
|
||||
folded.append([word, ms, 1])
|
||||
return folded
|
||||
|
||||
|
||||
def _words(test):
|
||||
got = _sequence(test)
|
||||
session, rows, anchor, worlds = got
|
||||
if session is None and not rows:
|
||||
return None
|
||||
return [(_word(r, worlds), round(r[0] - anchor, 1)) for r in rows]
|
||||
|
||||
|
||||
def _print_sequence(folded, indent=" "):
|
||||
for word, ms, count in folded:
|
||||
print("%s%+10.1f ms %s%s" % (indent, ms, word, " x%d" % count if count > 1 else ""))
|
||||
|
||||
|
||||
def _first_line(test):
|
||||
for text in (test.get("failure") or {}).values():
|
||||
for line in str(text).splitlines():
|
||||
if line.startswith("E ") and ("Error" in line or "error" in line):
|
||||
return line[1:].strip()[:200]
|
||||
return str(text).strip().splitlines()[0][:200] if str(text).strip() else ""
|
||||
return ""
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0], formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("directories", nargs="+", help="folders with the JSON of the plugin (searched however deep)")
|
||||
parser.add_argument("--around", type=float, default=None, metavar="MS",
|
||||
help="show only the rows from this many ms before set_content (default: the whole life of the page)")
|
||||
parser.add_argument("--top", type=int, default=3, help="how many green sequences to show per mode (default 3)")
|
||||
parser.add_argument("--max-reds", type=int, default=10, help="how many red tests to show in detail (default 10)")
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
tests = load(args.directories)
|
||||
if not tests:
|
||||
print("no JSON of the plugin under %s" % ", ".join(args.directories))
|
||||
return 1
|
||||
counts = Counter((t.get("system"), t.get("mode"), "red" if t["outcome"] in _RED else t["outcome"]) for t in tests)
|
||||
print("== %d test runs" % len(tests))
|
||||
for system, mode in sorted({(s, m) for s, m, _ in counts}, key=str):
|
||||
row = {k: v for (s, m, k), v in counts.items() if (s, m) == (system, mode)}
|
||||
print(" %-8s %-13s %s" % (system, mode, ", ".join("%s %d" % (k, v) for k, v in sorted(row.items()))))
|
||||
hooks = sorted({e for t in tests for e in t.get("hook_errors") or []})
|
||||
if hooks:
|
||||
print("== hooks that could not be installed (the trace is partial):")
|
||||
for e in hooks:
|
||||
print(" " + e)
|
||||
|
||||
reds = [t for t in tests if t["outcome"] in _RED]
|
||||
print("\n== %d red" % len(reds))
|
||||
for test in reds[:args.max_reds]:
|
||||
print("\n-- %s [%s, %s, pid %s, #%s]\n %s" % (test["nodeid"], test.get("system"), test.get("mode"), test.get("pid"),
|
||||
test.get("sequence"), _first_line(test)))
|
||||
words = _words(test)
|
||||
if words is None:
|
||||
print(" (no set_content and no caller_context in this test: the failure is not where the hunt looks)")
|
||||
continue
|
||||
if args.around is not None:
|
||||
words = [w for w in words if w[1] >= -args.around]
|
||||
print(" page session %s; ms from the start of set_content (events of THIS page; ## = a mark of the plugin):" % _sequence(test)[0])
|
||||
_print_sequence(_fold(words))
|
||||
if len(reds) > args.max_reds:
|
||||
print("\n(%d more red not shown: --max-reds)" % (len(reds) - args.max_reds))
|
||||
|
||||
greens = [t for t in tests if t["outcome"] == "passed"]
|
||||
print("\n== typical sequence of the %d green, per mode" % len(greens))
|
||||
for mode in sorted({t.get("mode") for t in greens}, key=str):
|
||||
groups = {}
|
||||
for test in (t for t in greens if t.get("mode") == mode):
|
||||
words = _words(test)
|
||||
if words is None:
|
||||
continue
|
||||
if args.around is not None:
|
||||
words = [w for w in words if w[1] >= -args.around]
|
||||
folded = _fold(words)
|
||||
slot = groups.setdefault(tuple((w, c) for w, _, c in folded), [0, folded])
|
||||
slot[0] += 1
|
||||
ranked = sorted(groups.values(), key=lambda item: -item[0])
|
||||
print("\n-- mode %s: %d distinct sequence(s)" % (mode, len(ranked)))
|
||||
for n, folded in ranked[:args.top]:
|
||||
print(" x%d (times of the first test with it):" % n)
|
||||
_print_sequence(folded)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,686 @@
|
||||
#!/usr/bin/env python3
|
||||
"""A MEASUREMENT, not a gate: one scenario, run on this package's browser and on stock Playwright's Firefox, side by side.
|
||||
|
||||
The scenario is the one of tests/test_navigation_across_processes_e2e.py::test_a_second_goto_to_a_third_site_interrupts_the_first_and_lands:
|
||||
|
||||
* sites isolated as in that file (`fission.autostart`, strategy 1), a local server on a thread, three hosts a.test, b.test and c.test
|
||||
on its one port, told to the browser by `network.dns.localDomains` (a standard Firefox pref: the same line reaches both browsers);
|
||||
* the page is at a.test/plain; goto 1 goes to b.test/partial, whose headers and first bytes the server sends and whose rest it HOLDS
|
||||
until the scenario is over; as soon as the client has heard the response of /partial, goto 2 goes to c.test/second
|
||||
(domcontentloaded, timeout 15 s).
|
||||
|
||||
Per repetition it records what the question "did the second goto leave the browser, and how did the two gotos end" needs:
|
||||
|
||||
* whether the request of /second reached the server, and at how many ms after the start of goto 2 (the server and the client read the
|
||||
same clock, `time.perf_counter()`, in this one process), and whether it came before or after goto 2 had ended;
|
||||
* how goto 1 ended (the error and its class), and at how many ms;
|
||||
* how goto 2 ended (it returned, or the error), at how many ms.
|
||||
|
||||
A new BROWSER per repetition, not a new context: what the navigation depends on is the processes the browser has (the spare process it
|
||||
preallocated, the one that holds a.test, the ones it starts for b.test and c.test); a new context of a warmed browser would inherit them and
|
||||
every repetition after the first would measure another state. A cold browser per repetition is the state a user's first navigations have,
|
||||
and it is the same for both. The two browsers alternate (ours, stock, ours, ...) so a runner that slows down in the middle of the run slows both.
|
||||
|
||||
Nothing here decides: the exit code is non-zero only when the script itself could not measure (a browser that never launched in any
|
||||
repetition, a binary that is not there). The result is one JSON per browser and system and a summary printed to the log.
|
||||
|
||||
python scripts/hunt_second_goto_vs_stock.py --binary "$FF" --out-dir out # both browsers, 20 repetitions each
|
||||
python scripts/hunt_second_goto_vs_stock.py --browser stock --repetitions 3 --out-dir out
|
||||
python scripts/hunt_second_goto_vs_stock.py --binary "$FF" --browser invisible --trace --out-dir out # the protocol trace of ours
|
||||
|
||||
`--trace` (our browser only) adds to every repetition what the client heard of the protocol, and when: see "the protocol trace" below.
|
||||
Stock Firefox is the one `python -m playwright install firefox` downloads for the `playwright` package installed (scripts/playwright_pin.txt).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import statistics
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from collections import Counter
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
from socketserver import ThreadingTCPServer
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
#: The prefs of the file the scenario comes from (FISSION_ON there): the same for both browsers.
|
||||
FISSION_ON = {
|
||||
"fission.autostart": True,
|
||||
"fission.webContentIsolationStrategy": 1,
|
||||
"dom.ipc.processCount.webIsolated": 4,
|
||||
"network.dns.localDomains": "a.test,b.test,c.test",
|
||||
}
|
||||
|
||||
SEED = 42 # the seed of the test this comes from (only ours reads it)
|
||||
REPETITIONS = 20
|
||||
GOTO1_TIMEOUT_MS = 30000 # the first goto ends when the second replaces it, or when the held answer is let go
|
||||
GOTO2_TIMEOUT_MS = 15000 # as asked: domcontentloaded, 15 s
|
||||
HEAR_RESPONSE_S = 15.0 # how long the client waits to hear the response of /partial before it gives the repetition up
|
||||
SETTLE_S = 1.0 # after the end of the scenario and the release: a /second that comes late is still counted
|
||||
LAUNCH_S = 90.0 # a launch that takes longer is a repetition lost, not a hang
|
||||
CLOSE_S = 30.0
|
||||
REPETITION_S = 150.0 # the whole scenario of one repetition: nothing may hold the run
|
||||
|
||||
|
||||
def _ms(seconds):
|
||||
return None if seconds is None else round(seconds * 1000.0, 1)
|
||||
|
||||
|
||||
class _Server(ThreadingTCPServer):
|
||||
"""A thread per connection and daemon threads: a connection the browser opens and leaves cannot hold the server or its shutdown."""
|
||||
daemon_threads = True
|
||||
allow_reuse_address = True
|
||||
|
||||
def server_bind(self):
|
||||
ThreadingTCPServer.server_bind(self)
|
||||
self.server_name, self.server_port = self.server_address[:2]
|
||||
|
||||
|
||||
class Sites:
|
||||
"""The local server of one repetition. `arrived` has the time (perf_counter) each path was first asked for."""
|
||||
|
||||
def __init__(self):
|
||||
self.arrived = {} # path -> perf_counter of the first request
|
||||
self.release = threading.Event() # what the server holds until the scenario is over
|
||||
owner = self
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
timeout = 10
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
path = self.path.split("?")[0]
|
||||
owner.arrived.setdefault(path, time.perf_counter())
|
||||
try:
|
||||
if path == "/partial":
|
||||
# the headers and the start of the body arrive, the rest is held: the response is there, the navigation has
|
||||
# changed process, the document is not complete
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html")
|
||||
self.send_header("Content-Length", "200")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"<!doctype html><title>partial</title><p>start")
|
||||
self.wfile.flush()
|
||||
owner.release.wait()
|
||||
self.wfile.write(b" " * 156)
|
||||
return
|
||||
body = ("<!doctype html><title>%s</title><p>%s" % (path, path)).encode()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.server = _Server(("127.0.0.1", 0), Handler)
|
||||
self.port = self.server.server_address[1]
|
||||
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
||||
self.thread.start()
|
||||
|
||||
def at(self, host, path):
|
||||
return "http://%s:%d%s" % (host, self.port, path)
|
||||
|
||||
def close(self):
|
||||
self.release.set()
|
||||
try:
|
||||
self.server.shutdown()
|
||||
self.server.server_close()
|
||||
except Exception:
|
||||
pass
|
||||
self.thread.join(timeout=10)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the two browsers
|
||||
|
||||
class _Ours:
|
||||
"""invisible_playwright, the published engine ($FF), the prefs of the scenario."""
|
||||
name = "invisible"
|
||||
|
||||
def __init__(self, binary):
|
||||
self.binary = binary
|
||||
self._cm = None
|
||||
|
||||
async def launch(self):
|
||||
from invisible_playwright.async_api import InvisiblePlaywright
|
||||
|
||||
self._cm = InvisiblePlaywright(seed=SEED, binary_path=self.binary, humanize=False, headless=True, extra_prefs=FISSION_ON)
|
||||
browser = await self._cm.__aenter__()
|
||||
return browser
|
||||
|
||||
async def close(self):
|
||||
cm, self._cm = self._cm, None
|
||||
if cm is not None:
|
||||
await cm.__aexit__(None, None, None)
|
||||
|
||||
|
||||
class _Stock:
|
||||
"""Stock Playwright with its own Firefox: no engine of ours, no seed, the same prefs."""
|
||||
name = "stock"
|
||||
|
||||
def __init__(self, binary=None):
|
||||
self._pw = None
|
||||
self._browser = None
|
||||
|
||||
async def launch(self):
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
self._pw = await async_playwright().start()
|
||||
self._browser = await self._pw.firefox.launch(headless=True, firefox_user_prefs=dict(FISSION_ON))
|
||||
return self._browser
|
||||
|
||||
async def close(self):
|
||||
browser, self._browser = self._browser, None
|
||||
pw, self._pw = self._pw, None
|
||||
try:
|
||||
if browser is not None:
|
||||
await browser.close()
|
||||
finally:
|
||||
if pw is not None:
|
||||
await pw.stop()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- one repetition
|
||||
|
||||
def _error_class(message):
|
||||
if message is None:
|
||||
return None
|
||||
if "is interrupted by another navigation" in message:
|
||||
return "interrupted by another navigation"
|
||||
if "NS_BINDING_ABORTED" in message:
|
||||
return "NS_BINDING_ABORTED"
|
||||
if "Timeout" in message and "exceeded" in message:
|
||||
return "timeout"
|
||||
if "load not reached" in message:
|
||||
return "load not reached"
|
||||
return "other"
|
||||
|
||||
|
||||
async def _scenario(page, sites, trace=None):
|
||||
"""The measurement. Every time is perf_counter; the row says them in ms from the start of goto 1 (`t=0`)."""
|
||||
if trace is not None:
|
||||
trace.attach(page) # before the first goto: nothing the navigations of the page say is missed
|
||||
heard = {} # path -> perf_counter the client heard its response
|
||||
page.on("response", lambda r: heard.setdefault(urlsplit(r.url).path, time.perf_counter()))
|
||||
|
||||
await page.goto(sites.at("a.test", "/plain"), wait_until="domcontentloaded", timeout=GOTO2_TIMEOUT_MS)
|
||||
|
||||
ends = {}
|
||||
|
||||
async def goto1():
|
||||
try:
|
||||
await page.goto(sites.at("b.test", "/partial"), wait_until="domcontentloaded", timeout=GOTO1_TIMEOUT_MS)
|
||||
return None
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
finally:
|
||||
ends["first"] = time.perf_counter()
|
||||
|
||||
t_first = time.perf_counter()
|
||||
if trace is not None:
|
||||
trace.t0 = t_first
|
||||
first = asyncio.ensure_future(goto1())
|
||||
deadline = time.monotonic() + HEAR_RESPONSE_S
|
||||
while "/partial" not in heard or "/partial" not in sites.arrived:
|
||||
if first.done() or time.monotonic() > deadline:
|
||||
break
|
||||
await asyncio.sleep(0.02)
|
||||
row = {"response_heard": "/partial" in heard}
|
||||
second_error = None
|
||||
second_status = None
|
||||
t_second = None
|
||||
if row["response_heard"]:
|
||||
t_second = time.perf_counter()
|
||||
if trace is not None:
|
||||
trace.t_second = t_second
|
||||
try:
|
||||
response = await page.goto(sites.at("c.test", "/second"), wait_until="domcontentloaded", timeout=GOTO2_TIMEOUT_MS)
|
||||
second_status = response.status if response is not None else None
|
||||
except Exception as e:
|
||||
second_error = str(e)
|
||||
ends["second"] = time.perf_counter()
|
||||
# the rest of the first response is sent only now: it can have ended only by being replaced (or, if it did not, by this)
|
||||
sites.release.set()
|
||||
try:
|
||||
first_error = await asyncio.wait_for(first, 20)
|
||||
except asyncio.TimeoutError:
|
||||
first.cancel()
|
||||
first_error = "(goto 1 still pending 20 s after the held response was let go)"
|
||||
ends.setdefault("first", time.perf_counter())
|
||||
await asyncio.sleep(SETTLE_S)
|
||||
|
||||
def at(stamp):
|
||||
return None if stamp is None else _ms(stamp - t_first)
|
||||
|
||||
second_request = sites.arrived.get("/second")
|
||||
row.update({
|
||||
"partial_request_ms": at(sites.arrived.get("/partial")),
|
||||
"partial_response_heard_ms": at(heard.get("/partial")),
|
||||
"goto2_start_ms": at(t_second),
|
||||
"second_request_arrived": second_request is not None,
|
||||
"second_request_ms": at(second_request),
|
||||
"second_request_after_goto2_start_ms": None if second_request is None or t_second is None else _ms(second_request - t_second),
|
||||
"second_request_before_goto2_end": None if second_request is None or "second" not in ends else second_request <= ends["second"],
|
||||
"goto1_end_ms": at(ends.get("first")),
|
||||
"goto1_error": first_error,
|
||||
"goto1_error_class": _error_class(first_error) if first_error is not None else "none (it returned)",
|
||||
"goto2_outcome": None if t_second is None else ("error" if second_error is not None else "commit"),
|
||||
"goto2_ms": None if t_second is None else _ms(ends["second"] - t_second),
|
||||
"goto2_error": second_error,
|
||||
"goto2_error_class": _error_class(second_error),
|
||||
"goto2_status": second_status,
|
||||
"url_after": page.url,
|
||||
"requests_at_the_server": sorted(sites.arrived),
|
||||
})
|
||||
return row
|
||||
|
||||
|
||||
async def _repetition(maker, index, binary, trace_on=False):
|
||||
row = {"repetition": index, "browser": maker.name, "launched": False}
|
||||
sites = Sites()
|
||||
kind = maker(binary)
|
||||
trace = Trace() if trace_on else None
|
||||
try:
|
||||
try:
|
||||
browser = await asyncio.wait_for(kind.launch(), LAUNCH_S)
|
||||
row["launched"] = True
|
||||
try:
|
||||
row["browser_version"] = browser.version
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
row["launch_error"] = "%s: %s" % (type(e).__name__, e)
|
||||
return row
|
||||
try:
|
||||
page = await browser.new_page()
|
||||
row.update(await asyncio.wait_for(_scenario(page, sites, trace), REPETITION_S))
|
||||
except Exception as e:
|
||||
row["scenario_error"] = "%s: %s" % (type(e).__name__, e)
|
||||
finally:
|
||||
if trace is not None:
|
||||
try:
|
||||
row.update(trace.finish(row))
|
||||
except Exception as e: # the trace never costs the measurement
|
||||
row["trace_error"] = "%s: %s" % (type(e).__name__, e)
|
||||
sites.close()
|
||||
try:
|
||||
await asyncio.wait_for(kind.close(), CLOSE_S)
|
||||
except BaseException as e:
|
||||
row["close_error"] = "%s: %s" % (type(e).__name__, e)
|
||||
return row
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the protocol trace
|
||||
|
||||
#: What the client hears, by method: the events of the navigations of the pages, of the requests of their documents, of their contexts, of the targets.
|
||||
_TRACED = frozenset((
|
||||
"Page.navigationStarted", "Page.navigationCommitted", "Page.navigationAborted", "Page.sameDocumentNavigation", "Page.eventFired",
|
||||
"Page.frameAttached", "Page.frameDetached",
|
||||
"Network.requestWillBeSent", "Network.responseReceived", "Network.requestFinished", "Network.requestFailed",
|
||||
"Runtime.executionContextsCleared", "Runtime.executionContextCreated",
|
||||
"Browser.attachedToTarget", "Browser.detachedFromTarget",
|
||||
))
|
||||
#: The commands that start, stop or replace a navigation: what the client SAID, with the reply of `Page.navigate` (the id of its navigation).
|
||||
_SAID = frozenset(("Page.navigate", "Page.stop", "Page.reload", "Page.goBack", "Page.goForward", "Page.close"))
|
||||
#: The params kept, per method (the rest is the bulk: headers, timing, security details).
|
||||
_KEPT = {
|
||||
"Page.navigationStarted": ("frameId", "navigationId"),
|
||||
"Page.navigationCommitted": ("frameId", "navigationId", "url"),
|
||||
"Page.navigationAborted": ("frameId", "navigationId", "errorText"),
|
||||
"Page.sameDocumentNavigation": ("frameId", "url"),
|
||||
"Page.eventFired": ("frameId", "name"),
|
||||
"Page.frameAttached": ("frameId", "parentFrameId"),
|
||||
"Page.frameDetached": ("frameId",),
|
||||
"Network.requestWillBeSent": ("requestId", "frameId", "navigationId", "url", "redirectedFrom", "cause"),
|
||||
"Network.responseReceived": ("requestId", "status", "fromCache"),
|
||||
"Network.requestFinished": ("requestId",),
|
||||
"Network.requestFailed": ("requestId", "errorCode"),
|
||||
"Runtime.executionContextCreated": ("executionContextId", "auxData"),
|
||||
"Runtime.executionContextsCleared": (),
|
||||
"Browser.attachedToTarget": ("sessionId",),
|
||||
"Browser.detachedFromTarget": ("sessionId",),
|
||||
}
|
||||
|
||||
|
||||
def _reduced(method, params):
|
||||
out = {k: params[k] for k in _KEPT.get(method, ()) if params.get(k) is not None}
|
||||
if method == "Browser.attachedToTarget":
|
||||
info = params.get("targetInfo") or {}
|
||||
out.update({k: info[k] for k in ("targetId", "type", "url") if k in info})
|
||||
return out
|
||||
|
||||
|
||||
class Trace:
|
||||
"""Every protocol event of the traced kinds that the CLIENT receives, with the time it received it.
|
||||
|
||||
The hook is the public one of the connection of the core, `Connection.add_listener(fn)` (invisible_core.juggler.connection): `fn(method,
|
||||
params, session)` is called on the reader thread of the connection for every event the engine sends, after the subscribers the page
|
||||
registered earlier. The connection is found the way tests/_screencast_evidence.py finds it:
|
||||
`page._impl_obj._connection._transport._server.object(guid).conn`. The commands that start, stop or replace a navigation are seen on the
|
||||
same connection (`send_placed`, wrapped on THIS instance only and passing everything through unchanged; removed in `finish`), so that the id of
|
||||
each goto is the one the engine answered to its `Page.navigate`. Nothing of src/ is touched.
|
||||
|
||||
Times are `time.perf_counter()`, the clock of the rest of the script; `finish` turns them into ms from the start of goto 1 (`t=0`).
|
||||
Of the network only the requests of DOCUMENTS are kept: the ones that carry a navigation id (or whose cause says document), and what follows them.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.t0 = None # perf_counter of the start of goto 1
|
||||
self.t_second = None # perf_counter of the start of goto 2
|
||||
self._raw = [] # (perf_counter, method, params, session)
|
||||
self._documents = set() # request ids of documents
|
||||
self._conn = None
|
||||
|
||||
# -- the hook
|
||||
def attach(self, page):
|
||||
impl = page._impl_obj
|
||||
conn = impl._connection._transport._server.object(impl._guid).conn
|
||||
self._conn = conn
|
||||
conn.add_listener(self._on_event)
|
||||
original = conn.send_placed
|
||||
raw = self._raw
|
||||
|
||||
def send_placed(method, params=None, session=None, timeout=30.0):
|
||||
said = method in _SAID
|
||||
if said:
|
||||
raw.append((time.perf_counter(), "send " + method, dict(params or {}), session))
|
||||
try:
|
||||
answer = original(method, params, session, timeout)
|
||||
except BaseException as failure:
|
||||
if said:
|
||||
raw.append((time.perf_counter(), "error " + method, {"error": str(failure)[:300]}, session))
|
||||
raise
|
||||
if said:
|
||||
result = answer[0] if isinstance(answer, tuple) else answer
|
||||
raw.append((time.perf_counter(), "reply " + method, dict(result) if isinstance(result, dict) else {}, session))
|
||||
return answer
|
||||
|
||||
conn.send_placed = send_placed
|
||||
|
||||
def _on_event(self, method, params, session):
|
||||
if method not in _TRACED:
|
||||
return
|
||||
now = time.perf_counter()
|
||||
params = params if isinstance(params, dict) else {}
|
||||
if method == "Network.requestWillBeSent":
|
||||
if params.get("navigationId") or "document" in str(params.get("cause", "")).lower():
|
||||
self._documents.add(params.get("requestId"))
|
||||
elif method.startswith("Network.") and params.get("requestId") not in self._documents:
|
||||
return
|
||||
self._raw.append((now, method, params, session))
|
||||
|
||||
def detach(self):
|
||||
conn, self._conn = self._conn, None
|
||||
if conn is not None:
|
||||
conn.remove_listener(self._on_event)
|
||||
conn.__dict__.pop("send_placed", None) # back to the method of the class
|
||||
|
||||
# -- the result
|
||||
def finish(self, row):
|
||||
self.detach()
|
||||
raw = sorted(self._raw, key=lambda item: item[0])
|
||||
base = self.t0 if self.t0 is not None else (raw[0][0] if raw else 0.0)
|
||||
events = []
|
||||
for stamp, method, params, session in raw:
|
||||
if method.startswith(("reply ", "error ")):
|
||||
kept = dict(params)
|
||||
elif method.startswith("send "):
|
||||
kept = {k: params[k] for k in ("url", "frameId") if k in params}
|
||||
else:
|
||||
kept = _reduced(method, params)
|
||||
if session:
|
||||
kept["session"] = session
|
||||
events.append([_ms(stamp - base), method, kept])
|
||||
|
||||
def navigate_id(path):
|
||||
"""The id of the navigation the engine answered to the `Page.navigate` of `path`."""
|
||||
sent = None
|
||||
for _, method, params, _ in raw:
|
||||
if method == "send Page.navigate":
|
||||
sent = params.get("url", "")
|
||||
elif method == "reply Page.navigate" and sent is not None and urlsplit(sent).path == path:
|
||||
return params.get("navigationId")
|
||||
return None
|
||||
|
||||
g1, g2 = navigate_id("/partial"), navigate_id("/second")
|
||||
source = "the reply of Page.navigate"
|
||||
if g1 is None or g2 is None:
|
||||
# no reply to say it: the navigationStarted that follows each goto
|
||||
started = [(stamp, params.get("navigationId")) for stamp, method, params, _ in raw if method == "Page.navigationStarted"]
|
||||
after1 = [nid for stamp, nid in started if self.t0 is not None and stamp >= self.t0]
|
||||
after2 = [nid for stamp, nid in started if self.t_second is not None and stamp >= self.t_second]
|
||||
g1 = g1 or (after1[0] if after1 else None)
|
||||
g2 = g2 or (after2[0] if after2 else None)
|
||||
source = "the navigationStarted after each goto"
|
||||
if row.get("goto2_outcome") is None:
|
||||
esito = "no goto 2 (%s)" % ("scenario error" if row.get("response_heard") else "the response of the first was never heard")
|
||||
elif row["goto2_outcome"] == "commit":
|
||||
esito = "commit"
|
||||
else:
|
||||
esito = "hung" if row.get("goto2_error_class") == "timeout" else "error: %s" % row.get("goto2_error_class")
|
||||
return {"goto1_id": g1, "goto2_id": g2, "goto_ids_from": source, "esito": esito, "events": events}
|
||||
|
||||
|
||||
def _token(event, goto1, goto2):
|
||||
"""One event as a short word: its method, the goto its navigation id belongs to (G1, G2, other) and what tells it apart."""
|
||||
_, method, params = event
|
||||
nid = params.get("navigationId")
|
||||
who = None if not nid else "G1" if nid == goto1 else "G2" if nid == goto2 else "other"
|
||||
short = method.replace("Page.", "").replace("Network.", "net.").replace("Runtime.", "").replace("Browser.", "")
|
||||
path = urlsplit(params["url"]).path if params.get("url") else None
|
||||
detail = [d for d in (who, path, params.get("errorText") or params.get("errorCode"), params.get("status"), params.get("name")) if d is not None]
|
||||
return "%s(%s)" % (short, " ".join(str(d) for d in detail)) if detail else short
|
||||
|
||||
|
||||
def trace_sequences(rows):
|
||||
"""Per outcome (hung, committed, other), the sequences of the events after the `navigationStarted` of goto 2, most frequent first:
|
||||
{outcome: [(count, [[word, ms after that navigationStarted, repeats], ...])]}. The ms are those of the first repetition with that sequence."""
|
||||
groups = {}
|
||||
for r in rows:
|
||||
events, g1, g2 = r.get("events"), r.get("goto1_id"), r.get("goto2_id")
|
||||
if not events or g2 is None:
|
||||
continue
|
||||
kind = {"hung": "hung", "commit": "good (committed)"}.get(r.get("esito"), r.get("esito") or "?")
|
||||
start = next((i for i, e in enumerate(events) if e[1] == "Page.navigationStarted" and e[2].get("navigationId") == g2), None)
|
||||
if start is None:
|
||||
groups.setdefault(kind + ", no navigationStarted for goto 2", {}).setdefault((), [0, []])[0] += 1
|
||||
continue
|
||||
t_start = events[start][0]
|
||||
folded = []
|
||||
for e in events[start + 1:]:
|
||||
if e[1] in ("send Page.navigate", "reply Page.navigate"):
|
||||
continue # said once per goto: not what the browser does after
|
||||
word = _token(e, g1, g2)
|
||||
if folded and folded[-1][0] == word: # consecutive repeats collapse: "x3"
|
||||
folded[-1][2] += 1
|
||||
else:
|
||||
folded.append([word, round(e[0] - t_start, 1), 1])
|
||||
slot = groups.setdefault(kind, {}).setdefault(tuple(w for w, _, _ in folded), [0, folded])
|
||||
slot[0] += 1
|
||||
return {kind: sorted(((n, f) for n, f in seqs.values()), key=lambda item: -item[0]) for kind, seqs in groups.items()}
|
||||
|
||||
|
||||
def render_trace(sequences, top=3):
|
||||
out = []
|
||||
for kind, seqs in sorted(sequences.items()):
|
||||
out.append("== trace, repetitions %s: %d" % (kind, sum(n for n, _ in seqs)))
|
||||
for n, folded in seqs[:top]:
|
||||
out.append(" x%d, after the navigationStarted of goto 2 (G1 = goto 1, G2 = goto 2):" % n)
|
||||
if not folded:
|
||||
out.append(" (nothing)")
|
||||
for word, at, count in folded:
|
||||
out.append(" +%8.1f ms %s%s" % (at, word, " x%d" % count if count > 1 else ""))
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the summary
|
||||
|
||||
def _first_line(message):
|
||||
return (message or "").strip().splitlines()[0][:160] if message else None
|
||||
|
||||
|
||||
def summarise(rows):
|
||||
measured = [r for r in rows if "second_request_arrived" in r]
|
||||
gotos2 = [r for r in measured if r.get("goto2_outcome")]
|
||||
ms2 = [r["goto2_ms"] for r in gotos2]
|
||||
asked = [r["second_request_after_goto2_start_ms"] for r in measured if r.get("second_request_after_goto2_start_ms") is not None]
|
||||
|
||||
def median_max(values):
|
||||
return {"median": round(statistics.median(values), 1), "max": round(max(values), 1)} if values else {"median": None, "max": None}
|
||||
|
||||
return {
|
||||
"repetitions": len(rows),
|
||||
"launched": sum(1 for r in rows if r.get("launched")),
|
||||
"measured": len(measured),
|
||||
"never_heard_the_response_of_the_first": sum(1 for r in measured if not r["response_heard"]),
|
||||
"second_request_arrived": {"yes": sum(1 for r in measured if r["second_request_arrived"]),
|
||||
"no": sum(1 for r in measured if not r["second_request_arrived"])},
|
||||
"second_request_arrived_after_goto2_ended": sum(1 for r in measured if r.get("second_request_before_goto2_end") is False),
|
||||
"goto2": {"commit": sum(1 for r in gotos2 if r["goto2_outcome"] == "commit"),
|
||||
"error": sum(1 for r in gotos2 if r["goto2_outcome"] == "error")},
|
||||
"goto2_errors": dict(Counter(_first_line(r["goto2_error"]) for r in gotos2 if r["goto2_error"])),
|
||||
"goto1_end": dict(Counter(r["goto1_error_class"] for r in measured if "goto1_error_class" in r)),
|
||||
"goto1_errors": dict(Counter(_first_line(r["goto1_error"]) for r in measured if r.get("goto1_error"))),
|
||||
"goto2_ms": median_max(ms2),
|
||||
"second_request_after_goto2_start_ms": median_max(asked),
|
||||
"launch_errors": dict(Counter(_first_line(r["launch_error"]) for r in rows if r.get("launch_error"))),
|
||||
"scenario_errors": dict(Counter(_first_line(r["scenario_error"]) for r in rows if r.get("scenario_error"))),
|
||||
}
|
||||
|
||||
|
||||
def render(name, summary):
|
||||
out = ["== %s: %d repetitions, %d launched, %d measured" % (name, summary["repetitions"], summary["launched"], summary["measured"])]
|
||||
s = summary["second_request_arrived"]
|
||||
out.append(" /second reached the server: yes %d, no %d (of the yes, %d after goto 2 had ended)"
|
||||
% (s["yes"], s["no"], summary["second_request_arrived_after_goto2_ended"]))
|
||||
g = summary["goto2"]
|
||||
out.append(" goto 2: committed %d, error %d" % (g["commit"], g["error"]))
|
||||
out.append(" goto 2 ms: median %(median)s, max %(max)s" % summary["goto2_ms"])
|
||||
out.append(" /second request, ms after goto 2 started: median %(median)s, max %(max)s" % summary["second_request_after_goto2_start_ms"])
|
||||
out.append(" goto 1 ended as: %s" % (", ".join("%s x%d" % kv for kv in sorted(summary["goto1_end"].items())) or "-"))
|
||||
for label, key in (("goto 2 errors", "goto2_errors"), ("goto 1 errors", "goto1_errors"), ("launch errors", "launch_errors"),
|
||||
("scenario errors", "scenario_errors")):
|
||||
for message, count in summary[key].items():
|
||||
out.append(" %s: x%d %s" % (label, count, message))
|
||||
if summary["never_heard_the_response_of_the_first"]:
|
||||
out.append(" the client never heard the response of the first goto in %d repetition(s)"
|
||||
% summary["never_heard_the_response_of_the_first"])
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the run
|
||||
|
||||
def _versions():
|
||||
found = {}
|
||||
for module, label in (("playwright", "playwright"), ("invisible_playwright", "invisible_playwright"), ("invisible_core", "invisible_core")):
|
||||
try:
|
||||
found[label] = __import__(module).__version__
|
||||
except Exception:
|
||||
found[label] = None
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
found["playwright"] = version("playwright")
|
||||
except Exception:
|
||||
pass
|
||||
return found
|
||||
|
||||
|
||||
def _declare_the_lab(directory):
|
||||
"""Where an e2e launch leaves from is declared, as the e2e suite does (tests/_lab_egress.py): no service of the internet is asked."""
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
import pytest
|
||||
|
||||
import _lab_egress
|
||||
|
||||
patch = pytest.MonkeyPatch()
|
||||
_lab_egress.install(patch, Path(directory))
|
||||
return patch
|
||||
|
||||
|
||||
async def _run(makers, repetitions, binary, out_dir, trace_on=False):
|
||||
rows = {m.name: [] for m in makers}
|
||||
for index in range(1, repetitions + 1):
|
||||
for maker in makers: # alternate: ours, stock, ours, stock, ...
|
||||
row = await _repetition(maker, index, binary, trace_on)
|
||||
rows[maker.name].append(row)
|
||||
shown = ["launched", "second_request_arrived", "second_request_after_goto2_start_ms", "goto1_error_class",
|
||||
"goto2_outcome", "goto2_ms", "launch_error", "scenario_error"]
|
||||
if trace_on:
|
||||
shown += ["esito", "goto1_id", "goto2_id", "trace_error"]
|
||||
print("[%s %d/%d] %s" % (maker.name, index, repetitions, json.dumps({k: row.get(k) for k in shown}, default=str)), flush=True)
|
||||
system = {"win32": "windows", "linux": "linux", "darwin": "macos"}.get(sys.platform, sys.platform)
|
||||
result = {}
|
||||
for maker in makers:
|
||||
summary = summarise(rows[maker.name])
|
||||
payload = {
|
||||
"meta": {"browser": maker.name, "system": system, "platform": platform.platform(), "python": sys.version.split()[0],
|
||||
"versions": _versions(), "binary": binary if maker.name == "invisible" else "the Firefox of `playwright install firefox`",
|
||||
"prefs": FISSION_ON, "hosts": "a.test, b.test, c.test -> the local server, by network.dns.localDomains",
|
||||
"goto1_timeout_ms": GOTO1_TIMEOUT_MS, "goto2_timeout_ms": GOTO2_TIMEOUT_MS,
|
||||
"trace": trace_on, "fresh_browser_per_repetition": True, "browsers_alternate": len(makers) > 1,
|
||||
"date": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())},
|
||||
"summary": summary,
|
||||
"rows": rows[maker.name],
|
||||
}
|
||||
if trace_on:
|
||||
payload["trace_sequences"] = {
|
||||
kind: [{"repetitions": n, "events": [{"word": w, "ms_after_goto2_started": at, "times": c} for w, at, c in folded]}
|
||||
for n, folded in seqs]
|
||||
for kind, seqs in trace_sequences(rows[maker.name]).items()}
|
||||
path = Path(out_dir) / ("second-goto-%s%s-%s.json" % ("trace-" if trace_on else "", maker.name, system))
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(payload, indent=2, default=str) + "\n", encoding="utf-8")
|
||||
print("written", path, flush=True)
|
||||
result[maker.name] = summary
|
||||
print()
|
||||
for maker in makers:
|
||||
print(render(maker.name, result[maker.name]), flush=True)
|
||||
if trace_on:
|
||||
print(render_trace(trace_sequences(rows[maker.name])), flush=True)
|
||||
return result
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0], formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--browser", choices=("both", "invisible", "stock"), default="both",
|
||||
help="which browser: both alternate, repetition by repetition (default)")
|
||||
parser.add_argument("--binary", default=os.environ.get("INVPW_BINARY_PATH") or os.environ.get("FF"),
|
||||
help="the engine of invisible_playwright (default: $INVPW_BINARY_PATH, then $FF)")
|
||||
parser.add_argument("--repetitions", type=int, default=REPETITIONS, help="per browser (default %d)" % REPETITIONS)
|
||||
parser.add_argument("--out-dir", default="second-goto", help="where the JSON of each browser is written")
|
||||
parser.add_argument("--trace", action="store_true",
|
||||
help="record, in every repetition, the protocol events the client hears with their time (needs --browser invisible)")
|
||||
args = parser.parse_args(argv)
|
||||
if args.trace and args.browser != "invisible":
|
||||
parser.error("--trace records the protocol of OUR browser: say --browser invisible")
|
||||
|
||||
makers = {"both": [_Ours, _Stock], "invisible": [_Ours], "stock": [_Stock]}[args.browser]
|
||||
if _Ours in makers and not args.binary:
|
||||
parser.error("the engine of invisible_playwright is needed: --binary, or $INVPW_BINARY_PATH / $FF")
|
||||
with tempfile.TemporaryDirectory(prefix="second-goto-") as lab:
|
||||
patch = _declare_the_lab(lab) if _Ours in makers else None
|
||||
try:
|
||||
result = asyncio.run(_run(makers, args.repetitions, args.binary, args.out_dir, args.trace))
|
||||
finally:
|
||||
if patch is not None:
|
||||
patch.undo()
|
||||
# the exit code says the script could measure, not what it measured
|
||||
dead = [name for name, s in result.items() if s["measured"] == 0]
|
||||
if dead:
|
||||
print("::error::no repetition of %s could be measured" % ", ".join(dead), flush=True)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,363 @@
|
||||
"""A pytest plugin for a HUNT, never for a gate: the protocol trace of every test it runs, one JSON per test.
|
||||
|
||||
python -m pytest -m e2e -p scripts.hunt_trace_plugin tests/test_control_a_selects_all_in_a_field_e2e.py
|
||||
|
||||
(run from the root of the repository, or with it on PYTHONPATH; the plugin is loaded with `-p` and is not in tests/conftest.py, so no other
|
||||
run sees it.) Where the JSON go: `$HUNT_TRACE_DIR` (default `hunt-trace`); `$HUNT_TRACE_TAG` is a label of the run (the round, the copy) that is
|
||||
written into every file name and every JSON.
|
||||
|
||||
Why it exists. `Page.set_content` failed, rarely, with "the caller's world never appeared for frame mainframe-N - did you call install()?
|
||||
Worlds seen: ['']" (tests/test_control_a_selects_all_in_a_field_e2e.py). The message is raised by `InjectedScript.caller_context` of
|
||||
invisible_core (juggler/injected.py) after 30 s of waiting for the context named `__ctx_caller__` of that frame, and the one thing that makes
|
||||
that context exist is `InjectedScript.install()`, which sends `Page.setInitScripts` with a script per world (`__ctx_aux__`, `__ctx_caller__`
|
||||
with worldKind "caller"): the engine creates the world when a document is created in the frame. `install()` is called once, in
|
||||
`PageDispatcher._build`, after the events the page missed are replayed. This plugin records what the browser said and what the server said
|
||||
to it, with times, so that a red run says in which order they happened.
|
||||
|
||||
What it records, per test (a time is `time.perf_counter()` in this process, written as ms from the start of the test):
|
||||
|
||||
* events the engine sent (heard by a listener of every `Connection`, registered at its birth): Page.navigationStarted / navigationCommitted /
|
||||
navigationAborted / sameDocumentNavigation / frameAttached / frameDetached / eventFired, Runtime.executionContextsCleared /
|
||||
executionContextCreated / executionContextDestroyed (frameId, world name, id), Browser.attachedToTarget / detachedFromTarget; the ones
|
||||
delivered again to a page built after them (`BrowserDispatcher.replay`) carry `replay: true`;
|
||||
* the commands the server sent (`Connection.send_placed`, wrapped on the CLASS, passing everything through): the command, its reduced
|
||||
parameters (the worlds of `Page.setInitScripts`, the context of a `Runtime.evaluate`, the start of its expression) and its reply or error
|
||||
with the time it took;
|
||||
* marks: the phases of the test, `InjectedScript.install` (start, end), `InjectedScript.caller_context` (start, end or error, with the worlds
|
||||
known for the frame at that moment), and `FrameDispatcher.op_set_content` (start, end or error), which is where `set_content` goes;
|
||||
* the outcome of each phase of the test and the text of its failure.
|
||||
|
||||
Both modes of the `browser` fixture are traced: the in-process one and the stock-client one, because in both the server (JugglerServer) runs
|
||||
in THIS process, on its own threads, and its `Connection` is the one hooked. What the stock client (the driver, a node process) says to
|
||||
it is not seen; what the server does is. Nothing of src/ is touched: the hooks are installed at run time on the classes, and a hook that cannot
|
||||
be installed (a name that moved) says so in the JSON (`hook_errors`) and the test goes on.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
#: Events kept, by method; the rest of what the engine says (network, console, screencast) is not what this hunt asks.
|
||||
_EVENTS = {
|
||||
"Page.navigationStarted": ("frameId", "navigationId"),
|
||||
"Page.navigationCommitted": ("frameId", "navigationId", "url"),
|
||||
"Page.navigationAborted": ("frameId", "navigationId", "errorText"),
|
||||
"Page.sameDocumentNavigation": ("frameId", "url"),
|
||||
"Page.eventFired": ("frameId", "name"),
|
||||
"Page.frameAttached": ("frameId", "parentFrameId"),
|
||||
"Page.frameDetached": ("frameId",),
|
||||
"Runtime.executionContextsCleared": (),
|
||||
"Runtime.executionContextCreated": ("executionContextId",),
|
||||
"Runtime.executionContextDestroyed": ("executionContextId",),
|
||||
"Browser.attachedToTarget": (),
|
||||
"Browser.detachedFromTarget": ("sessionId",),
|
||||
}
|
||||
#: Parameters kept of a command; a long text is cut.
|
||||
_COMMAND_KEYS = ("frameId", "executionContextId", "url", "worldName", "name", "targetId", "browserContextId")
|
||||
_CUT = 90
|
||||
_FAILURE_CUT = 4000
|
||||
|
||||
_lock = threading.Lock()
|
||||
_events: list = [] # [perf_counter, kind, method, detail, connection, session]
|
||||
_state = {"connections": 0, "test": None, "hook_errors": [], "installed": False}
|
||||
_replaying = threading.local()
|
||||
|
||||
|
||||
def _now():
|
||||
return time.perf_counter()
|
||||
|
||||
|
||||
def _add(kind, method, detail, conn=None, session=None):
|
||||
try:
|
||||
row = (_now(), kind, method, detail, conn, session)
|
||||
with _lock:
|
||||
_events.append(row)
|
||||
except Exception: # a recorder never costs the test
|
||||
pass
|
||||
|
||||
|
||||
def _cut(value):
|
||||
text = str(value)
|
||||
return text if len(text) <= _CUT else text[:_CUT] + "..."
|
||||
|
||||
|
||||
def _event_detail(method, params):
|
||||
params = params if isinstance(params, dict) else {}
|
||||
out = {k: params[k] for k in _EVENTS[method] if params.get(k) is not None}
|
||||
if method == "Runtime.executionContextCreated":
|
||||
aux = params.get("auxData") or {}
|
||||
out["frameId"] = aux.get("frameId")
|
||||
out["world"] = aux.get("name") or ""
|
||||
elif method == "Browser.attachedToTarget":
|
||||
info = params.get("targetInfo") or {}
|
||||
out.update({k: info[k] for k in ("targetId", "type", "url") if info.get(k) is not None})
|
||||
if params.get("sessionId"):
|
||||
out["sessionId"] = params["sessionId"]
|
||||
if getattr(_replaying, "on", False):
|
||||
out["replay"] = True
|
||||
return out
|
||||
|
||||
|
||||
def _command_detail(method, params):
|
||||
params = params if isinstance(params, dict) else {}
|
||||
out = {k: _cut(params[k]) for k in _COMMAND_KEYS if params.get(k) is not None}
|
||||
if method == "Page.setInitScripts":
|
||||
out["worlds"] = [[s.get("worldName"), s.get("worldKind"), len(s.get("script") or "")]
|
||||
for s in params.get("scripts") or [] if isinstance(s, dict)]
|
||||
for key in ("expression", "functionDeclaration"):
|
||||
if params.get(key):
|
||||
out[key] = _cut(params[key])
|
||||
return out
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the hooks on the classes
|
||||
|
||||
def _hook_connection():
|
||||
"""Every Connection hears its events through one listener, registered when it is built (before its reader thread starts, so the first
|
||||
events are not missed), and every command goes through `send_placed`, wrapped on the class."""
|
||||
from invisible_core.juggler import connection as module
|
||||
|
||||
base, cls = module.EventListeners, module.Connection
|
||||
original_init = base.__init__
|
||||
original_send = cls.send_placed
|
||||
|
||||
def init(self, *args, **kwargs):
|
||||
original_init(self, *args, **kwargs)
|
||||
with _lock:
|
||||
_state["connections"] += 1
|
||||
label = "c%d" % _state["connections"]
|
||||
self._hunt_label = label
|
||||
|
||||
def listen(method, params, session, _label=label):
|
||||
if method in _EVENTS:
|
||||
_add("event", method, _event_detail(method, params), _label, session)
|
||||
|
||||
self.add_listener(listen)
|
||||
|
||||
def send_placed(self, method, params=None, session=None, timeout=30.0):
|
||||
label = getattr(self, "_hunt_label", None)
|
||||
_add("send", method, _command_detail(method, params), label, session)
|
||||
started = _now()
|
||||
try:
|
||||
answer = original_send(self, method, params, session, timeout)
|
||||
except BaseException as failure:
|
||||
_add("error", method, {"error": _cut(failure), "ms": round((_now() - started) * 1000, 1)}, label, session)
|
||||
raise
|
||||
_add("reply", method, {"ms": round((_now() - started) * 1000, 1)}, label, session)
|
||||
return answer
|
||||
|
||||
base.__init__ = init
|
||||
cls.send_placed = send_placed
|
||||
|
||||
|
||||
def _worlds_of(injected, frame_id):
|
||||
try:
|
||||
return sorted("%s=%s" % (n or "''", v) for (f, n), v in list(injected.contexts.items()) if f == frame_id)
|
||||
except Exception as failure:
|
||||
return ["(unreadable: %s)" % failure]
|
||||
|
||||
|
||||
def _hook_injected():
|
||||
from invisible_core.juggler import injected as module
|
||||
|
||||
cls = module.InjectedScript
|
||||
install, caller_context = cls.install, cls.caller_context
|
||||
|
||||
def label(self):
|
||||
return getattr(self.c, "_hunt_label", None)
|
||||
|
||||
def hooked_install(self):
|
||||
_add("mark", "install.start", {}, label(self), self.session)
|
||||
try:
|
||||
return install(self)
|
||||
except BaseException as failure:
|
||||
_add("mark", "install.error", {"error": _cut(failure)}, label(self), self.session)
|
||||
raise
|
||||
finally:
|
||||
_add("mark", "install.end", {}, label(self), self.session)
|
||||
|
||||
def hooked_caller_context(self, frame_id, *args, **kwargs):
|
||||
_add("mark", "caller_context.start", {"frameId": frame_id, "worlds": _worlds_of(self, frame_id)}, label(self), self.session)
|
||||
try:
|
||||
context = caller_context(self, frame_id, *args, **kwargs)
|
||||
except BaseException as failure:
|
||||
_add("mark", "caller_context.error",
|
||||
{"frameId": frame_id, "error": _cut(failure), "worlds": _worlds_of(self, frame_id)}, label(self), self.session)
|
||||
raise
|
||||
_add("mark", "caller_context.end", {"frameId": frame_id, "executionContextId": context}, label(self), self.session)
|
||||
return context
|
||||
|
||||
cls.install = hooked_install
|
||||
cls.caller_context = hooked_caller_context
|
||||
|
||||
|
||||
def _hook_server():
|
||||
from invisible_playwright._juggler import server as module
|
||||
|
||||
frame_cls = module.FrameDispatcher
|
||||
set_content = frame_cls.op_set_content
|
||||
browser_cls = module.BrowserDispatcher
|
||||
replay = browser_cls.replay
|
||||
|
||||
def hooked_set_content(self, params):
|
||||
injected = getattr(self, "injected", None)
|
||||
session = getattr(injected, "session", None)
|
||||
conn = getattr(getattr(injected, "c", None), "_hunt_label", None)
|
||||
frame_id = getattr(self, "frame_id", None)
|
||||
detail = {"frameId": frame_id, "worlds": _worlds_of(injected, frame_id) if injected is not None else None,
|
||||
"delivered": getattr(getattr(injected, "c", None), "delivered", None)}
|
||||
_add("mark", "set_content.start", detail, conn, session)
|
||||
try:
|
||||
result = set_content(self, params)
|
||||
except BaseException as failure:
|
||||
_add("mark", "set_content.error", {"frameId": frame_id, "error": _cut(failure)}, conn, session)
|
||||
raise
|
||||
_add("mark", "set_content.end", {"frameId": frame_id}, conn, session)
|
||||
return result
|
||||
|
||||
def hooked_replay(self, session, deliver):
|
||||
_replaying.on = True
|
||||
try:
|
||||
return replay(self, session, deliver)
|
||||
finally:
|
||||
_replaying.on = False
|
||||
|
||||
frame_cls.op_set_content = hooked_set_content
|
||||
browser_cls.replay = hooked_replay
|
||||
|
||||
|
||||
def _install_hooks():
|
||||
if _state["installed"]:
|
||||
return
|
||||
_state["installed"] = True
|
||||
for hook in (_hook_connection, _hook_injected, _hook_server):
|
||||
try:
|
||||
hook()
|
||||
except Exception as failure: # the hunt goes on without that part, and says so
|
||||
_state["hook_errors"].append("%s: %s: %s" % (hook.__name__, type(failure).__name__, failure))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- the tests
|
||||
|
||||
def pytest_configure(config):
|
||||
_install_hooks()
|
||||
|
||||
|
||||
def _safe(name):
|
||||
return re.sub(r"[^A-Za-z0-9._-]+", "_", name)[-120:]
|
||||
|
||||
|
||||
class _Current:
|
||||
def __init__(self, item):
|
||||
self.item = item
|
||||
self.start = _now()
|
||||
with _lock:
|
||||
self.first = len(_events)
|
||||
self.phases = {}
|
||||
self.failure = {}
|
||||
|
||||
|
||||
def _mode(item):
|
||||
callspec = getattr(item, "callspec", None)
|
||||
params = getattr(callspec, "params", {}) if callspec else {}
|
||||
return params.get("browser") # "in-process" or "stock-client" (the fixture's param)
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtest_protocol(item, nextitem):
|
||||
current = _state["test"] = _Current(item)
|
||||
_add("mark", "test.start", {"nodeid": item.nodeid})
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_add("mark", "test.end", {})
|
||||
try:
|
||||
_write(current)
|
||||
except Exception as failure:
|
||||
_state["hook_errors"].append("write: %s: %s" % (type(failure).__name__, failure))
|
||||
_state["test"] = None
|
||||
|
||||
|
||||
def _phase_marks(phase):
|
||||
_add("mark", "test.%s.start" % phase, {})
|
||||
outcome = yield
|
||||
_add("mark", "test.%s.end" % phase, {"raised": outcome.excinfo is not None})
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_setup(item):
|
||||
yield from _phase_marks("setup")
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_call(item):
|
||||
yield from _phase_marks("call")
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_teardown(item):
|
||||
yield from _phase_marks("teardown")
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
current = _state["test"]
|
||||
if current is None:
|
||||
return
|
||||
report = outcome.get_result()
|
||||
current.phases[call.when] = report.outcome
|
||||
if report.outcome in ("failed",) or (report.outcome == "skipped" and call.when == "setup"):
|
||||
text = str(report.longrepr)
|
||||
current.failure[call.when] = text if len(text) <= _FAILURE_CUT else text[:_FAILURE_CUT] + "\n..."
|
||||
|
||||
|
||||
def _verdict(phases):
|
||||
if phases.get("setup") == "failed" or phases.get("teardown") == "failed":
|
||||
return "error"
|
||||
if phases.get("call") == "failed":
|
||||
return "failed"
|
||||
if phases.get("setup") == "skipped" or phases.get("call") == "skipped":
|
||||
return "skipped"
|
||||
return "passed" if phases.get("call") == "passed" else "unknown"
|
||||
|
||||
|
||||
_sequence = {"n": 0}
|
||||
|
||||
|
||||
def _write(current):
|
||||
with _lock:
|
||||
rows = list(_events[current.first:])
|
||||
_sequence["n"] += 1
|
||||
number = _sequence["n"]
|
||||
base = current.start
|
||||
events = [[round((t - base) * 1000, 2), kind, method, detail, conn, session]
|
||||
for t, kind, method, detail, conn, session in rows]
|
||||
item = current.item
|
||||
tag = os.environ.get("HUNT_TRACE_TAG", "")
|
||||
payload = {
|
||||
"nodeid": item.nodeid,
|
||||
"mode": _mode(item),
|
||||
"outcome": _verdict(current.phases),
|
||||
"phases": current.phases,
|
||||
"failure": current.failure,
|
||||
"tag": tag,
|
||||
"system": platform.system(),
|
||||
"pid": os.getpid(),
|
||||
"sequence": number,
|
||||
"hook_errors": list(_state["hook_errors"]),
|
||||
"columns": ["ms_from_test_start", "kind", "method", "detail", "connection", "session"],
|
||||
"events": events,
|
||||
}
|
||||
out = os.environ.get("HUNT_TRACE_DIR", "hunt-trace")
|
||||
os.makedirs(out, exist_ok=True)
|
||||
name = "%s%s-%04d-%s.json" % (_safe(tag) + "-" if tag else "", os.getpid(), number, _safe(item.nodeid.split("::", 1)[-1]))
|
||||
with open(os.path.join(out, name), "w", encoding="utf-8", newline="\n") as handle:
|
||||
json.dump(payload, handle, indent=1, default=str)
|
||||
handle.write("\n")
|
||||
@@ -1,195 +0,0 @@
|
||||
"""Run the same e2e through BOTH transports and compare, test by test.
|
||||
|
||||
⛔ THIS IS THE JUDGEMENT ITEM 8 WAITS FOR. The Node driver and the Python
|
||||
server answer the same protocol, so the only honest way to know the second one
|
||||
is correct is to run the same session through both and compare the results
|
||||
name by name. Deleting the driver before this has run leaves the new path with
|
||||
nothing to be measured against - a build that agrees with itself.
|
||||
|
||||
⛔ AND A DIFFERENCE IS NOT AUTOMATICALLY OURS. In two days this comparison has
|
||||
already answered in both directions: `go_back` fails identically on both arms,
|
||||
so it is the engine ([B185]); an unanswered dialog failed only on ours, so it
|
||||
was ours. The table below keeps them apart instead of counting failures.
|
||||
|
||||
python scripts/judge_both_transports.py <firefox-binary>
|
||||
python scripts/judge_both_transports.py <binary> -k juggler # a subset
|
||||
|
||||
⛔ THE MACHINE MUST BE QUIET. Both arms launch real browsers, and this project
|
||||
has three recorded cases of measuring under load and reading the noise as a
|
||||
product defect. The script refuses to start if a firefox is already alive.
|
||||
|
||||
⛔ AND THE ARMS RUN INTERLEAVED PER FILE, never all-of-A then all-of-B. Machine
|
||||
load and disk cache drift over minutes; running one arm to completion first
|
||||
puts every one of its tests in a different window from the other's, which turns
|
||||
"this arm is worse" and "that minute was worse" into the same measurement.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
|
||||
#: The files worth running on both. ⛔ NOT the whole suite: most of it never
|
||||
#: touches a transport, so running it twice would double the time and add no
|
||||
#: information. These are the ones that drive a browser through the seam.
|
||||
FILES = [
|
||||
"tests/test_juggler_transport.py",
|
||||
"tests/test_hidden_desktop.py",
|
||||
"tests/test_new_page_defaults.py",
|
||||
"tests/test_cross_origin_iframe.py",
|
||||
"tests/test_file_chooser.py",
|
||||
]
|
||||
|
||||
ESITO = re.compile(r"^(tests[^\s:]+)::(\S+)\s+(PASSED|FAILED|ERROR|XFAIL|XPASS|SKIPPED)",
|
||||
re.M)
|
||||
|
||||
|
||||
def quiet_machine() -> int:
|
||||
r = subprocess.run(
|
||||
["powershell", "-NoProfile", "-Command",
|
||||
"(Get-Process firefox -ErrorAction SilentlyContinue | Measure-Object).Count"],
|
||||
capture_output=True, text=True)
|
||||
try:
|
||||
return int((r.stdout or "0").strip() or 0)
|
||||
except ValueError:
|
||||
return -1
|
||||
|
||||
|
||||
#: A checkout that still carries the Node driver, for the day this one does not.
|
||||
#:
|
||||
#: ⛔ THIS GATE EXISTS ONLY WHILE THERE ARE TWO ARMS, and the driver is on its
|
||||
#: way out of the tree. When it goes, the second arm comes from a git worktree
|
||||
#: at the last commit that carried it:
|
||||
#:
|
||||
#: git worktree add /tmp/judge <that commit>
|
||||
#: INVPW_DRIVER_TREE=/tmp/judge python scripts/judge_both_transports.py <bin>
|
||||
#:
|
||||
#: A worktree rather than an installed release, because a published wrapper
|
||||
#: pins a published core and a sealed engine and therefore cannot drive a
|
||||
#: locally built binary - which is the only kind worth judging.
|
||||
DRIVER_TREE_ENV = "INVPW_DRIVER_TREE"
|
||||
|
||||
|
||||
def run_one(transport: str, binary: str, path: str, extra: list) -> dict:
|
||||
import os
|
||||
env = dict(os.environ)
|
||||
env["INVPW_TRANSPORT"] = transport
|
||||
env["INVPW_BINARY_PATH"] = binary
|
||||
tree = os.environ.get(DRIVER_TREE_ENV)
|
||||
if transport == "driver" and tree:
|
||||
# ⛔ PREPENDED, so the older tree's package wins the import. The TESTS
|
||||
# still come from this checkout: what is being borrowed is the driver,
|
||||
# not the suite, and running the old suite would compare two different
|
||||
# sets of assertions and call it a transport difference.
|
||||
src = str(pathlib.Path(tree) / "src")
|
||||
env["PYTHONPATH"] = os.pathsep.join(
|
||||
[src] + ([env["PYTHONPATH"]] if env.get("PYTHONPATH") else []))
|
||||
r = subprocess.run(
|
||||
[sys.executable, "-m", "pytest", path, "-o", "addopts=", "-v",
|
||||
"-p", "no:cacheprovider"] + extra,
|
||||
cwd=ROOT, env=env, capture_output=True, text=True, timeout=3600)
|
||||
return {name: verdict
|
||||
for _, name, verdict in ESITO.findall(r.stdout + r.stderr)}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
p.add_argument("binary")
|
||||
p.add_argument("-k", dest="selection", default=None)
|
||||
p.add_argument("--allow-busy", action="store_true",
|
||||
help="run even with a browser already alive. ⛔ The result "
|
||||
"is then not a measurement, and the report says so.")
|
||||
a = p.parse_args()
|
||||
|
||||
alive = quiet_machine()
|
||||
if alive and not a.allow_busy:
|
||||
print("REFUSING: %d firefox processes are already alive. A run under "
|
||||
"load is not a measurement - this project has three recorded "
|
||||
"cases of reading that noise as a product defect. Close them, or "
|
||||
"pass --allow-busy and read the result as indicative." % alive)
|
||||
return 2
|
||||
if alive:
|
||||
print("WARNING: %d firefox alive, the result is INDICATIVE" % alive)
|
||||
|
||||
extra = ["-k", a.selection] if a.selection else []
|
||||
driver, juggler = {}, {}
|
||||
for path in FILES:
|
||||
if not (ROOT / path).exists():
|
||||
print(" (skipped, absent: %s)" % path)
|
||||
continue
|
||||
print("running %s ..." % path, flush=True)
|
||||
# ⛔ Interleaved per file: see the module docstring.
|
||||
driver.update(run_one("driver", a.binary, path, extra))
|
||||
juggler.update(run_one("juggler", a.binary, path, extra))
|
||||
|
||||
names = sorted(set(driver) | set(juggler))
|
||||
ok = both_fail = only_ours = only_theirs = not_run = 0
|
||||
rows = []
|
||||
for name in names:
|
||||
d = driver.get(name, "ABSENT")
|
||||
j = juggler.get(name, "ABSENT")
|
||||
good = ("PASSED", "XFAIL", "SKIPPED")
|
||||
# ⛔ A TEST THE OTHER ARM NEVER RAN IS NOT A TEST THE OTHER ARM
|
||||
# FAILED, and folding the two was making this gate lie in the
|
||||
# comfortable direction. The driver arm imports an OLD `src/`, so any
|
||||
# test file naming something added since that commit fails to COLLECT
|
||||
# there and every test in it comes back ABSENT. Counted as "only the
|
||||
# driver fails", they printed under "ours is BETTER here" - measured
|
||||
# 2026-08-28 at 32 of them, essentially all of that kind. The number
|
||||
# grows on its own as this tree moves, which is the property that
|
||||
# turns a gate into decoration.
|
||||
if "ABSENT" in (d, j) and not (d in good and j in good):
|
||||
not_run += 1
|
||||
rows.append(("NOT RUN", name, d, j))
|
||||
elif d in good and j in good:
|
||||
ok += 1
|
||||
elif d not in good and j not in good:
|
||||
both_fail += 1
|
||||
rows.append(("ENGINE?", name, d, j))
|
||||
elif d in good:
|
||||
only_ours += 1
|
||||
rows.append(("OURS", name, d, j))
|
||||
else:
|
||||
only_theirs += 1
|
||||
rows.append(("DRIVER", name, d, j))
|
||||
|
||||
print()
|
||||
print("=" * 78)
|
||||
print("%-8s %-46s %-10s %s" % ("verdict", "test", "driver", "juggler"))
|
||||
print("-" * 78)
|
||||
for kind, name, d, j in rows:
|
||||
print("%-8s %-46s %-10s %s" % (kind, name[:46], d, j))
|
||||
print("-" * 78)
|
||||
print("both green %d" % ok)
|
||||
print("BOTH fail -> the ENGINE %d" % both_fail)
|
||||
print("only OURS fails %d <- the ones that are ours to fix"
|
||||
% only_ours)
|
||||
print("only the DRIVER fails %d <- ours is BETTER here, verify why"
|
||||
% only_theirs)
|
||||
print("never ran on one arm %d <- NOT a comparison: the old arm "
|
||||
"could not collect these" % not_run)
|
||||
if not_run:
|
||||
print()
|
||||
print(" WARNING: %d of the rows above were never compared at all. The driver "
|
||||
"arm's `src/` is a worktree that ages: a test naming anything "
|
||||
"added since it was cut fails to collect there. When this number "
|
||||
"approaches the total, this gate has stopped answering its own "
|
||||
"question and the worktree needs re-cutting." % not_run)
|
||||
print()
|
||||
if only_ours:
|
||||
print("VERDICT: not ready to delete the driver. %d tests pass through "
|
||||
"it and fail through us." % only_ours)
|
||||
return 1
|
||||
print("VERDICT: no test passes on the driver and fails on us.")
|
||||
if both_fail:
|
||||
print(" (%d fail on BOTH: engine defects, not a reason to wait)"
|
||||
% both_fail)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -7,7 +7,7 @@ against anything of ours: its `conftest.py` imports the real `playwright`
|
||||
package, so it has only ever measured Microsoft's client.
|
||||
|
||||
The plan it serves: replacing the channel between our client and our server
|
||||
removes the boundary `diff_protocol.py` compares across, so the judgement has to
|
||||
removes the boundary the old protocol comparison compared across, so the judgement has to
|
||||
move up a level, from the PROTOCOL to the CONTRACT. This suite is that judge -
|
||||
but only if we know, before touching anything, which of those 2173 pass TODAY.
|
||||
A baseline taken afterwards proves nothing: every failure would be arguable.
|
||||
|
||||
@@ -52,14 +52,14 @@ did so on evidence rather than on the code looking finished:
|
||||
regenerating them. `injected.js` (the selector engines, actionability and
|
||||
`expect` that run in the page), `keylayout.py` (both in `invisible_core.juggler`
|
||||
since 0.30.0, with their extractors in the core's `scripts/`), and the four rules
|
||||
`prefs_byte_parity.py` compares our `user.js` writer against - now frozen in
|
||||
`tests/gates/driver_prefs_rules.json` with the sha of the bundle and of the
|
||||
exact window they came from.
|
||||
- ⛔ And the second arm. `judge_both_transports.py` and `diff_protocol.py` exist
|
||||
only while there are two implementations to compare. To get one back:
|
||||
the `user.js` writer was compared against (the comparison script and the frozen
|
||||
rules file were later deleted; they are in git history).
|
||||
- ⛔ And the second arm. A comparison between the two transports only exists
|
||||
while there are two implementations to compare, and the scripts that did it
|
||||
were deleted with the driver arm. To get one back:
|
||||
|
||||
git worktree add /tmp/judge <the last commit that carried _driver/>
|
||||
INVPW_DRIVER_TREE=/tmp/judge python scripts/judge_both_transports.py <bin>
|
||||
INVPW_DRIVER_TREE=/tmp/judge python scripts/capture_protocol.py <bin>
|
||||
|
||||
A worktree rather than an installed release, because a published wrapper pins
|
||||
a published core and a sealed engine and therefore cannot drive a locally
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
"""`expose_binding` / `expose_function`: the script a page runs, and the way a call is read and answered.
|
||||
|
||||
THE RULE: THE PAGE SEES `foo` AND NOTHING ELSE. A page can list the names on its window, so a transport left there ("a binding
|
||||
function", a controller) is the driver's signature. Nothing is left:
|
||||
|
||||
* One engine binding PER EXPOSED NAME (`Browser.addBinding` for a context, `Page.addBinding` for a page), under a native name chosen
|
||||
for the session. The engine puts the native function on the window of every document of the page or context, present and future,
|
||||
in every process, BEFORE any script of the page, and then runs the script below.
|
||||
* The script takes the native function off the window at once and keeps it in a closure; defines `foo` (an ordinary function whose
|
||||
source says nothing of what it is for); and hands the engine, through the native function, the function that answers a call
|
||||
(the engine keeps it as an object of that context and reports its id: `payload.bindingEnd`).
|
||||
* A call travels as a JSON string through the native function; the answer is `Runtime.callFunction` on the kept function.
|
||||
|
||||
LIMIT, SAID HERE. Arguments and results cross as JSON: `undefined`, functions and `NaN` arrive as `null`, and a `Date` as its ISO
|
||||
string. A caller who needs one passes it as a string. Workers do not get the function (the engine installs bindings in the frames
|
||||
of a page, as Playwright's does).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import json
|
||||
|
||||
|
||||
def install_script(native: str, name: str) -> str:
|
||||
"""Run by the engine in each document, after it exports the native function `native` on the window."""
|
||||
return (
|
||||
"(() => {"
|
||||
" const send = globalThis[%(native)s];"
|
||||
" try { delete globalThis[%(native)s]; } catch (e) {}"
|
||||
" if (typeof send !== 'function') return;"
|
||||
" const text = JSON.stringify, waiting = new Map();"
|
||||
" let last = 0;"
|
||||
" const ask = (name, args) => new Promise((resolve, reject) => {"
|
||||
" const id = ++last; waiting.set(id, [resolve, reject]);"
|
||||
" try { send(text({ name, seq: id, args })); } catch (e) { waiting.delete(id); reject(e); } });"
|
||||
" const f = { [%(name)s]: function (...args) { return ask(%(name)s, args); } }[%(name)s];"
|
||||
" Object.defineProperty(globalThis, %(name)s,"
|
||||
" { value: f, writable: true, configurable: true, enumerable: true });"
|
||||
" send(function (id, ok, value) {"
|
||||
" const w = waiting.get(id); if (!w) return; waiting.delete(id);"
|
||||
" if (ok) w[0](value); else w[1](new Error(value)); });"
|
||||
" })()") % {"native": json.dumps(native), "name": json.dumps(name)}
|
||||
|
||||
|
||||
def remove_script(native: str, name: str) -> str:
|
||||
"""The same binding again, as the engine runs the last one it was given for a native name: it takes the native function
|
||||
off the window and the exposed function with it. A document that exists loses `foo`; one to come never gets it."""
|
||||
return ("(() => { try { delete globalThis[%s]; } catch (e) {}"
|
||||
" try { delete globalThis[%s]; } catch (e) {} })()") % (json.dumps(native), json.dumps(name))
|
||||
|
||||
|
||||
#: `Runtime.callFunction` with the kept function as the first argument.
|
||||
DELIVER = "(end, seq, ok, value) => end(seq, ok, value)"
|
||||
|
||||
|
||||
def read_call(payload) -> tuple:
|
||||
"""`(name, seq, args)` of a `Page.bindingCalled` payload, or `None` if it is not a call."""
|
||||
try:
|
||||
data = json.loads(payload) if isinstance(payload, str) else payload
|
||||
return str(data["name"]), int(data["seq"]), list(data.get("args") or [])
|
||||
except (TypeError, ValueError, KeyError):
|
||||
return None
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=16)
|
||||
def engine_supports(engine_dir: str) -> bool:
|
||||
"""Whether the engine in `engine_dir` has `Page.addBinding` and the binding that hands its end over.
|
||||
|
||||
Read from the engine's own files (the schema of its protocol, and its Runtime), so an engine without them is known BEFORE a
|
||||
function is exposed: there is no fallback to a name on the window, and a clear refusal is the answer. An engine that cannot
|
||||
be read is treated as one that cannot."""
|
||||
if not engine_dir:
|
||||
return False
|
||||
try:
|
||||
import os
|
||||
|
||||
from invisible_core.juggler._gen_protocol import protocol_source
|
||||
_label, text = protocol_source(engine_dir)
|
||||
if text.count("'addBinding'") < 2:
|
||||
return False
|
||||
omni = os.path.join(engine_dir, "omni.ja")
|
||||
if os.path.isfile(omni):
|
||||
from invisible_core.jar import open_jar
|
||||
jar = open_jar(omni)
|
||||
return b"bindingEnd" in jar.read("modules/juggler/content/Runtime.js")
|
||||
return True
|
||||
except BaseException:
|
||||
return False
|
||||
@@ -0,0 +1,126 @@
|
||||
"""The one way this package starts a thread from a place that must not wait for it.
|
||||
|
||||
`Thread.start` does not return until the new thread is running (`self._started.wait()`), and on Windows under load that wait is
|
||||
milliseconds long. Two places in the package cannot afford it: the engine connection's reader (an event is measured late by every
|
||||
millisecond the reader is late) and the user's event loop (`InProcessTransport.connect`: four worker starts held the loop ~200 ms per
|
||||
launch with four browsers in one process). Both hand the thread to `ThreadStarter`.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import _thread as _raw_thread
|
||||
import queue
|
||||
import threading
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
|
||||
class ThreadStarter:
|
||||
"""The ONE long-lived thread that starts the other threads it is handed.
|
||||
|
||||
⛔ NO `Thread.start` ON THE CALLER, AND THAT INCLUDES BUILDING THE STARTER. `start` and `start_built` only queue (a `Thread` that is
|
||||
only BUILT waits for nothing); this thread starts what is queued. The starter's own thread is begun with `_thread.start_new_thread`
|
||||
running `Thread.start`: the OS makes a thread and the caller returns at once, and the wait for the starter to run happens on that
|
||||
raw thread, not on the caller. The starter is still a `threading.Thread` named `invpw-thread-starter` (it is alive a moment after
|
||||
the constructor returns, not before).
|
||||
|
||||
It starts threads and does not run the work itself, on purpose: an adoption waits for the engine as long as the engine takes (a popup
|
||||
whose destination never answers is waited for without a limit), and a worker that ran it would hold every later adoption behind it,
|
||||
`new_page()` included. Each piece of work keeps the thread of its own and the name it always had.
|
||||
"""
|
||||
|
||||
#: Every starter built and not yet ended (from the constructor, which returns before its thread runs, to the end of that thread).
|
||||
#: Without it a starter whose thread has not begun yet is in no `threading.enumerate()` and nobody can count it: the census of
|
||||
#: tests/_browser_census.py missed the leaked starters on a machine where the raw thread was late to run.
|
||||
_open: "set" = set()
|
||||
_open_lock = threading.Lock()
|
||||
|
||||
@classmethod
|
||||
def open_starters(cls) -> list:
|
||||
with cls._open_lock:
|
||||
return list(cls._open)
|
||||
|
||||
def __init__(self, on_error: Callable[[str], None]) -> None:
|
||||
with ThreadStarter._open_lock:
|
||||
ThreadStarter._open.add(self)
|
||||
self._queue: "queue.SimpleQueue" = queue.SimpleQueue()
|
||||
self._on_error = on_error
|
||||
self._stopped = False
|
||||
self._thread = threading.Thread(target=self._run, daemon=True, name="invpw-thread-starter")
|
||||
_raw_thread.start_new_thread(self._begin, ())
|
||||
|
||||
def _begin(self) -> None:
|
||||
try:
|
||||
self._thread.start()
|
||||
except BaseException as failure:
|
||||
self._ended()
|
||||
self._report("%s could not be started: %s" % (self._thread.name, failure))
|
||||
|
||||
def _ended(self) -> None:
|
||||
with ThreadStarter._open_lock:
|
||||
ThreadStarter._open.discard(self)
|
||||
|
||||
def start(self, **thread_arguments: Any) -> None:
|
||||
"""Called from any thread, the reader's and the loop's included: builds a daemon thread and queues it. Never waits."""
|
||||
if self._stopped:
|
||||
return
|
||||
self._queue.put((threading.Thread(daemon=True, **thread_arguments), None))
|
||||
|
||||
def start_built(self, thread: threading.Thread, on_failure: Optional[Callable[[str], None]] = None) -> None:
|
||||
"""Queue a thread the caller built (its name, its daemon flag, its target). Never waits.
|
||||
|
||||
`on_failure(why)` runs on the starter if this thread cannot be started, besides the starter's own report."""
|
||||
if self._stopped:
|
||||
return
|
||||
self._queue.put((thread, on_failure))
|
||||
|
||||
def stop(self) -> None:
|
||||
self._stopped = True
|
||||
self._queue.put(None)
|
||||
|
||||
def _report(self, why: str) -> None:
|
||||
try:
|
||||
self._on_error(why)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _run(self) -> None:
|
||||
try:
|
||||
self._loop()
|
||||
finally:
|
||||
self._ended()
|
||||
|
||||
def _loop(self) -> None:
|
||||
while True:
|
||||
item = self._queue.get()
|
||||
if item is None:
|
||||
return
|
||||
thread, on_failure = item
|
||||
try:
|
||||
thread.start()
|
||||
except Exception as failure:
|
||||
why = "%s could not be started: %s" % (thread.name, failure)
|
||||
self._report(why)
|
||||
if on_failure is not None:
|
||||
try:
|
||||
on_failure(why)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class ThreadStarterLease:
|
||||
"""One browser's use of the connection's starter: `start` while the browser's connection lives, nothing after it.
|
||||
|
||||
The starter is the SERVER's (one thread per connection, however many browsers it launches, `Server.thread_starter`) and ends with
|
||||
the server. A browser's connection ends earlier than that: from then on a thread its events ask for must not start, which is
|
||||
what `stop` on the browser's own starter used to give. The starter is asked for on the first `start`, so a browser that never
|
||||
needs a thread makes none."""
|
||||
|
||||
def __init__(self, get_starter: Callable[[], ThreadStarter]) -> None:
|
||||
self._get_starter = get_starter
|
||||
self._stopped = False
|
||||
|
||||
def start(self, **thread_arguments: Any) -> None:
|
||||
if not self._stopped:
|
||||
self._get_starter().start(**thread_arguments)
|
||||
|
||||
def stop(self) -> None:
|
||||
self._stopped = True
|
||||
@@ -39,6 +39,7 @@ import time
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from . import perimeter, variants
|
||||
from ._threads import ThreadStarter
|
||||
# One class for a target that is gone, raised here for a disposed object and
|
||||
# by the connection for a closed pipe. Defined there, the lower layer.
|
||||
from invisible_core.juggler.connection import TargetClosedError # noqa: F401 - re-exported on purpose
|
||||
@@ -274,8 +275,30 @@ class Server:
|
||||
self._on_shutdown: list = []
|
||||
#: What `shutdown` runs after every hook. See `after_shutdown`.
|
||||
self._after_shutdown: list = []
|
||||
self._starter: Optional[ThreadStarter] = None
|
||||
self._starter_lock = threading.Lock()
|
||||
self._is_shut_down = False
|
||||
#: Why a thread the starter was handed could not be started (the last few).
|
||||
self.start_errors: list = []
|
||||
|
||||
# ── plumbing ────────────────────────────────────────────────────────────
|
||||
@property
|
||||
def thread_starter(self) -> ThreadStarter:
|
||||
"""The ONE thread that starts threads for this connection: the transport's workers and every browser's reader hand theirs to it.
|
||||
|
||||
Built on first use, ended by `shutdown`. Served by several clients (`remote._SharedServer`) it is the same one: the server
|
||||
is the connection's owner there too, and its browser's contexts come and go under it."""
|
||||
with self._starter_lock:
|
||||
if self._starter is None:
|
||||
self._starter = ThreadStarter(self._start_failed)
|
||||
if self._is_shut_down:
|
||||
self._starter.stop()
|
||||
return self._starter
|
||||
|
||||
def _start_failed(self, why: str) -> None:
|
||||
if len(self.start_errors) < 32:
|
||||
self.start_errors.append(why)
|
||||
|
||||
def attach(self, transport: Any) -> None:
|
||||
self._transport = transport
|
||||
|
||||
@@ -436,6 +459,11 @@ class Server:
|
||||
except Exception:
|
||||
pass
|
||||
self._after_shutdown.clear()
|
||||
with self._starter_lock:
|
||||
self._is_shut_down = True
|
||||
starter = self._starter
|
||||
if starter is not None:
|
||||
starter.stop()
|
||||
|
||||
# ── the entry point ─────────────────────────────────────────────────────
|
||||
def handle(self, message: Dict) -> Any:
|
||||
|
||||
@@ -169,13 +169,6 @@ FIXED_AT_BUILD = {
|
||||
#: Our debt, plainly. Nothing external blocks these: they are not written yet.
|
||||
#: This set is the honest list of what "100% compatible" does not cover today.
|
||||
NOT_WIRED_YET = {
|
||||
"exposeBinding",
|
||||
# ⛔ `reject` shares its handler with `resolve`, and that is how it stayed
|
||||
# invisible: the first scan keyed the method table by python name, so the
|
||||
# second operation routed to `op_binding_reply` overwrote the first. Two
|
||||
# operations, one handler, one of them unaccounted for.
|
||||
"reject",
|
||||
"resolve",
|
||||
"setExtraHTTPHeaders",
|
||||
}
|
||||
|
||||
|
||||
@@ -837,7 +837,6 @@ def launch_server(host: str = DEFAULT_HOST, port: int = 0, *,
|
||||
LocalUtilsDispatcher(server)
|
||||
browser = server.object(
|
||||
browser_type.op_launch(params)["browser"]["guid"])
|
||||
session._bind_process_tree()
|
||||
|
||||
class _Reported: # what assert_wire_version reads off a Browser
|
||||
version = browser.initializer.get("version", "")
|
||||
|
||||
@@ -36,6 +36,7 @@ import pathlib
|
||||
import queue
|
||||
import sys
|
||||
import tempfile
|
||||
import secrets
|
||||
import threading
|
||||
import collections
|
||||
import time
|
||||
@@ -46,7 +47,8 @@ from invisible_core.juggler import PageActs, popup_number
|
||||
from invisible_core.juggler import connection as juggler
|
||||
from invisible_core.juggler.actions import Actions
|
||||
from invisible_core.juggler.deadline import Deadline
|
||||
from . import dialogs
|
||||
from . import _bindings, dialogs
|
||||
from ._threads import ThreadStarterLease
|
||||
from .pointer import Pointer
|
||||
from .dispatcher import (Dispatcher, ExpectNotMet, ProtocolException,
|
||||
Server, current_call)
|
||||
@@ -547,6 +549,12 @@ def _run_callers_code(injected: InjectedScript, frame_id: str, params: Dict,
|
||||
return remote
|
||||
|
||||
|
||||
def _round_px(value: float) -> int:
|
||||
"""To the nearest whole pixel, halves up (Python's `round` goes to even: 0.5 -> 0, 1.5 -> 2)."""
|
||||
import math
|
||||
return int(math.floor(value + 0.5))
|
||||
|
||||
|
||||
class ElementHandleDispatcher(Dispatcher):
|
||||
TYPE = "ElementHandle"
|
||||
METHODS = {
|
||||
@@ -560,6 +568,7 @@ class ElementHandleDispatcher(Dispatcher):
|
||||
"inputValue": "op_input_value",
|
||||
"getAttribute": "op_get_attribute",
|
||||
"scrollIntoViewIfNeeded": "op_scroll_into_view",
|
||||
"screenshot": "op_screenshot",
|
||||
"ownerFrame": "op_owner_frame",
|
||||
"contentFrame": "op_content_frame",
|
||||
"getProperty": "op_get_property",
|
||||
@@ -799,6 +808,44 @@ class ElementHandleDispatcher(Dispatcher):
|
||||
params.get("rect"))
|
||||
return None
|
||||
|
||||
def op_screenshot(self, params: Dict) -> Any:
|
||||
"""A picture of this element: scroll it into view, take its box, and
|
||||
ask the page's own screenshot for exactly that rectangle.
|
||||
|
||||
⛔ THE BOX IS IN THE MAIN FRAME'S VIEWPORT, AND THE ENGINE'S CLIP IS IN
|
||||
DOCUMENT COORDINATES. `Page.getContentQuads` answers in the main frame's
|
||||
space whatever frame the element is in (it carries a node up every
|
||||
`<iframe>`, across processes), so the same box is right for an element
|
||||
of the page, of a frame of another site and of a frame nested in it.
|
||||
What is missing to reach the document is the main frame's scroll, read
|
||||
after the element has been scrolled in. The screenshot itself is the
|
||||
page's (`PageDispatcher.op_screenshot`): a second path would be a second
|
||||
place for the type, the quality and the scale to disagree.
|
||||
|
||||
The rectangle is rounded to whole pixels outward-stable, the way
|
||||
Playwright's screenshotter does: the left and top edges to the nearest
|
||||
pixel, the size from the rounded right and bottom edges.
|
||||
"""
|
||||
# An element with no layout object (display: none, detached) cannot be scrolled to: the engine says so
|
||||
# with an exception of its own. For the caller that is the same answer as an empty box.
|
||||
try:
|
||||
self.injected.scroll_into_view(self.frame.frame_id, self.object_id, None)
|
||||
box = self.injected.bounding_box(self.frame.frame_id, self.object_id)
|
||||
except Exception:
|
||||
box = None
|
||||
if not box or box["width"] <= 0 or box["height"] <= 0:
|
||||
raise ValueError("Element is not visible")
|
||||
page = self.page
|
||||
scroll = page.injected.evaluate(
|
||||
page.frame.frame_id, "({x: window.scrollX, y: window.scrollY})") or {"x": 0, "y": 0}
|
||||
left = _round_px(box["x"] + scroll["x"])
|
||||
top = _round_px(box["y"] + scroll["y"])
|
||||
right = _round_px(box["x"] + scroll["x"] + box["width"])
|
||||
bottom = _round_px(box["y"] + scroll["y"] + box["height"])
|
||||
clip = {"x": left, "y": top,
|
||||
"width": max(right - left, 1), "height": max(bottom - top, 1)}
|
||||
return page.op_screenshot(dict(params, clip=clip))
|
||||
|
||||
def op_owner_frame(self, params: Dict) -> Any:
|
||||
return {"frame": self.frame.channel}
|
||||
|
||||
@@ -1058,6 +1105,9 @@ class FrameDispatcher(Dispatcher):
|
||||
#: The load states the client has been told this frame has (the initializer's, then each `loadstate`): what the hand-over of the
|
||||
#: page from its buffer to its dispatcher compares the lifecycle's states with (`PageDispatcher._reconcile_frame`).
|
||||
self.told_states = set(load_states or ["commit"])
|
||||
#: The address the client has been TOLD (the initializer's, then each `navigated` once it has gone up). `url`
|
||||
#: is set a moment before the event is sent; a BindingCall waits for this one (`_announce_binding`).
|
||||
self.committed_url = url
|
||||
#: Same reason, and both navigation events report it: a same-document
|
||||
#: navigation carries no name, so it has to repeat the one the frame
|
||||
#: already has rather than blank it.
|
||||
@@ -2684,6 +2734,48 @@ def _target_is_gone(error: BaseException) -> bool:
|
||||
return True
|
||||
text = str(error).lower()
|
||||
return "cannot find session" in text or "target closed" in text or "session closed" in text
|
||||
class BindingCallDispatcher(Dispatcher):
|
||||
"""One call of an exposed function, waiting for the client's answer.
|
||||
|
||||
The client runs the Python function and sends `resolve` or `reject`; the answer goes back into the promise the page is
|
||||
holding, in the context the call came from (`controller.deliver`, see `_bindings`)."""
|
||||
|
||||
TYPE = "BindingCall"
|
||||
METHODS = {"resolve": "op_resolve", "reject": "op_reject"}
|
||||
|
||||
def __init__(self, server, page: "PageDispatcher", frame: "FrameDispatcher", context_id: str, native: str,
|
||||
name: str, seq: int, args: List[Any]) -> None:
|
||||
self.page = page
|
||||
self.context_id = context_id
|
||||
self.native = native
|
||||
self.seq = seq
|
||||
super().__init__(server, page, {
|
||||
"frame": frame.channel, "name": name,
|
||||
"args": [_serialize(a) for a in args]})
|
||||
|
||||
@staticmethod
|
||||
def _deliver(page: "PageDispatcher", context_id: str, native: str, seq: int, ok: bool, value: Any) -> None:
|
||||
end = page._binding_ends.get((context_id, native))
|
||||
if end is None:
|
||||
return # the document left (or never handed its end over): nobody is waiting
|
||||
try:
|
||||
page.injected.call_raw(context_id, _bindings.DELIVER,
|
||||
[{"objectId": end}, {"value": seq}, {"value": ok}, {"value": value}],
|
||||
by_value=True, timeout=10.0)
|
||||
except Exception:
|
||||
pass # the document left: nobody is waiting for the answer
|
||||
|
||||
def op_resolve(self, params: Dict) -> Any:
|
||||
self._deliver(self.page, self.context_id, self.native, self.seq, True, _deserialize(params.get("result")))
|
||||
self.dispose()
|
||||
return None
|
||||
|
||||
def op_reject(self, params: Dict) -> Any:
|
||||
error = (params.get("error") or {}).get("error") or {}
|
||||
self._deliver(self.page, self.context_id, self.native, self.seq, False,
|
||||
error.get("message") or error.get("name") or "binding failed")
|
||||
self.dispose()
|
||||
return None
|
||||
|
||||
|
||||
class PageDispatcher(Dispatcher):
|
||||
@@ -2718,8 +2810,6 @@ class PageDispatcher(Dispatcher):
|
||||
"touchscreenTap": "op_touchscreen_tap",
|
||||
"requests": "op_requests",
|
||||
"__waitInfo__": "op_noop",
|
||||
"reject": "op_binding_reply",
|
||||
"resolve": "op_binding_reply",
|
||||
"requestGC": "op_request_gc",
|
||||
"addScriptTag": "op_add_script_tag",
|
||||
"addStyleTag": "op_add_style_tag",
|
||||
@@ -2923,6 +3013,14 @@ class PageDispatcher(Dispatcher):
|
||||
#: to answer after a reader's pause, see `dialogs.plan_answer_ms`.
|
||||
self._dialogs_open: Dict[str, Any] = {}
|
||||
self._dialogs_seen = 0
|
||||
#: `page.expose_binding` names -> the script that makes the function (see `_bindings`).
|
||||
self._exposed: Dict[str, str] = {}
|
||||
#: The calls of exposed functions, announced in the order they were made, by one worker (see `_on_binding_called`).
|
||||
self._binding_jobs: "queue.Queue" = queue.Queue()
|
||||
self._binding_running = False
|
||||
self._binding_lock = threading.Lock()
|
||||
#: (execution context, native name) -> objectId of the function that answers the calls made there (see `_bindings`).
|
||||
self._binding_ends: Dict[tuple, str] = {}
|
||||
self.main_frame_id = self._main_frame_unless_gone()
|
||||
# ⛔ The Frame is created BEFORE the Page and adopted after: the Page
|
||||
# initializer has to name a mainFrame the client can already resolve.
|
||||
@@ -3179,6 +3277,7 @@ class PageDispatcher(Dispatcher):
|
||||
frame.url, frame.name, frame.told_commit = url, name, commit
|
||||
navigation = known._commits[-1][1] if known._commits else None
|
||||
frame.emit("navigated", {"url": url, "name": name, "newDocument": self.navigation_document(navigation)})
|
||||
frame.committed_url = url
|
||||
for state in self.CANON_STATES:
|
||||
if state in known.states and state not in frame.told_states:
|
||||
frame.emit("loadstate", {"add": state})
|
||||
@@ -3261,6 +3360,7 @@ class PageDispatcher(Dispatcher):
|
||||
"newDocument": self.navigation_document(navigation),
|
||||
})
|
||||
child.emit("loadstate", {"add": "commit"})
|
||||
child.committed_url = child.url
|
||||
|
||||
#: Events held while the page is being built. The birth of a page is a
|
||||
#: burst of a few dozen; a page that never finishes building must not
|
||||
@@ -3441,9 +3541,11 @@ class PageDispatcher(Dispatcher):
|
||||
# Doing it here would block the reader waiting for a message the
|
||||
# reader is the one who has to receive.
|
||||
# ⛔ AND NOT STARTED HERE EITHER: `Thread.start` waits for the new thread to run, and this is the reader.
|
||||
# The browser's thread starter does it (`_ThreadStarter`).
|
||||
# The browser's thread starter does it (`ThreadStarter`).
|
||||
self.context.browser.thread_starter.start(
|
||||
target=self._announce_file_chooser, args=(params,))
|
||||
elif method == "Page.bindingCalled":
|
||||
self._on_binding_called(params)
|
||||
elif method == "Page.crashed":
|
||||
self.emit("crash")
|
||||
# ⛔ `Page.frameAttached` / `Page.frameDetached` ARE NOT READ HERE: the
|
||||
@@ -3472,6 +3574,15 @@ class PageDispatcher(Dispatcher):
|
||||
# cannot disagree about a request, a redirect or a replay.
|
||||
if method == "Network.requestWillBeSent" and params.get("isIntercepted"):
|
||||
self._let_through(params.get("requestId"))
|
||||
elif (method == "Network.requestWillBeSent" and params.get("method") == "OPTIONS"
|
||||
and not params.get("isIntercepted")):
|
||||
# ⛔ AS PLAYWRIGHT'S OWN SERVER (ffNetworkManager `_onRequestWillBeSent`: `if (event.method === "OPTIONS" &&
|
||||
# !event.isIntercepted) return;`): an OPTIONS request that no route holds is a CORS preflight, which the browser
|
||||
# makes for the page and the page cannot see; a client never hears of it. Reported here, a page with a
|
||||
# preflighted fetch showed one request more than on stock Firefox (10 per page on cnbc.com, 18 on scmp.com),
|
||||
# in `page.on("request")`, in `route`, in a request counter. Its response and its end find no request and are
|
||||
# dropped with it.
|
||||
pass
|
||||
elif method == "Network.requestWillBeSent":
|
||||
request = RequestDispatcher(self.server, self, params)
|
||||
self._requests[params.get("requestId")] = request
|
||||
@@ -4116,39 +4227,83 @@ class PageDispatcher(Dispatcher):
|
||||
def op_requests(self, params: Dict) -> Any:
|
||||
return {"requests": [r.channel for r in self._request_log]}
|
||||
|
||||
def op_binding_reply(self, params: Dict) -> Any:
|
||||
"""⛔ `resolve` and `reject` are the REPLY half of `expose_binding`,
|
||||
and they are unreachable while that is refused: they arrive on a
|
||||
BindingCall object, and no BindingCall is ever created. This exists so
|
||||
the refusal names the feature instead of answering "Page has no method
|
||||
resolve", which would send the reader looking in the wrong place."""
|
||||
raise ProtocolException(
|
||||
"this is the reply path of expose_binding(), which is not "
|
||||
"implemented: no binding is ever installed, so nothing can call "
|
||||
"back into one")
|
||||
|
||||
# ── expose_binding / expose_function ────────────────────────────────────
|
||||
def op_expose_binding(self, params: Dict) -> Any:
|
||||
"""`expose_binding` / `expose_function`.
|
||||
"""`page.expose_binding` / `page.expose_function`: the function `name` on this page, in the page's own world
|
||||
(a site can see it, which is what the caller asked for, and nothing else: see `_bindings`). The engine installs it
|
||||
in every document of the page, present and future, in every process the frames live in."""
|
||||
name = params["name"]
|
||||
native = self.context.binding_native(name)
|
||||
self.context.require_binding_engine()
|
||||
self._exposed[name] = native
|
||||
self.send("Page.addBinding", {"name": native, "script": _bindings.install_script(native, name)})
|
||||
|
||||
⛔ THE PAGE-FACING HALF IS NOT THE HARD PART. Installing a function on
|
||||
the page is one init script; what makes this a real feature is the
|
||||
REPLY path - the page calls it, the server raises `bindingCalled`, the
|
||||
client runs Python, and the answer has to travel back into the promise
|
||||
the page is holding. That is what `reject` and `resolve` are for, and
|
||||
they are only reachable through the BindingCall object this creates.
|
||||
def undo() -> None:
|
||||
self._exposed.pop(name, None)
|
||||
self.send("Page.addBinding", {"name": native, "script": _bindings.remove_script(native, name)})
|
||||
handle = DisposableDispatcher(self.server, self, undo)
|
||||
return {"disposable": handle.channel}
|
||||
|
||||
⛔ AND THE FUNCTION MUST LIVE IN THE PAGE'S WORLD. Installed behind the
|
||||
Xray it would be invisible to the site, which is the whole point of the
|
||||
call. Juggler's `Page.addBinding` does that, so the world is not ours
|
||||
to choose here - which is also why it cannot be hidden from the page:
|
||||
a binding is a name the site can enumerate, and a caller asking for one
|
||||
is asking for that trade.
|
||||
"""
|
||||
raise ProtocolException(
|
||||
"expose_binding() is not implemented yet: the page-facing half is "
|
||||
"one init script, but the reply path - bindingCalled, then resolve "
|
||||
"or reject into the promise the page holds - is not wired, and a "
|
||||
"binding that never answers hangs the page that called it")
|
||||
def _on_binding_called(self, params: Dict) -> None:
|
||||
"""The page called an exposed function. Announced to the client from a worker, in order, and not here.
|
||||
|
||||
OFF THE READER THREAD, because the announcement may need an answer from the engine (the address of the document
|
||||
that called, see `_announce_binding`), which only the reader can deliver. In order, because two calls made one
|
||||
after the other are announced one after the other: one worker per page, started by the first call and gone after
|
||||
thirty idle seconds."""
|
||||
payload = params.get("payload")
|
||||
if isinstance(payload, dict) and payload.get("bindingEnd"):
|
||||
# The page-side end of a binding, handed over by its script once, before any call: kept for the answers.
|
||||
self._binding_ends[(params.get("executionContextId"), params.get("name"))] = payload["bindingEnd"]
|
||||
return
|
||||
call = _bindings.read_call(payload)
|
||||
if call is None:
|
||||
return
|
||||
self._binding_jobs.put((params.get("executionContextId"), call))
|
||||
with self._binding_lock:
|
||||
if self._binding_running:
|
||||
return
|
||||
self._binding_running = True
|
||||
# ⛔ NOT `Thread.start` HERE: this is the reader, and the browser's thread starter does it (`ThreadStarter`).
|
||||
self.context.browser.thread_starter.start(target=self._binding_loop)
|
||||
|
||||
def _binding_loop(self) -> None:
|
||||
while True:
|
||||
try:
|
||||
context_id, call = self._binding_jobs.get(timeout=30.0)
|
||||
except queue.Empty:
|
||||
with self._binding_lock:
|
||||
if self._binding_jobs.empty():
|
||||
self._binding_running = False
|
||||
return
|
||||
continue
|
||||
try:
|
||||
self._announce_binding(context_id, *call)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _announce_binding(self, context_id: str, name: str, seq: int, args: List[Any]) -> None:
|
||||
"""A BindingCall to the client, or an error to the page when nobody exposed `name` here (left alone the
|
||||
page's promise would wait for ever).
|
||||
|
||||
THE FRAME THE CLIENT IS TOLD OF HAS TO HAVE ITS ADDRESS. A script that calls the function in its first lines
|
||||
runs before the lifecycle has told the client the document committed, and the call would name a frame whose
|
||||
`url` is still the empty one. The address is asked of the document that called, and the call waits (a second
|
||||
at most) until the client has been told that same address."""
|
||||
injected = self.injected
|
||||
native = self._exposed.get(name) or self.context._exposed.get(name)
|
||||
if native is None:
|
||||
return # nothing exposed under this name here: the page's promise cannot be answered, and was not offered
|
||||
frame = self.frame_for(injected.frame_of_context(context_id) or self.frame.frame_id)
|
||||
try:
|
||||
href = injected.call_raw(context_id, "() => location.href", [], by_value=True, timeout=5.0).get("value")
|
||||
except Exception:
|
||||
href = None
|
||||
end = time.monotonic() + 1.0
|
||||
while href and frame.committed_url != href and time.monotonic() < end:
|
||||
time.sleep(0.005)
|
||||
binding = BindingCallDispatcher(self.server, self, frame, context_id, native, name, seq, args)
|
||||
self.emit("bindingCall", {"binding": binding.channel})
|
||||
|
||||
def op_bring_to_front(self, params: Dict) -> Any:
|
||||
self.send("Page.bringToFront", {})
|
||||
@@ -4342,9 +4497,10 @@ class PageDispatcher(Dispatcher):
|
||||
# too, because `_connection.py` only drops an object when it is told
|
||||
# to. The driver disposes Page, BrowserContext, Browser, ElementHandle
|
||||
# and APIRequestContext; the only one we were missing was Page, which
|
||||
# is why `diff_protocol.py` grew a fifth dimension to see it: the other
|
||||
# four compare `__create__`, initializers, events and parentage, and
|
||||
# the event comparison skips every method starting with `__`.
|
||||
# is why the protocol comparison that used to exist needed a fifth
|
||||
# dimension to see it: the other four compared `__create__`, initializers,
|
||||
# events and parentage, and the event comparison skips every method
|
||||
# starting with `__`.
|
||||
|
||||
|
||||
|
||||
@@ -4488,6 +4644,7 @@ class BrowserContextDispatcher(Dispatcher):
|
||||
"close": "op_close",
|
||||
"updateSubscription": "op_noop",
|
||||
"addInitScript": "op_context_init_script",
|
||||
"exposeBinding": "op_expose_binding",
|
||||
"addCookies": "op_add_cookies",
|
||||
"cookies": "op_cookies",
|
||||
"clearCookies": "op_clear_cookies",
|
||||
@@ -4545,11 +4702,51 @@ class BrowserContextDispatcher(Dispatcher):
|
||||
#: The caller's context-level init scripts, in order. The engine's
|
||||
#: command replaces the list, so the accumulation lives here.
|
||||
self._init_scripts: List[str] = []
|
||||
#: `context.expose_binding` names -> the engine's native name for each (see `binding_native`).
|
||||
self._exposed: Dict[str, str] = {}
|
||||
self._native_names: Dict[str, str] = {}
|
||||
self._transport_lock = threading.Lock()
|
||||
|
||||
@property
|
||||
def conn(self) -> "juggler.Connection":
|
||||
return self.browser.conn
|
||||
|
||||
def binding_native(self, name: str) -> str:
|
||||
"""The name of the engine's native function for the exposed function `name`: unique to this context and this
|
||||
session, chosen here (the page never sees it: its script takes it off the window before any script of the page)."""
|
||||
with self._transport_lock:
|
||||
native = self._native_names.get(name)
|
||||
if native is None:
|
||||
native = "__%s_%d" % (self.browser.binding_token, len(self._native_names))
|
||||
self._native_names[name] = native
|
||||
return native
|
||||
|
||||
def require_binding_engine(self) -> None:
|
||||
"""Exposed functions need the engine that hands the page-side end of a binding over and has `Page.addBinding`.
|
||||
With an engine that does not, they REFUSE: the way around it is a global on the window that a page can list,
|
||||
and that is the tell this design exists to avoid."""
|
||||
if not _bindings.engine_supports(self.browser.engine_dir):
|
||||
raise ProtocolException(
|
||||
"expose_function() and expose_binding() need a newer engine than this one (the one with "
|
||||
"Page.addBinding and the binding that hands its end over): this engine would have to leave a "
|
||||
"name on the page's window to answer the calls, and a page can list its globals")
|
||||
|
||||
def op_expose_binding(self, params: Dict) -> Any:
|
||||
"""`context.expose_binding` / `context.expose_function`: the function `name` on every page of the context,
|
||||
present and future. The engine installs it in every document of every page, in every process (see
|
||||
`_bindings`); one registration, no init script, nothing run by this server in the documents."""
|
||||
name = params["name"]
|
||||
native = self.binding_native(name)
|
||||
self.require_binding_engine()
|
||||
self._exposed[name] = native
|
||||
self._browser_send("Browser.addBinding", {"name": native, "script": _bindings.install_script(native, name)})
|
||||
|
||||
def undo() -> None:
|
||||
self._exposed.pop(name, None)
|
||||
self._browser_send("Browser.addBinding", {"name": native, "script": _bindings.remove_script(native, name)})
|
||||
handle = DisposableDispatcher(self.server, self, undo)
|
||||
return {"disposable": handle.channel}
|
||||
|
||||
def released(self) -> None:
|
||||
"""⛔ THE BROWSER'S LIST LET GO TOO. Every way a context ends passes
|
||||
here, and `browser.contexts` kept each one - with its options, its
|
||||
@@ -4583,11 +4780,6 @@ class BrowserContextDispatcher(Dispatcher):
|
||||
self._browser_send("Browser.setInitScripts",
|
||||
{"scripts": [{"script": s}
|
||||
for s in self._init_scripts]})
|
||||
for page in list(self.pages):
|
||||
try:
|
||||
page.injected.add_init_script(source)
|
||||
except Exception:
|
||||
pass
|
||||
handle = DisposableDispatcher(self.server, self,
|
||||
lambda: self._remove_init_script(source))
|
||||
return {"disposable": handle.channel}
|
||||
@@ -4599,11 +4791,6 @@ class BrowserContextDispatcher(Dispatcher):
|
||||
self._browser_send("Browser.setInitScripts",
|
||||
{"scripts": [{"script": s}
|
||||
for s in self._init_scripts]})
|
||||
for page in list(self.pages):
|
||||
try:
|
||||
page.injected.remove_init_script(source)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def op_set_storage_state(self, params: Dict) -> Any:
|
||||
"""⛔ COOKIES ONLY, and it refuses the rest rather than dropping it.
|
||||
@@ -4830,51 +5017,6 @@ NO_OVERRIDE = "no-override"
|
||||
NO_OVERRIDE_OPTIONS = ("colorScheme", "reducedMotion", "forcedColors")
|
||||
|
||||
|
||||
class _ThreadStarter:
|
||||
"""The ONE long-lived thread that starts the other threads the engine's events ask for.
|
||||
|
||||
⛔ NO `Thread.start` ON THE CONNECTION'S READER THREAD. `Thread.start` does not return until the new thread is running
|
||||
(`self._started.wait()`), and on Windows under load that wait is milliseconds long: it was the larger part of the reader's delay, and
|
||||
every millisecond the reader is late is a millisecond a `networkidle` quiet is measured late (7 misses in 400 with four browsers at
|
||||
once, none in 400 when the start did not wait). A listener that runs on the reader and needs work done elsewhere hands it to `start`
|
||||
here: a `Thread` that is only BUILT on the reader (building waits for nothing) goes into a queue, and this thread starts it.
|
||||
|
||||
It starts threads and does not run the work itself, on purpose: an adoption waits for the engine as long as the engine takes (a popup
|
||||
whose destination never answers is waited for without a limit), and a worker that ran it would hold every later adoption behind it,
|
||||
`new_page()` included. Each piece of work keeps the thread of its own and the name it always had.
|
||||
"""
|
||||
|
||||
def __init__(self, on_error: Callable[[str], None]) -> None:
|
||||
self._queue: "queue.SimpleQueue" = queue.SimpleQueue()
|
||||
self._on_error = on_error
|
||||
self._stopped = False
|
||||
self._thread = threading.Thread(target=self._run, daemon=True, name="invpw-thread-starter")
|
||||
self._thread.start()
|
||||
|
||||
def start(self, **thread_arguments: Any) -> None:
|
||||
"""Called from any thread, the reader's included: builds the thread and queues it. Never waits."""
|
||||
if self._stopped:
|
||||
return
|
||||
self._queue.put(threading.Thread(daemon=True, **thread_arguments))
|
||||
|
||||
def stop(self) -> None:
|
||||
self._stopped = True
|
||||
self._queue.put(None)
|
||||
|
||||
def _run(self) -> None:
|
||||
while True:
|
||||
thread = self._queue.get()
|
||||
if thread is None:
|
||||
return
|
||||
try:
|
||||
thread.start()
|
||||
except Exception as failure:
|
||||
try:
|
||||
self._on_error("%s could not be started: %s" % (thread.name, failure))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class BrowserDispatcher(Dispatcher):
|
||||
TYPE = "Browser"
|
||||
METHODS = {"newContext": "op_new_context", "close": "op_close",
|
||||
@@ -4947,6 +5089,10 @@ class BrowserDispatcher(Dispatcher):
|
||||
#: Where this session measures a proxy's UDP exit from (the launch's `udp_stun_servers`, "ip:port"
|
||||
#: strings; None = the two public defaults): the launch and every context proxy use the same list.
|
||||
self.udp_stun_servers = udp_stun_servers
|
||||
#: Chosen for this browser: the prefix of the native names of its exposed functions (see `_bindings`), and the
|
||||
#: directory of its engine (set by `launch`), which says whether the engine has what they need.
|
||||
self.binding_token = secrets.token_hex(6)
|
||||
self.engine_dir = ""
|
||||
#: Whether this browser's pages walk the pointer onto their targets
|
||||
#: (`pointer.py`): the launcher chose the Python generator. Off for a
|
||||
#: browser built without saying so, which acts as the caller wrote.
|
||||
@@ -5063,8 +5209,9 @@ class BrowserDispatcher(Dispatcher):
|
||||
# subscriber seeing an event before this one records the session, and
|
||||
# recording earlier can only shorten the window in which `session_for`
|
||||
# is waiting for something that has already arrived.
|
||||
self._starter = _ThreadStarter(
|
||||
lambda why: conn.handler_errors.append(why) if len(conn.handler_errors) < 32 else None)
|
||||
# ⛔ NOT A STARTER OF ITS OWN: the connection's server owns the one (`Server.thread_starter`), and this is the browser's lease on
|
||||
# it, ended by the browser's connection.
|
||||
self._starter = ThreadStarterLease(lambda: server.thread_starter)
|
||||
conn.add_close_listener(self._starter.stop)
|
||||
conn.add_listener(self._route_browser_event)
|
||||
# The last step of starting the browser, under what is left of the
|
||||
@@ -5090,8 +5237,8 @@ class BrowserDispatcher(Dispatcher):
|
||||
self._adopt_enabled = True
|
||||
|
||||
@property
|
||||
def thread_starter(self) -> "_ThreadStarter":
|
||||
"""The one thread that starts threads on behalf of the engine's reader (`_ThreadStarter`)."""
|
||||
def thread_starter(self) -> "ThreadStarterLease":
|
||||
"""What starts threads on behalf of the engine's reader: the connection's one starter (`Server.thread_starter`), while this browser lives."""
|
||||
return self._starter
|
||||
|
||||
def require_interception(self, what: str) -> None:
|
||||
@@ -6153,6 +6300,7 @@ class BrowserTypeDispatcher(Dispatcher):
|
||||
except BaseException:
|
||||
conn.close()
|
||||
raise
|
||||
browser.engine_dir = os.path.dirname(str(executable))
|
||||
return {"browser": browser.channel}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ names the guid it creates, and that is the dispatcher's job, not the pool's.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import _thread as _raw_thread
|
||||
import asyncio
|
||||
import os
|
||||
import queue
|
||||
@@ -50,6 +51,7 @@ import threading
|
||||
import traceback
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from invisible_core._offloop import off_the_loop
|
||||
from invisible_playwright._pw._impl._helper import parse_error
|
||||
from invisible_playwright._pw._impl._transport import Transport
|
||||
|
||||
@@ -101,15 +103,33 @@ class InProcessTransport(Transport):
|
||||
self._stopped = threading.Event()
|
||||
self._stopped_future: asyncio.Future = loop.create_future()
|
||||
self._threads: list = []
|
||||
#: The thread that runs the server's shutdown (see `request_stop`); None until the stop is requested.
|
||||
self._shutdown_thread: Optional[threading.Thread] = None
|
||||
#: Set once the raw thread has begun (or failed to begin) the shutdown thread, so the join below knows whether to wait.
|
||||
self._shutdown_begun = threading.Event()
|
||||
server.attach(self)
|
||||
|
||||
# ── the five methods the seam declares ──────────────────────────────────
|
||||
async def connect(self) -> None:
|
||||
for i in range(self.WORKERS):
|
||||
t = threading.Thread(target=self._work, name="juggler-%d" % i,
|
||||
daemon=True)
|
||||
t.start()
|
||||
self._threads.append(t)
|
||||
"""⛔ NO `Thread.start` ON THE LOOP, NOT EVEN ONE. `connect` is a coroutine of the caller's event loop, and
|
||||
`Thread.start` does not return until the new thread is running (`self._started.wait()`): measured with four
|
||||
browsers in one process under CPU load on Windows, the four starts held the loop ~200 ms per launch (4.4% of the
|
||||
main thread's wall time), the same wait the engine's reader is spared by the same starter.
|
||||
|
||||
The four `Thread` objects are only BUILT here (building waits for nothing), so `request_stop` still knows how many
|
||||
sentinels the pool needs, and the server's one starter (`Server.thread_starter`, shared with every browser's reader) starts them. Messages sent before a worker runs wait in the queue and are
|
||||
answered when it does, which is what `send` always relied on."""
|
||||
self._threads = [
|
||||
threading.Thread(target=self._work, name="juggler-%d" % i, daemon=True)
|
||||
for i in range(self.WORKERS)]
|
||||
server_starter = self._server.thread_starter
|
||||
for t in self._threads:
|
||||
server_starter.start_built(t, self._workers_could_not_start)
|
||||
|
||||
def _workers_could_not_start(self, why: str) -> None:
|
||||
"""No worker may ever answer a queued message, so the session cannot go on: end it, the way a transport that lost
|
||||
its other end ends, instead of leaving every call to wait for a reply that cannot come."""
|
||||
self.request_stop()
|
||||
|
||||
async def run(self) -> None:
|
||||
"""⛔ Must not return until the transport is stopped: `Connection.run`
|
||||
@@ -117,6 +137,14 @@ class InProcessTransport(Transport):
|
||||
await self._stopped_future
|
||||
|
||||
def request_stop(self) -> None:
|
||||
"""⛔ THE SERVER'S SHUTDOWN IS NOT RUN BY THE CALLER, and the caller is usually the user's event loop. `server.shutdown()` runs the
|
||||
hooks of the session (the engine's `conn.close`, which waits for its processes to exit) and then the removal of its directories:
|
||||
seconds of waiting, and on the loop they stopped every other browser of the process for as long as they took (measured with
|
||||
four browsers in one process). It runs on a thread of its own, NOT a daemon: a close that the interpreter's exit could cut short
|
||||
is a browser left half closed, a leak. `wait_until_stopped` is where it is waited for, and off the loop too.
|
||||
|
||||
The thread is begun by a raw thread, as the server's starter is: `Thread.start` does not return until the new thread runs, and
|
||||
that wait on a loaded machine is the loop's own (see `connect`)."""
|
||||
if self._stopped.is_set():
|
||||
return
|
||||
self._stopped.set()
|
||||
@@ -124,21 +152,58 @@ class InProcessTransport(Transport):
|
||||
# a flag.
|
||||
for _ in self._threads:
|
||||
self._queue.put(None)
|
||||
|
||||
def shutdown() -> None:
|
||||
try:
|
||||
self._server.shutdown()
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
# The stop is settled when the shutdown has ended, as it always was: `run` returns after the hooks.
|
||||
try:
|
||||
self._loop.call_soon_threadsafe(self._settle)
|
||||
except RuntimeError:
|
||||
pass # the loop is closed: nobody waits for the stop any more
|
||||
|
||||
thread = threading.Thread(target=shutdown, name="juggler-shutdown")
|
||||
self._shutdown_thread = thread
|
||||
# Not through the server's `ThreadStarter`: `Server.shutdown` stops it, and a starter that has stopped drops what it is handed,
|
||||
# which here would be the shutdown itself. A raw thread begins this one (the caller returns at once).
|
||||
try:
|
||||
self._server.shutdown()
|
||||
except Exception:
|
||||
pass
|
||||
if not self._stopped_future.done():
|
||||
self._loop.call_soon_threadsafe(self._settle)
|
||||
_raw_thread.start_new_thread(self._begin, (thread, shutdown))
|
||||
except RuntimeError:
|
||||
self._shutdown_begun.set()
|
||||
shutdown() # no thread can be made: the shutdown still has to happen, as it did before
|
||||
|
||||
def _begin(self, thread: threading.Thread, shutdown: Any) -> None:
|
||||
try:
|
||||
thread.start()
|
||||
except BaseException:
|
||||
self._shutdown_begun.set()
|
||||
shutdown() # on this raw thread, which is not the loop's
|
||||
else:
|
||||
self._shutdown_begun.set()
|
||||
|
||||
def _settle(self) -> None:
|
||||
if not self._stopped_future.done():
|
||||
self._stopped_future.set_result(None)
|
||||
|
||||
def _join_workers(self) -> None:
|
||||
"""What `wait_until_stopped` waits for besides the stop itself: the workers (and the shutdown thread, which has settled the stop
|
||||
and is ending). Blocking, so never on the loop."""
|
||||
for t in self._threads:
|
||||
# A worker the starter never started (the transport stopped first) has nothing to join.
|
||||
if t.is_alive():
|
||||
t.join(timeout=5)
|
||||
shutdown = self._shutdown_thread
|
||||
if shutdown is not None:
|
||||
self._shutdown_begun.wait(5) # the raw thread that begins it may be a moment late
|
||||
if shutdown.is_alive():
|
||||
shutdown.join(timeout=5)
|
||||
|
||||
async def wait_until_stopped(self) -> None:
|
||||
await self._stopped_future
|
||||
for t in self._threads:
|
||||
t.join(timeout=5)
|
||||
await off_the_loop(self._join_workers)
|
||||
|
||||
def send(self, message: Dict) -> None:
|
||||
"""⛔ ENQUEUE ONLY. Running the operation here would run it on the
|
||||
@@ -282,8 +347,8 @@ def make_transport(loop: asyncio.AbstractEventLoop) -> "InProcessTransport":
|
||||
"only transport - unset %s and it runs. To get the old arm back "
|
||||
"for a COMPARISON (the only thing it was still for): check out "
|
||||
"the last commit that carried it into a git worktree and point "
|
||||
"INVPW_DRIVER_TREE at it. Both `judge_both_transports.py` and "
|
||||
"`diff_protocol.py` read that variable." % CHOICE_ENV)
|
||||
"INVPW_DRIVER_TREE at it, which `scripts/capture_protocol.py` "
|
||||
"reads." % CHOICE_ENV)
|
||||
from .server import JugglerServer
|
||||
if (os.environ.get(WIRE_ENV) or "").strip().lower() == "json":
|
||||
return JsonWireTransport(loop, JugglerServer())
|
||||
|
||||
@@ -26,7 +26,7 @@ What each 1.62 addition becomes here:
|
||||
target into view first, which is `auto`; `none` asks to act on the element
|
||||
where it is, and honouring it needs an action path that does not scroll,
|
||||
which does not exist. The action still happens, scrolled.
|
||||
* `noGlobal` on exposeBinding: moot, `exposeBinding` is refused as a whole.
|
||||
* `noGlobal` on exposeBinding: not read. The function is always defined on the page's `window`, as `expose_function` documents.
|
||||
* `type` "webp" on screenshot: REFUSED. The engine captures PNG and JPEG, and
|
||||
answering a webp request with PNG bytes would hand the caller a file that
|
||||
is not the format it asked for.
|
||||
|
||||
@@ -102,5 +102,5 @@ class Transport(ABC):
|
||||
#
|
||||
# ⛔ To get the old arm back for a comparison - which is the only thing it
|
||||
# was still for - check out the last commit that carried it into a git
|
||||
# worktree and point `INVPW_DRIVER_TREE` at it. `judge_both_transports.py`
|
||||
# and `diff_protocol.py` both read that variable.
|
||||
# worktree and point `INVPW_DRIVER_TREE` at it. `scripts/capture_protocol.py`
|
||||
# reads that variable.
|
||||
@@ -20,6 +20,7 @@ the two classes is `await`, and nothing else belongs in this file.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from ._cursor import (ENGINE_BINARY,
|
||||
ENGINE_PYTHON,
|
||||
@@ -436,19 +437,72 @@ class CommonLaunch:
|
||||
``self._virtual_display`` is the fact ``_build_prefs`` reads to decide
|
||||
whether the desktop workarounds apply (B172).
|
||||
"""
|
||||
pw_headless, vd = self._plan_headless()
|
||||
if vd is not None:
|
||||
vd.start()
|
||||
self._virtual_display = vd
|
||||
return pw_headless
|
||||
|
||||
def _plan_headless(self) -> "tuple[bool, Any]":
|
||||
"""THE decision, made once for both APIs: ``(pw_headless, display)``.
|
||||
|
||||
``pw_headless`` is what Playwright is told; ``display`` is the hidden
|
||||
surface the caller must START (and then record in
|
||||
``self._virtual_display``, which `_build_prefs` reads), or None when
|
||||
none is wanted: headless off, true headless asked for, or a platform
|
||||
with no display to make. The two callers only decide WHERE the start
|
||||
runs - inline in the sync client, in a worker in the async one - so
|
||||
the decision cannot drift between them (B172 was one such drift).
|
||||
"""
|
||||
if not self._headless:
|
||||
return False
|
||||
return False, None
|
||||
# Opt-in TRUE headless, shared with the async class. It existed on the
|
||||
# async API ONLY until 2026-07-27: a documented env var that worked
|
||||
# depending on which entry point the caller happened to pick, which is
|
||||
# the same drift that shipped the process-leak fix to half the users.
|
||||
if true_headless_requested():
|
||||
return True
|
||||
vd = make_virtual_display()
|
||||
if vd is not None:
|
||||
vd.start()
|
||||
self._virtual_display = vd
|
||||
return False
|
||||
return True, None
|
||||
return False, make_virtual_display()
|
||||
|
||||
async def _resolve_headless_async(self) -> bool:
|
||||
"""`_resolve_headless` for the async API: the display starts in a worker.
|
||||
|
||||
Starting the surface is a blocking call - on Linux it spawns an Xvfb
|
||||
and waits for it to report ready (~75 ms measured, seconds on a loaded
|
||||
host) - and `__aenter__` made it on the user's loop, so every other
|
||||
browser of the process stood still for that long, `headless=True`
|
||||
or not. The surface is the same and is still created before the prefs
|
||||
are composed; only the thread changes. The sync API keeps the direct
|
||||
call: nothing else runs on its thread.
|
||||
"""
|
||||
pw_headless, vd = self._plan_headless()
|
||||
if vd is None:
|
||||
return pw_headless
|
||||
started = asyncio.ensure_future(asyncio.to_thread(vd.start))
|
||||
try:
|
||||
await asyncio.shield(started)
|
||||
except asyncio.CancelledError:
|
||||
# The worker cannot be interrupted and may yet create the surface
|
||||
# for a launch nobody is waiting for: release it when it ends.
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
def release(done: "asyncio.Future") -> None:
|
||||
if not done.cancelled() and done.exception() is None:
|
||||
loop.run_in_executor(None, vd.stop)
|
||||
|
||||
started.add_done_callback(release)
|
||||
raise
|
||||
self._virtual_display = vd
|
||||
return pw_headless
|
||||
|
||||
def _take_display(self) -> Any:
|
||||
"""THE release, made once for both APIs: the hidden surface this session started, taken out of it (None when there is none).
|
||||
|
||||
The counterpart of `_plan_headless`: the two teardowns only decide WHERE the stop runs - inline in the sync client, off the
|
||||
loop in the async one. Stopping waits for the Xvfb to exit (`Popen.wait`, a loop of sleeps on POSIX), and on the user's loop
|
||||
that wait held every other browser of the process (e2e Linux, run 43701692047)."""
|
||||
display, self._virtual_display = self._virtual_display, None
|
||||
return display
|
||||
|
||||
def _default_context_kwargs(self) -> Dict[str, Any]:
|
||||
# The screen and viewport in CSS pixels, derived once in the core:
|
||||
@@ -546,24 +600,3 @@ class CommonLaunch:
|
||||
_enable_cursor_engine(
|
||||
owner, seed=self.seed, max_seconds=_cursor_max_seconds(self._humanize)
|
||||
)
|
||||
|
||||
def _bind_process_tree(self) -> None:
|
||||
"""Tie the browser tree to this process's lifetime, at the OS level.
|
||||
|
||||
MEASURED before being written, because the first attempt at this fixed
|
||||
a path that was not broken: an exception out of the `with` block does
|
||||
NOT leak - __exit__ runs and Playwright cleans up, zero survivors over
|
||||
an interleaved A/B. The leak is the killed-runner path, where __exit__
|
||||
never executes at all: launch, kill the runner, and eight processes
|
||||
were still alive; twelve on the second attempt. Nothing written inside
|
||||
_teardown can reach that, so the guarantee comes from a Windows job
|
||||
object that the kernel empties when this process's handle closes,
|
||||
however this process ends.
|
||||
|
||||
Best-effort by construction: a failure here leaves the pre-existing
|
||||
behaviour rather than breaking a launch that is otherwise fine.
|
||||
"""
|
||||
try:
|
||||
self._lifetime_guard.bind(self._session_token)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -15,6 +15,7 @@ from invisible_core._fpforge import Profile, generate_profile
|
||||
from invisible_core import SessionLocale, persona_cookies, prepare_session_geo, record_session_seed, resolve_session_seed
|
||||
from ._engine import assert_wire_version, resolve_executable
|
||||
from invisible_core import configure_proxy as _configure_proxy_shared
|
||||
from invisible_core._offloop import off_the_loop
|
||||
from ._reaper import SessionToken, guard_for
|
||||
|
||||
|
||||
@@ -129,7 +130,7 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
# the REAL result of _resolve_headless (did it create an
|
||||
# alternate desktop or not?) must be known BEFORE composing the
|
||||
# prefs, not after: B172, 2026-08-24.
|
||||
pw_headless = self._resolve_headless()
|
||||
pw_headless = await self._resolve_headless_async()
|
||||
prefs = self._build_prefs()
|
||||
playwright_proxy = _configure_proxy_shared(self._proxy, prefs)
|
||||
self._session_token = SessionToken.mint()
|
||||
@@ -153,7 +154,6 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
env=env,
|
||||
**self._default_context_kwargs(),
|
||||
)
|
||||
self._bind_process_tree()
|
||||
self._arm_cursor_engine(self._persistent_context)
|
||||
return self._persistent_context
|
||||
self._browser = await self._pw.firefox.launch(
|
||||
@@ -167,7 +167,6 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
# See the sync launcher: browser.version comes from the connection
|
||||
# initializer, costs no round trip, and cannot be spoofed by a pref.
|
||||
assert_wire_version(self._browser)
|
||||
self._bind_process_tree()
|
||||
except BaseException:
|
||||
await self._teardown()
|
||||
raise
|
||||
@@ -351,18 +350,18 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
if self._pw is not None:
|
||||
await close(self._pw.stop())
|
||||
self._pw = None
|
||||
if self._virtual_display is not None:
|
||||
# Synchronous, so it cannot be cancelled mid-call the way the
|
||||
# three awaits above can.
|
||||
try:
|
||||
self._virtual_display.stop()
|
||||
except Exception:
|
||||
pass
|
||||
self._virtual_display = None
|
||||
display = self._take_display()
|
||||
if display is not None:
|
||||
# Off the loop like its start (`_resolve_headless_async`): a cancellation stops the waiting, not the stop.
|
||||
await close(off_the_loop(display.stop))
|
||||
finally:
|
||||
if self._session_token:
|
||||
# ⛔ NOT ON THE LOOP: `reap` waits for the tree of the session to be gone. It runs in a thread of its own
|
||||
# (`off_the_loop`); a cancellation of this task stops the waiting and not the reaping, which runs to its end.
|
||||
try:
|
||||
self._lifetime_guard.reap(self._session_token)
|
||||
await off_the_loop(self._lifetime_guard.reap, self._session_token)
|
||||
except asyncio.CancelledError as stop:
|
||||
cancelled = stop
|
||||
except Exception:
|
||||
pass
|
||||
self._session_token = SessionToken()
|
||||
|
||||
@@ -358,7 +358,6 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
env=env,
|
||||
**self._persistent_context_kwargs(),
|
||||
)
|
||||
self._bind_process_tree()
|
||||
self._arm_cursor_engine(self._persistent_context)
|
||||
return self._persistent_context
|
||||
self._browser = self._pw.firefox.launch(
|
||||
@@ -374,7 +373,6 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
# pref can spoof it. Inside the try so a refusal tears the browser
|
||||
# down instead of leaking the process we just refused.
|
||||
assert_wire_version(self._browser)
|
||||
self._bind_process_tree()
|
||||
except BaseException:
|
||||
# Python doesn't call __exit__ when __enter__ raises - clean up
|
||||
# the virtual display + Playwright manually so we don't leak Xvfb
|
||||
@@ -571,12 +569,12 @@ class InvisiblePlaywright(_session.CommonLaunch):
|
||||
except Exception:
|
||||
pass
|
||||
self._pw = None
|
||||
if self._virtual_display is not None:
|
||||
display = self._take_display()
|
||||
if display is not None:
|
||||
try:
|
||||
self._virtual_display.stop()
|
||||
display.stop()
|
||||
except Exception:
|
||||
pass
|
||||
self._virtual_display = None
|
||||
# Last, and unconditionally: whatever Playwright's close() did or did
|
||||
# not manage, nothing carrying this session's token may outlive it. Each
|
||||
# step above is individually wrapped in `except: pass`, so before this
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
"""What a test that expects a page back from the back-forward cache writes down BEFORE it asserts anything, and the wait that leaves it
|
||||
a page the cache can take.
|
||||
|
||||
The test used to read `window.__shown` after `go_back()` and assert on it with nothing else saved: a red said "the page was loaded again" and
|
||||
nobody could tell whether the engine had announced a restore (and the page was loaded again anyway), or Firefox had refused or evicted the page.
|
||||
`read_after_go_back` takes, in one place and before any assertion, what tells them apart:
|
||||
|
||||
* `__shown`: `[False, True]` is a `pageshow` with `persisted` after the first one; `[False]` alone is a document that was built again;
|
||||
* the type of the navigation entry and the `readyState` of the document that answers;
|
||||
* the protocol events since `go_back()`: a restore is announced by the engine with a navigation id that starts with `nav-bfcache-` (and
|
||||
`Page.frameDocumentRestored`); a document that loaded again comes with a `Page.eventFired` `load` and new execution contexts.
|
||||
|
||||
`decide_outcome` writes that down FIRST (stdout, which pytest prints with the failure) and then says which of the two outcomes happened:
|
||||
the page was `restored` from the cache, or the document was built again (`reloaded`). The second is accepted ONLY where Firefox itself may
|
||||
not use the cache: a navigation the PARENT starts (`Page.navigate`, `goto`, to the same site or to another) is checked by the parent against the
|
||||
requests in the old document's loadgroup, and the navigation's own DocumentChannel may still be there when the check runs (measured 2026-11-12,
|
||||
SHIPBFCache log: `AllowedInBFCache` found "requests in the loadgroup" in 15 of 56 goto sessions, never after the page's own navigation). The test then asserts the worker's contract for the outcome that happened, whole, and says which it was.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Callable, List
|
||||
|
||||
#: The navigation id of a restore: Juggler's FrameTree.announceRestoredDocument gives it `nav-bfcache-<n>`; a document loaded again has the id of its load.
|
||||
RESTORE_PREFIX = "nav-bfcache-"
|
||||
|
||||
#: The protocol events that say what the engine did with the document, and the one parameter that names each.
|
||||
_SAID = {
|
||||
"Page.navigationStarted": "navigationId",
|
||||
"Page.navigationCommitted": "navigationId",
|
||||
"Page.eventFired": "name",
|
||||
"Page.frameDocumentRestored": "frameId",
|
||||
"Runtime.executionContextsCleared": None,
|
||||
"Runtime.executionContextCreated": None,
|
||||
"Page.workerCreated": "workerId",
|
||||
"Page.workerDestroyed": "workerId",
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class Evidence:
|
||||
shown: object
|
||||
navigation_type: object
|
||||
ready_state: object
|
||||
events: List[str] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def restored(self) -> bool:
|
||||
return self.shown == [False, True]
|
||||
|
||||
@property
|
||||
def engine_announced_a_restore(self) -> bool:
|
||||
return any(e.startswith("Page.navigationCommitted " + RESTORE_PREFIX) for e in self.events)
|
||||
|
||||
def text(self) -> str:
|
||||
return ("[bfcache] after go_back: __shown=%r navigation entry type=%r readyState=%r; the engine announced a restore: %s; events: %s"
|
||||
% (self.shown, self.navigation_type, self.ready_state, "yes" if self.engine_announced_a_restore else "no",
|
||||
self.events))
|
||||
|
||||
def why_not(self) -> str:
|
||||
if self.engine_announced_a_restore:
|
||||
return ("the engine announced a restore (%s...) but the page did not run a pageshow with persisted after its first one"
|
||||
% RESTORE_PREFIX)
|
||||
return ("the page was built again instead of restored from the back-forward cache (no restore was announced by the engine), "
|
||||
"so this test proves nothing")
|
||||
|
||||
|
||||
def summarize_events(events, start: int) -> List[str]:
|
||||
"""The events since ``start`` that say what became of the document, one short string each, in order."""
|
||||
said = []
|
||||
for method, params in events[start:]:
|
||||
if method not in _SAID:
|
||||
continue
|
||||
key = _SAID[method]
|
||||
said.append(method if key is None else "%s %s" % (method, params.get(key)) + (
|
||||
" %s" % params.get("url") if method == "Page.navigationCommitted" else ""))
|
||||
return said
|
||||
|
||||
|
||||
def read_after_go_back(page, events, start: int) -> Evidence:
|
||||
"""Everything the test knows right after ``go_back()``, taken before any assertion."""
|
||||
return Evidence(
|
||||
shown=page.evaluate("window.__shown"),
|
||||
navigation_type=page.evaluate("() => { const e = performance.getEntriesByType('navigation')[0]; return e ? e.type : null; }"),
|
||||
ready_state=page.evaluate("document.readyState"),
|
||||
events=summarize_events(events, start),
|
||||
)
|
||||
|
||||
|
||||
def decide_outcome(evidence: Evidence, may_reload: bool, write: Callable[[str], None] = print) -> str:
|
||||
"""Write the evidence down (always, first), then say what happened: ``"restored"``, or ``"reloaded"`` when the document was built again
|
||||
and ``may_reload`` (the case where Firefox may refuse the cache); anything else fails, naming why and carrying the evidence. A restore
|
||||
the engine announced that the page did not see fails even where a reload is accepted: that is a defect of ours, not of the cache."""
|
||||
outcome = "restored" if evidence.restored else (
|
||||
"reloaded" if may_reload and not evidence.engine_announced_a_restore else "failed")
|
||||
write(evidence.text() + " => outcome: " + outcome)
|
||||
assert outcome != "failed", "%s: %s" % (evidence.why_not(), evidence.text())
|
||||
return outcome
|
||||
|
||||
|
||||
def wait_cacheable(page, seconds: float = 10.0) -> None:
|
||||
"""Until every document of the page that records `pageshow` has had it. A document whose `pageshow` has not run is still marked as
|
||||
loading and Firefox will not cache it (Document::OnPageShow clears the mark): the lab does not leave before that, however slow the
|
||||
machine is. The worker has started and answered before this: the callers asked it twice."""
|
||||
def shown() -> bool:
|
||||
return all(frame.evaluate("(window.__shown || [0]).length >= 1") for frame in page.frames)
|
||||
|
||||
end = time.monotonic() + seconds
|
||||
while time.monotonic() < end:
|
||||
if shown():
|
||||
return
|
||||
time.sleep(0.1)
|
||||
assert shown(), "a document of the page never ran its pageshow: %r" % [f.url for f in page.frames]
|
||||
@@ -1,35 +1,44 @@
|
||||
"""The check that no test module leaves a browser open.
|
||||
|
||||
A `BrowserDispatcher` starts one daemon thread, "invpw-thread-starter", and stops it only when the connection's close listeners fire. A
|
||||
unit test that builds a dispatcher on a fake connection and never closes it leaves that thread alive, and the thread keeps the connection,
|
||||
A connection's server owns ONE daemon thread, "invpw-thread-starter" (`Server.thread_starter`, made when the first thread is asked of it), and
|
||||
stops it only on `shutdown`. A unit test that builds a dispatcher on a server and never shuts the server down leaves that thread alive, and the thread keeps the connection,
|
||||
the browser and every context alive for the rest of the worker (a gc census of a closed context once found 7 of them, and one file alone
|
||||
left 635). So the number of live starters, counted when the last test of a module has torn down, must be what it was before the module.
|
||||
|
||||
Module level and not per test: a module-scoped browser (the e2e ones) is legitimately open between its tests and closed at the end.
|
||||
"""
|
||||
import threading
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
STARTER_NAME = "invpw-thread-starter"
|
||||
_THREADS_MODULE = "invisible_playwright._juggler._threads"
|
||||
# `stop` is asynchronous: it queues a None and the thread leaves on its next turn. A moment, not a wait for a leak that will not leave.
|
||||
_JOIN_SECONDS = 5.0
|
||||
|
||||
|
||||
def starters_alive():
|
||||
return [t for t in threading.enumerate() if t.name == STARTER_NAME and t.is_alive()]
|
||||
"""The starters built and not ended, counted from their construction: `ThreadStarter` begins its thread without waiting for it, so
|
||||
one that has not run yet is in no `threading.enumerate()` (a census of live threads missed 2 leaks on a Linux runner).
|
||||
|
||||
NO IMPORT HERE. A module that never loaded `_threads` cannot have built a starter, so the answer is empty without importing anything:
|
||||
the census runs from conftest in every job, including ones that install pytest alone and have no `invisible_core` (the `version`
|
||||
job failed on `invisible_playwright._pin` when this function imported the package)."""
|
||||
threads = sys.modules.get(_THREADS_MODULE)
|
||||
if threads is None:
|
||||
return []
|
||||
return threads.ThreadStarter.open_starters()
|
||||
|
||||
|
||||
def wait_until_back_to(before, seconds=_JOIN_SECONDS):
|
||||
"""The starters still alive after `seconds` beyond the `before` that were there already (0 when the module closed everything)."""
|
||||
"""The starters still open after `seconds` beyond the `before` that were there already (0 when the module closed everything)."""
|
||||
deadline = time.monotonic() + seconds
|
||||
while True:
|
||||
extra = len(starters_alive()) - before
|
||||
if extra <= 0 or time.monotonic() >= deadline:
|
||||
return max(extra, 0)
|
||||
for t in starters_alive():
|
||||
t.join(0.05)
|
||||
time.sleep(0.05)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
"""The verdicts of `test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py`, as pure functions of what its client recorded (so a
|
||||
unit test feeds them the red case and the green case without a browser).
|
||||
|
||||
None of them reads how long something took: a loop that is held is told by WHERE the thread of the loop was (inside a blocking step of
|
||||
the close), and a browser that keeps answering is told by the ORDER of the events (a call that began and ended while the close was in
|
||||
flight, and answers that came while the removal of the profile was held until every other browser had answered). A machine that is
|
||||
slow stretches every duration and changes none of these.
|
||||
|
||||
``inside`` is what the watcher saw of the loop's thread, one entry per frame that was ever on its stack while it was running something
|
||||
(not waiting in the selector): ``{"<file>:<function>": {"n": samples, "stack": [the innermost frames of the first stack it was seen in]}}``.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, Iterable, List, Optional, Sequence, Tuple
|
||||
|
||||
#: A blocking step of a close: (a part of the file's path, the functions of it). They WAIT (for the processes of the tree, for the
|
||||
#: workers, for the directories to go), so none of them may be on the stack of the thread that runs the loop of the user:
|
||||
#: `InProcessTransport.request_stop`'s `shutdown` and `_join_workers`, `reap` / `reap_session` of the core, `op_close` of the engine's
|
||||
#: dispatcher, and the blocking calls those make (`psutil.wait_procs`, `shutil.rmtree`, `Thread.join`).
|
||||
BLOCKING_STEPS: Tuple[Tuple[str, Tuple[str, ...]], ...] = (
|
||||
("/invisible_playwright/", ("shutdown", "_join_workers", "op_close")),
|
||||
("/invisible_core/", ("shutdown", "reap", "reap_session")),
|
||||
("/psutil/", ("wait_procs",)),
|
||||
("/shutil.py", ("rmtree",)),
|
||||
("/threading.py", ("join",)),
|
||||
)
|
||||
|
||||
|
||||
def blocked_by(inside: Dict[str, dict], steps: Iterable[Tuple[str, Sequence[str]]] = BLOCKING_STEPS) -> List[str]:
|
||||
"""The frames of ``steps`` that were on the stack of the loop's thread while it ran something, sorted."""
|
||||
found = []
|
||||
for frame in inside:
|
||||
path, _, function = frame.rpartition(":")
|
||||
for part, functions in steps:
|
||||
if part in path and function in functions:
|
||||
found.append(frame)
|
||||
break
|
||||
return sorted(found)
|
||||
|
||||
|
||||
def close_on_the_loop_problem(inside: Dict[str, dict]) -> Optional[str]:
|
||||
"""What is wrong when a step of the close that waits ran on the thread of the loop, or None. Red on a close made on the loop
|
||||
(the defect), whatever the speed of the machine; green on one made in threads of their own."""
|
||||
found = blocked_by(inside)
|
||||
if not found:
|
||||
return None
|
||||
lines = []
|
||||
for frame in found:
|
||||
entry = inside[frame]
|
||||
lines.append("%s (seen in %d samples of the loop's thread), the innermost frames of the first one:\n %s"
|
||||
% (frame, entry["n"], "\n ".join(entry["stack"])))
|
||||
return "the loop's own thread was inside a step of the close that waits:\n" + "\n".join(lines)
|
||||
|
||||
|
||||
def blind_instrument_problem(inside: Dict[str, dict], steps: Iterable[Tuple[str, Sequence[str]]]) -> Optional[str]:
|
||||
"""The control: a loop that was held on purpose, inside the function ``steps`` names, must have been seen there at least once."""
|
||||
if blocked_by(inside, steps):
|
||||
return None
|
||||
return ("the watcher never saw the loop's thread inside %s while the loop was held on purpose: it could not see a close made on "
|
||||
"the loop (frames it did see: %s)" % (list(steps), sorted(inside)[:12]))
|
||||
|
||||
|
||||
def charged_more_than_ran_problem(held: float, busy_run: float) -> Optional[str]:
|
||||
"""The second control: a loop the machine did not schedule waits in its selector, and only the time its thread was seen RUNNING is
|
||||
held. ``busy_run`` is the longest stretch the watcher saw the thread run without a pause in the selector, read off the same
|
||||
samples as ``held``: what is charged can never be more than that. Charging the whole lateness (the wait in the selector too, as
|
||||
the first instrument did: 94 ms with nothing on the loop's thread, candidate 43727128285) is more than that, whatever the machine."""
|
||||
if held <= busy_run:
|
||||
return None
|
||||
return ("the loop was charged %.0f ms of hold and its thread was seen running for at most %.0f ms in a row: the time it waited in "
|
||||
"its selector (the machine did not schedule it) was counted as held" % (held * 1000, busy_run * 1000))
|
||||
|
||||
|
||||
def others_answered_problem(others: Sequence[dict], gate: dict) -> Optional[str]:
|
||||
"""What is wrong with the way the other browsers answered while the first one closed, or None.
|
||||
|
||||
``others`` has one record per other browser: ``inside`` is the calls that began AFTER the close began and ended BEFORE it ended
|
||||
(a call that was answered during the close, in the order of the events, not by how long it took), ``during_removal`` the calls
|
||||
that did the same while the removal of the closing browser's profile was held. ``gate`` says how that hold ended: ``reached``
|
||||
(the removal ran in the window of the close), ``released_by``: ``answered`` (every other browser had answered a call that began
|
||||
after the removal began: the loop was free while the removal ran) or ``deadline`` (they had not, in 30 s: the loop could not run
|
||||
while the removal was waiting, which is a removal made on the loop's thread)."""
|
||||
if len(others) != 3:
|
||||
return "the client followed %d other browsers instead of 3: %r" % (len(others), others)
|
||||
silent = [i for i, r in enumerate(others) if r["inside"] < 1]
|
||||
if silent:
|
||||
return ("the other browsers %s did not answer a single call that began and ended inside the close (calls inside it, per "
|
||||
"browser: %s): the loop that serves them did not run during the close" % (silent, [r["inside"] for r in others]))
|
||||
if gate.get("reached") and gate.get("released_by") != "answered":
|
||||
return ("the removal of the profile was held until every other browser answered, and they did not (%s): the loop that "
|
||||
"serves them could not run while the removal waited, so the removal ran on it (answers during the removal, per "
|
||||
"browser: %s)" % (gate.get("released_by"), [r["during_removal"] for r in others]))
|
||||
return None
|
||||
@@ -0,0 +1,111 @@
|
||||
"""The CPU the engine's processes use, by type of process, read from the processes of this test.
|
||||
|
||||
A Firefox browser is a tree: the parent, content processes (`tab`), and, where there are any, a GPU process (`gpu`), a socket process,
|
||||
a media process (`rdd`) and utility processes. Every one but the parent is started with `-contentproc ... <type>` as the last argument
|
||||
of its command line, so the type is read from there; no `-contentproc` is the parent.
|
||||
|
||||
`CpuSampler` reads the cumulative CPU time (user + kernel) of every engine process below the process that runs the test, every
|
||||
`period` seconds, from a thread. A process that ends inside the window keeps the last value read before its end (at most one period of
|
||||
its end is lost). The CPU of a type in a window is the sum, over its processes, of the last value minus the value at the start of the
|
||||
window (zero for a process born after it).
|
||||
|
||||
The process of a test is the root: the browser a test starts is its descendant, and so is nothing else of the engine (an e2e run opens
|
||||
several browsers at once, in several workers, each in its own process tree).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
import time
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
TYPES = ("parent", "tab", "gpu", "socket", "rdd", "utility", "forkserver", "other")
|
||||
|
||||
|
||||
def classify(cmdline: List[str]) -> str:
|
||||
"""parent = no `-contentproc`; otherwise the last argument (tab, gpu, socket, rdd, utility, forkserver), `other` for any other."""
|
||||
if "-contentproc" not in cmdline:
|
||||
return "parent"
|
||||
last = str(cmdline[-1]).strip('"').lower() if cmdline else "?"
|
||||
return last if last in TYPES else "other"
|
||||
|
||||
|
||||
def delta_by_type(start: Dict[int, Tuple[str, float]], last: Dict[int, Tuple[str, float]]) -> Dict[str, float]:
|
||||
"""CPU seconds per type over a window: `start` and `last` map pid -> (type, cumulative CPU seconds)."""
|
||||
out = {t: 0.0 for t in TYPES}
|
||||
for pid, (kind, cpu) in last.items():
|
||||
out[kind] = out.get(kind, 0.0) + max(0.0, cpu - start.get(pid, (kind, 0.0))[1])
|
||||
return out
|
||||
|
||||
|
||||
def is_engine(proc) -> bool:
|
||||
"""True when the process runs the firefox executable (its file name, whatever name the process gave itself)."""
|
||||
import psutil
|
||||
|
||||
try:
|
||||
exe = proc.exe()
|
||||
except (psutil.Error, OSError):
|
||||
exe = ""
|
||||
# Either separator: the file name of the executable, whichever system wrote the path.
|
||||
return (exe or proc.name()).replace("\\", "/").rsplit("/", 1)[-1].lower().startswith("firefox")
|
||||
|
||||
|
||||
def engine_processes(root_pid: int) -> Dict[int, Tuple[str, float]]:
|
||||
"""pid -> (type, cumulative CPU seconds) of every process of the engine below `root_pid`, now.
|
||||
|
||||
⛔ AN ENGINE PROCESS IS KNOWN BY ITS EXECUTABLE, NOT BY ITS NAME. On Linux a child names itself after its role ("Web Content",
|
||||
"Isolated Web Co", "forkserver", "Socket Process", read from /proc/<pid>/comm) while its executable stays the firefox binary, so a
|
||||
filter on the name kept the parent alone and the content processes were never counted (e2e Linux, run 43701692047). On Windows the
|
||||
name and the executable are the same file."""
|
||||
import psutil
|
||||
|
||||
out: Dict[int, Tuple[str, float]] = {}
|
||||
try:
|
||||
below = psutil.Process(root_pid).children(recursive=True)
|
||||
except psutil.Error:
|
||||
return out
|
||||
for proc in below:
|
||||
try:
|
||||
if not is_engine(proc):
|
||||
continue
|
||||
times = proc.cpu_times()
|
||||
out[proc.pid] = (classify(proc.cmdline()), times.user + times.system)
|
||||
except psutil.Error:
|
||||
continue
|
||||
return out
|
||||
|
||||
|
||||
class CpuSampler:
|
||||
def __init__(self, root_pid: int, period: float = 0.25) -> None:
|
||||
self.root_pid = root_pid
|
||||
self.period = period
|
||||
self.last: Dict[int, Tuple[str, float]] = {}
|
||||
self.start: Dict[int, Tuple[str, float]] = {}
|
||||
self._halt = threading.Event()
|
||||
self._thread = threading.Thread(target=self._run, name="cpu-sampler", daemon=True)
|
||||
|
||||
def _take(self) -> None:
|
||||
self.last.update(engine_processes(self.root_pid))
|
||||
|
||||
def _run(self) -> None:
|
||||
while not self._halt.is_set():
|
||||
self._take()
|
||||
self._halt.wait(self.period)
|
||||
|
||||
def begin(self) -> None:
|
||||
"""Mark the start of the window (what every process has used until now is not counted) and start sampling."""
|
||||
self._take()
|
||||
self.start = dict(self.last)
|
||||
self._thread.start()
|
||||
|
||||
def end(self) -> Dict[str, float]:
|
||||
"""Stop, take one more sample, and return the CPU seconds of the window by type.
|
||||
|
||||
The window ends HERE. The counters are cumulative, so the sample taken now already holds everything the processes used until
|
||||
this call: waiting before it (the old ``sleep(0.3)``) added a third of a second of whatever the browser did after the
|
||||
measured work to the number, and a slower machine added more. The sampler's thread is waited for up to 30 s (it ends at once:
|
||||
its only wait is the event just set, after the sample it was in the middle of), and a sample still running then is a hang."""
|
||||
self._halt.set()
|
||||
self._thread.join(timeout=30)
|
||||
assert not self._thread.is_alive(), "the CPU sampler's thread did not end within 30 s of being told to stop"
|
||||
self._take()
|
||||
return delta_by_type(self.start, self.last)
|
||||
@@ -0,0 +1,736 @@
|
||||
"""What an e2e test of this repository must not depend on: the reading of the sources behind ``test_the_e2e_tests_do_not_wait_on_clocks.py``.
|
||||
|
||||
An e2e test is red for no fault of the product when its verdict depends on something that is not the product: the speed of the machine (a fixed pause before
|
||||
a read, an absolute bound on a duration), a resource the workers share (a literal port, ``os.environ``), or the world (a real site, a service of the internet).
|
||||
This module reads the e2e files and the helpers of ``tests/`` with ``ast`` (a word in a comment or in a docstring counts for nothing) and says where each of those
|
||||
is. It decides nothing about what is allowed: the exceptions are a reviewed list (``tests/gates/e2e_clock_exceptions.json``), and the occurrences that are
|
||||
dangerous and not yet corrected are the ``debt`` of that file, which a script regenerates (``scripts/e2e_clock_exceptions.py --write``).
|
||||
|
||||
THE RULES (a stable name each; ``CLASS`` is the letter of the audit of the e2e tests that the rule belongs to):
|
||||
|
||||
* ``sleep`` (A): ``time.sleep``, ``asyncio.sleep`` (not ``sleep(0)``), ``.wait_for_timeout(``. A fixed pause and then a read judges the speed of the machine.
|
||||
* ``js-timer`` (A): ``setTimeout(`` / ``setInterval(`` in a string of the test (a page of the test): when the verdict depends on when it fires, it judges the machine.
|
||||
* ``bound`` (B): ``assert <something that is a duration> < <an absolute limit>`` (``<=`` too): an upper bound on a time. An absolute limit is a number, a name in capitals,
|
||||
a variable NAMED a limit (``limit_s``, ``max_ms``), or anything an absolute slack is added to (``rtt_ms + 250``, ``control + 0.5``). A bound against a value measured in the
|
||||
same run and scaled (``took <= control * 3``) is not flagged, and neither is a lower bound (it cannot fail because the machine is slow).
|
||||
* ``port`` (C): a port written as a number in a ``bind``, a ``*Server((addr, N))``, a ``port=N``, a ``"...port": N`` or a ``NAME_PORT = N`` (N not 0). Two workers that
|
||||
run at once, or a port someone else holds, make it red.
|
||||
* ``env`` (C): ``os.environ`` written (``[k] = v``, ``pop``, ``setdefault``, ``update``, ``del``, ``putenv``): ``monkeypatch.setenv`` undoes itself, this does not.
|
||||
* ``net`` (D): a ``http(s)://`` URL of a real host, ``urlopen``, ``requests.get``, a ``pip install``, outside the files of the round after a publication.
|
||||
* ``count`` (E): ``assert len(<processes, pids, children>) == N``: a number of processes the product does not promise (``_processes.py`` and ``_waits.py`` are how it is counted).
|
||||
* ``timeout`` (F): an explicit deadline under 30 s on a wait for something that MUST happen: ``timeout=`` (``wait_for_*``, ``expect_*``, ``goto``, an action, ``join``, ``urlopen``,
|
||||
``create_connection``, a subprocess), ``set_default_timeout(...)``, ``set_default_navigation_timeout(...)``, the default of a parameter named ``timeout``. A deadline is the
|
||||
time a healthy run is allowed, and a loaded runner takes longer than a developer's machine: 30 s is the one the whole suite uses (the unit is read from the callee:
|
||||
milliseconds for the Playwright API, seconds for the standard library and for the helpers of ``tests/``). A wait for something that must NOT happen is accepted by its shape
|
||||
(inside ``pytest.raises``, under a ``try`` that swallows the timeout, or a limit that is NAMED ``NEGATIVE_...``); any other is a reviewed ``entries`` item with its reason.
|
||||
* ``egress`` (D): the conftest has no autouse session fixture that declares the exit of the lab (tests/_lab_egress.py), so a launch asks three services of the internet.
|
||||
|
||||
WHAT IS ACCEPTED WITHOUT A LIST, because it is recognised by its shape: a pause that is the step of a poll with a deadline (a ``while``/``for`` that compares with a clock
|
||||
or a deadline and ends with a ``return``, ``break`` or ``raise``); the body of ``pump``/``pause``/``wait_*``/``*_until``/``poll*``, a function handed by name to ``wait_until``/``watch``/``awatch``, and a lambda passed as the ``pump`` of
|
||||
those; a ``sleep`` in a method of a ``*Handler``/``*Server`` class (a test server that is slow on purpose); a ``sleep(0)``; a test that
|
||||
carries no ``e2e`` marker (it runs in the unit run, with fakes).
|
||||
|
||||
An occurrence is named by ``(file, scope, rule, nth)``: the file, the qualified name of the function or class that holds it (a module-level constant: ``<module>.NAME``), the rule,
|
||||
and its position among the occurrences of that rule in that scope. No line number, so moving code does not break the list.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import ipaddress
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterable, List, Optional, Set, Tuple
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
|
||||
#: The rule -> the class of the audit.
|
||||
CLASS = {"sleep": "A", "js-timer": "A", "bound": "B", "port": "C", "env": "C", "net": "D", "egress": "D", "count": "E", "timeout": "F"}
|
||||
RULES = tuple(CLASS)
|
||||
|
||||
#: The files that say what is forbidden (their own patterns would be found) and the files of the round after a publication (``net`` is theirs by design).
|
||||
SELF = {"_e2e_clocks.py", "test_the_e2e_tests_do_not_wait_on_clocks.py"}
|
||||
POST_PUBLICATION = ("test_release_e2e.py", "test_upgrade_e2e.py")
|
||||
#: How processes are counted: the one allowed way.
|
||||
COUNTING = {"_processes.py", "_waits.py"}
|
||||
|
||||
_DURATION_WORDS = {"took", "elapsed", "seconds", "secs", "sec", "duration", "wall", "latency", "ms", "held", "late", "waited", "wait", "slowest",
|
||||
"longest", "spent", "rtt", "cpu", "lag", "stall", "delay", "opened"}
|
||||
#: A variable that is named a limit (``limit``, ``max_ms``, ``deadline_s``) is a constant of the test even when it is not written in capitals.
|
||||
_LIMIT_WORDS = {"limit", "limits", "bound", "ceiling", "budget", "timeout", "threshold", "max", "maximum", "allowed", "slack", "margin", "cap"}
|
||||
_CLOCKS = {"monotonic", "perf_counter", "time", "process_time", "time_ns", "monotonic_ns", "perf_counter_ns"}
|
||||
_DEADLINE_NAMES = re.compile(r"(deadline|until|give_?up|stop_at|expires?|budget|limit|timeout|end_at)", re.I)
|
||||
_POLLING_FUNCTIONS = re.compile(r"^(_?pump\w*|_?pause\w*|_?wait\w*|\w*wait_for\w*|\w*_until|_?poll\w*|_?settle\w*|_?spin\w*)$")
|
||||
_PUMP_CALLEES = {"wait_until", "watch", "awatch"}
|
||||
_PROCESS_WORDS = re.compile(r"(pids?|processes|children|procs|content_processes)\b")
|
||||
_SERVER_BASE = re.compile(r"(Handler|Server|Protocol)$")
|
||||
_TIMER = re.compile(r"\bset(?:Timeout|Interval)\(")
|
||||
_URL = re.compile(r"https?://([^\s/:'\"<>)\\]*)(?::[^\s/'\"<>)\\]*)?")
|
||||
_SAFE_HOST = re.compile(r"(^|\.)(test|invalid|localhost|example|local)$|^localhost$")
|
||||
#: The shortest deadline an e2e test may give to a wait for something that must happen, in seconds.
|
||||
MIN_DEADLINE_S = 30
|
||||
#: The callees whose ``timeout`` is in SECONDS (the standard library and the helpers of ``tests/``); the Playwright API (``goto``, ``wait_for_*``, ``expect_*``, an action) is in milliseconds.
|
||||
_SECONDS_CALLEES = re.compile(r"^(join|acquire|wait|communicate|run|check_call|check_output|call|Popen|urlopen|create_connection|settimeout|get|put|recv|accept|connect|"
|
||||
r"_?run|_?retry\w*|send|launch\w*|wait_until\w*|wait_procs|wait_for_state|wait_for_new_navigation|\w*_s)$")
|
||||
_PLAYWRIGHT_CALLEES = re.compile(r"^(goto|click|dblclick|tap|fill|type|type_text|press|hover|focus|blur|check|uncheck|select_option|set_input_files|set_files|dispatch_event|"
|
||||
r"drag_and_drop|screenshot|inner_text|inner_html|text_content|input_value|scroll_into_view_if_needed|go_back|go_forward|reload|"
|
||||
r"wait_for\w*|expect_\w+|to_\w+|not_to_\w+|set_default_timeout|set_default_navigation_timeout)$")
|
||||
_TIMEOUT_KEYWORD = re.compile(r"(^|_)timeout(_ms|_s)?$")
|
||||
_PIP = re.compile(r"\bpip\b.*\binstall\b|\buv\b.*\b(add|pip|install|sync)\b")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Violation:
|
||||
file: str
|
||||
scope: str
|
||||
rule: str
|
||||
nth: int
|
||||
line: int
|
||||
text: str = ""
|
||||
|
||||
@property
|
||||
def key(self) -> Tuple[str, str, str, int]:
|
||||
return (self.file, self.scope, self.rule, self.nth)
|
||||
|
||||
@property
|
||||
def klass(self) -> str:
|
||||
return CLASS[self.rule]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# What a node is
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
def _dotted(node: ast.AST) -> str:
|
||||
"""``a.b.c`` of an attribute chain, or the name; '' for anything else."""
|
||||
parts: List[str] = []
|
||||
while isinstance(node, ast.Attribute):
|
||||
parts.append(node.attr)
|
||||
node = node.value
|
||||
if isinstance(node, ast.Name):
|
||||
parts.append(node.id)
|
||||
return ".".join(reversed(parts))
|
||||
return ""
|
||||
|
||||
|
||||
def _marks(node: ast.AST) -> Set[str]:
|
||||
"""The names of the ``pytest.mark.X`` of a decorator list, a ``pytestmark`` value, or one mark."""
|
||||
found: Set[str] = set()
|
||||
for sub in ast.walk(node):
|
||||
if isinstance(sub, ast.Attribute) and isinstance(sub.value, ast.Attribute) and sub.value.attr == "mark":
|
||||
found.add(sub.attr)
|
||||
return found
|
||||
|
||||
|
||||
def _identifier_words(node: ast.AST) -> Set[str]:
|
||||
words: Set[str] = set()
|
||||
for sub in ast.walk(node):
|
||||
names = []
|
||||
if isinstance(sub, ast.Name):
|
||||
names.append(sub.id)
|
||||
elif isinstance(sub, ast.Attribute):
|
||||
names.append(sub.attr)
|
||||
elif isinstance(sub, ast.Constant) and isinstance(sub.value, str) and len(sub.value) < 40:
|
||||
names.append(sub.value)
|
||||
for name in names:
|
||||
words.update(w for w in re.split(r"[^A-Za-z0-9]+|_", name.lower()) if w)
|
||||
return words
|
||||
|
||||
|
||||
def _is_constant_number(node: ast.AST) -> bool:
|
||||
"""A number, or arithmetic of numbers and of NAMES IN CAPITALS (a constant of the module)."""
|
||||
if isinstance(node, ast.Constant):
|
||||
return isinstance(node.value, (int, float)) and not isinstance(node.value, bool)
|
||||
if isinstance(node, ast.Name):
|
||||
return node.id.isupper()
|
||||
if isinstance(node, ast.Attribute):
|
||||
return node.attr.isupper() and isinstance(node.value, (ast.Name, ast.Attribute))
|
||||
if isinstance(node, ast.UnaryOp):
|
||||
return _is_constant_number(node.operand)
|
||||
if isinstance(node, ast.BinOp):
|
||||
return _is_constant_number(node.left) and _is_constant_number(node.right)
|
||||
return False
|
||||
|
||||
_NUMBER_CALLS = {"int": int, "float": float, "min": min, "max": max, "round": round, "abs": abs}
|
||||
|
||||
|
||||
def _number(node: ast.AST, names: Dict[str, float]) -> Optional[float]:
|
||||
"""The value of an expression made of numbers, of the numbers the module names (``names``) and of ``int``/``min``/``max``...; None for anything else (a parameter, a call)."""
|
||||
if isinstance(node, ast.Constant):
|
||||
return node.value if isinstance(node.value, (int, float)) and not isinstance(node.value, bool) else None
|
||||
if isinstance(node, ast.Name):
|
||||
return names.get(node.id)
|
||||
if isinstance(node, ast.UnaryOp) and isinstance(node.op, (ast.USub, ast.UAdd)):
|
||||
value = _number(node.operand, names)
|
||||
return None if value is None else (-value if isinstance(node.op, ast.USub) else value)
|
||||
if isinstance(node, ast.BinOp) and isinstance(node.op, (ast.Add, ast.Sub, ast.Mult, ast.Div, ast.FloorDiv)):
|
||||
left, right = _number(node.left, names), _number(node.right, names)
|
||||
if left is None or right is None:
|
||||
return None
|
||||
try:
|
||||
return {ast.Add: lambda: left + right, ast.Sub: lambda: left - right, ast.Mult: lambda: left * right,
|
||||
ast.Div: lambda: left / right, ast.FloorDiv: lambda: left // right}[type(node.op)]()
|
||||
except ZeroDivisionError:
|
||||
return None
|
||||
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id in _NUMBER_CALLS and node.args and not node.keywords:
|
||||
values = [_number(a, names) for a in node.args]
|
||||
if all(v is not None for v in values):
|
||||
return _NUMBER_CALLS[node.func.id](*values) # type: ignore[arg-type]
|
||||
return None
|
||||
|
||||
|
||||
#: The objects of the package under test that take a ``timeout`` in SECONDS (the actions and the lifecycle of the driver), where the Playwright API takes milliseconds.
|
||||
_SECONDS_RECEIVERS = {"actions", "lifecycle", "lc", "inj", "sess", "session", "conn", "connection", "transport"}
|
||||
|
||||
|
||||
def _receiver(node: ast.AST) -> str:
|
||||
"""The name at the left end of a call chain (``actions`` of ``actions.click(...)``, ``page`` of ``page.locator(x).click(...)``)."""
|
||||
while isinstance(node, (ast.Attribute, ast.Call, ast.Subscript)):
|
||||
node = node.func if isinstance(node, ast.Call) else node.value
|
||||
return node.id if isinstance(node, ast.Name) else ""
|
||||
|
||||
|
||||
def _deadline_seconds(value: float, callee: str, keyword: str, receiver: str = "", driver: bool = False) -> float:
|
||||
"""A ``timeout`` in seconds: milliseconds for the Playwright API (an object of the driver, ``actions.click`` or ``goto(until=...)``, reads seconds) and for a keyword that says ``_ms``,
|
||||
seconds for the standard library, a keyword that says ``_s`` and the helpers of ``tests/``; any other callee is read by size (a thousand or more is milliseconds)."""
|
||||
if keyword.endswith("_ms"):
|
||||
return value / 1000.0
|
||||
if keyword.endswith("_s") or _SECONDS_CALLEES.match(callee) or ((driver or receiver in _SECONDS_RECEIVERS) and value < 1000):
|
||||
return float(value)
|
||||
if _PLAYWRIGHT_CALLEES.match(callee):
|
||||
return value / 1000.0
|
||||
return value / 1000.0 if value >= 1000 else float(value)
|
||||
|
||||
|
||||
def _is_an_absolute_limit(node: ast.AST) -> bool:
|
||||
"""What an upper bound on a duration is held to be absolute by: a constant (:func:`_is_constant_number`), a variable that is NAMED a limit (``limit_s``, ``max_ms``),
|
||||
or anything with an absolute slack added to it or taken from it (``rtt_ms + 250``, ``control + 0.5``: a stall of the machine longer than the slack is red whatever
|
||||
the control was). A product (``control * 3``) is relative: it grows with a measure of the same run."""
|
||||
if _is_constant_number(node):
|
||||
return True
|
||||
if isinstance(node, (ast.Name, ast.Attribute)):
|
||||
return bool(_identifier_words(node) & _LIMIT_WORDS)
|
||||
if isinstance(node, ast.BinOp):
|
||||
if isinstance(node.op, (ast.Add, ast.Sub)) and any(
|
||||
_is_constant_number(side) for side in (node.left, node.right)):
|
||||
return True
|
||||
return _is_an_absolute_limit(node.left) and _is_an_absolute_limit(node.right)
|
||||
return False
|
||||
|
||||
|
||||
def _reads_a_clock(node: ast.AST) -> bool:
|
||||
for sub in ast.walk(node):
|
||||
if isinstance(sub, ast.Call):
|
||||
name = _dotted(sub.func).rsplit(".", 1)[-1]
|
||||
if name in _CLOCKS:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _is_a_duration(node: ast.AST) -> bool:
|
||||
if _reads_a_clock(node):
|
||||
return True
|
||||
return bool(_identifier_words(node) & _DURATION_WORDS)
|
||||
|
||||
|
||||
def _host_is_real(host: str) -> bool:
|
||||
host = host.strip().strip("[]").lower()
|
||||
if not host or host[0] in "{%$" or "{" in host or "%" in host:
|
||||
return False
|
||||
if "." not in host and ":" not in host: # http://x/, http://a/: not a name anyone owns
|
||||
return False
|
||||
try:
|
||||
address = ipaddress.ip_address(host)
|
||||
except ValueError:
|
||||
return not _SAFE_HOST.search(host)
|
||||
return address.is_global # loopback, private, documentation, link-local: not the world
|
||||
|
||||
|
||||
class _Reader(ast.NodeVisitor):
|
||||
def __init__(self, file: str, tree: ast.Module, e2e_file: bool) -> None:
|
||||
self.file = file
|
||||
self.is_test_file = file.startswith("test_")
|
||||
self.e2e_file = e2e_file
|
||||
self.stack: List[str] = []
|
||||
self.assign: Optional[str] = None
|
||||
self.found: List[Tuple[str, str, int, str]] = [] # scope, rule, line, text
|
||||
self.exempt = 0
|
||||
self.module_marks = set()
|
||||
self.class_marks: List[Set[str]] = []
|
||||
self.post = file in POST_PUBLICATION
|
||||
self.server_depth = 0
|
||||
#: The functions this file hands to ``wait_until``/``watch``/``awatch`` by name: their body is the step between two looks of a wait with a deadline.
|
||||
self.pumps: Set[str] = set()
|
||||
for call in ast.walk(tree):
|
||||
if isinstance(call, ast.Call) and _dotted(call.func).rsplit(".", 1)[-1] in _PUMP_CALLEES:
|
||||
self.pumps.update(a.id for a in list(call.args) + [k.value for k in call.keywords] if isinstance(a, ast.Name))
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "pytestmark" for t in node.targets):
|
||||
self.module_marks |= _marks(node.value)
|
||||
#: The numbers the module names (``GOTO_MS = 30000``), so that ``timeout=GOTO_MS`` is read as what it is.
|
||||
self.numbers: Dict[str, float] = {}
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Assign) and len(node.targets) == 1 and isinstance(node.targets[0], ast.Name):
|
||||
value = _number(node.value, self.numbers)
|
||||
if value is not None:
|
||||
self.numbers[node.targets[0].id] = value
|
||||
for parent in ast.walk(tree):
|
||||
for child in ast.iter_child_nodes(parent):
|
||||
child._parent = parent # type: ignore[attr-defined]
|
||||
self.visit(tree)
|
||||
|
||||
# -- scopes ---------------------------------------------------------------------------------------------------------------------------------
|
||||
@property
|
||||
def scope(self) -> str:
|
||||
if self.stack:
|
||||
return ".".join(self.stack)
|
||||
return "<module>." + self.assign if self.assign else "<module>"
|
||||
|
||||
def add(self, rule: str, node: ast.AST, text: str = "", line: Optional[int] = None) -> None:
|
||||
if self.exempt:
|
||||
return
|
||||
self.found.append((self.scope, rule, line or getattr(node, "lineno", 0), text))
|
||||
|
||||
def _enter_class(self, node: ast.ClassDef) -> None:
|
||||
marks = set()
|
||||
for stmt in node.body:
|
||||
if isinstance(stmt, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "pytestmark" for t in stmt.targets):
|
||||
marks |= _marks(stmt.value)
|
||||
marks |= set().union(*[_marks(d) for d in node.decorator_list]) if node.decorator_list else set()
|
||||
self.class_marks.append(marks)
|
||||
|
||||
def visit_ClassDef(self, node: ast.ClassDef) -> None:
|
||||
self._enter_class(node)
|
||||
self.stack.append(node.name)
|
||||
server = any(_SERVER_BASE.search(_dotted(b).rsplit(".", 1)[-1] or "") for b in node.bases)
|
||||
self.server_depth += 1 if server else 0
|
||||
for stmt in node.body:
|
||||
self.visit(stmt)
|
||||
self.server_depth -= 1 if server else 0
|
||||
self.stack.pop()
|
||||
self.class_marks.pop()
|
||||
|
||||
def _is_e2e_test(self, node: ast.AST) -> bool:
|
||||
marks = set(self.module_marks)
|
||||
for group in self.class_marks:
|
||||
marks |= group
|
||||
for decorator in getattr(node, "decorator_list", []):
|
||||
marks |= _marks(decorator)
|
||||
return "e2e" in marks
|
||||
|
||||
def _visit_function(self, node: ast.AST) -> None:
|
||||
name = node.name # type: ignore[attr-defined]
|
||||
skip = self.is_test_file and name.startswith("test_") and not self._is_e2e_test(node)
|
||||
self.stack.append(name)
|
||||
if skip:
|
||||
self.exempt += 1
|
||||
for decorator in node.decorator_list: # type: ignore[attr-defined]
|
||||
self.visit(decorator)
|
||||
self._visit_defaults(node)
|
||||
for stmt in node.body: # type: ignore[attr-defined]
|
||||
self.visit(stmt)
|
||||
for default in list(node.args.defaults) + [d for d in node.args.kw_defaults if d is not None]: # type: ignore[attr-defined]
|
||||
self.visit(default)
|
||||
if skip:
|
||||
self.exempt -= 1
|
||||
self.stack.pop()
|
||||
|
||||
visit_FunctionDef = _visit_function
|
||||
visit_AsyncFunctionDef = _visit_function
|
||||
|
||||
def visit_Assign(self, node: ast.Assign) -> None:
|
||||
in_module = not self.stack
|
||||
previous = self.assign
|
||||
if in_module and node.targets and isinstance(node.targets[0], ast.Name):
|
||||
self.assign = node.targets[0].id
|
||||
if in_module:
|
||||
for target in node.targets:
|
||||
if isinstance(target, ast.Name) and re.search(r"PORT$", target.id) and isinstance(node.value, ast.Constant) \
|
||||
and isinstance(node.value.value, int) and not isinstance(node.value.value, bool) and node.value.value != 0:
|
||||
self.add("port", node, "%s = %r" % (target.id, node.value.value))
|
||||
for target in node.targets:
|
||||
if self._is_environ_subscript(target):
|
||||
self.add("env", node, "os.environ[...] = ...")
|
||||
self.generic_visit(node)
|
||||
self.assign = previous
|
||||
|
||||
def visit_AnnAssign(self, node: ast.AnnAssign) -> None:
|
||||
previous = self.assign
|
||||
if not self.stack and isinstance(node.target, ast.Name):
|
||||
self.assign = node.target.id
|
||||
self.generic_visit(node)
|
||||
self.assign = previous
|
||||
|
||||
def visit_AugAssign(self, node: ast.AugAssign) -> None:
|
||||
if self._is_environ_subscript(node.target):
|
||||
self.add("env", node, "os.environ[...] op= ...")
|
||||
self.generic_visit(node)
|
||||
|
||||
def visit_Delete(self, node: ast.Delete) -> None:
|
||||
for target in node.targets:
|
||||
if self._is_environ_subscript(target):
|
||||
self.add("env", node, "del os.environ[...]")
|
||||
self.generic_visit(node)
|
||||
|
||||
@staticmethod
|
||||
def _is_environ_subscript(node: ast.AST) -> bool:
|
||||
return isinstance(node, ast.Subscript) and _dotted(node.value) in ("os.environ", "environ")
|
||||
|
||||
# -- strings --------------------------------------------------------------------------------------------------------------------------------
|
||||
def _is_docstring(self, node: ast.Constant) -> bool:
|
||||
parent = getattr(node, "_parent", None)
|
||||
if isinstance(parent, ast.Expr):
|
||||
return True
|
||||
return False
|
||||
|
||||
def visit_Constant(self, node: ast.Constant) -> None:
|
||||
if not isinstance(node.value, str) or self._is_docstring(node):
|
||||
return
|
||||
text = node.value
|
||||
for found in _TIMER.finditer(text):
|
||||
self.add("js-timer", node, found.group(0), line=node.lineno + text.count("\n", 0, found.start()))
|
||||
if not self.post:
|
||||
for found in _URL.finditer(text):
|
||||
if _host_is_real(found.group(1)):
|
||||
self.add("net", node, found.group(0), line=node.lineno + text.count("\n", 0, found.start()))
|
||||
if re.fullmatch(r"[\w.-]*port", text) is not None:
|
||||
pass
|
||||
|
||||
def visit_Dict(self, node: ast.Dict) -> None:
|
||||
for key, value in zip(node.keys, node.values):
|
||||
if isinstance(key, ast.Constant) and isinstance(key.value, str) and key.value.lower().endswith("port") \
|
||||
and isinstance(value, ast.Constant) and isinstance(value.value, int) and not isinstance(value.value, bool) and value.value != 0:
|
||||
self.add("port", node, "%s: %r" % (key.value, value.value))
|
||||
self.generic_visit(node)
|
||||
|
||||
# -- calls ----------------------------------------------------------------------------------------------------------------------------------
|
||||
def visit_Call(self, node: ast.Call) -> None:
|
||||
name = _dotted(node.func)
|
||||
leaf = name.rsplit(".", 1)[-1]
|
||||
if self._is_sleep(node, name, leaf) and not self._accepted_pause(node):
|
||||
self.add("sleep", node, "%s(%s)" % (name or leaf, ast.unparse(node.args[0]) if node.args else ""))
|
||||
self._ports_of(node, name, leaf)
|
||||
self._deadlines_of(node, leaf)
|
||||
if name in ("os.environ.pop", "os.environ.setdefault", "os.environ.update", "os.environ.clear", "os.putenv", "os.unsetenv",
|
||||
"environ.pop", "environ.setdefault", "environ.update", "environ.clear"):
|
||||
self.add("env", node, name)
|
||||
if not self.post and leaf in ("run", "check_call", "check_output", "Popen", "call") and name.startswith("subprocess."):
|
||||
installing = _PIP.search(" ".join(re.findall(r"'([^']*)'", ast.unparse(node))))
|
||||
if installing:
|
||||
self.add("net", node, "subprocess " + installing.group(0))
|
||||
if not self.post and (name in ("urllib.request.urlopen", "urlopen") or re.match(r"requests\.(get|post|put|head|request|delete)$", name)):
|
||||
self.add("net", node, name)
|
||||
self.generic_visit(node)
|
||||
|
||||
# -- deadlines ------------------------------------------------------------------------------------------------------------------------------
|
||||
def _deadlines_of(self, node: ast.Call, leaf: str) -> None:
|
||||
"""``timeout``: an explicit deadline under :data:`MIN_DEADLINE_S` on a wait for something that must happen."""
|
||||
leaf = node.func.attr if isinstance(node.func, ast.Attribute) else leaf
|
||||
receiver = _receiver(node.func)
|
||||
found: List[Tuple[ast.AST, str]] = []
|
||||
for keyword in node.keywords:
|
||||
if keyword.arg and _TIMEOUT_KEYWORD.search(keyword.arg):
|
||||
found.append((keyword.value, keyword.arg + "="))
|
||||
if leaf in ("set_default_timeout", "set_default_navigation_timeout") and node.args:
|
||||
found.append((node.args[0], ""))
|
||||
for value_node, label in found:
|
||||
value = _number(value_node, self.numbers)
|
||||
if value is None or value <= 0:
|
||||
continue # a variable (its own definition is read), None, or 0 (no deadline at all)
|
||||
driver = any(k.arg == "until" for k in node.keywords) # ``goto(url, until="load", timeout=30)``: the lifecycle of the driver, in seconds
|
||||
seconds = _deadline_seconds(value, leaf, label.rstrip("=") or "timeout", receiver, driver)
|
||||
if seconds >= MIN_DEADLINE_S or self._is_a_wait_for_nothing(node, value_node):
|
||||
continue
|
||||
self.add("timeout", node, "%s(%s%s)" % (leaf, label, ast.unparse(value_node)))
|
||||
|
||||
def _visit_defaults(self, node: ast.AST) -> None:
|
||||
"""The default of a parameter that is a deadline (``def wait(timeout=5)``): every call that leaves it out waits that long."""
|
||||
arguments = node.args # type: ignore[attr-defined]
|
||||
positional = list(arguments.posonlyargs) + list(arguments.args)
|
||||
pairs = list(zip(positional[len(positional) - len(arguments.defaults):], arguments.defaults)) + [
|
||||
(a, d) for a, d in zip(arguments.kwonlyargs, arguments.kw_defaults) if d is not None]
|
||||
for argument, default in pairs:
|
||||
if not _TIMEOUT_KEYWORD.search(argument.arg):
|
||||
continue
|
||||
value = _number(default, self.numbers)
|
||||
if value is None or value <= 0:
|
||||
continue
|
||||
if _deadline_seconds(value, node.name, argument.arg) < MIN_DEADLINE_S: # type: ignore[attr-defined]
|
||||
self.add("timeout", default, "def %s(%s=%s)" % (node.name, argument.arg, ast.unparse(default))) # type: ignore[attr-defined]
|
||||
|
||||
@staticmethod
|
||||
def _is_a_wait_for_nothing(call: ast.Call, limit: ast.AST) -> bool:
|
||||
"""A wait for something that must NOT happen, by its shape: a limit NAMED ``NEGATIVE...``; a call inside ``with pytest.raises(...)`` (the call is
|
||||
expected to run out of time); a call in the body of a ``try`` whose handler of a timeout goes on without failing. A slow machine can only make
|
||||
such a window a weaker check, never a red."""
|
||||
if isinstance(limit, ast.Name) and "NEGATIVE" in limit.id.upper():
|
||||
return True
|
||||
child: ast.AST = call
|
||||
parent: Optional[ast.AST] = getattr(call, "_parent", None)
|
||||
while parent is not None and not isinstance(parent, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):
|
||||
if isinstance(parent, (ast.With, ast.AsyncWith)) and child in parent.body:
|
||||
for item in parent.items:
|
||||
context = item.context_expr
|
||||
if isinstance(context, ast.Call) and _dotted(context.func).rsplit(".", 1)[-1] == "raises":
|
||||
return True
|
||||
if isinstance(parent, ast.Try) and child in parent.body:
|
||||
for handler in parent.handlers:
|
||||
caught = ast.unparse(handler.type) if handler.type is not None else ""
|
||||
fails = any(isinstance(sub, (ast.Raise, ast.Assert)) or (isinstance(sub, ast.Call) and _dotted(sub.func).rsplit(".", 1)[-1] in ("fail", "skip"))
|
||||
for sub in ast.walk(handler))
|
||||
if "Timeout" in caught and not fails:
|
||||
return True
|
||||
child, parent = parent, getattr(parent, "_parent", None)
|
||||
return False
|
||||
|
||||
def _is_sleep(self, node: ast.Call, name: str, leaf: str) -> bool:
|
||||
if leaf == "wait_for_timeout":
|
||||
return True
|
||||
if name in ("time.sleep", "asyncio.sleep") or (name == "sleep" and not isinstance(node.func, ast.Attribute)):
|
||||
argument = node.args[0] if node.args else None
|
||||
return not (isinstance(argument, ast.Constant) and argument.value == 0)
|
||||
return False
|
||||
|
||||
def _accepted_pause(self, node: ast.Call) -> bool:
|
||||
"""The shapes of a pause that is not a verdict on the speed of the machine."""
|
||||
function = None
|
||||
parent: Optional[ast.AST] = getattr(node, "_parent", None)
|
||||
lambda_of_a_pump = False
|
||||
loops: List[ast.AST] = []
|
||||
while parent is not None:
|
||||
if isinstance(parent, ast.Lambda):
|
||||
caller = getattr(parent, "_parent", None)
|
||||
if isinstance(caller, ast.keyword) and caller.arg in ("pump", "step", "pause"):
|
||||
lambda_of_a_pump = True
|
||||
elif isinstance(caller, ast.Call) and _dotted(caller.func).rsplit(".", 1)[-1] in _PUMP_CALLEES:
|
||||
lambda_of_a_pump = True
|
||||
if isinstance(parent, (ast.While, ast.For, ast.AsyncFor)):
|
||||
loops.append(parent)
|
||||
if isinstance(parent, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
||||
function = parent
|
||||
break
|
||||
parent = getattr(parent, "_parent", None)
|
||||
if lambda_of_a_pump:
|
||||
return True
|
||||
if function is not None and not function.name.startswith("test_") and (_POLLING_FUNCTIONS.match(function.name) or function.name in self.pumps):
|
||||
return True
|
||||
if self.server_depth > 0:
|
||||
return True
|
||||
for loop in loops:
|
||||
if self._is_a_poll_with_a_deadline(loop):
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _is_a_poll_with_a_deadline(loop: ast.AST) -> bool:
|
||||
"""A loop whose pause is the step of a wait that ends: a ``range`` of tries; or a comparison with a clock or a deadline that ends the loop, as its
|
||||
condition (``while not done and time.time() < deadline``), as an assertion inside it, or as a ``return``/``break``/``raise`` it leads to."""
|
||||
if isinstance(loop, (ast.For, ast.AsyncFor)) and isinstance(loop.iter, ast.Call) and _dotted(loop.iter.func) == "range":
|
||||
return any(isinstance(sub, (ast.Return, ast.Break, ast.Raise)) for sub in ast.walk(loop)) # N tries: the deadline is N pauses
|
||||
|
||||
def is_a_deadline(compare: ast.AST) -> bool:
|
||||
return isinstance(compare, ast.Compare) and (
|
||||
_reads_a_clock(compare) or any(_DEADLINE_NAMES.search(w) for w in re.findall(r"[A-Za-z_][A-Za-z0-9_]*", ast.unparse(compare))))
|
||||
|
||||
if isinstance(loop, ast.While) and any(is_a_deadline(sub) for sub in ast.walk(loop.test)):
|
||||
return True
|
||||
if any(isinstance(sub, ast.Assert) and any(is_a_deadline(c) for c in ast.walk(sub.test)) for sub in ast.walk(loop)):
|
||||
return True
|
||||
leaves = any(isinstance(sub, (ast.Return, ast.Break, ast.Raise)) for sub in ast.walk(loop))
|
||||
return leaves and any(is_a_deadline(sub) for sub in ast.walk(loop))
|
||||
|
||||
def _ports_of(self, node: ast.Call, name: str, leaf: str) -> None:
|
||||
if leaf in ("bind", "create_server", "create_datagram_endpoint", "start_server", "serve") or leaf.endswith("Server") or leaf.endswith("Proxy"):
|
||||
for argument in node.args[:1]:
|
||||
if isinstance(argument, ast.Tuple) and len(argument.elts) == 2:
|
||||
port = argument.elts[1]
|
||||
if isinstance(port, ast.Constant) and isinstance(port.value, int) and not isinstance(port.value, bool) and port.value != 0:
|
||||
self.add("port", node, "%s(..., %r)" % (leaf, port.value))
|
||||
for keyword in node.keywords:
|
||||
if keyword.arg == "port" and isinstance(keyword.value, ast.Constant) and isinstance(keyword.value.value, int) \
|
||||
and not isinstance(keyword.value.value, bool) and keyword.value.value != 0:
|
||||
self.add("port", node, "port=%r" % keyword.value.value)
|
||||
|
||||
# -- asserts --------------------------------------------------------------------------------------------------------------------------------
|
||||
@staticmethod
|
||||
def _upper_bounds(test: ast.AST, violated: bool = False) -> List[ast.Compare]:
|
||||
"""The comparisons of ``test`` that bound a duration from above by an absolute limit; ``violated``: the test is the condition that is reported
|
||||
(``if took > LIMIT``), not the one that must hold (``assert took < LIMIT``)."""
|
||||
found: List[ast.Compare] = []
|
||||
for sub in ast.walk(test):
|
||||
if not isinstance(sub, ast.Compare):
|
||||
continue
|
||||
left = sub.left
|
||||
for op, right in zip(sub.ops, sub.comparators):
|
||||
above = (isinstance(op, (ast.Lt, ast.LtE)) and _is_an_absolute_limit(right) and _is_a_duration(left)) \
|
||||
or (isinstance(op, (ast.Gt, ast.GtE)) and _is_an_absolute_limit(left) and _is_a_duration(right))
|
||||
over = (isinstance(op, (ast.Gt, ast.GtE)) and _is_an_absolute_limit(right) and _is_a_duration(left)) \
|
||||
or (isinstance(op, (ast.Lt, ast.LtE)) and _is_an_absolute_limit(left) and _is_a_duration(right))
|
||||
if over if violated else above:
|
||||
found.append(sub)
|
||||
left = right
|
||||
return found
|
||||
|
||||
def visit_If(self, node: ast.If) -> None:
|
||||
"""``bound`` in a judge that hands its problems back as sentences instead of asserting: ``if wall > first + MARGIN_MS: problems.append(...)`` is the same verdict
|
||||
on the machine as the assert. Only an ``if`` that REPORTS (appends, raises, fails) counts: the other ifs of a test are its logic."""
|
||||
reports = any(isinstance(sub, ast.Raise) or (isinstance(sub, ast.Call) and _dotted(sub.func).rsplit(".", 1)[-1] in ("append", "fail"))
|
||||
for stmt in node.body for sub in ast.walk(stmt))
|
||||
if reports:
|
||||
for found in self._upper_bounds(node.test, violated=True):
|
||||
self.add("bound", node, ast.unparse(found)[:80])
|
||||
self.generic_visit(node)
|
||||
|
||||
def visit_Assert(self, node: ast.Assert) -> None:
|
||||
for found in self._upper_bounds(node.test):
|
||||
self.add("bound", node, ast.unparse(found)[:80])
|
||||
for sub in ast.walk(node.test):
|
||||
if not isinstance(sub, ast.Compare):
|
||||
continue
|
||||
left = sub.left
|
||||
for op, right in zip(sub.ops, sub.comparators):
|
||||
if isinstance(op, (ast.Eq, ast.NotEq)) and self.file not in COUNTING:
|
||||
for side in (left, right):
|
||||
if isinstance(side, ast.Call) and _dotted(side.func) in ("len", "sorted") and side.args \
|
||||
and _PROCESS_WORDS.search(ast.unparse(side.args[0])):
|
||||
self.add("count", node, ast.unparse(sub)[:80])
|
||||
left = right
|
||||
self.generic_visit(node)
|
||||
|
||||
|
||||
def _is_e2e_file(tree: ast.Module) -> bool:
|
||||
return any(isinstance(sub, ast.Attribute) and sub.attr == "e2e" and isinstance(sub.value, ast.Attribute) and sub.value.attr == "mark"
|
||||
for sub in ast.walk(tree))
|
||||
|
||||
|
||||
def analyze(source: str, file: str, *, force: bool = False) -> List[Violation]:
|
||||
"""The occurrences of ``source`` (the content of ``tests/<file>``). A test file with no ``e2e`` marker is not read, unless ``force`` (the helpers always are)."""
|
||||
tree = ast.parse(source)
|
||||
e2e = _is_e2e_file(tree) or not file.startswith("test_") or force
|
||||
if not e2e or file in SELF:
|
||||
return []
|
||||
reader = _Reader(file, tree, e2e)
|
||||
reader.found.sort(key=lambda item: item[2])
|
||||
counts: Dict[Tuple[str, str], int] = {}
|
||||
out: List[Violation] = []
|
||||
for scope, rule, line, text in reader.found:
|
||||
counts[(scope, rule)] = counts.get((scope, rule), 0) + 1
|
||||
out.append(Violation(file, scope, rule, counts[(scope, rule)], line, text))
|
||||
return out
|
||||
|
||||
|
||||
def analyze_conftest(source: str) -> List[Violation]:
|
||||
"""``egress``: the conftest declares the exit of the lab for the session, or every launch asks the internet."""
|
||||
tree = ast.parse(source)
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.FunctionDef) and node.name == "_the_lab_declares_the_exit":
|
||||
for decorator in node.decorator_list:
|
||||
if isinstance(decorator, ast.Call) and _dotted(decorator.func).endswith("fixture"):
|
||||
options = {kw.arg: getattr(kw.value, "value", None) for kw in decorator.keywords}
|
||||
if options.get("scope") == "session" and options.get("autouse") is True and "install" in ast.unparse(node):
|
||||
return []
|
||||
return [Violation("conftest.py", "<module>", "egress", 1, 1, "no autouse session fixture declares the exit of the lab")]
|
||||
|
||||
|
||||
def files(directory: Path = TESTS) -> Iterable[Path]:
|
||||
"""The python files of ``tests/`` (not the subfolders: ``gates/`` is data, ``playwright-upstream/`` is another suite)."""
|
||||
return sorted(p for p in directory.glob("*.py") if p.name not in SELF)
|
||||
|
||||
|
||||
def scan(directory: Path = TESTS) -> List[Violation]:
|
||||
"""Every occurrence of every file of ``tests/``."""
|
||||
out: List[Violation] = []
|
||||
for path in files(directory):
|
||||
source = path.read_text(encoding="utf-8")
|
||||
out.extend(analyze(source, path.name))
|
||||
conftest = directory / "conftest.py"
|
||||
if conftest.is_file():
|
||||
out.extend(analyze_conftest(conftest.read_text(encoding="utf-8")))
|
||||
return out
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The reviewed list: ``tests/gates/e2e_clock_exceptions.json``
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
GATE_FILE = TESTS / "gates" / "e2e_clock_exceptions.json"
|
||||
|
||||
#: Why an occurrence is deliberate, as a closed vocabulary:
|
||||
#:
|
||||
#: * ``negative-window``: a fixed window in which something must NOT happen; a slow machine can only make it a weaker check (a false green), never a red.
|
||||
#: * ``stimulus``: the time is the input the test gives: a page timer that fires the thing the product waits for, a server, relay or client that answers late on purpose,
|
||||
#: or a pause between two events the test generates. The product waits with a deadline; the verdict does not read when it fired.
|
||||
#: * ``instrument``: a measuring or a test-server tool: the test of ``wait_for_timeout`` itself, the pause that lets a value settle before it is READ back, the teardown of a
|
||||
#: test server's loop.
|
||||
#: * ``virtual-port``: a port number that is never bound: the gateway of the test answers for it by name.
|
||||
#: * ``post-publication``: the round after a publication (``tests/_post_publication.py``).
|
||||
#: * ``hang-detector``: the deadline of a wait for a thing that must happen (a timer, a step or a limit of 30 s or more that ends the wait of a condition), a limit as high as
|
||||
#: the product's own timeout, or a wait with no clock whose end is an event of the test's own server; it ends a hang, it judges no speed.
|
||||
#: * ``cpu-budget``: a bound on the CPU seconds of a process (user + kernel), not on a time that passes: a machine that is slow or stops stretches the clock and not the CPU,
|
||||
#: and the bound has a margin measured on the runner (it is not a structure, so the reason says the numbers).
|
||||
KINDS = ("negative-window", "stimulus", "instrument", "virtual-port", "post-publication", "hang-detector", "cpu-budget")
|
||||
|
||||
#: What a ``debt`` item says, by rule: why the occurrence can be red for a reason that is nobody's fault, and what replaces it.
|
||||
DEBT_REASON = {
|
||||
"sleep": "A fixed pause and then a read judges the speed of the machine: wait for the condition with a deadline (tests/_waits.py wait_until) and read after it.",
|
||||
"js-timer": "The verdict depends on when a timer of the test page fires against what the product does: let the test decide when the thing happens, then wait for it with a deadline.",
|
||||
"bound": "An absolute upper bound on a duration is a verdict on the machine: compare with a control measured in the same run, or assert the order of the events.",
|
||||
"port": "A literal port is shared by the workers that run at once and by whoever else holds it: bind port 0 and read the port back.",
|
||||
"env": "os.environ written directly is not undone when the test ends or fails: use monkeypatch.setenv, which restores it.",
|
||||
"net": "A real host in a gate is a third party: serve the page and the answer from the test's own server.",
|
||||
"count": "The number of processes is not something the product promises: count by site name or against the pool the product keeps (tests/_processes.py, tests/_waits.py).",
|
||||
"timeout": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it.",
|
||||
"egress": "The launch asks three services of the internet where it leaves from: declare the exit (tests/_lab_egress.py).",
|
||||
}
|
||||
|
||||
|
||||
def empty_document() -> Dict[str, object]:
|
||||
return {"version": 1, "entries": [], "debt": []}
|
||||
|
||||
|
||||
def load(path: Path = GATE_FILE) -> Dict[str, object]:
|
||||
import json
|
||||
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def dump(document: Dict[str, object]) -> str:
|
||||
"""The file as it is written: stable order, one item per line, a newline at the end (the same bytes whoever writes it)."""
|
||||
import json
|
||||
|
||||
def line(item: Dict[str, object]) -> str:
|
||||
return " " + json.dumps(item, ensure_ascii=False)
|
||||
|
||||
out = ["{", ' "version": %d,' % document["version"]]
|
||||
for name, last in (("entries", False), ("debt", True)):
|
||||
items = sorted(document[name], key=lambda i: (i["file"], i["scope"], i["rule"], i["nth"])) # type: ignore[index, union-attr]
|
||||
out.append(' "%s": [' % name)
|
||||
out.append(",\n".join(line(i) for i in items))
|
||||
out.append(" ]" + ("" if last else ","))
|
||||
out.append("}")
|
||||
return "\n".join(out) + "\n"
|
||||
|
||||
|
||||
def key_of(item: Dict[str, object]) -> Tuple[str, str, str, int]:
|
||||
return (str(item["file"]), str(item["scope"]), str(item["rule"]), int(item["nth"])) # type: ignore[call-overload]
|
||||
|
||||
|
||||
def compare(found: Iterable[Violation], document: Dict[str, object]) -> Dict[str, List[Tuple[str, str, str, int]]]:
|
||||
"""``new``: occurrences in no list; ``stale_entries`` / ``stale_debt``: items of a list that match no occurrence; ``both``: in the two lists."""
|
||||
seen = {v.key for v in found}
|
||||
entries = {key_of(i) for i in document["entries"]} # type: ignore[union-attr]
|
||||
debt = {key_of(i) for i in document["debt"]} # type: ignore[union-attr]
|
||||
return {"new": sorted(seen - entries - debt), "stale_entries": sorted(entries - seen), "stale_debt": sorted(debt - seen),
|
||||
"both": sorted(entries & debt)}
|
||||
|
||||
|
||||
def regenerate(document: Dict[str, object], found: Iterable[Violation], *, prune_entries: bool = False) -> Dict[str, object]:
|
||||
"""The document with its ``debt`` made again: every occurrence that no ``entries`` item covers. ``entries`` are reviewed by a person and stay as they
|
||||
are (``prune_entries`` drops the ones that match nothing any more: a correction that removed a deliberate pause)."""
|
||||
found = list(found)
|
||||
seen = {v.key for v in found}
|
||||
entries = [dict(i) for i in document["entries"]] # type: ignore[union-attr]
|
||||
if prune_entries:
|
||||
entries = [i for i in entries if key_of(i) in seen]
|
||||
covered = {key_of(i) for i in entries}
|
||||
debt = [{"file": v.file, "scope": v.scope, "rule": v.rule, "nth": v.nth, "class": v.klass, "reason": DEBT_REASON[v.rule]}
|
||||
for v in sorted(found, key=lambda v: v.key) if v.key not in covered]
|
||||
return {"version": document.get("version", 1), "entries": entries, "debt": debt}
|
||||
@@ -0,0 +1,173 @@
|
||||
"""Verdicts the e2e tests give from what they recorded, as pure functions of it (so a unit test can feed them the red
|
||||
case and the green case without a browser).
|
||||
|
||||
A verdict here never reads a clock of the machine it runs on: it compares what happened to what happened, or to a
|
||||
control measured in the same launch.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable, List, Optional, Sequence, Tuple
|
||||
|
||||
|
||||
def cold_association_problem(associations: Sequence[Sequence[Optional[float]]],
|
||||
via: Iterable[Tuple[str, int, int, float]], host: str, born: float) -> Optional[str]:
|
||||
"""What is wrong with the way the first STUN datagram of a PeerConnection left, or None.
|
||||
|
||||
``associations`` are the UDP associations the gateway granted, ``[start, end]`` in seconds from its start (``end``
|
||||
None while unanswered; the first granted one is the core's own probe, made before the browser exists, and is no
|
||||
association of the engine); ``via`` are the datagrams the relay carried, ``(host, port, association index, time)``;
|
||||
``born`` is the birth of the PeerConnection on the gateway's clock.
|
||||
|
||||
The promise is that the first datagram leaves on an association that was ready before the PeerConnection was
|
||||
born, not that it leaves within some number of milliseconds: a cold association is made AFTER the birth, so the
|
||||
datagram that leaves on one is the defect, whatever the speed of the machine."""
|
||||
granted = [i for i, a in enumerate(associations) if a[1] is not None][1:]
|
||||
if not granted:
|
||||
return "the engine never asked the proxy for an association (only the core's probe did)"
|
||||
ready = [i for i in granted if associations[i][1] < born]
|
||||
if not ready:
|
||||
return ("no association was completed before the PeerConnection was born (granted at %s s from the gateway's "
|
||||
"start, the PeerConnection at %.3f s): the first ICE socket made its own, from scratch"
|
||||
% ([round(associations[i][1], 3) for i in granted], born))
|
||||
sent = sorted((t, index) for h, _port, index, t in via if h == host)
|
||||
if not sent:
|
||||
return "no STUN datagram of the PeerConnection reached the relay"
|
||||
at, index = sent[0]
|
||||
if index not in ready:
|
||||
return ("the first STUN datagram (at %.3f s) left on association #%d, granted at %s s, after the PeerConnection "
|
||||
"was born at %.3f s: a cold association, made from scratch (ready before the birth: %s)"
|
||||
% (at, index, associations[index][1] and round(associations[index][1], 3), born, ready))
|
||||
return None
|
||||
|
||||
|
||||
# ── the road of a TURN server written as a name ────────────────────────────────────────────────────────────────────────
|
||||
#
|
||||
# Two promises, and neither is a number of seconds. The first is CAUSAL: the test holds the handshakes that were begun after the
|
||||
# pool of associations was ready (the gateway answers nothing on them, whatever the speed of the machine) and the allocation has to
|
||||
# be answered all the same, while they are held; a handshake that waits for another leaves it waiting until the test lets them go.
|
||||
# The second is a COUNT: the exchanges the gateway, the DoH and the TURN server recorded from the birth of the PeerConnection to
|
||||
# the Allocate answered with credentials are no more than the protocols ask for. A slow machine makes each of them later, never more.
|
||||
|
||||
#: The exchanges of a SOCKS5 control connection (RFC 1928): the method negotiation (section 3) and the request with its reply
|
||||
#: (sections 4 and 6). With a user and a password (RFC 1929, section 2) the sub-negotiation is one more.
|
||||
SOCKS_EXCHANGES = 2
|
||||
SOCKS_AUTH_EXCHANGES = 1
|
||||
#: A name asked of the DoH by a resolver that was told the family it wants (`nriceresolver.cpp` passes RESOLVE_DISABLE_IPV6 for
|
||||
#: AF_INET, and a SOCKS5 UDP relay carries IPv4 here): ONE question, the A record, answered in one HTTP exchange (RFC 8484, section 4).
|
||||
DOH_QUESTIONS = 1
|
||||
#: The Allocate of a TURN client (RFC 8656, section 7.1, with the long-term credential mechanism of RFC 8489, section 9.2): the first
|
||||
#: request carries no credentials and is answered 401 with a REALM and a NONCE, the second carries them and is answered with the
|
||||
#: relayed address. A retransmission of one is the same transaction (same transaction id), so it is not counted twice.
|
||||
ALLOCATE_TRANSACTIONS = 2
|
||||
#: The control connections of the road after the birth that are not an ASSOCIATE: ONE, the CONNECT to the DoH that carries the
|
||||
#: question, and none when the connection that loaded the page is still open and carries it. A connection for every question, or a
|
||||
#: second one, is a handshake nobody needs.
|
||||
CONNECTS_AFTER_THE_BIRTH = 1
|
||||
|
||||
|
||||
def turn_exchanges_most(auth: bool = False) -> int:
|
||||
"""The most exchanges the road may cost (see :func:`turn_exchanges_problem`): five with no user and password, six with them."""
|
||||
per_connection = SOCKS_EXCHANGES + (SOCKS_AUTH_EXCHANGES if auth else 0)
|
||||
return CONNECTS_AFTER_THE_BIRTH * per_connection + DOH_QUESTIONS + ALLOCATE_TRANSACTIONS
|
||||
|
||||
|
||||
def turn_exchanges(born: float, allocated_at: float, requests: Iterable[Tuple[float, int, str, str]],
|
||||
doh_questions: Sequence[Tuple[str, int]], allocates: Sequence[Tuple[float, bytes, int, bool]],
|
||||
auth: bool = False) -> Tuple[int, List[str]]:
|
||||
"""The exchanges of the road from the birth to the Allocate answered with credentials, as (their number, what is more than the
|
||||
protocols ask for, in words). Every control connection that carried a CONNECT (or any command but ASSOCIATE) costs its greeting
|
||||
and its command (and the authentication); every DoH question one; every distinct Allocate transaction one."""
|
||||
commands = [r for r in requests if r[2] in ("connect", "other") and born <= r[0] <= allocated_at]
|
||||
transactions = [t for t in allocates if t[0] <= allocated_at]
|
||||
per_connection = SOCKS_EXCHANGES + (SOCKS_AUTH_EXCHANGES if auth else 0)
|
||||
found = []
|
||||
if len(commands) > CONNECTS_AFTER_THE_BIRTH:
|
||||
found.append("%d SOCKS5 control connections with a command other than ASSOCIATE after the birth (%s), the design needs %d at most"
|
||||
% (len(commands), [r[3] for r in commands], CONNECTS_AFTER_THE_BIRTH))
|
||||
if len(doh_questions) > DOH_QUESTIONS:
|
||||
found.append("%d DoH questions for the name (%s), a resolver told its family asks %d"
|
||||
% (len(doh_questions), list(doh_questions), DOH_QUESTIONS))
|
||||
if len(transactions) > ALLOCATE_TRANSACTIONS:
|
||||
found.append("%d Allocate transactions (%s), the long-term credential asks %d: the one without credentials, answered 401, and "
|
||||
"the one with them" % (len(transactions), [("credentials" if t[3] else "no credentials") for t in transactions],
|
||||
ALLOCATE_TRANSACTIONS))
|
||||
return len(commands) * per_connection + len(doh_questions) + len(transactions), found
|
||||
|
||||
|
||||
def turn_exchanges_problem(born: float, allocated_at: float, requests: Iterable[Tuple[float, int, str, str]],
|
||||
doh_questions: Sequence[Tuple[str, int]],
|
||||
allocates: Sequence[Tuple[float, bytes, int, bool]], auth: bool = False) -> Optional[str]:
|
||||
"""What is wrong with the NUMBER of exchanges of the road, from the birth of the PeerConnection (``born``) to the Allocate answered
|
||||
with credentials (``allocated_at``), or None. The times are seconds on the gateway's clock and only ORDER the records: nothing
|
||||
here compares one with a duration, so a machine whose every stamp is later gives the same count.
|
||||
|
||||
``requests`` is ``Gateway.requests``; ``doh_questions`` the (name, type) of every question the DoH heard for the TURN name (nothing
|
||||
else asks it, so the question is the PeerConnection's); ``allocates`` the transactions of ``TurnServer.transactions()``.
|
||||
|
||||
The most the road may cost: one SOCKS5 control connection with its CONNECT to the DoH (``SOCKS_EXCHANGES``, one more with a user
|
||||
and a password), the one DoH question, the two transactions of the Allocate. An ASSOCIATE is no exchange of this road: the
|
||||
association that carries the Allocate is made before the birth (``cold_association_problem`` judges it, and the held handshakes
|
||||
of ``held_handshake_problem`` prove that nothing waits for one made after)."""
|
||||
seen, found = turn_exchanges(born, allocated_at, requests, doh_questions, allocates, auth)
|
||||
most = turn_exchanges_most(auth)
|
||||
if not found and seen <= most:
|
||||
return None
|
||||
return ("the road made %d exchanges from the birth to the Allocate answered with credentials, the protocols ask for %d at most "
|
||||
"(%d per SOCKS5 control connection x %d, %d DoH question, %d Allocate transactions): %s"
|
||||
% (seen, most, SOCKS_EXCHANGES + (SOCKS_AUTH_EXCHANGES if auth else 0), CONNECTS_AFTER_THE_BIRTH, DOH_QUESTIONS,
|
||||
ALLOCATE_TRANSACTIONS, "; ".join(found) or "more than that in all"))
|
||||
|
||||
|
||||
def held_handshake_problem(allocated_at: Optional[float], released_at: float, held: Sequence[float]) -> Optional[str]:
|
||||
"""What is wrong with the way the road behaved while the handshakes begun after the pool was ready were HELD, or None.
|
||||
|
||||
``held`` are the starts (seconds on the gateway's clock) of the associations whose answer the test held; ``released_at`` is the
|
||||
instant the test let them go (once the page had posted its srflx, or at its 30 s deadline); ``allocated_at`` is the moment the
|
||||
TURN server answered the Allocate that carried credentials (None: it never did).
|
||||
|
||||
The promise is an ORDER, read off two stamps of the same clock: the allocation was answered BEFORE the held handshakes were let
|
||||
go. A road whose Allocate needs no handshake made after the birth, and whose DoH connection does not wait behind one, does not
|
||||
notice them; one whose handshakes are made one after the other on the same thread (or whose Allocate leaves on an association
|
||||
made from scratch) is left waiting for the test, whatever the speed of the machine."""
|
||||
shown = [round(t, 3) for t in held]
|
||||
if allocated_at is None:
|
||||
return ("the TURN server never answered an Allocate that carried credentials, with %d association handshake(s) held after the "
|
||||
"pool was ready (begun at %s s): something of the road waits for a handshake" % (len(held), shown))
|
||||
if allocated_at > released_at:
|
||||
return ("the Allocate was answered at %.3f s, after the %d held association handshake(s) (begun at %s s) were let go at "
|
||||
"%.3f s: the road waited for a handshake it does not need, one handshake waits for another"
|
||||
% (allocated_at, len(held), shown, released_at))
|
||||
return None
|
||||
|
||||
|
||||
def turn_chain_problem(born: float, allocated_at: Optional[float], released_at: float, held: Sequence[float],
|
||||
requests: Iterable[Tuple[float, int, str, str]], doh_questions: Sequence[Tuple[str, int]],
|
||||
allocates: Sequence[Tuple[float, bytes, int, bool]],
|
||||
associations: Sequence[Sequence[Optional[float]]], via: Iterable[Tuple[str, int, int, float]], host: str,
|
||||
auth: bool = False) -> Optional[str]:
|
||||
"""What is wrong with the road of a TURN server written as a name, or None: the allocation was answered while the later handshakes
|
||||
were held (:func:`held_handshake_problem`), it cost no exchange more than the protocols ask for (:func:`turn_exchanges_problem`),
|
||||
and the Allocate left on an association that was ready before the birth (:func:`cold_association_problem`). ``host`` is the
|
||||
address of the TURN server: the datagrams of the allocation are the ones judged. Nothing here reads a duration."""
|
||||
problem = held_handshake_problem(allocated_at, released_at, held)
|
||||
if problem is not None or allocated_at is None:
|
||||
return problem
|
||||
return (turn_exchanges_problem(born, allocated_at, requests, doh_questions, allocates, auth)
|
||||
or cold_association_problem(associations, via, host, born))
|
||||
|
||||
|
||||
#: The first retry of the mDNS responder: a name that does not come back opens a connection only after it.
|
||||
MDNS_RETRY_MS = 3000
|
||||
#: A page whose own loop did not run for this long (milliseconds) while it waited was stalled by the machine, not by the product.
|
||||
STALL_MS = 1000
|
||||
|
||||
|
||||
def opened_at_the_retry_problem(opened_ms: float, stalled_ms: float, retry_ms: float = MDNS_RETRY_MS, stall_ms: float = STALL_MS) -> Optional[str]:
|
||||
"""What is wrong with the time a connection took to open, or None. The promise is that it opens before the responder's retry (a name
|
||||
that did not come back is the slow road), and a clock cannot say it alone: a machine that stops for seconds opens late on the best of roads.
|
||||
``stalled_ms`` is the longest time the page's own loop did not run while it waited, read in the same run; a page that was stopped for
|
||||
``stall_ms`` or more says nothing of the road, so no time is judged then."""
|
||||
if opened_ms < retry_ms or stalled_ms >= stall_ms:
|
||||
return None
|
||||
return "opened after %d ms, at the responder's retry (%d ms), and the page's own loop was never stopped for %d ms (longest %d ms)" % (
|
||||
opened_ms, retry_ms, stall_ms, stalled_ms)
|
||||
@@ -0,0 +1,303 @@
|
||||
"""What the Fission frame tests (`test_fission_frames_*_e2e.py`) share: three sites, and a proof of a process.
|
||||
|
||||
Three SITES on one machine, told apart by HOST and never by port (`127.0.0.1:1` and `127.0.0.1:2` are one site,
|
||||
so a frame served from the other port stays in the process of its page):
|
||||
|
||||
A 127.0.0.1 the top page, and the A inside A > B > A > C
|
||||
B localhost the iframe of another site
|
||||
C 127.0.0.2 the third site
|
||||
|
||||
The wrapper runs Fission the way retail Firefox does (strategy 1, one content process per site), so with no pref a
|
||||
frame of B inside a page of A runs in another process.
|
||||
|
||||
`assert_other_process` is how a test proves that, from inside the pages and with no help from the driver: the
|
||||
frame spins for 600 ms and the observer frame ticks a 10 ms timer: a tick that runs INSIDE the spin proves the two do
|
||||
not share a process (one thread cannot tick while it spins), and no amount of load can fake that. The absence of ticks
|
||||
proves nothing on a loaded machine (the observer may be starved for the whole spin), so the spin is repeated, up to six
|
||||
times, and the test is red only when no spin ever shows a tick inside it.
|
||||
A test file calls it at least once, so the suite cannot silently turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import struct
|
||||
import threading
|
||||
import zlib
|
||||
import time
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
from _servers import LocalServer
|
||||
|
||||
HOSTS = {"A": "127.0.0.1", "B": "localhost", "C": "127.0.0.2"}
|
||||
|
||||
#: How long the frame keeps its main thread busy.
|
||||
SPIN_MS = 600
|
||||
|
||||
HTML = "text/html; charset=utf-8"
|
||||
|
||||
|
||||
class Sites:
|
||||
"""Three local servers, one per site, and the routes they serve.
|
||||
|
||||
``route(site, path, body, ...)`` registers a page; ``body`` is a string or bytes, or a function of the request
|
||||
that returns the same (the request is the handler: ``.headers``, ``.query``). ``requests`` lists what arrived,
|
||||
as dicts with ``site``, ``path``, ``query``, ``method`` and ``headers``.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._routes = {}
|
||||
self.requests = []
|
||||
self.servers = {}
|
||||
self.origin = {}
|
||||
sites = self
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
timeout = 10
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def _answer(self):
|
||||
url = urlsplit(self.path)
|
||||
self.query = parse_qs(url.query)
|
||||
site = self.server.site
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
self.body = self.rfile.read(length) if length else b""
|
||||
# `at` is when it arrived and `done` when its answer was written (the clock of the test process):
|
||||
# what a test needs to say how long the network was quiet between two requests
|
||||
entry = {"site": site, "path": url.path, "query": self.query, "method": self.command,
|
||||
"headers": dict(self.headers), "at": time.monotonic(), "done": None}
|
||||
sites.requests.append(entry)
|
||||
spec = sites._routes.get((site, url.path))
|
||||
if spec is None:
|
||||
self.send_response(404)
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
entry["done"] = time.monotonic()
|
||||
return
|
||||
body = spec["body"](self) if callable(spec["body"]) else spec["body"]
|
||||
if isinstance(body, str):
|
||||
body = body.encode("utf-8")
|
||||
if spec["delay"]:
|
||||
time.sleep(spec["delay"])
|
||||
try:
|
||||
self.send_response(spec["status"])
|
||||
self.send_header("Content-Type", spec["ctype"])
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
for name, value in spec["headers"]:
|
||||
self.send_header(name, value)
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
except OSError:
|
||||
pass
|
||||
entry["done"] = time.monotonic()
|
||||
|
||||
do_GET = _answer
|
||||
do_POST = _answer
|
||||
|
||||
self._handler = Handler
|
||||
|
||||
def __enter__(self):
|
||||
for site, host in HOSTS.items():
|
||||
server = LocalServer((host if host != "localhost" else "127.0.0.1", 0), self._handler)
|
||||
server.site = site
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
self.servers[site] = server
|
||||
self.origin[site] = "http://%s:%d" % (host, server.server_address[1])
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
for server in self.servers.values():
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
def url(self, site, path=""):
|
||||
return self.origin[site] + path
|
||||
|
||||
def route(self, site, path, body, ctype=HTML, status=200, headers=(), delay=0):
|
||||
self._routes[(site, path)] = {"body": body, "ctype": ctype, "status": status,
|
||||
"headers": list(headers), "delay": delay}
|
||||
|
||||
def seen(self, site, path):
|
||||
return [r for r in self.requests if r["site"] == site and r["path"] == path]
|
||||
|
||||
|
||||
def wait_for(page, predicate, seconds=10.0):
|
||||
"""Until ``predicate()``, with the client's events being read (the sync client takes the engine's events only
|
||||
inside its own calls, so a plain sleep would never see a frame arrive)."""
|
||||
end = time.monotonic() + seconds
|
||||
while time.monotonic() < end:
|
||||
if predicate():
|
||||
return True
|
||||
page.wait_for_timeout(100)
|
||||
return bool(predicate())
|
||||
|
||||
|
||||
def frame_of(page, origin, path=None):
|
||||
"""The frame of ``page`` whose url starts with ``origin`` (and ``path``), or None."""
|
||||
prefix = origin + (path or "")
|
||||
for frame in page.frames:
|
||||
if frame.url.startswith(prefix):
|
||||
return frame
|
||||
return None
|
||||
|
||||
|
||||
def wait_frame(page, origin, path=None, seconds=10.0):
|
||||
wait_for(page, lambda: frame_of(page, origin, path) is not None, seconds)
|
||||
frame = frame_of(page, origin, path)
|
||||
assert frame is not None, "no frame at %s%s; page.frames = %r" % (origin, path or "", [f.url for f in page.frames])
|
||||
return frame
|
||||
|
||||
|
||||
def launch(binary, humanize=False, **kwargs):
|
||||
"""The browser of every test here: seed 42, headless, no humanizing unless asked."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
return InvisiblePlaywright(seed=42, binary_path=binary, humanize=humanize, headless=True, **kwargs)
|
||||
|
||||
|
||||
def new_page(browser, **context_kwargs):
|
||||
context = browser.new_context(**context_kwargs)
|
||||
page = context.new_page()
|
||||
page.set_default_timeout(30000)
|
||||
page.set_default_navigation_timeout(30000)
|
||||
return context, page
|
||||
|
||||
|
||||
def spin_trial(observer, frame, spin_ms=SPIN_MS):
|
||||
"""Make ``frame`` spin for ``spin_ms`` while ``observer`` (a frame) ticks a 10 ms timer, and return
|
||||
``(ticks, window)``: the wall-clock time (ms) of every tick, and the ``(start, end)`` of the spin, both read
|
||||
from ``Date.now()`` (one clock for every process)."""
|
||||
observer.evaluate("""() => {
|
||||
window.__ticks = [];
|
||||
window.__tick = setInterval(() => window.__ticks.push(Date.now()), 10);
|
||||
}""")
|
||||
frame.evaluate("""(ms) => { window.__spin = null; setTimeout(() => {
|
||||
const start = Date.now();
|
||||
const end = performance.now() + ms;
|
||||
while (performance.now() < end) { /* spin */ }
|
||||
window.__spin = [start, Date.now()];
|
||||
}, 50); }""", spin_ms)
|
||||
# until the frame says its spin is over (a condition with a deadline, not spin_ms + 800 ms): the ticks of the whole spin are in the list by then
|
||||
window = wait_for_value(observer.page, lambda: frame.evaluate("window.__spin"))
|
||||
ticks = observer.evaluate("() => { clearInterval(window.__tick); return window.__ticks; }")
|
||||
return ticks, window
|
||||
|
||||
|
||||
def wait_for_value(page, read, seconds=30.0):
|
||||
"""``read()`` once it is not None, with the client's events being read; None if it never is."""
|
||||
end = time.monotonic() + seconds
|
||||
value = read()
|
||||
while value is None and time.monotonic() < end:
|
||||
page.wait_for_timeout(100)
|
||||
value = read()
|
||||
return value
|
||||
|
||||
|
||||
#: A tick counts as "inside" the spin when it is this far (ms) from both ends of it, and the spin must hold this
|
||||
#: many of them. A page that shares the frame's process runs no tick in the spin at all.
|
||||
INSIDE_MARGIN_MS = 10
|
||||
INSIDE_TICKS = 3
|
||||
|
||||
|
||||
def ticks_inside(ticks, window):
|
||||
"""How many ``ticks`` ran strictly inside the spin ``window`` (start, end)."""
|
||||
if window is None:
|
||||
return 0
|
||||
start, end = window
|
||||
return sum(1 for tick in ticks if start + INSIDE_MARGIN_MS < tick < end - INSIDE_MARGIN_MS)
|
||||
|
||||
|
||||
def other_process_proved(trials):
|
||||
"""Whether any trial ``(ticks, window)`` shows the observer running while the frame spun.
|
||||
|
||||
The proof is one-sided on purpose. A frame that shares the observer's process spins ON the observer's thread, so
|
||||
no tick of the observer can run between the start and the end of the spin: in every trial, whatever the load,
|
||||
zero ticks are inside. A frame in another process leaves the observer free, and ticks run inside the spin unless
|
||||
the machine happens to starve the observer for the whole spin; a loaded machine does that now and then (stalls of
|
||||
2 s have been seen between two processes), so a trial where no tick ran says nothing, and the test asks again.
|
||||
What it cannot be is wrong the other way: a tick inside a spin is impossible in one process."""
|
||||
return any(ticks_inside(ticks, window) >= INSIDE_TICKS for ticks, window in trials)
|
||||
|
||||
|
||||
#: The spins of the proof that two frames share ONE process (``test_fission_identity_parity_e2e.py`` strategy 0): a frame that shares the observer's process shows no
|
||||
#: tick inside, in any spin (the absence is the proof), so a fixed number of spins is enough to say it, and there is no clock in it.
|
||||
TRIALS = 6
|
||||
#: The proof of ANOTHER process is one spin with ticks inside it, and a loaded machine starves the observer for a whole spin now and then: the spins go on until
|
||||
#: one shows them, within this many seconds (the deadline of the wait; no healthy run comes near it).
|
||||
PROOF_SECONDS = 30.0
|
||||
|
||||
|
||||
def assert_other_process(observer, frame, seconds=PROOF_SECONDS, clock=time.monotonic):
|
||||
"""``frame`` runs in a process of its own, not the one of ``observer``: the observer's timer ticks while the frame
|
||||
spins. Spins until one shows ticks inside it (a healthy machine needs one), for ``seconds``."""
|
||||
trials = []
|
||||
end = clock() + seconds
|
||||
while True:
|
||||
trials.append(spin_trial(observer, frame))
|
||||
if other_process_proved(trials):
|
||||
return
|
||||
if clock() >= end:
|
||||
break
|
||||
assert False, (
|
||||
"the frame at %s shares the process of the observer at %s: in %d spins of %d ms the observer's 10 ms timer never "
|
||||
"ticked inside a spin (a frame of another process leaves it free; here: ticks inside, ticks in all, spin ms) %s" % (
|
||||
frame.url, observer.url, len(trials), SPIN_MS,
|
||||
[(ticks_inside(t, w), len(t), (w[1] - w[0]) if w else None) for t, w in trials]))
|
||||
|
||||
|
||||
def js(value):
|
||||
"""``value`` as a JavaScript literal, for a page built from a template."""
|
||||
return json.dumps(value)
|
||||
|
||||
|
||||
def decode_png(data):
|
||||
"""``(width, height, pixel)`` of a PNG made by the browser (8 bits, no interlace); ``pixel(x, y)`` is the
|
||||
``(r, g, b)`` tuple. Enough to ask what colour a screenshot has at a point, with no imaging library."""
|
||||
assert data[:8] == bytes([137, 80, 78, 71, 13, 10, 26, 10]), "not a PNG"
|
||||
pos, idat, width = 8, b"", None
|
||||
while pos < len(data):
|
||||
(length,) = struct.unpack(">I", data[pos:pos + 4])
|
||||
kind, body = data[pos + 4:pos + 8], data[pos + 8:pos + 8 + length]
|
||||
if kind == b"IHDR":
|
||||
width, height, depth, color, _, _, interlace = struct.unpack(">IIBBBBB", body)
|
||||
assert depth == 8 and interlace == 0 and color in (2, 6), (depth, color, interlace)
|
||||
channels = 3 if color == 2 else 4
|
||||
elif kind == b"IDAT":
|
||||
idat += body
|
||||
pos += 12 + length
|
||||
raw = zlib.decompress(idat)
|
||||
stride = width * channels
|
||||
rows, previous = [], bytearray(stride)
|
||||
for y in range(height):
|
||||
start = y * (stride + 1)
|
||||
filter_type, line = raw[start], bytearray(raw[start + 1:start + 1 + stride])
|
||||
for i in range(stride):
|
||||
left = line[i - channels] if i >= channels else 0
|
||||
up = previous[i]
|
||||
upleft = previous[i - channels] if i >= channels else 0
|
||||
if filter_type == 1:
|
||||
line[i] = (line[i] + left) & 255
|
||||
elif filter_type == 2:
|
||||
line[i] = (line[i] + up) & 255
|
||||
elif filter_type == 3:
|
||||
line[i] = (line[i] + (left + up) // 2) & 255
|
||||
elif filter_type == 4:
|
||||
estimate = left + up - upleft
|
||||
pa, pb, pc = abs(estimate - left), abs(estimate - up), abs(estimate - upleft)
|
||||
line[i] = (line[i] + (left if pa <= pb and pa <= pc else up if pb <= pc else upleft)) & 255
|
||||
rows.append(line)
|
||||
previous = line
|
||||
|
||||
def pixel(x, y):
|
||||
offset = x * channels
|
||||
return tuple(rows[y][offset:offset + 3])
|
||||
|
||||
return width, height, pixel
|
||||
|
||||
|
||||
def near(color, expected, tolerance=3):
|
||||
"""``color`` is ``expected`` give or take ``tolerance`` per channel."""
|
||||
return all(abs(a - b) <= tolerance for a, b in zip(color, expected))
|
||||
+11
-8
@@ -23,7 +23,7 @@ import threading
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
|
||||
from _ports import bind_tcp_and_probe_udp
|
||||
from _ports import bind_tcp_and_hold_udp
|
||||
|
||||
|
||||
def _certificate(address: str, directory: Path):
|
||||
@@ -57,12 +57,13 @@ class _TcpServer(socketserver.ThreadingTCPServer):
|
||||
|
||||
|
||||
def _tcp_server_on_a_port_udp_binds(address: str):
|
||||
"""A TCP server on a port number that UDP can bind too, as ``(server, port)``: the one picker of the harness (tests/_ports.py), which the
|
||||
"""A TCP server on a port number that UDP can bind too, with the UDP socket already bound to it, as ``(server, port, udp)``: the one picker of the harness (tests/_ports.py), which the
|
||||
witness and the resolver trap walk the same sequence of. The first try is the system's own pick (port 0); the others are drawn at random
|
||||
below the dynamic range, because Windows hands out ephemeral TCP ports in sequence and keeps excluded ranges of a hundred ports for UDP
|
||||
inside the same zone (run 43230437094, ``wrapper.e2e.web`` on Windows: fifty consecutive picks refused, three tests red). Every refusal is
|
||||
kept with its code and the last three are in the error."""
|
||||
return bind_tcp_and_probe_udp(address, lambda host, number: _TcpServer((host, number), _TcpHandler), socket_module=socket)
|
||||
kept with its code and the last three are in the error. The UDP socket is NOT closed again: it goes to the QUIC server's loop, so that the
|
||||
number is held on UDP from the first look at it to its use (a probe that was closed left a window for any other bind of that number)."""
|
||||
return bind_tcp_and_hold_udp(address, lambda host, number: _TcpServer((host, number), _TcpHandler), socket_module=socket)
|
||||
|
||||
|
||||
class _TcpHandler(socketserver.BaseRequestHandler):
|
||||
@@ -145,8 +146,8 @@ class H3Server:
|
||||
"""TCP+TLS (HTTP/2) and QUIC (HTTP/3) on one port of `address`."""
|
||||
|
||||
def __init__(self, address: str):
|
||||
from aioquic.asyncio import serve
|
||||
from aioquic.asyncio.protocol import QuicConnectionProtocol
|
||||
from aioquic.asyncio.server import QuicServer
|
||||
from aioquic.h3.connection import H3_ALPN, H3Connection
|
||||
from aioquic.h3.events import HeadersReceived
|
||||
from aioquic.quic.configuration import QuicConfiguration
|
||||
@@ -169,10 +170,11 @@ class H3Server:
|
||||
server = self
|
||||
|
||||
# One port for both: the TCP port first, then the same number for UDP.
|
||||
tcp, port = _tcp_server_on_a_port_udp_binds(address)
|
||||
tcp, port, udp = _tcp_server_on_a_port_udp_binds(address)
|
||||
self.port = port
|
||||
#: What the TCP answer says about HTTP/3: the same port, for an hour.
|
||||
self.alt_svc = 'h3=":%d"; ma=3600' % port
|
||||
self._udp = udp
|
||||
self._tls = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
self._tls.load_cert_chain(str(cert), str(key))
|
||||
self._tls.set_alpn_protocols(["h2", "http/1.1"])
|
||||
@@ -209,8 +211,9 @@ class H3Server:
|
||||
|
||||
def run():
|
||||
asyncio.set_event_loop(self._loop)
|
||||
self._quic = self._loop.run_until_complete(
|
||||
serve(address, port, configuration=configuration, create_protocol=Protocol))
|
||||
# What ``aioquic.asyncio.serve(address, port)`` does (1.x), with the socket that already holds the number.
|
||||
_transport, self._quic = self._loop.run_until_complete(self._loop.create_datagram_endpoint(
|
||||
lambda: QuicServer(configuration=configuration, create_protocol=Protocol), sock=self._udp))
|
||||
started.set()
|
||||
try:
|
||||
self._loop.run_forever()
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
"""The exit address of the lab: what a launch of an e2e test is told about where it leaves from, so that no test asks a service of the internet.
|
||||
|
||||
A launch (``InvisiblePlaywright(...)``, ``launch_server(...)``) composes its session in the core (``invisible_core.prepare_session_geo``), and the first step
|
||||
of it is ``invisible_core._geo.discover_egress_ip``: with no proxy, an HTTP request to three "what is my address" services (api.ipify.org, icanhazip.com,
|
||||
checkip.amazonaws.com, a budget of 15 s), whose answer is looked up in the GeoIP database for the zone, the language and the position of the session.
|
||||
Every e2e test that names neither ``timezone=`` nor ``proxy=`` (222 launches in 125 files), and every test that names only a zone, therefore depended on
|
||||
three services and on the network of the runner reaching them. The product is not wrong to ask: a user has no other way to know their exit. A TEST has one:
|
||||
it declares it.
|
||||
|
||||
This module is that declaration, made once per session by the autouse fixture of ``conftest.py`` (``_the_lab_declares_the_exit``):
|
||||
|
||||
* the question with NO proxy is answered :data:`LAB_EGRESS_IP`, a public address (so the core does not refuse it as unroutable) that the GeoIP database of
|
||||
the lab (``scripts/ci_lab_geoip.py``: one record for every public address that is not one of its six exits) maps to New York, en-US. The same session
|
||||
as before on every runner, whatever its address and whatever its network;
|
||||
* the question WITH a proxy is left to what answered it before: the local gateways of the tests answer ``api.ipify.org`` themselves
|
||||
(``tests/_socks_servers.py``), and a test that replaces the question (``tests/_udp_line.egress_by_proxy``) does it with ``monkeypatch`` for its own
|
||||
duration, which undoes to this answer and not to the network;
|
||||
* the database is the lab's too: when ``STEALTHFOX_GEOIP_MMDB`` is not set (a developer's machine; the CI legs set it) it is built here, from the same table
|
||||
and the same bytes, instead of the core asking GitHub which database is the latest.
|
||||
|
||||
A test that must prove the discovery itself asks for the fixture ``local_egress_echo``: the real function, against an echo service of its own on
|
||||
loopback. Nothing in a test goes to the internet to know an address.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from _servers import LocalServer
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def _address(*parts: int) -> str:
|
||||
return ".".join(str(part) for part in parts)
|
||||
|
||||
|
||||
#: The exit every e2e launch with no proxy declares. A public address that is in no reserved range and in none of the six exits of the lab database, so
|
||||
#: the lab database answers it with its one record for the rest of the public space (US, America/New_York, en-US), the same on every machine.
|
||||
LAB_EGRESS_IP = _address(8, 8, 8, 8)
|
||||
|
||||
|
||||
class DeclaredExit:
|
||||
"""The replacement of ``discover_egress_ip``: counts the questions it answers, and passes a proxied one on to what answered it before."""
|
||||
|
||||
def __init__(self, original: Callable[..., str], ip: str = LAB_EGRESS_IP) -> None:
|
||||
self.original = original
|
||||
self.ip = ip
|
||||
self.direct_questions = 0
|
||||
self.proxied_questions: List[Any] = []
|
||||
|
||||
def __call__(self, proxy: Optional[Dict[str, Any]] = None, *args: Any, **kwargs: Any) -> str:
|
||||
if not proxy:
|
||||
self.direct_questions += 1
|
||||
return self.ip
|
||||
self.proxied_questions.append(proxy.get("server") if isinstance(proxy, dict) else proxy)
|
||||
return self.original(proxy, *args, **kwargs)
|
||||
|
||||
|
||||
def lab_database_bytes() -> bytes:
|
||||
"""The GeoIP database of the lab, from ``scripts/ci_lab_geoip.py`` (the same bytes on every run)."""
|
||||
spec = importlib.util.spec_from_file_location("ci_lab_geoip_of_the_tests", ROOT / "scripts" / "ci_lab_geoip.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module.build_bytes()
|
||||
|
||||
|
||||
def use_the_lab_database(patch: Any, directory: Path, environ: Optional[Dict[str, str]] = None) -> Optional[Path]:
|
||||
"""Point ``STEALTHFOX_GEOIP_MMDB`` at the lab database when nothing does yet (a CI leg has set it, and its sha256 is the pin's). ``patch`` is a
|
||||
``pytest.MonkeyPatch``: the variable goes back with it. Returns the file written, or None when the variable was already set."""
|
||||
import os
|
||||
|
||||
seen = os.environ if environ is None else environ
|
||||
if seen.get("STEALTHFOX_GEOIP_MMDB"):
|
||||
return None
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
path = directory / "geoip-aio-all.mmdb"
|
||||
path.write_bytes(lab_database_bytes())
|
||||
patch.setenv("STEALTHFOX_GEOIP_MMDB", str(path))
|
||||
return path
|
||||
|
||||
|
||||
def install(patch: Any, directory: Path) -> Optional[DeclaredExit]:
|
||||
"""Declare the exit of the lab for the duration of ``patch`` (a ``pytest.MonkeyPatch``). None when the core is not importable: the user-path e2e
|
||||
files run in an environment that has not got it and make their own."""
|
||||
try:
|
||||
import invisible_core
|
||||
from invisible_core import _geo
|
||||
except ImportError:
|
||||
return None
|
||||
declared = DeclaredExit(_geo.discover_egress_ip)
|
||||
patch.setattr(_geo, "discover_egress_ip", declared)
|
||||
patch.setattr(invisible_core, "discover_egress_ip", declared, raising=False)
|
||||
use_the_lab_database(patch, directory)
|
||||
return declared
|
||||
|
||||
|
||||
class EchoService:
|
||||
"""What the three services of the product answer, on loopback: the address of the caller as the body, and the number of questions it was asked."""
|
||||
|
||||
def __init__(self, answer: str = LAB_EGRESS_IP) -> None:
|
||||
owner = self
|
||||
self.answer = answer
|
||||
self.questions = 0
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
timeout = 5
|
||||
|
||||
def do_GET(self) -> None:
|
||||
owner.questions += 1
|
||||
body = owner.answer.encode("ascii")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
self._server = LocalServer(("127.0.0.1", 0), Handler)
|
||||
self.url = "http://127.0.0.1:%d/" % self._server.server_address[1]
|
||||
threading.Thread(target=self._server.serve_forever, daemon=True).start()
|
||||
|
||||
def close(self) -> None:
|
||||
self._server.shutdown()
|
||||
self._server.server_close()
|
||||
@@ -0,0 +1,216 @@
|
||||
"""What the page-bytes e2e needs, apart from the browser: the probe's values, the PNG comparison on decoded pixels, and the
|
||||
comparison with a reference committed per operating system (tests/data/page_bytes_<os>.json).
|
||||
|
||||
The probe (tests/page_bytes_probe.js) resolves to a flat object {key: value} where a value is
|
||||
{"s": "a short string"} a string of at most 3000 characters, or
|
||||
{"h": ..., "n": ..., "s0": ...} a longer string: the hash of its bytes (cyrb53), its length, its first 200 characters, or
|
||||
{"h": ..., "n": ..., "w": ..., "b64": ...} bytes: hash, length, pixels per row, the bytes themselves when at most 400 KiB.
|
||||
A PNG that the page reads (toDataURL, toBlob, convertToBlob) also carries `b64`: the bytes of the file.
|
||||
|
||||
Two kinds of key in the reference:
|
||||
"keys" stable values, equal in every launch: compared as they are (the string, or the hash and the length);
|
||||
"pngs" the keys that are PNG files. A PNG the engine writes holds a 16-byte ancillary chunk, `deBG`, that differs in every
|
||||
launch (measured on the Windows runner, run 43652292533: the same arm launched twice differs in that chunk and
|
||||
nowhere else, the length is the same). So its bytes are not compared: its length, and the pixels it decodes to
|
||||
(width, height, colour type, and the sha256 of the unfiltered scanlines).
|
||||
|
||||
No value here is made up: an entry the reference does not hold is a problem (the test is red), and the problem carries the
|
||||
entry the run measured, in the form the reference file takes, so that a run on the engine of the day writes it down.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import struct
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n"
|
||||
DATA_PREFIX = "data:image/png;base64,"
|
||||
#: the end of a key that is a PNG file (the jpeg and webp encodings are stable and are compared as they are)
|
||||
PNG_KEY_ENDS = (".png", ".toBlob", ".convertToBlob", ".toDataURL")
|
||||
DATA_DIR = Path(__file__).resolve().parent / "data"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ PNG
|
||||
|
||||
class NotAPng(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def png_chunks(png: bytes) -> List[Tuple[bytes, bytes]]:
|
||||
if not png.startswith(PNG_SIGNATURE):
|
||||
raise NotAPng("no PNG signature")
|
||||
out, i = [], len(PNG_SIGNATURE)
|
||||
while i + 12 <= len(png):
|
||||
size = struct.unpack(">I", png[i:i + 4])[0]
|
||||
tag, data = png[i + 4:i + 8], png[i + 8:i + 8 + size]
|
||||
if len(data) != size:
|
||||
raise NotAPng("a chunk is cut")
|
||||
out.append((tag, data))
|
||||
i += 12 + size
|
||||
return out
|
||||
|
||||
|
||||
def _paeth(a: int, b: int, c: int) -> int:
|
||||
p = a + b - c
|
||||
pa, pb, pc = abs(p - a), abs(p - b), abs(p - c)
|
||||
return a if pa <= pb and pa <= pc else (b if pb <= pc else c)
|
||||
|
||||
|
||||
def decode_png(png: bytes) -> Dict[str, Any]:
|
||||
"""{w, h, ct, sha256} of a non-interlaced 8-bit PNG (grey, RGB, grey+alpha, RGBA): the sha256 is over the unfiltered
|
||||
scanlines, so two files with the same pixels and different ancillary chunks or compression give the same answer."""
|
||||
chunks = png_chunks(png)
|
||||
head = [d for t, d in chunks if t == b"IHDR"]
|
||||
if not head:
|
||||
raise NotAPng("no IHDR")
|
||||
w, h, depth, ct, _comp, _filt, interlace = struct.unpack(">IIBBBBB", head[0])
|
||||
channels = {0: 1, 2: 3, 4: 2, 6: 4}.get(ct)
|
||||
if depth != 8 or interlace != 0 or channels is None:
|
||||
raise NotAPng("only 8-bit, non-interlaced, non-palette PNG is decoded here (bit depth %d, colour type %d, interlace %d)"
|
||||
% (depth, ct, interlace))
|
||||
raw = zlib.decompress(b"".join(d for t, d in chunks if t == b"IDAT"))
|
||||
stride = w * channels
|
||||
if len(raw) != h * (stride + 1):
|
||||
raise NotAPng("the scanlines are %d bytes, %d expected" % (len(raw), h * (stride + 1)))
|
||||
out = bytearray()
|
||||
prev = bytearray(stride)
|
||||
pos = 0
|
||||
for _ in range(h):
|
||||
ftype = raw[pos]
|
||||
line = bytearray(raw[pos + 1:pos + 1 + stride])
|
||||
pos += 1 + stride
|
||||
if ftype == 1:
|
||||
for i in range(channels, stride):
|
||||
line[i] = (line[i] + line[i - channels]) & 255
|
||||
elif ftype == 2:
|
||||
for i in range(stride):
|
||||
line[i] = (line[i] + prev[i]) & 255
|
||||
elif ftype == 3:
|
||||
for i in range(stride):
|
||||
left = line[i - channels] if i >= channels else 0
|
||||
line[i] = (line[i] + ((left + prev[i]) >> 1)) & 255
|
||||
elif ftype == 4:
|
||||
for i in range(stride):
|
||||
left = line[i - channels] if i >= channels else 0
|
||||
upleft = prev[i - channels] if i >= channels else 0
|
||||
line[i] = (line[i] + _paeth(left, prev[i], upleft)) & 255
|
||||
elif ftype != 0:
|
||||
raise NotAPng("filter type %d" % ftype)
|
||||
out += line
|
||||
prev = line
|
||||
return {"w": w, "h": h, "ct": ct, "sha256": hashlib.sha256(bytes(out)).hexdigest()}
|
||||
|
||||
|
||||
def png_bytes_of(value: Dict[str, Any]) -> Optional[bytes]:
|
||||
"""The PNG file a probe value holds, or None when the probe did not keep its bytes."""
|
||||
if "b64" in value:
|
||||
return base64.b64decode(value["b64"])
|
||||
text = value.get("s")
|
||||
if isinstance(text, str) and text.startswith(DATA_PREFIX):
|
||||
return base64.b64decode(text[len(DATA_PREFIX):])
|
||||
return None
|
||||
|
||||
|
||||
def is_png_key(key: str) -> bool:
|
||||
return key.endswith(PNG_KEY_ENDS)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------- the reference
|
||||
|
||||
def ident(value: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""What identifies a stable value: its string, or the hash and the length of its bytes."""
|
||||
if "s" in value:
|
||||
return {"s": value["s"]}
|
||||
return {"h": value.get("h"), "n": value.get("n")}
|
||||
|
||||
|
||||
def png_entry(value: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""The entry of a PNG key: its length and, when the bytes were kept, the pixels they decode to."""
|
||||
# n: the length of the string for a data URL, of the file for bytes
|
||||
entry: Dict[str, Any] = {"n": value["n"] if "n" in value else len(value.get("s", ""))}
|
||||
data = png_bytes_of(value)
|
||||
if data is None:
|
||||
return entry
|
||||
try:
|
||||
entry.update(decode_png(data))
|
||||
except (NotAPng, zlib.error) as exc:
|
||||
entry["undecodable"] = str(exc)
|
||||
return entry
|
||||
|
||||
|
||||
def entry_of(key: str, value: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return png_entry(value) if is_png_key(key) else ident(value)
|
||||
|
||||
|
||||
def reference_path(os_name: str) -> Path:
|
||||
return DATA_DIR / ("page_bytes_%s.json" % os_name)
|
||||
|
||||
|
||||
def load_reference(os_name: str) -> Dict[str, Any]:
|
||||
"""The reference of an operating system; an empty one when the file does not exist yet (every key is then a problem
|
||||
that carries its own entry, which is how the first reference is written)."""
|
||||
path = reference_path(os_name)
|
||||
if not path.is_file():
|
||||
return {"keys": {}, "pngs": {}}
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def compare(reference: Dict[str, Any], measured: Dict[str, Dict[str, Any]]) -> Tuple[List[str], Dict[str, Dict[str, Any]]]:
|
||||
"""(problems, record). `problems` is empty when every key the probe returned is in the reference with the same value
|
||||
and the reference holds no key the probe did not return. `record` is the entry the run measured for every key that is
|
||||
missing from the reference or incomplete in it (a PNG with no decoded pixels), in the form the reference file takes."""
|
||||
problems: List[str] = []
|
||||
record: Dict[str, Dict[str, Any]] = {}
|
||||
stable, pngs = reference.get("keys", {}), reference.get("pngs", {})
|
||||
for key in sorted(measured):
|
||||
mine = entry_of(key, measured[key])
|
||||
if is_png_key(key):
|
||||
if "undecodable" in mine:
|
||||
problems.append("%s: the PNG the page read does not decode (%s)" % (key, mine["undecodable"]))
|
||||
continue
|
||||
if "sha256" not in mine:
|
||||
problems.append("%s: the probe did not keep the bytes of this PNG" % key)
|
||||
continue
|
||||
ref = pngs.get(key)
|
||||
if ref is None:
|
||||
problems.append("%s: not in the reference" % key)
|
||||
record[key] = mine
|
||||
elif ref.get("n") != mine.get("n"):
|
||||
problems.append("%s: the PNG is %s bytes, the reference says %s" % (key, mine.get("n"), ref.get("n")))
|
||||
elif "sha256" not in ref:
|
||||
problems.append("%s: the reference has the length of this PNG and not yet its decoded pixels" % key)
|
||||
record[key] = mine
|
||||
elif (ref["w"], ref["h"], ref["ct"], ref["sha256"]) != (mine["w"], mine["h"], mine["ct"], mine["sha256"]):
|
||||
problems.append("%s: the decoded pixels differ (%sx%s ct %s %s, the reference %sx%s ct %s %s)"
|
||||
% (key, mine["w"], mine["h"], mine["ct"], mine["sha256"][:12],
|
||||
ref["w"], ref["h"], ref["ct"], ref["sha256"][:12]))
|
||||
else:
|
||||
ref = stable.get(key)
|
||||
if ref is None:
|
||||
problems.append("%s: not in the reference" % key)
|
||||
record[key] = mine
|
||||
elif ref != mine:
|
||||
problems.append("%s: %s, the reference %s" % (key, _short(mine), _short(ref)))
|
||||
for key in sorted((set(stable) | set(pngs)) - set(measured)):
|
||||
problems.append("%s: in the reference and not read by the probe" % key)
|
||||
return problems, record
|
||||
|
||||
|
||||
def _short(entry: Dict[str, Any], limit: int = 120) -> str:
|
||||
return json.dumps(entry, sort_keys=True)[:limit]
|
||||
|
||||
|
||||
def message(os_name: str, problems: List[str], record: Dict[str, Dict[str, Any]]) -> str:
|
||||
"""The failure text: the problems, and the entries to add to tests/data/page_bytes_<os>.json."""
|
||||
text = "%d problem(s) in the bytes a page reads on %s against %s:\n %s" % (
|
||||
len(problems), os_name, reference_path(os_name).name, "\n ".join(problems[:60]))
|
||||
if record:
|
||||
keys = {k: v for k, v in record.items() if not is_png_key(k)}
|
||||
pngs = {k: v for k, v in record.items() if is_png_key(k)}
|
||||
text += ("\nTO RECORD (merge into tests/data/page_bytes_%s.json, from a run on the engine whose bytes are the reference):\n"
|
||||
"RECORD-BEGIN %s\n%s\nRECORD-END" % (os_name, os_name, json.dumps({"keys": keys, "pngs": pngs}, sort_keys=True)))
|
||||
return text
|
||||
+16
-6
@@ -37,11 +37,20 @@ def candidates(tries: int = TRIES, draw: Any = None):
|
||||
yield 0 if attempt == 0 else draw.randint(*DRAW_FROM)
|
||||
|
||||
|
||||
def bind_tcp_and_probe_udp(address: str, make_tcp: Callable[[str, int], Any], tries: int = TRIES, socket_module: Any = None,
|
||||
draw: Any = None) -> Tuple[Any, int]:
|
||||
def bind_tcp_and_hold_udp(address: str, make_tcp: Callable[[str, int], Any], tries: int = TRIES, socket_module: Any = None,
|
||||
draw: Any = None) -> Tuple[Any, int, Any]:
|
||||
"""``make_tcp(address, port)`` makes the TCP server (it binds, with port 0 for the system's pick; it has ``server_address`` and
|
||||
``server_close``). Returns ``(that server, its port)`` once UDP binds the same number too (the probe is closed again: whoever needs the UDP
|
||||
socket binds it next). Raises RuntimeError saying how many tries were made and the last refusals, codes included."""
|
||||
``server_close``). Returns ``(that server, its port, the UDP socket bound to the same number)`` once UDP binds that number too. Raises
|
||||
RuntimeError saying how many tries were made and the last refusals, codes included.
|
||||
|
||||
The caller owns the UDP socket and closes it, or hands it to the loop that serves it (``create_datagram_endpoint(sock=...)``): from the first
|
||||
look at the number to the use of it nobody else can bind it, on TCP or on UDP. (A picker that closed its UDP probe and left "whoever needs the
|
||||
socket binds it next" held the number on TCP only: another picker of the harness could not take it, but any other bind of that UDP number
|
||||
could, the system's own pick of an ephemeral port for another process first among them.)"""
|
||||
return _bind_both(address, make_tcp, tries, socket_module, draw)
|
||||
|
||||
|
||||
def _bind_both(address: str, make_tcp: Callable[[str, int], Any], tries: int, socket_module: Any, draw: Any) -> Tuple[Any, int, Any]:
|
||||
sock = socket_module or socket
|
||||
refusals: List[str] = []
|
||||
last = 0
|
||||
@@ -53,9 +62,10 @@ def bind_tcp_and_probe_udp(address: str, make_tcp: Callable[[str, int], Any], tr
|
||||
probe = sock.socket(sock.AF_INET, sock.SOCK_DGRAM)
|
||||
try:
|
||||
probe.bind((address, port))
|
||||
finally:
|
||||
except BaseException:
|
||||
probe.close()
|
||||
return tcp, port
|
||||
raise
|
||||
return tcp, port, probe
|
||||
except OSError as exc:
|
||||
refusals.append("%s: %s" % (wanted or "system pick", exc))
|
||||
if tcp is not None:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"""The e2e files that need what exists only AFTER a publication: the index, GitHub releases, pip and uv.
|
||||
|
||||
``test_release_e2e.py`` installs the README's block from the real index (uv, pip), downloads the 110 MB binary from the GitHub release, walks every
|
||||
published version against the changelog and the GitHub API; ``test_upgrade_e2e.py`` upgrades from the previous release with pip. They are the one place that
|
||||
proves what a user receives, and for the same reason they can be red for a reason that is nobody's change: PyPI or GitHub down or slow, a rate limit, an index
|
||||
mirror that lags. A gate of a pull request or of a candidate must not wait on any of that (the rule of the project: no real site in a gate; the real ones are
|
||||
in the release round and the round after the publication), so they run only where ``user-install.yml`` runs them: named on the command line, after the upload.
|
||||
|
||||
How that is held, with no new pytest marker (the marker vocabulary is shared with ``invisible_core``, which compares the lists of the repositories):
|
||||
``tests/conftest.py`` deselects the ``e2e`` tests of these files from every run that does not NAME the file. ``scripts/run_e2e.py`` (the run of ``e2e.yml``,
|
||||
of the hunt and of a candidate) names none, the Windows legs build their lists from a collection that no longer holds them, and ``user-install.yml`` names both.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Iterable
|
||||
|
||||
FILES = ("test_release_e2e.py", "test_upgrade_e2e.py")
|
||||
|
||||
|
||||
def named(args: Iterable[str]) -> "set[Path]":
|
||||
"""The files a command line names (``path`` or ``path::test``), resolved."""
|
||||
return {Path(str(arg).split("::", 1)[0]).resolve() for arg in args}
|
||||
|
||||
|
||||
def is_left_out(path: "str | Path", args: Iterable[str]) -> bool:
|
||||
"""True for a test of a post-publication file in a run that does not name that file."""
|
||||
path = Path(str(path))
|
||||
return path.name in FILES and path.resolve() not in named(args)
|
||||
@@ -41,10 +41,14 @@ class Stream:
|
||||
self.frames = []
|
||||
self.started = None # when `start()` returned, i.e. the reply was handled
|
||||
self.first = None # when the first frame reached the handler
|
||||
self.arrivals = [] # when each frame reached the handler (time.monotonic), in order
|
||||
self.stamps = [] # the engine's `timestamp` of each frame (seconds, stamped in the browser when it sent it)
|
||||
|
||||
def on_frame(frame):
|
||||
if self.first is None:
|
||||
self.first = time.monotonic()
|
||||
self.arrivals.append(time.monotonic())
|
||||
self.stamps.append(frame.get("timestamp") if isinstance(frame, dict) else getattr(frame, "timestamp", None))
|
||||
self.frames.append(frame)
|
||||
|
||||
self.on_frame = on_frame
|
||||
@@ -60,6 +64,16 @@ class Stream:
|
||||
return None
|
||||
return self.first - self.started
|
||||
|
||||
def rate(self, stamps=None):
|
||||
"""Frames a second between the first frame and the last one, on the ENGINE's stamps of the frames (default: all so
|
||||
far), or None with fewer than two stamped frames or no time between them. Not on the times the frames reached this
|
||||
process: a client that stalls receives the frames of the stall in one burst, and a burst is a rate the engine never
|
||||
produced (a cap of 2 fps read as 5). A rate of the frames that came, whatever the time they took to start."""
|
||||
stamps = [s for s in (self.stamps if stamps is None else stamps) if s]
|
||||
if len(stamps) < 2 or stamps[-1] <= stamps[0]:
|
||||
return None
|
||||
return (len(stamps) - 1) / (stamps[-1] - stamps[0])
|
||||
|
||||
def describe(self):
|
||||
delay = self.first_after_start()
|
||||
return "%s: %d frame(s), first frame %s" % (
|
||||
|
||||
+105
-25
@@ -50,7 +50,7 @@ import socket
|
||||
import struct
|
||||
import threading
|
||||
import time
|
||||
from typing import List, Optional, Set, Tuple
|
||||
from typing import Callable, List, Optional, Set, Tuple
|
||||
|
||||
#: The name the product's STUN probe sends through the relay. The relay maps it
|
||||
#: to the fake STUN server; every other destination is forwarded for real.
|
||||
@@ -97,6 +97,11 @@ class FakeStun:
|
||||
# On the address the relay sends from: Windows sends neither from an address of the host to loopback (WinError 10049) nor
|
||||
# from loopback to an address of the host (10051), so a relay that leaves from the host's address needs its STUN there too.
|
||||
self._sock.bind((bind_host, 0))
|
||||
self._closing = False
|
||||
if hasattr(socket, "SIO_UDP_CONNRESET"):
|
||||
# Windows: an ICMP "port unreachable" to an answer (a client that already closed its socket) makes the NEXT recvfrom raise
|
||||
# WinError 10054; left on, the server that reads would end there and answer nobody afterwards. Off, as a real server has it.
|
||||
self._sock.ioctl(socket.SIO_UDP_CONNRESET, False)
|
||||
self.address: Tuple[str, int] = self._sock.getsockname()
|
||||
self._thread = threading.Thread(target=self._serve, daemon=True)
|
||||
self._thread.start()
|
||||
@@ -105,8 +110,12 @@ class FakeStun:
|
||||
while True:
|
||||
try:
|
||||
data, peer = self._sock.recvfrom(2048)
|
||||
except ConnectionResetError:
|
||||
continue # an earlier answer found nobody: that is that client's business, not the server's end
|
||||
except OSError:
|
||||
return
|
||||
if self._closing:
|
||||
return # the datagram `close` sent to wake this thread, or one that came after it
|
||||
if len(data) < 20 or data[0:2] != b"\x00\x01":
|
||||
continue
|
||||
self.requests += 1
|
||||
@@ -118,9 +127,25 @@ class FakeStun:
|
||||
try:
|
||||
self._sock.sendto(resp, peer)
|
||||
except OSError:
|
||||
return
|
||||
if self._closing:
|
||||
return
|
||||
continue # a send that failed (the peer is gone) does not end the server for the next client
|
||||
|
||||
def close(self) -> None:
|
||||
"""Ends the server and its thread. Closing the socket wakes a `recvfrom` blocked in another thread on Windows, not on Linux,
|
||||
where the thread would stay blocked for the rest of the process: so the server first sends itself one datagram, which wakes the
|
||||
thread to see `_closing`, waits for the thread, and only then closes the socket."""
|
||||
self._closing = True
|
||||
try:
|
||||
waker = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
waker.sendto(b"", self.address)
|
||||
finally:
|
||||
waker.close()
|
||||
except OSError:
|
||||
pass
|
||||
if self._thread is not threading.current_thread():
|
||||
self._thread.join(timeout=2)
|
||||
self._sock.close()
|
||||
|
||||
|
||||
@@ -149,6 +174,22 @@ class Gateway:
|
||||
#: Whether the TCP connections the gateway opens for a CONNECT also leave from ``exit_host`` (as its datagrams do): a server that
|
||||
#: is reachable DIRECT then tells a connection of the proxy from a connection of the browser by the source.
|
||||
self.tcp_from_exit = tcp_from_exit
|
||||
#: While this Event is set to a cleared state, every answer of the gateway on a control connection waits for it (a
|
||||
#: handshake the test holds, whatever the speed of the machine): None, the default, holds nothing. A test sets it after
|
||||
#: the launch (the core's own probe goes through the gateway before the browser exists) and opens it when it chooses.
|
||||
self.gate: Optional[threading.Event] = None
|
||||
#: The same hold, one control connection at a time: ``hold(index, kind)`` is asked before each answer of the gateway on a
|
||||
#: control connection, with the ``index`` of that connection in ``accepted`` and what it asked for (``kind``: None while only the
|
||||
#: greeting is known, then ``"connect"``, ``"associate"`` or ``"other"``), and returns the Event the answer waits for (or None: no
|
||||
#: hold). A test holds the handshakes it chooses (the ASSOCIATEs begun from an instant on, one connection by its index) and
|
||||
#: lets every other one run, whatever the speed of the machine; None, the default, holds nothing.
|
||||
self.hold: Optional[Callable[[int, Optional[str]], Optional[threading.Event]]] = None
|
||||
#: Every request the gateway read on a control connection, in order, as (seconds from t0, index of the connection in
|
||||
#: ``accepted``, kind, detail): ``"greeting"`` when the connection was accepted (the first bytes of the client), then
|
||||
#: ``"connect"`` (detail ``host:port``), ``"associate"`` (detail ``association #n`` of ``associations``, ``refused`` when
|
||||
#: UDP is refused) or ``"other"``. The EXCHANGES of a road, counted by what the gateway saw and not by how long they took.
|
||||
self.requests: List[Tuple[float, int, str, str]] = []
|
||||
self._local = threading.local()
|
||||
#: Whether each chunk of a forwarded TCP stream also waits half the round trip (a far gateway), as the datagrams do.
|
||||
self.tcp_data_delay = tcp_data_delay
|
||||
self.tcp_exit = tcp_exit
|
||||
@@ -168,6 +209,9 @@ class Gateway:
|
||||
self.associations: List[List[Optional[float]]] = []
|
||||
#: Every datagram the relay carried out, as (host as sent, port, address type, seconds from t0).
|
||||
self.datagram_log: List[Tuple[str, int, int, float]] = []
|
||||
#: Every datagram the relay carried out, as (host as sent, port, index in ``associations`` of the association it came
|
||||
#: on, seconds from t0): which association carried a datagram, not only when it left.
|
||||
self.datagram_via: List[Tuple[str, int, int, float]] = []
|
||||
#: Every datagram the relay carried out, as (host, port, payload).
|
||||
self.datagrams: List[Tuple[str, int, bytes]] = []
|
||||
#: The local port of the socket each granted association sends from: what a server behind the gateway sees as the port
|
||||
@@ -223,7 +267,20 @@ class Gateway:
|
||||
self.close()
|
||||
|
||||
# --- the TCP side --------------------------------------------------------
|
||||
def _request(self, kind: str, detail: str = "") -> None:
|
||||
"""Record a request of the client on the control connection of this thread, and what it asked for (``hold`` is told)."""
|
||||
self._local.kind = None if kind == "greeting" else kind
|
||||
self.requests.append((time.monotonic() - self.t0, getattr(self._local, "index", -1), kind, detail))
|
||||
|
||||
def _send(self, c: socket.socket, data: bytes) -> None:
|
||||
gate = self.gate
|
||||
if gate is not None:
|
||||
gate.wait(120)
|
||||
hold = self.hold
|
||||
if hold is not None:
|
||||
held = hold(getattr(self._local, "index", -1), getattr(self._local, "kind", None))
|
||||
if held is not None:
|
||||
held.wait(120)
|
||||
if self.rtt:
|
||||
time.sleep(self.rtt)
|
||||
c.sendall(data)
|
||||
@@ -234,8 +291,16 @@ class Gateway:
|
||||
conn, _ = self._listener.accept()
|
||||
except OSError:
|
||||
return
|
||||
index = len(self.accepted)
|
||||
self.accepted.append(time.monotonic() - self.t0)
|
||||
threading.Thread(target=self._handle, args=(conn,), daemon=True).start()
|
||||
threading.Thread(target=self._run, args=(conn, index), daemon=True).start()
|
||||
|
||||
def _run(self, conn: socket.socket, index: int) -> None:
|
||||
"""One control connection: remembers its index (for ``hold`` and ``requests``), then serves it."""
|
||||
self._local.index = index
|
||||
self._local.kind = None
|
||||
self.requests.append((self.accepted[index], index, "greeting", ""))
|
||||
self._handle(conn)
|
||||
|
||||
def _greet(self, c: socket.socket) -> bool:
|
||||
ver, n = _recv_exact(c, 2)
|
||||
@@ -284,10 +349,12 @@ class Gateway:
|
||||
ver, cmd, _rsv = _recv_exact(c, 3)
|
||||
host, port = self._read_address(c)
|
||||
if cmd == 1:
|
||||
self._request("connect", "%s:%d" % (host, port))
|
||||
self._connect(c, host, port)
|
||||
elif cmd == 3:
|
||||
self._associate(c)
|
||||
else:
|
||||
self._request("other", "command %d" % cmd)
|
||||
self._send(c, self._reply(7))
|
||||
except (OSError, ConnectionError):
|
||||
pass
|
||||
@@ -409,10 +476,13 @@ class Gateway:
|
||||
def _associate(self, c: socket.socket) -> None:
|
||||
self.associates += 1
|
||||
if self.udp == "refuse":
|
||||
self._request("associate", "refused")
|
||||
self._send(c, self._reply(7))
|
||||
return
|
||||
record: List[Optional[float]] = [time.monotonic() - self.t0, None]
|
||||
self.associations.append(record)
|
||||
index = next(i for i, r in enumerate(self.associations) if r is record)
|
||||
self._request("associate", "association #%d" % index)
|
||||
relay = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
relay.bind((self.relay_host, 0))
|
||||
out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
@@ -433,6 +503,12 @@ class Gateway:
|
||||
self._deliver(relay, client[0], host, port, data)
|
||||
|
||||
def inbound() -> None: # client -> world
|
||||
# The port of the exit socket is read ONCE: asked at every datagram it fell on a socket the teardown had already closed
|
||||
# (OSError WinError 10038 in a thread nobody joins). An OSError of the body is the association ending, not a failure.
|
||||
try:
|
||||
out_port = out.getsockname()[1]
|
||||
except OSError:
|
||||
return
|
||||
while True:
|
||||
try:
|
||||
d, peer = relay.recvfrom(65536)
|
||||
@@ -440,28 +516,32 @@ class Gateway:
|
||||
continue
|
||||
except OSError:
|
||||
return
|
||||
if len(d) < 10 or d[2] != 0:
|
||||
continue
|
||||
client[0] = peer
|
||||
atyp, i = d[3], 4
|
||||
if atyp == 1:
|
||||
host, i = socket.inet_ntoa(d[i:i + 4]), i + 4
|
||||
elif atyp == 3:
|
||||
n = d[i]
|
||||
host, i = d[i + 1:i + 1 + n].decode(), i + 1 + n
|
||||
else:
|
||||
host, i = socket.inet_ntop(socket.AF_INET6, d[i:i + 16]), i + 16
|
||||
dport = struct.unpack("!H", d[i:i + 2])[0]
|
||||
payload = d[i + 2:]
|
||||
self.datagrams.append((host, dport, payload))
|
||||
self.datagram_log.append((host, dport, atyp, time.monotonic() - self.t0))
|
||||
routed = self._route(host, dport, atyp, payload, out.getsockname()[1], answer)
|
||||
if routed is None:
|
||||
continue
|
||||
target, reported = routed
|
||||
if reported is not None:
|
||||
asked_at[target] = reported
|
||||
self._later(lambda p=payload, t=target: out.sendto(p, t), "the datagram to %s:%d" % target)
|
||||
try:
|
||||
if len(d) < 10 or d[2] != 0:
|
||||
continue
|
||||
client[0] = peer
|
||||
atyp, i = d[3], 4
|
||||
if atyp == 1:
|
||||
host, i = socket.inet_ntoa(d[i:i + 4]), i + 4
|
||||
elif atyp == 3:
|
||||
n = d[i]
|
||||
host, i = d[i + 1:i + 1 + n].decode(), i + 1 + n
|
||||
else:
|
||||
host, i = socket.inet_ntop(socket.AF_INET6, d[i:i + 16]), i + 16
|
||||
dport = struct.unpack("!H", d[i:i + 2])[0]
|
||||
payload = d[i + 2:]
|
||||
self.datagrams.append((host, dport, payload))
|
||||
self.datagram_log.append((host, dport, atyp, time.monotonic() - self.t0))
|
||||
self.datagram_via.append((host, dport, index, time.monotonic() - self.t0))
|
||||
routed = self._route(host, dport, atyp, payload, out_port, answer)
|
||||
if routed is None:
|
||||
continue
|
||||
target, reported = routed
|
||||
if reported is not None:
|
||||
asked_at[target] = reported
|
||||
self._later(lambda p=payload, t=target: out.sendto(p, t), "the datagram to %s:%d" % target)
|
||||
except OSError:
|
||||
return
|
||||
|
||||
def outbound() -> None: # world -> client
|
||||
while True:
|
||||
|
||||
+37
-9
@@ -21,8 +21,8 @@ that address, by SOCKS5 address type 1, through the UDP relay. The gateway resol
|
||||
loopback address), so the TURN server sees a source that is not the browser's own: if it sees the browser's, the road was
|
||||
not the gateway's.
|
||||
* :class:`Page` - the page and the verdict, with the shape of a leak test's logic: a tick of 2 seconds after the page starts that
|
||||
marks TIMEOUT, cleared only after a POST made when a server-reflexive candidate arrives; the server compares the address
|
||||
of that candidate with the source the TURN saw.
|
||||
marks TIMEOUT, cleared the moment a server-reflexive candidate arrives (before the POST, so the verdict does not depend on
|
||||
the POST coming back within the tick); the server compares the address of that candidate with the source the TURN saw.
|
||||
|
||||
The names and the addresses are RFC 2606 / RFC 5737: nothing in a test can be mistaken for a real host.
|
||||
"""
|
||||
@@ -55,6 +55,8 @@ EXIT_HOST = "127.0.0.2"
|
||||
#: The exit of a lab that a browser accepts as a real one: a documentation address (RFC 5737, TEST-NET-2, like the TURN server's) that
|
||||
#: the host holds on its loopback interface (`lab_exit_address`). A mapped address in 127/8 is thrown away by nICEr as bogus.
|
||||
LAB_EXIT = "198.51.100.9"
|
||||
#: The path of an empty page of the page server (no PeerConnection): see :attr:`Page.warm_url`.
|
||||
WARM_PATH = "/warm"
|
||||
MAGIC = 0x2112A442
|
||||
PASSWORD = "qwerty"
|
||||
REALM = "hermetic"
|
||||
@@ -111,6 +113,8 @@ def _message(mtype: int, tid: bytes, attrs: bytes, key: Optional[bytes] = None)
|
||||
|
||||
class TurnServer:
|
||||
"""UDP TURN server on 127.0.0.1. ``seen`` is every datagram as (source ip, source port, STUN type), in order;
|
||||
``requests`` the same datagrams as (monotonic time, transaction id, STUN type, carries credentials): a retransmission has the
|
||||
transaction id of the request it repeats, so the TRANSACTIONS of a road are the distinct ids (:meth:`transactions`);
|
||||
``allocations`` the successful Allocates as (source ip, source port, username, time)."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -119,9 +123,18 @@ class TurnServer:
|
||||
self.address: Tuple[str, int] = self.sock.getsockname()
|
||||
self.seen: List[Tuple[str, int, int]] = []
|
||||
self.allocations: List[Tuple[str, int, str, float]] = []
|
||||
self.requests: List[Tuple[float, bytes, int, bool]] = []
|
||||
self._closed = False
|
||||
threading.Thread(target=self._serve, daemon=True).start()
|
||||
|
||||
def transactions(self, mtype: int = 0x0003) -> List[Tuple[float, bytes, int, bool]]:
|
||||
"""The first datagram of each transaction of type ``mtype`` (Allocate by default), in order: a retransmission is not another one."""
|
||||
first: Dict[bytes, Tuple[float, bytes, int, bool]] = {}
|
||||
for request in list(self.requests):
|
||||
if request[2] == mtype:
|
||||
first.setdefault(request[1], request)
|
||||
return sorted(first.values(), key=lambda r: r[0])
|
||||
|
||||
def close(self) -> None:
|
||||
self._closed = True
|
||||
self.sock.close()
|
||||
@@ -137,6 +150,7 @@ class TurnServer:
|
||||
mtype, tid = struct.unpack("!H", data[:2])[0], data[8:20]
|
||||
self.seen.append((src[0], src[1], mtype))
|
||||
attrs = _attrs(data)
|
||||
self.requests.append((time.monotonic(), tid, mtype, 0x0008 in attrs and 0x0006 in attrs))
|
||||
if mtype == 0x0003: # Allocate
|
||||
if 0x0008 not in attrs or 0x0006 not in attrs: # no credentials: 401 with a realm and a nonce
|
||||
err = _attr(0x0009, b"\x00\x00\x04\x01Unauthorized") + _attr(0x0014, REALM.encode()) + _attr(0x0015, NONCE.encode())
|
||||
@@ -257,7 +271,7 @@ class Chain(DohGateway):
|
||||
why = "the TURN server heard the browser but no Allocate was answered with credentials: the 401 round trip did not finish"
|
||||
elif result.get("status") == "TIMEOUT":
|
||||
ends = [e for _s, e in self.associations if e is not None]
|
||||
why = ("the allocation succeeded but too late for the tick of 2000 ms: the association handshakes alone ended at %s s"
|
||||
why = ("the allocation succeeded but the page read no server-reflexive candidate: the association handshakes ended at %s s"
|
||||
% ", ".join("%.2f" % e for e in ends))
|
||||
else:
|
||||
why = "the srflx of the page is not the address the TURN server saw (%s)" % [("%s:%d" % (a[0], a[1])) for a in self.turn.allocations]
|
||||
@@ -274,8 +288,12 @@ let status = 'PENDING';
|
||||
const finish = (s) => { status = s; window.__result.status = s; window.__done = true; };
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
mark('dom');
|
||||
// the tick of a leak test: 2 seconds after the page starts. It is cleared only after the POST made on a srflx.
|
||||
// the tick of a leak test: 2 seconds after the page starts. It stops the moment a srflx arrives, before the POST: what the
|
||||
// test asks is whether the srflx came before the tick, not whether the POST came back within it. The tick is the model of the
|
||||
// page and decides nothing: a srflx that comes after it is still read and posted (`late`), and the test judges the road by the
|
||||
// stamps of the gateway, the DoH and the TURN server.
|
||||
const tick = setInterval(() => { if (status === 'PENDING') { mark('tick'); finish('TIMEOUT'); } clearInterval(tick); }, 2000);
|
||||
window.__result.born = Date.now();
|
||||
const pc = new RTCPeerConnection({iceServers: [{urls: ['turn:%(turn)s:%(port)d?transport=udp'], username: 'challenge-' + Date.now(), credential: '%(password)s'}]});
|
||||
pc.createDataChannel('x');
|
||||
mark('pc');
|
||||
@@ -284,14 +302,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
pc.onicecandidate = async (e) => {
|
||||
if (!e.candidate) return;
|
||||
window.__result.candidates.push(e.candidate.candidate);
|
||||
if (e.candidate.candidate.indexOf(' typ srflx ') < 0 || status !== 'PENDING') return;
|
||||
if (e.candidate.candidate.indexOf(' typ srflx ') < 0 || window.__result.srflx) return;
|
||||
window.__result.late = status !== 'PENDING';
|
||||
clearInterval(tick);
|
||||
mark('srflx');
|
||||
window.__result.srflx = e.candidate.candidate;
|
||||
const r = await fetch('/verdict', {method: 'POST', body: JSON.stringify({srflx: e.candidate.candidate})});
|
||||
const ok = (await r.json()).ok;
|
||||
// `posted` and the final status are set in one step, after the last await: a test that waits for `posted` and reads the status never reads
|
||||
// the one of a page whose verdict has not been read yet (PENDING or the tick's TIMEOUT).
|
||||
mark('posted');
|
||||
if (status !== 'PENDING') return;
|
||||
clearInterval(tick);
|
||||
finish((await r.json()).ok ? 'DONE' : 'REFUSED');
|
||||
window.__result.posted = true;
|
||||
finish(ok ? 'DONE' : 'REFUSED');
|
||||
};
|
||||
pc.createOffer().then((o) => pc.setLocalDescription(o));
|
||||
});
|
||||
@@ -315,7 +337,8 @@ class Page:
|
||||
|
||||
def do_GET(self):
|
||||
outer.hits.append((self.headers.get("Host", ""), self.path))
|
||||
body = (PAGE_HTML % {"turn": TURN_NAME, "port": TURN_PORT, "password": PASSWORD}).encode()
|
||||
body = (b"<!doctype html><meta charset=utf-8><title>warm</title>" if self.path == WARM_PATH else
|
||||
(PAGE_HTML % {"turn": TURN_NAME, "port": TURN_PORT, "password": PASSWORD}).encode())
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
@@ -346,5 +369,10 @@ class Page:
|
||||
def url(self) -> str:
|
||||
return "http://%s:%d/" % (PAGE_NAME, self.port)
|
||||
|
||||
@property
|
||||
def warm_url(self) -> str:
|
||||
"""An empty page of the same server: opened first, it makes the browser learn the proxy and fill its pool of associations."""
|
||||
return "http://%s:%d%s" % (PAGE_NAME, self.port, WARM_PATH)
|
||||
|
||||
def close(self) -> None:
|
||||
self.httpd.shutdown()
|
||||
@@ -88,6 +88,39 @@ def declared_udp(proxy: Dict[str, Any], servers: Sequence[str]) -> str:
|
||||
return entry[1]
|
||||
|
||||
|
||||
def declared_udp_or_absent(proxy: Dict[str, Any], servers: Sequence[str]) -> Optional[str]:
|
||||
""":func:`declared_udp`, or None when the launch measured nothing for ``proxy`` (a report must say that, not raise)."""
|
||||
try:
|
||||
return declared_udp(proxy, servers)
|
||||
except AssertionError:
|
||||
return None
|
||||
|
||||
|
||||
def udp_measure_sentence(declared: Optional[str], rtt_ms: int) -> str:
|
||||
"""What the core declared for the proxy of a bench, as a sentence of the verdict of a failed test. A measurement that is
|
||||
not ``coherent`` is said outright: the engine then never sends the page's UDP to the relay, and the test fails for a reason
|
||||
that is the measurement's (the budget of the core against the round trip of the gateway), not the page's."""
|
||||
if declared == "coherent":
|
||||
return "UDP verdict the core declared for this proxy: coherent"
|
||||
if declared is None:
|
||||
return ("the core measured nothing for this proxy: the UDP measure of the core did not finish in its budget "
|
||||
"with rtt %d ms (no verdict was declared)" % rtt_ms)
|
||||
return ("the UDP measure of the core did not finish coherent in its budget with rtt %d ms: it declared %r for this proxy, "
|
||||
"so the engine had no relay to use" % (rtt_ms, declared))
|
||||
|
||||
|
||||
def bench_report(gateway: Any, rtt_ms: int, declared: Optional[str]) -> str:
|
||||
"""What the bench saw, as one string for the verdict of a failed test: the datagrams the relay carried with their times
|
||||
(seconds from the start of the gateway), the sends that failed, the CONNECTs, the TCP connections accepted, the UDP
|
||||
ASSOCIATEs and their start and end, and what the core declared for the proxy. Nothing here changes an outcome."""
|
||||
log = ["%s:%d atyp=%d t=%.3fs" % (host, port, atyp, at) for host, port, atyp, at in list(gateway.datagram_log)]
|
||||
associations = [[None if x is None else round(x, 3) for x in record] for record in list(gateway.associations)]
|
||||
return ("%s; gateway send errors: %s; CONNECTs the gateway saw: %s; TCP connections it accepted: %d; "
|
||||
"associations (start, end in s from its start): %s; datagram log with times: %s"
|
||||
% (udp_measure_sentence(declared, rtt_ms), list(gateway.send_errors), list(gateway.connects),
|
||||
len(gateway.accepted), associations, log))
|
||||
|
||||
|
||||
def visits_for(road: str) -> int:
|
||||
"""How many times the page is visited on ``road``: three with no proxy, :data:`PROXY_VISITS` behind any proxy."""
|
||||
if road == _DIRECT_ROAD:
|
||||
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
"""What the e2e tests wait for: a CONDITION with a deadline, and a record of what was seen while waiting.
|
||||
|
||||
A test that sleeps a fixed time and then reads the state judges the speed of the machine it runs on: on a loaded
|
||||
Windows runner the event arrives after the sleep and the test is red, while the product did nothing wrong. A test
|
||||
that waits until the condition holds (or a deadline that is far beyond any healthy run) is red only when the
|
||||
condition never holds, and it says what it saw on the way, so a red run tells a slow machine from a lost event.
|
||||
|
||||
* :func:`wait_until` and :func:`awatch` poll a condition; ``pump`` is what lets the events of a sync client be
|
||||
read (``page.wait_for_timeout``) or a coroutine yield. The deadline is the only clock the verdict depends on, and
|
||||
it is the one the test names.
|
||||
* :class:`Timeline` is a list of events with the time each was heard, relative to a start the test chooses.
|
||||
* :func:`without_end` says which requests began and never ended.
|
||||
* :func:`quiet_problem` judges a `networkidle` from the server's own stamps of each request.
|
||||
* :func:`spare_processes` is the pool of preallocated content processes retail Firefox keeps (see its docstring).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from collections import Counter
|
||||
from typing import Any, Callable, Iterable, List, Optional, Tuple
|
||||
|
||||
|
||||
class Watch:
|
||||
"""The outcome of a wait: ``ok`` (the condition held before the deadline) and ``history``, the sampled value each
|
||||
time it changed, as ``(seconds since the wait began, value)``."""
|
||||
|
||||
def __init__(self, ok: bool, history: List[Tuple[float, Any]], took: float) -> None:
|
||||
self.ok = ok
|
||||
self.history = history
|
||||
self.took = took
|
||||
|
||||
def render(self) -> str:
|
||||
return "; ".join("+%.2fs %r" % (at, value) for at, value in self.history) or "nothing sampled"
|
||||
|
||||
|
||||
def wait_until(condition: Callable[[], Any], seconds: float, pump: Callable[[], Any],
|
||||
clock: Callable[[], float] = time.monotonic) -> bool:
|
||||
"""Until ``condition()`` is true, calling ``pump()`` between two looks; False if ``seconds`` pass first."""
|
||||
return watch(lambda: bool(condition()), lambda value: value, seconds, pump, clock).ok
|
||||
|
||||
|
||||
def watch(sample: Callable[[], Any], done: Callable[[Any], Any], seconds: float, pump: Callable[[], Any],
|
||||
clock: Callable[[], float] = time.monotonic) -> Watch:
|
||||
"""Until ``done(sample())``, calling ``pump()`` between two looks. The deadline is ``seconds`` from the start; the
|
||||
last look is taken AT the deadline, so a condition that became true during the last pump is not missed."""
|
||||
began = clock()
|
||||
history: List[Tuple[float, Any]] = []
|
||||
while True:
|
||||
value = sample()
|
||||
now = clock()
|
||||
if not history or history[-1][1] != value:
|
||||
history.append((now - began, value))
|
||||
if done(value):
|
||||
return Watch(True, history, now - began)
|
||||
if now - began >= seconds:
|
||||
return Watch(False, history, now - began)
|
||||
pump()
|
||||
|
||||
|
||||
async def awatch(sample: Callable[[], Any], done: Callable[[Any], Any], seconds: float,
|
||||
pump: Callable[[], Any], clock: Callable[[], float] = time.monotonic) -> Watch:
|
||||
""":func:`watch` for an async client: ``pump`` is awaited."""
|
||||
began = clock()
|
||||
history: List[Tuple[float, Any]] = []
|
||||
while True:
|
||||
value = sample()
|
||||
now = clock()
|
||||
if not history or history[-1][1] != value:
|
||||
history.append((now - began, value))
|
||||
if done(value):
|
||||
return Watch(True, history, now - began)
|
||||
if now - began >= seconds:
|
||||
return Watch(False, history, now - began)
|
||||
await pump()
|
||||
|
||||
|
||||
class Timeline:
|
||||
"""Events with the time each was heard, relative to ``start`` (set by the test just before the action)."""
|
||||
|
||||
def __init__(self, clock: Callable[[], float] = time.monotonic) -> None:
|
||||
self._clock = clock
|
||||
self.start = clock()
|
||||
self.events: List[Tuple[float, str, str]] = []
|
||||
|
||||
def begin(self) -> None:
|
||||
self.start = self._clock()
|
||||
|
||||
def add(self, kind: str, what: str) -> None:
|
||||
self.events.append((self._clock() - self.start, kind, what))
|
||||
|
||||
def of(self, *kinds: str) -> List[str]:
|
||||
return [what for _at, kind, what in self.events if kind in kinds]
|
||||
|
||||
def render(self) -> str:
|
||||
return "\n".join(" +%.3fs %-9s %s" % (at, kind, what) for at, kind, what in sorted(self.events)) or " no event"
|
||||
|
||||
|
||||
def without_end(started: Iterable[str], ended: Iterable[str]) -> List[str]:
|
||||
"""The requests that began and never ended: each url as many times as it began more than it ended."""
|
||||
return sorted((Counter(started) - Counter(ended)).elements())
|
||||
|
||||
|
||||
def spare_processes(total_memory_bytes: Optional[int], lowmem_mb: int = 4096, fission_number: int = 3) -> int:
|
||||
"""How many preallocated content processes retail Firefox keeps beside the ones that host pages.
|
||||
|
||||
With Fission on (the wrapper's strategy 1), `PreallocatedProcessManagerImpl::RereadPrefs`
|
||||
(dom/ipc/PreallocatedProcessManager.cpp) keeps a pool of `dom.ipc.processPrelaunch.fission.number` processes
|
||||
(StaticPrefList.yaml: 3 on desktop), and 1 on a machine whose memory is at or under
|
||||
`dom.ipc.processPrelaunch.lowmem_mb` (4096 MB). The pool is refilled one process at a time, each after
|
||||
`dom.ipc.processPrelaunch.delayMs` (1000 ms) and when the loop is idle, so how many of them exist at the moment a
|
||||
test looks depends on how long ago the last page took one."""
|
||||
if total_memory_bytes and total_memory_bytes <= lowmem_mb * 1024 * 1024:
|
||||
return 1
|
||||
return fission_number
|
||||
|
||||
|
||||
def quiet_problem(stamps: Iterable[Tuple[str, float, Optional[float]]], returned: float, quiet: float) -> Optional[str]:
|
||||
"""What is wrong with a `networkidle` that came at ``returned`` (None if nothing), from ``(path, arrival, end)``
|
||||
stamps of the requests of the page on the server's clock (``end`` None: not answered yet).
|
||||
|
||||
`networkidle` promises that no request is in flight and that half a second has passed since the last one ended.
|
||||
Asked here for ``quiet`` (a little under the half second, because the client hears of an end a moment after the
|
||||
server writes it). A late request that has not even arrived is no reason to complain when the network really was
|
||||
quiet before ``returned``, and a request in flight, or an end too near, is."""
|
||||
stamps = list(stamps)
|
||||
in_flight = [path for path, _arrival, end in stamps if end is None or end > returned]
|
||||
if in_flight:
|
||||
return "networkidle came while %s was in flight" % in_flight
|
||||
if not stamps:
|
||||
return "no request of the page was seen at all"
|
||||
since = returned - max(end for _path, _arrival, end in stamps)
|
||||
if since < quiet:
|
||||
return "networkidle came after only %.3f s without network (it promises 0.5)" % since
|
||||
return None
|
||||
@@ -96,6 +96,18 @@ def pytest_runtest_teardown(item, nextitem):
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
"""The e2e tests of the post-publication files (``tests/_post_publication.py``: pip, uv, PyPI, GitHub) belong to the round after a publication: a run
|
||||
that does not NAME their file does not run them. ``user-install.yml`` names both files; ``scripts/run_e2e.py`` and every PR or candidate leg do not."""
|
||||
import _post_publication
|
||||
|
||||
left = [item for item in items
|
||||
if item.get_closest_marker("e2e") is not None and _post_publication.is_left_out(item.path, config.args)]
|
||||
if left:
|
||||
items[:] = [item for item in items if item not in left]
|
||||
config.hook.pytest_deselected(items=left)
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
global _watchdog_handle
|
||||
if _watchdog_handle is not None:
|
||||
@@ -151,6 +163,41 @@ def _offline_session_geo(request, monkeypatch):
|
||||
monkeypatch.setattr(_session, "session_geo", lambda *_a, **_k: geo)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def _the_lab_declares_the_exit(request, tmp_path_factory):
|
||||
"""Where an e2e launch leaves from is DECLARED, not asked of three services of the internet.
|
||||
|
||||
A launch with no proxy asks the core's ``discover_egress_ip`` for its exit, which asks api.ipify.org, icanhazip.com and checkip.amazonaws.com: a
|
||||
third party in every one of the 222 launches that name neither ``timezone=`` nor ``proxy=``. For a session in which an e2e test is selected, the
|
||||
question with no proxy is answered the exit of the lab (``tests/_lab_egress.py``), and the GeoIP database is the lab's when no leg set one. SESSION
|
||||
scope, because the module-scoped browsers of several files launch before any function-scoped fixture; a test that replaces the question (an exit
|
||||
behind its own gateway) does it with ``monkeypatch`` and goes back to this answer. A session with no e2e test selected is left as it is: the unit
|
||||
tests of the discovery call the real function."""
|
||||
if not any(item.get_closest_marker("e2e") is not None for item in request.session.items):
|
||||
yield None
|
||||
return
|
||||
import _lab_egress
|
||||
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
yield _lab_egress.install(patch, tmp_path_factory.mktemp("lab-geoip"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_egress_echo(monkeypatch):
|
||||
"""The REAL discovery of the exit, for the test that must prove it, against an echo service of its own on loopback: the three services of the
|
||||
product are replaced by one that answers :data:`_lab_egress.LAB_EGRESS_IP` and counts its questions. Nothing goes to the internet."""
|
||||
from invisible_core import _geo
|
||||
|
||||
import _lab_egress
|
||||
|
||||
current = _geo.discover_egress_ip
|
||||
monkeypatch.setattr(_geo, "discover_egress_ip", getattr(current, "original", current))
|
||||
echo = _lab_egress.EchoService()
|
||||
monkeypatch.setattr(_geo, "_IP_ECHO_ENDPOINTS", (echo.url,))
|
||||
yield echo
|
||||
echo.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def deterministic_rng():
|
||||
"""Seeded RNG for reproducible tests."""
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
{
|
||||
"os": "linux",
|
||||
"source": "GitHub Actions run 43661728392 (workflow page-bytes-reference-hunt, runner image ubuntu24 20261111.370.1), wrapper commit 455d5619e5, invisible-core 64.71.0, engine firefox-64_159.0_20261114003728, seed 42, locale en-US, timezone Europe/Rome, headless=True; 2 launches, every key below is equal in all of them. `pngs`: the PNG keys, compared on their length and decoded pixels because every PNG carries a per-launch chunk.",
|
||||
"keys": {
|
||||
"c2d.composite.getImageData": {
|
||||
"h": "df65ebe03bf31",
|
||||
"n": 131072
|
||||
},
|
||||
"c2d.composite.jpeg": {
|
||||
"h": "1c1b75006c5984",
|
||||
"n": 11535
|
||||
},
|
||||
"c2d.composite.webp": {
|
||||
"h": "182ab2238ae6c0",
|
||||
"n": 5431
|
||||
},
|
||||
"c2d.gradtext.getImageData": {
|
||||
"h": "ba9fb4487cdea",
|
||||
"n": 352800
|
||||
},
|
||||
"c2d.image.getImageData": {
|
||||
"h": "8218d41a1794c",
|
||||
"n": 76800
|
||||
},
|
||||
"c2d.image.jpeg": {
|
||||
"h": "125de65c968e30",
|
||||
"n": 7315
|
||||
},
|
||||
"c2d.image.webp": {
|
||||
"h": "26ea5dc80f98c",
|
||||
"n": 5659
|
||||
},
|
||||
"c2d.measure": {
|
||||
"h": "14a71ef40cb01c",
|
||||
"n": 9488
|
||||
},
|
||||
"c2d.offscreen.getImageData": {
|
||||
"h": "5a93b1c32ab60",
|
||||
"n": 51200
|
||||
},
|
||||
"c2d.scale.high.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.low.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.medium.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.off.getImageData": {
|
||||
"h": "c673134829639",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.shapes.getImageData": {
|
||||
"h": "18fe9a0f7336da",
|
||||
"n": 163840
|
||||
},
|
||||
"c2d.shapes.jpeg": {
|
||||
"h": "18d82802030ab3",
|
||||
"n": 6975
|
||||
},
|
||||
"c2d.shapes.webp": {
|
||||
"h": "1ec9fa4e39f8de",
|
||||
"n": 3287
|
||||
},
|
||||
"c2d.text.getImageData": {
|
||||
"h": "e141df45718e",
|
||||
"n": 856960
|
||||
},
|
||||
"c2d.text.jpeg": {
|
||||
"h": "23b24c30781ee",
|
||||
"n": 41751
|
||||
},
|
||||
"c2d.text.webp": {
|
||||
"h": "1b0cc3c21c4f0f",
|
||||
"n": 26215
|
||||
},
|
||||
"dom.fonts_check": {
|
||||
"s": "[[\"16px sans-serif\",true],[\"20px serif\",true],[\"18px monospace\",true],[\"bold 16px Arial\",true],[\"italic 15px 'Segoe UI'\",true],[\"16px 'Times New Roman'\",true],[\"16px Calibri\",true],[\"14px Consolas\",true],[\"16px Verdana\",true],[\"16px Tahoma\",true],[\"17px Georgia\",true],[\"16px 'Segoe UI Emoji'\",true],[\"16px 'Microsoft YaHei'\",true],[\"16px 'Yu Gothic'\",true]]"
|
||||
},
|
||||
"dom.paragraphs": {
|
||||
"s": "[[\"16px sans-serif\",200,21],[\"15px 'Times New Roman'\",200,20],[\"14px Consolas\",200,19]]"
|
||||
},
|
||||
"dom.span_boxes": {
|
||||
"h": "1435dcc5a321d6",
|
||||
"n": 5864
|
||||
},
|
||||
"dom.system_colors": {
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 215)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 215)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
},
|
||||
"env.dpr": {
|
||||
"s": "1"
|
||||
},
|
||||
"env.hw": {
|
||||
"s": "8"
|
||||
},
|
||||
"env.lang": {
|
||||
"s": "[\"en-US\",\"en\"]"
|
||||
},
|
||||
"env.mq": {
|
||||
"s": "[true,false,false,false,false,false,false]"
|
||||
},
|
||||
"env.oscpu": {
|
||||
"s": "Windows NT 10.0; Win64; x64"
|
||||
},
|
||||
"env.platform": {
|
||||
"s": "Win32"
|
||||
},
|
||||
"env.screen": {
|
||||
"s": "[1920,1080,1920,1032,24,24]"
|
||||
},
|
||||
"env.ua": {
|
||||
"s": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:159.0) Gecko/20100101 Firefox/159.0"
|
||||
},
|
||||
"gl1.anisotropy": {
|
||||
"s": "16"
|
||||
},
|
||||
"gl1.antialias.false.readPixels": {
|
||||
"h": "abed055e93fb8",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.antialias.false.samples": {
|
||||
"s": "0"
|
||||
},
|
||||
"gl1.antialias.true.readPixels": {
|
||||
"h": "155744fc8af4b9",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.antialias.true.samples": {
|
||||
"s": "4"
|
||||
},
|
||||
"gl1.attributes": {
|
||||
"s": "{\"alpha\":true,\"antialias\":true,\"depth\":true,\"failIfMajorPerformanceCaveat\":false,\"powerPreference\":\"default\",\"premultipliedAlpha\":true,\"preserveDrawingBuffer\":true,\"stencil\":false}"
|
||||
},
|
||||
"gl1.blend.readPixels": {
|
||||
"h": "cfef8e9072c0c",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.depth_stencil.readPixels": {
|
||||
"h": "eaa3d5d41cfb",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.extension_objects": {
|
||||
"s": "[[\"ANGLE_instanced_arrays\",4],[\"EXT_blend_minmax\",2],[\"EXT_clip_control\",7],[\"EXT_color_buffer_half_float\",4],[\"EXT_depth_clamp\",1],[\"EXT_float_blend\",0],[\"EXT_frag_depth\",0],[\"EXT_polygon_offset_clamp\",2],[\"EXT_shader_texture_lod\",0],[\"EXT_sRGB\",4],[\"EXT_texture_compression_bptc\",4],[\"EXT_texture_compression_rgtc\",4],[\"EXT_texture_filter_anisotropic\",2],[\"EXT_texture_mirror_clamp_to_edge\",1],[\"OES_element_index_uint\",0],[\"OES_fbo_render_mipmap\",0],[\"OES_standard_derivatives\",1],[\"OES_texture_float\",0],[\"OES_texture_float_linear\",0],[\"OES_texture_half_float\",1],[\"OES_texture_half_float_linear\",0],[\"OES_vertex_array_object\",5],[\"WEBGL_color_buffer_float\",4],[\"WEBGL_compressed_texture_s3tc\",4],[\"WEBGL_compressed_texture_s3tc_srgb\",4],[\"WEBGL_debug_renderer_info\",2],[\"WEBGL_debug_shaders\",1],[\"WEBGL_depth_texture\",1],[\"WEBGL_draw_buffers\",35],[\"WEBGL_lose_context\",2],[\"WEBGL_provoking_vertex\",4]]"
|
||||
},
|
||||
"gl1.extensions": {
|
||||
"s": "[\"ANGLE_instanced_arrays\",\"EXT_blend_minmax\",\"EXT_clip_control\",\"EXT_color_buffer_half_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_frag_depth\",\"EXT_polygon_offset_clamp\",\"EXT_shader_texture_lod\",\"EXT_sRGB\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"OES_element_index_uint\",\"OES_fbo_render_mipmap\",\"OES_standard_derivatives\",\"OES_texture_float\",\"OES_texture_float_linear\",\"OES_texture_half_float\",\"OES_texture_half_float_linear\",\"OES_vertex_array_object\",\"WEBGL_color_buffer_float\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_depth_texture\",\"WEBGL_draw_buffers\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"]"
|
||||
},
|
||||
"gl1.lines_points.readPixels": {
|
||||
"h": "1841f80a258941",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.math.highp.readPixels": {
|
||||
"h": "14f93cecd95f86",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.math.mediump.readPixels": {
|
||||
"h": "14f93cecd95f86",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.params": {
|
||||
"s": "{\"VERSION\":\"WebGL 1.0\",\"SHADING_LANGUAGE_VERSION\":\"WebGL GLSL ES 1.0\",\"VENDOR\":\"Mozilla\",\"RENDERER\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"MAX_TEXTURE_SIZE\":16384,\"MAX_CUBE_MAP_TEXTURE_SIZE\":16384,\"MAX_RENDERBUFFER_SIZE\":16384,\"MAX_VIEWPORT_DIMS\":[32767,32767],\"ALIASED_LINE_WIDTH_RANGE\":[1,1],\"ALIASED_POINT_SIZE_RANGE\":[1,1024],\"MAX_VERTEX_ATTRIBS\":16,\"MAX_VARYING_VECTORS\":30,\"MAX_COMBINED_TEXTURE_IMAGE_UNITS\":32,\"MAX_VERTEX_TEXTURE_IMAGE_UNITS\":16,\"MAX_TEXTURE_IMAGE_UNITS\":16,\"MAX_VERTEX_UNIFORM_VECTORS\":4096,\"MAX_FRAGMENT_UNIFORM_VECTORS\":1024,\"RED_BITS\":8,\"GREEN_BITS\":8,\"BLUE_BITS\":8,\"ALPHA_BITS\":8,\"DEPTH_BITS\":24,\"STENCIL_BITS\":0,\"SAMPLES\":4,\"SAMPLE_BUFFERS\":1,\"SUBPIXEL_BITS\":4}"
|
||||
},
|
||||
"gl1.precision": {
|
||||
"s": "[[\"VERTEX_SHADER\",\"LOW_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"LOW_INT\",31,30,0],[\"VERTEX_SHADER\",\"MEDIUM_INT\",31,30,0],[\"VERTEX_SHADER\",\"HIGH_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"LOW_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"LOW_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"MEDIUM_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"HIGH_INT\",31,30,0]]"
|
||||
},
|
||||
"gl1.texture.linear.readPixels": {
|
||||
"h": "5fdcdb999f3e0",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.texture.mip.readPixels": {
|
||||
"h": "5fdcdb999f3e0",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.texture.nearest.readPixels": {
|
||||
"h": "160f810aa6835f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.triangle.drawImage": {
|
||||
"h": "81a61d733e561",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.triangle.readPixels": {
|
||||
"h": "12bb7ce7d2f21",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.triangle.toDataURL_jpeg": {
|
||||
"s": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABgAGADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDxKiiivTPOCiiigAopDwOaro5MpfnB7e1enl+V1ceqjp/ZV/V9vnqJuyuWaKKK81pp2YwooopAFFFFABRRRQAUUUUAMlPy4HU0RR05U3NmrMUdfdZXbBYZR6vV/wBeR1VaHJTV9yMxHZkdqjrTijqre25hYMPuN+h9K8LOKMZT9vT67/5/5nl0qtpezl8itRRRXhHUFFFFABRRRQAUqjJxSVYt4+MnvW+GipVE3sjvy7CvE1kui1YsUdW4o6WKOrcUdevUx3mehjqe4kUdWTbrLEyOPlYYp8UdW4o64KuNvofG46DTujj7y3a1uGifnHIOOoqGu01LTRfW2wELIpyjEd/Q+1cYysjFXBVgcEEYINeepxk9DfB4pV42fxLf/MSiiimdgUUUUAOiQu4UfjWpFHjFQafD8pc9+BWnFHWM8Uqd0j7zJsv9hg1Vkvenr8un+fzEijq3FHSxR1bijriqY7zPPx1PcSKOrcUdLFHVuKOuCpjvM+Nx1PcSKOsHxdpDPF9ugUl0GJVUD7v978On0+ldTFHVuKOuVZk6U1JHys608LVVWHT8Txyit/xboR0m7WSBXNnL91jyEb+7n9Rn9cGsCvp6FeFeCqU3dM+qoV4YimqlN6MKdGhkdUXqTim1p6PAGLSnnHyipxNdYek6jPaybLpZljIYdbPf0W/9dy/DEFAAHAGBVuKOlijqYyQQsFmmjRsZwzAGvk54yU3Zas/VsfCFOOtkvuJIo6txR1SbUrCDbvuYzn+5838s0kniHT4du1pJc9didPzxWXLiqnwU2/kz4jH1qKuudfebMUdW4o65iTxbaogMFtM755DkKMfUZqGbxpNsAtrKNHzyZHLjH0GKn+zsfU2hb1a/zufI4tRn8LO4ijq3FHXmsvjPU3iKRrbRMejohJH5kj9KpzeKNZmiaNr5wp6lFVD+YAIprh/HVPicV83+iPncRldSts0j1e+02HUrCW0uQxilGDtOCOcgj6ECvHdb0yfSNSmtLhWBU/IxGN654YfX/wCt2ok1fUpI2jk1C8eNgVZWnYgg9QRmqNe7lGWYjAOSnUTi+luve9/0Ncsy6rgpSvO8X0t17hUiTyooVJZFA7BiKjor25RUlaSue3TqzpO9OTT8tB0kjyHMjs5xjLHNNooppJKyJlJzfNJ3YUUUUCCiiigAooooAKKKKAP/2Q=="
|
||||
},
|
||||
"gl1.unmasked": {
|
||||
"s": "[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"]"
|
||||
},
|
||||
"gl2.anisotropy": {
|
||||
"s": "16"
|
||||
},
|
||||
"gl2.antialias.false.readPixels": {
|
||||
"h": "abed055e93fb8",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.antialias.false.samples": {
|
||||
"s": "0"
|
||||
},
|
||||
"gl2.antialias.true.readPixels": {
|
||||
"h": "155744fc8af4b9",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.antialias.true.samples": {
|
||||
"s": "4"
|
||||
},
|
||||
"gl2.attributes": {
|
||||
"s": "{\"alpha\":true,\"antialias\":true,\"depth\":true,\"failIfMajorPerformanceCaveat\":false,\"powerPreference\":\"default\",\"premultipliedAlpha\":true,\"preserveDrawingBuffer\":true,\"stencil\":false}"
|
||||
},
|
||||
"gl2.blend.readPixels": {
|
||||
"h": "cfef8e9072c0c",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.depth_stencil.readPixels": {
|
||||
"h": "eaa3d5d41cfb",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.extension_objects": {
|
||||
"s": "[[\"EXT_clip_control\",7],[\"EXT_color_buffer_float\",0],[\"EXT_depth_clamp\",1],[\"EXT_float_blend\",0],[\"EXT_polygon_offset_clamp\",2],[\"EXT_texture_compression_bptc\",4],[\"EXT_texture_compression_rgtc\",4],[\"EXT_texture_filter_anisotropic\",2],[\"EXT_texture_mirror_clamp_to_edge\",1],[\"EXT_texture_norm16\",8],[\"OES_draw_buffers_indexed\",7],[\"OES_texture_float_linear\",0],[\"OVR_multiview2\",5],[\"WEBGL_compressed_texture_s3tc\",4],[\"WEBGL_compressed_texture_s3tc_srgb\",4],[\"WEBGL_debug_renderer_info\",2],[\"WEBGL_debug_shaders\",1],[\"WEBGL_lose_context\",2],[\"WEBGL_provoking_vertex\",4]]"
|
||||
},
|
||||
"gl2.extensions": {
|
||||
"s": "[\"EXT_clip_control\",\"EXT_color_buffer_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_polygon_offset_clamp\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"EXT_texture_norm16\",\"OES_draw_buffers_indexed\",\"OES_texture_float_linear\",\"OVR_multiview2\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"]"
|
||||
},
|
||||
"gl2.float_target.readPixels": {
|
||||
"h": "1ba8f4b0bbe2d8",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.lines_points.readPixels": {
|
||||
"h": "1841f80a258941",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.math.highp.readPixels": {
|
||||
"h": "14f93cecd95f86",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.math.mediump.readPixels": {
|
||||
"h": "14f93cecd95f86",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.msaa_resolve.readPixels": {
|
||||
"h": "1a2cbef856e591",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.params": {
|
||||
"s": "{\"VERSION\":\"WebGL 2.0\",\"SHADING_LANGUAGE_VERSION\":\"WebGL GLSL ES 3.00\",\"VENDOR\":\"Mozilla\",\"RENDERER\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"MAX_TEXTURE_SIZE\":16384,\"MAX_CUBE_MAP_TEXTURE_SIZE\":16384,\"MAX_RENDERBUFFER_SIZE\":16384,\"MAX_VIEWPORT_DIMS\":[32767,32767],\"ALIASED_LINE_WIDTH_RANGE\":[1,1],\"ALIASED_POINT_SIZE_RANGE\":[1,1024],\"MAX_VERTEX_ATTRIBS\":16,\"MAX_VARYING_VECTORS\":30,\"MAX_COMBINED_TEXTURE_IMAGE_UNITS\":32,\"MAX_VERTEX_TEXTURE_IMAGE_UNITS\":16,\"MAX_TEXTURE_IMAGE_UNITS\":16,\"MAX_VERTEX_UNIFORM_VECTORS\":4096,\"MAX_FRAGMENT_UNIFORM_VECTORS\":1024,\"RED_BITS\":8,\"GREEN_BITS\":8,\"BLUE_BITS\":8,\"ALPHA_BITS\":8,\"DEPTH_BITS\":24,\"STENCIL_BITS\":0,\"SAMPLES\":4,\"SAMPLE_BUFFERS\":1,\"SUBPIXEL_BITS\":4,\"MAX_3D_TEXTURE_SIZE\":2048,\"MAX_ARRAY_TEXTURE_LAYERS\":2048,\"MAX_COLOR_ATTACHMENTS\":8,\"MAX_DRAW_BUFFERS\":8,\"MAX_ELEMENTS_INDICES\":2147483647,\"MAX_ELEMENTS_VERTICES\":2147483647,\"MAX_FRAGMENT_INPUT_COMPONENTS\":120,\"MAX_FRAGMENT_UNIFORM_BLOCKS\":12,\"MAX_FRAGMENT_UNIFORM_COMPONENTS\":4096,\"MAX_PROGRAM_TEXEL_OFFSET\":7,\"MAX_SAMPLES\":8,\"MAX_SERVER_WAIT_TIMEOUT\":0,\"MAX_TEXTURE_LOD_BIAS\":2,\"MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\":120,\"MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\":4,\"MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\":4,\"MAX_UNIFORM_BLOCK_SIZE\":65536,\"MAX_UNIFORM_BUFFER_BINDINGS\":24,\"MAX_VARYING_COMPONENTS\":120,\"MAX_VERTEX_OUTPUT_COMPONENTS\":120,\"MAX_VERTEX_UNIFORM_BLOCKS\":12,\"MAX_VERTEX_UNIFORM_COMPONENTS\":16384,\"MIN_PROGRAM_TEXEL_OFFSET\":-8,\"MAX_COMBINED_UNIFORM_BLOCKS\":24,\"MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS\":200704,\"MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS\":212992,\"UNIFORM_BUFFER_OFFSET_ALIGNMENT\":256}"
|
||||
},
|
||||
"gl2.precision": {
|
||||
"s": "[[\"VERTEX_SHADER\",\"LOW_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"LOW_INT\",31,30,0],[\"VERTEX_SHADER\",\"MEDIUM_INT\",31,30,0],[\"VERTEX_SHADER\",\"HIGH_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"LOW_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"LOW_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"MEDIUM_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"HIGH_INT\",31,30,0]]"
|
||||
},
|
||||
"gl2.texture.linear.readPixels": {
|
||||
"h": "5fdcdb999f3e0",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.texture.mip.readPixels": {
|
||||
"h": "5fdcdb999f3e0",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.texture.nearest.readPixels": {
|
||||
"h": "160f810aa6835f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.triangle.drawImage": {
|
||||
"h": "81a61d733e561",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.triangle.readPixels": {
|
||||
"h": "12bb7ce7d2f21",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.triangle.toDataURL_jpeg": {
|
||||
"s": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABgAGADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDxKiiivTPOCiiigAopDwOaro5MpfnB7e1enl+V1ceqjp/ZV/V9vnqJuyuWaKKK81pp2YwooopAFFFFABRRRQAUUUUAMlPy4HU0RR05U3NmrMUdfdZXbBYZR6vV/wBeR1VaHJTV9yMxHZkdqjrTijqre25hYMPuN+h9K8LOKMZT9vT67/5/5nl0qtpezl8itRRRXhHUFFFFABRRRQAUqjJxSVYt4+MnvW+GipVE3sjvy7CvE1kui1YsUdW4o6WKOrcUdevUx3mehjqe4kUdWTbrLEyOPlYYp8UdW4o64KuNvofG46DTujj7y3a1uGifnHIOOoqGu01LTRfW2wELIpyjEd/Q+1cYysjFXBVgcEEYINeepxk9DfB4pV42fxLf/MSiiimdgUUUUAOiQu4UfjWpFHjFQafD8pc9+BWnFHWM8Uqd0j7zJsv9hg1Vkvenr8un+fzEijq3FHSxR1bijriqY7zPPx1PcSKOrcUdLFHVuKOuCpjvM+Nx1PcSKOsHxdpDPF9ugUl0GJVUD7v978On0+ldTFHVuKOuVZk6U1JHys608LVVWHT8Txyit/xboR0m7WSBXNnL91jyEb+7n9Rn9cGsCvp6FeFeCqU3dM+qoV4YimqlN6MKdGhkdUXqTim1p6PAGLSnnHyipxNdYek6jPaybLpZljIYdbPf0W/9dy/DEFAAHAGBVuKOlijqYyQQsFmmjRsZwzAGvk54yU3Zas/VsfCFOOtkvuJIo6txR1SbUrCDbvuYzn+5838s0kniHT4du1pJc9didPzxWXLiqnwU2/kz4jH1qKuudfebMUdW4o65iTxbaogMFtM755DkKMfUZqGbxpNsAtrKNHzyZHLjH0GKn+zsfU2hb1a/zufI4tRn8LO4ijq3FHXmsvjPU3iKRrbRMejohJH5kj9KpzeKNZmiaNr5wp6lFVD+YAIprh/HVPicV83+iPncRldSts0j1e+02HUrCW0uQxilGDtOCOcgj6ECvHdb0yfSNSmtLhWBU/IxGN654YfX/wCt2ok1fUpI2jk1C8eNgVZWnYgg9QRmqNe7lGWYjAOSnUTi+luve9/0Ncsy6rgpSvO8X0t17hUiTyooVJZFA7BiKjor25RUlaSue3TqzpO9OTT8tB0kjyHMjs5xjLHNNooppJKyJlJzfNJ3YUUUUCCiiigAooooAKKKKAP/2Q=="
|
||||
},
|
||||
"gl2.unmasked": {
|
||||
"s": "[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"]"
|
||||
},
|
||||
"gpu.webgpu.features": {
|
||||
"s": "{\"depth-clip-control\":true,\"depth32float-stencil8\":true,\"texture-compression-bc\":true,\"texture-compression-bc-sliced-3d\":true,\"texture-compression-etc2\":false,\"texture-compression-astc\":false,\"texture-compression-astc-sliced-3d\":false,\"timestamp-query\":true,\"indirect-first-instance\":true,\"shader-f16\":true,\"rg11b10ufloat-renderable\":true,\"bgra8unorm-storage\":true,\"float32-filterable\":true,\"float32-blendable\":true,\"clip-distances\":false,\"dual-source-blending\":true,\"subgroups\":false}"
|
||||
},
|
||||
"gpu.webgpu.info": {
|
||||
"s": "{\"vendor\":\"\",\"architecture\":\"\",\"device\":\"\",\"description\":\"\"}"
|
||||
},
|
||||
"gpu.webgpu.limits": {
|
||||
"s": "{\"maxTextureDimension1D\":16384,\"maxTextureDimension2D\":16384,\"maxTextureDimension3D\":2048,\"maxTextureArrayLayers\":2048,\"maxBindGroups\":8,\"maxBindGroupsPlusVertexBuffers\":24,\"maxBindingsPerBindGroup\":4294967295,\"maxDynamicUniformBuffersPerPipelineLayout\":8,\"maxDynamicStorageBuffersPerPipelineLayout\":4,\"maxSampledTexturesPerShaderStage\":64,\"maxSamplersPerShaderStage\":64,\"maxStorageBuffersPerShaderStage\":64,\"maxStorageTexturesPerShaderStage\":64,\"maxUniformBuffersPerShaderStage\":64,\"maxUniformBufferBindingSize\":65536,\"maxStorageBufferBindingSize\":2147483644,\"minUniformBufferOffsetAlignment\":256,\"minStorageBufferOffsetAlignment\":32,\"maxVertexBuffers\":16,\"maxBufferSize\":2147483644,\"maxVertexAttributes\":30,\"maxVertexBufferArrayStride\":2048,\"maxInterStageShaderVariables\":31,\"maxColorAttachments\":8,\"maxColorAttachmentBytesPerSample\":128,\"maxComputeWorkgroupStorageSize\":32768,\"maxComputeInvocationsPerWorkgroup\":1024,\"maxComputeWorkgroupSizeX\":1024,\"maxComputeWorkgroupSizeY\":1024,\"maxComputeWorkgroupSizeZ\":64,\"maxComputeWorkgroupsPerDimension\":65535}"
|
||||
},
|
||||
"worker.webgl": {
|
||||
"s": "{\"vendor\":\"Mozilla\",\"renderer\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"unmasked\":[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"],\"exts\":[\"ANGLE_instanced_arrays\",\"EXT_blend_minmax\",\"EXT_clip_control\",\"EXT_color_buffer_half_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_frag_depth\",\"EXT_polygon_offset_clamp\",\"EXT_shader_texture_lod\",\"EXT_sRGB\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"OES_element_index_uint\",\"OES_fbo_render_mipmap\",\"OES_standard_derivatives\",\"OES_texture_float\",\"OES_texture_float_linear\",\"OES_texture_half_float\",\"OES_texture_half_float_linear\",\"OES_vertex_array_object\",\"WEBGL_color_buffer_float\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_depth_texture\",\"WEBGL_draw_buffers\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"],\"px\":[64,128,191,255,64,128,191,255,64,128,191,255,64,128,191,255]}"
|
||||
}
|
||||
},
|
||||
"pngs": {
|
||||
"c2d.composite.png": {
|
||||
"n": 2414,
|
||||
"w": 256,
|
||||
"h": 128,
|
||||
"ct": 6,
|
||||
"sha256": "fb585f18240eb1a787a5b146d6332a0376dae76f8c8716e99f68fbbf9eff905e"
|
||||
},
|
||||
"c2d.composite.toBlob": {
|
||||
"n": 1794,
|
||||
"w": 256,
|
||||
"h": 128,
|
||||
"ct": 6,
|
||||
"sha256": "fb585f18240eb1a787a5b146d6332a0376dae76f8c8716e99f68fbbf9eff905e"
|
||||
},
|
||||
"c2d.gradtext.png": {
|
||||
"n": 56850,
|
||||
"w": 420,
|
||||
"h": 210,
|
||||
"ct": 6,
|
||||
"sha256": "a294763c6eca0c9178d09052cfaa5ac92932d8cf32909f31bbb387810d473310"
|
||||
},
|
||||
"c2d.image.png": {
|
||||
"n": 19502,
|
||||
"w": 160,
|
||||
"h": 120,
|
||||
"ct": 6,
|
||||
"sha256": "51bc3789f2e238dfbf8899eb7a965a4f04d3e0e7f2246b1bd3cfdc9597bd2a77"
|
||||
},
|
||||
"c2d.image.toBlob": {
|
||||
"n": 14610,
|
||||
"w": 160,
|
||||
"h": 120,
|
||||
"ct": 6,
|
||||
"sha256": "51bc3789f2e238dfbf8899eb7a965a4f04d3e0e7f2246b1bd3cfdc9597bd2a77"
|
||||
},
|
||||
"c2d.offscreen.convertToBlob": {
|
||||
"n": 2687,
|
||||
"w": 160,
|
||||
"h": 80,
|
||||
"ct": 6,
|
||||
"sha256": "38b7fa4aa1d61a5bae5b92e8b9216ff61ce4d4a8d15cc0fa6d8a8c8441a3fdb8"
|
||||
},
|
||||
"c2d.scale.high.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.low.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.medium.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.off.png": {
|
||||
"n": 20890,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "c28700e28636d69dfe9bf293fadebae1fdf970949ac90147836ab1837065f46d"
|
||||
},
|
||||
"c2d.shapes.png": {
|
||||
"n": 19226,
|
||||
"w": 256,
|
||||
"h": 160,
|
||||
"ct": 6,
|
||||
"sha256": "89ee57c100f4682099bd3a5f2de56c5b31091dae253bd7e3db4f254fb8b9e6a3"
|
||||
},
|
||||
"c2d.shapes.toBlob": {
|
||||
"n": 14402,
|
||||
"w": 256,
|
||||
"h": 160,
|
||||
"ct": 6,
|
||||
"sha256": "89ee57c100f4682099bd3a5f2de56c5b31091dae253bd7e3db4f254fb8b9e6a3"
|
||||
},
|
||||
"c2d.text.png": {
|
||||
"n": 51610,
|
||||
"w": 520,
|
||||
"h": 412,
|
||||
"ct": 6,
|
||||
"sha256": "1c56511f78721be0423bbcef100bf7b52e9997da498bd1f771d0d8348a791d3b"
|
||||
},
|
||||
"c2d.text.toBlob": {
|
||||
"n": 38691,
|
||||
"w": 520,
|
||||
"h": 412,
|
||||
"ct": 6,
|
||||
"sha256": "1c56511f78721be0423bbcef100bf7b52e9997da498bd1f771d0d8348a791d3b"
|
||||
},
|
||||
"gl1.triangle.toDataURL": {
|
||||
"n": 7470,
|
||||
"w": 96,
|
||||
"h": 96,
|
||||
"ct": 6,
|
||||
"sha256": "3f24afcf21a411e18ef9256e558a30ec589bbb51923fedf485cd0e6a2dcd9919"
|
||||
},
|
||||
"gl2.triangle.toDataURL": {
|
||||
"n": 7470,
|
||||
"w": 96,
|
||||
"h": 96,
|
||||
"ct": 6,
|
||||
"sha256": "3f24afcf21a411e18ef9256e558a30ec589bbb51923fedf485cd0e6a2dcd9919"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
{
|
||||
"os": "windows",
|
||||
"source": "GitHub Actions run 43661728392 (workflow page-bytes-reference-hunt, runner image win22 20261112.366.7), wrapper commit 455d5619e5, invisible-core 64.71.0, engine firefox-64_159.0_20261114003728, seed 42, locale en-US, timezone Europe/Rome, headless=True; 2 launches, every key below is equal in all of them. `pngs`: the PNG keys, compared on their length and decoded pixels because every PNG carries a per-launch chunk.",
|
||||
"keys": {
|
||||
"c2d.composite.getImageData": {
|
||||
"h": "df65ebe03bf31",
|
||||
"n": 131072
|
||||
},
|
||||
"c2d.composite.jpeg": {
|
||||
"h": "1c1b75006c5984",
|
||||
"n": 11535
|
||||
},
|
||||
"c2d.composite.webp": {
|
||||
"h": "182ab2238ae6c0",
|
||||
"n": 5431
|
||||
},
|
||||
"c2d.gradtext.getImageData": {
|
||||
"h": "42edf4d4d5394",
|
||||
"n": 352800
|
||||
},
|
||||
"c2d.image.getImageData": {
|
||||
"h": "8218d41a1794c",
|
||||
"n": 76800
|
||||
},
|
||||
"c2d.image.jpeg": {
|
||||
"h": "125de65c968e30",
|
||||
"n": 7315
|
||||
},
|
||||
"c2d.image.webp": {
|
||||
"h": "26ea5dc80f98c",
|
||||
"n": 5659
|
||||
},
|
||||
"c2d.measure": {
|
||||
"h": "a731f7d3287e2",
|
||||
"n": 9495
|
||||
},
|
||||
"c2d.offscreen.getImageData": {
|
||||
"h": "1d9666b372acb1",
|
||||
"n": 51200
|
||||
},
|
||||
"c2d.scale.high.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.low.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.medium.getImageData": {
|
||||
"h": "10d3beda5ba224",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.scale.off.getImageData": {
|
||||
"h": "c673134829639",
|
||||
"n": 114400
|
||||
},
|
||||
"c2d.shapes.getImageData": {
|
||||
"h": "18fe9a0f7336da",
|
||||
"n": 163840
|
||||
},
|
||||
"c2d.shapes.jpeg": {
|
||||
"h": "18d82802030ab3",
|
||||
"n": 6975
|
||||
},
|
||||
"c2d.shapes.webp": {
|
||||
"h": "1ec9fa4e39f8de",
|
||||
"n": 3287
|
||||
},
|
||||
"c2d.text.getImageData": {
|
||||
"h": "11041652732d2c",
|
||||
"n": 856960
|
||||
},
|
||||
"c2d.text.jpeg": {
|
||||
"h": "15a47ca2d73ab",
|
||||
"n": 43163
|
||||
},
|
||||
"c2d.text.webp": {
|
||||
"h": "59e03617b84b1",
|
||||
"n": 26943
|
||||
},
|
||||
"dom.fonts_check": {
|
||||
"s": "[[\"16px sans-serif\",true],[\"20px serif\",true],[\"18px monospace\",true],[\"bold 16px Arial\",true],[\"italic 15px 'Segoe UI'\",true],[\"16px 'Times New Roman'\",true],[\"16px Calibri\",true],[\"14px Consolas\",true],[\"16px Verdana\",true],[\"16px Tahoma\",true],[\"17px Georgia\",true],[\"16px 'Segoe UI Emoji'\",true],[\"16px 'Microsoft YaHei'\",true],[\"16px 'Yu Gothic'\",true]]"
|
||||
},
|
||||
"dom.paragraphs": {
|
||||
"s": "[[\"16px sans-serif\",200,21],[\"15px 'Times New Roman'\",200,20],[\"14px Consolas\",200,19]]"
|
||||
},
|
||||
"dom.span_boxes": {
|
||||
"h": "157207c863aeec",
|
||||
"n": 5863
|
||||
},
|
||||
"dom.system_colors": {
|
||||
"s": "[[\"Canvas\",\"rgb(255, 255, 255)\"],[\"CanvasText\",\"rgb(0, 0, 0)\"],[\"ButtonFace\",\"rgb(233, 233, 237)\"],[\"ButtonText\",\"rgb(0, 0, 0)\"],[\"ButtonBorder\",\"rgb(129, 127, 132)\"],[\"Field\",\"rgb(255, 255, 255)\"],[\"FieldText\",\"rgb(0, 0, 0)\"],[\"Highlight\",\"rgb(0, 120, 215)\"],[\"HighlightText\",\"rgb(255, 255, 255)\"],[\"GrayText\",\"rgb(109, 109, 109)\"],[\"LinkText\",\"rgb(0, 0, 238)\"],[\"VisitedText\",\"rgb(85, 26, 139)\"],[\"ActiveText\",\"rgb(238, 0, 0)\"],[\"Mark\",\"rgb(255, 255, 0)\"],[\"MarkText\",\"rgb(0, 0, 0)\"],[\"AccentColor\",\"rgb(0, 96, 223)\"],[\"AccentColorText\",\"rgb(255, 255, 255)\"],[\"SelectedItem\",\"rgb(0, 120, 215)\"],[\"SelectedItemText\",\"rgb(255, 255, 255)\"]]"
|
||||
},
|
||||
"env.dpr": {
|
||||
"s": "1"
|
||||
},
|
||||
"env.hw": {
|
||||
"s": "8"
|
||||
},
|
||||
"env.lang": {
|
||||
"s": "[\"en-US\",\"en\"]"
|
||||
},
|
||||
"env.mq": {
|
||||
"s": "[true,false,false,false,false,false,false]"
|
||||
},
|
||||
"env.oscpu": {
|
||||
"s": "Windows NT 10.0; Win64; x64"
|
||||
},
|
||||
"env.platform": {
|
||||
"s": "Win32"
|
||||
},
|
||||
"env.screen": {
|
||||
"s": "[1920,1080,1920,1032,24,24]"
|
||||
},
|
||||
"env.ua": {
|
||||
"s": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:159.0) Gecko/20100101 Firefox/159.0"
|
||||
},
|
||||
"gl1.anisotropy": {
|
||||
"s": "16"
|
||||
},
|
||||
"gl1.antialias.false.readPixels": {
|
||||
"h": "abed055e93fb8",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.antialias.false.samples": {
|
||||
"s": "0"
|
||||
},
|
||||
"gl1.antialias.true.readPixels": {
|
||||
"h": "155744fc8af4b9",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.antialias.true.samples": {
|
||||
"s": "4"
|
||||
},
|
||||
"gl1.attributes": {
|
||||
"s": "{\"alpha\":true,\"antialias\":true,\"depth\":true,\"failIfMajorPerformanceCaveat\":false,\"powerPreference\":\"default\",\"premultipliedAlpha\":true,\"preserveDrawingBuffer\":true,\"stencil\":false}"
|
||||
},
|
||||
"gl1.blend.readPixels": {
|
||||
"h": "1e61b0c76b34d",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.depth_stencil.readPixels": {
|
||||
"h": "eaa3d5d41cfb",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.extension_objects": {
|
||||
"s": "[[\"ANGLE_instanced_arrays\",4],[\"EXT_blend_minmax\",2],[\"EXT_clip_control\",7],[\"EXT_color_buffer_half_float\",4],[\"EXT_depth_clamp\",1],[\"EXT_float_blend\",0],[\"EXT_frag_depth\",0],[\"EXT_polygon_offset_clamp\",2],[\"EXT_shader_texture_lod\",0],[\"EXT_sRGB\",4],[\"EXT_texture_compression_bptc\",4],[\"EXT_texture_compression_rgtc\",4],[\"EXT_texture_filter_anisotropic\",2],[\"EXT_texture_mirror_clamp_to_edge\",1],[\"OES_element_index_uint\",0],[\"OES_fbo_render_mipmap\",0],[\"OES_standard_derivatives\",1],[\"OES_texture_float\",0],[\"OES_texture_float_linear\",0],[\"OES_texture_half_float\",1],[\"OES_texture_half_float_linear\",0],[\"OES_vertex_array_object\",5],[\"WEBGL_color_buffer_float\",4],[\"WEBGL_compressed_texture_s3tc\",4],[\"WEBGL_compressed_texture_s3tc_srgb\",4],[\"WEBGL_debug_renderer_info\",2],[\"WEBGL_debug_shaders\",1],[\"WEBGL_depth_texture\",1],[\"WEBGL_draw_buffers\",35],[\"WEBGL_lose_context\",2],[\"WEBGL_provoking_vertex\",4]]"
|
||||
},
|
||||
"gl1.extensions": {
|
||||
"s": "[\"ANGLE_instanced_arrays\",\"EXT_blend_minmax\",\"EXT_clip_control\",\"EXT_color_buffer_half_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_frag_depth\",\"EXT_polygon_offset_clamp\",\"EXT_shader_texture_lod\",\"EXT_sRGB\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"OES_element_index_uint\",\"OES_fbo_render_mipmap\",\"OES_standard_derivatives\",\"OES_texture_float\",\"OES_texture_float_linear\",\"OES_texture_half_float\",\"OES_texture_half_float_linear\",\"OES_vertex_array_object\",\"WEBGL_color_buffer_float\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_depth_texture\",\"WEBGL_draw_buffers\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"]"
|
||||
},
|
||||
"gl1.lines_points.readPixels": {
|
||||
"h": "1841f80a258941",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.math.highp.readPixels": {
|
||||
"h": "85fe168c6de19",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.math.mediump.readPixels": {
|
||||
"h": "85fe168c6de19",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.params": {
|
||||
"s": "{\"VERSION\":\"WebGL 1.0\",\"SHADING_LANGUAGE_VERSION\":\"WebGL GLSL ES 1.0\",\"VENDOR\":\"Mozilla\",\"RENDERER\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"MAX_TEXTURE_SIZE\":16384,\"MAX_CUBE_MAP_TEXTURE_SIZE\":16384,\"MAX_RENDERBUFFER_SIZE\":16384,\"MAX_VIEWPORT_DIMS\":[32767,32767],\"ALIASED_LINE_WIDTH_RANGE\":[1,1],\"ALIASED_POINT_SIZE_RANGE\":[1,1024],\"MAX_VERTEX_ATTRIBS\":16,\"MAX_VARYING_VECTORS\":30,\"MAX_COMBINED_TEXTURE_IMAGE_UNITS\":32,\"MAX_VERTEX_TEXTURE_IMAGE_UNITS\":16,\"MAX_TEXTURE_IMAGE_UNITS\":16,\"MAX_VERTEX_UNIFORM_VECTORS\":4096,\"MAX_FRAGMENT_UNIFORM_VECTORS\":1024,\"RED_BITS\":8,\"GREEN_BITS\":8,\"BLUE_BITS\":8,\"ALPHA_BITS\":8,\"DEPTH_BITS\":24,\"STENCIL_BITS\":0,\"SAMPLES\":4,\"SAMPLE_BUFFERS\":1,\"SUBPIXEL_BITS\":4}"
|
||||
},
|
||||
"gl1.precision": {
|
||||
"s": "[[\"VERTEX_SHADER\",\"LOW_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"LOW_INT\",31,30,0],[\"VERTEX_SHADER\",\"MEDIUM_INT\",31,30,0],[\"VERTEX_SHADER\",\"HIGH_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"LOW_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"LOW_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"MEDIUM_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"HIGH_INT\",31,30,0]]"
|
||||
},
|
||||
"gl1.texture.linear.readPixels": {
|
||||
"h": "12a052fdb7d89f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.texture.mip.readPixels": {
|
||||
"h": "12a052fdb7d89f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.texture.nearest.readPixels": {
|
||||
"h": "160f810aa6835f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl1.triangle.drawImage": {
|
||||
"h": "1f2476721e653d",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.triangle.readPixels": {
|
||||
"h": "e35b6ac5b7d59",
|
||||
"n": 36864
|
||||
},
|
||||
"gl1.triangle.toDataURL_jpeg": {
|
||||
"s": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABgAGADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDxKiiivTPOCiiigAopDwOaro5MpfnB7e1enl+V1ceqjp/ZV/V9vnqJuyuWaKKK81pp2YwooopAFFFFABRRRQAUUUUAMlPy4HU0RR05U3NmrMUdfdZXbBYZR6vV/wBeR1VaHJTV9yMxHZkdqjrTijqre25hYMPuN+h9K8LOKMZT9vDrv/n/AJnl0qtpezl8itRRRXhHUFFFFABRRRQAUqjJxSVYt4+MnvW+GipVE3sjvy7CvE1kui1YsUdW4o6WKOrcUdevUx3mehjqe4kUdWTbrLEyOPlYYp8UdW4o64KuNvofG46DTujj7y3a1uGifnHIOOoqGu01LTRfW2wELIpyjEd/Q+1cYysjFXBVgcEEYINeepxk9DfB4pV42fxLf/MSiiimdgUUUUAOiQu4UfjWpFHjFQafD8pc9+BWnFHWM8Uqd0j7zJsv9hg1Vkvenr8un+fzEijq3FHSxR1bijriqY7zPPx1PcSKOrcUdLFHVuKOuCpjvM+Nx1PcSKOsHxdpDPF9ugUl0GJVUD7v978On0+ldTFHVuKOuVZk6U1JHys608LVVWHT8Txyit/xboR0m7WSBXNnL91jyEb+7n9Rn9cGsCvp6FeFeCqU3dM+qoV4YimqlN6MKdGhkdUXqTim1p6PAGLSnnHyipxNdYek6jPaybLpZljIYdbPf0W/9dy/DEFAAHAGBVuKOlijqYyQQsFmmjRsZwzAGvk54yU3Zas/VsfCFOOtkvuJIo6txR1SbUrCDbvuYzn+5838s0kniHT4du1pJc9didPzxWXLiqnwU2/kz4jH1qKuudfebMUdW4o65iTxbaogMFtM755DkKMfUZqGbxpNsAtrKNHzyZHLjH0GKn+zsfU2hb1a/wA7nyOLUZ/CzuIo6txR15rL4z1N4ika20THo6ISR+ZI/Sqc3ijWZomja+cKepRVQ/mACKa4fx1T4nFfN/oj53EZXUrbNI9XvtNh1KwltLkMYpRg7TgjnII+hArx3W9Mn0jUprS4VgVPyMRjeueGH1/+t2ok1fUpI2jk1C8eNgVZWnYgg9QRmqNe7lGWYjAOSnUTi+luve9/0Ncsy6rgpSvO8X0t17hUiTyooVJZFA7BiKjor25RUlaSue3TqzpO9OTT8tB0kjyHMjs5xjLHNNooppJKyJlJzfNJ3YUUUUCCiiigAooooAKKKKAP/9k="
|
||||
},
|
||||
"gl1.unmasked": {
|
||||
"s": "[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"]"
|
||||
},
|
||||
"gl2.anisotropy": {
|
||||
"s": "16"
|
||||
},
|
||||
"gl2.antialias.false.readPixels": {
|
||||
"h": "abed055e93fb8",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.antialias.false.samples": {
|
||||
"s": "0"
|
||||
},
|
||||
"gl2.antialias.true.readPixels": {
|
||||
"h": "155744fc8af4b9",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.antialias.true.samples": {
|
||||
"s": "4"
|
||||
},
|
||||
"gl2.attributes": {
|
||||
"s": "{\"alpha\":true,\"antialias\":true,\"depth\":true,\"failIfMajorPerformanceCaveat\":false,\"powerPreference\":\"default\",\"premultipliedAlpha\":true,\"preserveDrawingBuffer\":true,\"stencil\":false}"
|
||||
},
|
||||
"gl2.blend.readPixels": {
|
||||
"h": "1e61b0c76b34d",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.depth_stencil.readPixels": {
|
||||
"h": "eaa3d5d41cfb",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.extension_objects": {
|
||||
"s": "[[\"EXT_clip_control\",7],[\"EXT_color_buffer_float\",0],[\"EXT_depth_clamp\",1],[\"EXT_float_blend\",0],[\"EXT_polygon_offset_clamp\",2],[\"EXT_texture_compression_bptc\",4],[\"EXT_texture_compression_rgtc\",4],[\"EXT_texture_filter_anisotropic\",2],[\"EXT_texture_mirror_clamp_to_edge\",1],[\"EXT_texture_norm16\",8],[\"OES_draw_buffers_indexed\",7],[\"OES_texture_float_linear\",0],[\"OVR_multiview2\",5],[\"WEBGL_compressed_texture_s3tc\",4],[\"WEBGL_compressed_texture_s3tc_srgb\",4],[\"WEBGL_debug_renderer_info\",2],[\"WEBGL_debug_shaders\",1],[\"WEBGL_lose_context\",2],[\"WEBGL_provoking_vertex\",4]]"
|
||||
},
|
||||
"gl2.extensions": {
|
||||
"s": "[\"EXT_clip_control\",\"EXT_color_buffer_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_polygon_offset_clamp\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"EXT_texture_norm16\",\"OES_draw_buffers_indexed\",\"OES_texture_float_linear\",\"OVR_multiview2\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"]"
|
||||
},
|
||||
"gl2.float_target.readPixels": {
|
||||
"h": "4036e3357974d",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.lines_points.readPixels": {
|
||||
"h": "1841f80a258941",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.math.highp.readPixels": {
|
||||
"h": "85fe168c6de19",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.math.mediump.readPixels": {
|
||||
"h": "85fe168c6de19",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.msaa_resolve.readPixels": {
|
||||
"h": "1a2cbef856e591",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.params": {
|
||||
"s": "{\"VERSION\":\"WebGL 2.0\",\"SHADING_LANGUAGE_VERSION\":\"WebGL GLSL ES 3.00\",\"VENDOR\":\"Mozilla\",\"RENDERER\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"MAX_TEXTURE_SIZE\":16384,\"MAX_CUBE_MAP_TEXTURE_SIZE\":16384,\"MAX_RENDERBUFFER_SIZE\":16384,\"MAX_VIEWPORT_DIMS\":[32767,32767],\"ALIASED_LINE_WIDTH_RANGE\":[1,1],\"ALIASED_POINT_SIZE_RANGE\":[1,1024],\"MAX_VERTEX_ATTRIBS\":16,\"MAX_VARYING_VECTORS\":30,\"MAX_COMBINED_TEXTURE_IMAGE_UNITS\":32,\"MAX_VERTEX_TEXTURE_IMAGE_UNITS\":16,\"MAX_TEXTURE_IMAGE_UNITS\":16,\"MAX_VERTEX_UNIFORM_VECTORS\":4096,\"MAX_FRAGMENT_UNIFORM_VECTORS\":1024,\"RED_BITS\":8,\"GREEN_BITS\":8,\"BLUE_BITS\":8,\"ALPHA_BITS\":8,\"DEPTH_BITS\":24,\"STENCIL_BITS\":0,\"SAMPLES\":4,\"SAMPLE_BUFFERS\":1,\"SUBPIXEL_BITS\":4,\"MAX_3D_TEXTURE_SIZE\":2048,\"MAX_ARRAY_TEXTURE_LAYERS\":2048,\"MAX_COLOR_ATTACHMENTS\":8,\"MAX_DRAW_BUFFERS\":8,\"MAX_ELEMENTS_INDICES\":2147483647,\"MAX_ELEMENTS_VERTICES\":2147483647,\"MAX_FRAGMENT_INPUT_COMPONENTS\":120,\"MAX_FRAGMENT_UNIFORM_BLOCKS\":12,\"MAX_FRAGMENT_UNIFORM_COMPONENTS\":4096,\"MAX_PROGRAM_TEXEL_OFFSET\":7,\"MAX_SAMPLES\":8,\"MAX_SERVER_WAIT_TIMEOUT\":0,\"MAX_TEXTURE_LOD_BIAS\":2,\"MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\":120,\"MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\":4,\"MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\":4,\"MAX_UNIFORM_BLOCK_SIZE\":65536,\"MAX_UNIFORM_BUFFER_BINDINGS\":24,\"MAX_VARYING_COMPONENTS\":120,\"MAX_VERTEX_OUTPUT_COMPONENTS\":120,\"MAX_VERTEX_UNIFORM_BLOCKS\":12,\"MAX_VERTEX_UNIFORM_COMPONENTS\":16384,\"MIN_PROGRAM_TEXEL_OFFSET\":-8,\"MAX_COMBINED_UNIFORM_BLOCKS\":24,\"MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS\":200704,\"MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS\":212992,\"UNIFORM_BUFFER_OFFSET_ALIGNMENT\":256}"
|
||||
},
|
||||
"gl2.precision": {
|
||||
"s": "[[\"VERTEX_SHADER\",\"LOW_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"VERTEX_SHADER\",\"LOW_INT\",31,30,0],[\"VERTEX_SHADER\",\"MEDIUM_INT\",31,30,0],[\"VERTEX_SHADER\",\"HIGH_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"LOW_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"MEDIUM_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"HIGH_FLOAT\",127,127,23],[\"FRAGMENT_SHADER\",\"LOW_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"MEDIUM_INT\",31,30,0],[\"FRAGMENT_SHADER\",\"HIGH_INT\",31,30,0]]"
|
||||
},
|
||||
"gl2.texture.linear.readPixels": {
|
||||
"h": "12a052fdb7d89f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.texture.mip.readPixels": {
|
||||
"h": "12a052fdb7d89f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.texture.nearest.readPixels": {
|
||||
"h": "160f810aa6835f",
|
||||
"n": 16384
|
||||
},
|
||||
"gl2.triangle.drawImage": {
|
||||
"h": "1f2476721e653d",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.triangle.readPixels": {
|
||||
"h": "e35b6ac5b7d59",
|
||||
"n": 36864
|
||||
},
|
||||
"gl2.triangle.toDataURL_jpeg": {
|
||||
"s": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABgAGADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDxKiiivTPOCiiigAopDwOaro5MpfnB7e1enl+V1ceqjp/ZV/V9vnqJuyuWaKKK81pp2YwooopAFFFFABRRRQAUUUUAMlPy4HU0RR05U3NmrMUdfdZXbBYZR6vV/wBeR1VaHJTV9yMxHZkdqjrTijqre25hYMPuN+h9K8LOKMZT9vDrv/n/AJnl0qtpezl8itRRRXhHUFFFFABRRRQAUqjJxSVYt4+MnvW+GipVE3sjvy7CvE1kui1YsUdW4o6WKOrcUdevUx3mehjqe4kUdWTbrLEyOPlYYp8UdW4o64KuNvofG46DTujj7y3a1uGifnHIOOoqGu01LTRfW2wELIpyjEd/Q+1cYysjFXBVgcEEYINeepxk9DfB4pV42fxLf/MSiiimdgUUUUAOiQu4UfjWpFHjFQafD8pc9+BWnFHWM8Uqd0j7zJsv9hg1Vkvenr8un+fzEijq3FHSxR1bijriqY7zPPx1PcSKOrcUdLFHVuKOuCpjvM+Nx1PcSKOsHxdpDPF9ugUl0GJVUD7v978On0+ldTFHVuKOuVZk6U1JHys608LVVWHT8Txyit/xboR0m7WSBXNnL91jyEb+7n9Rn9cGsCvp6FeFeCqU3dM+qoV4YimqlN6MKdGhkdUXqTim1p6PAGLSnnHyipxNdYek6jPaybLpZljIYdbPf0W/9dy/DEFAAHAGBVuKOlijqYyQQsFmmjRsZwzAGvk54yU3Zas/VsfCFOOtkvuJIo6txR1SbUrCDbvuYzn+5838s0kniHT4du1pJc9didPzxWXLiqnwU2/kz4jH1qKuudfebMUdW4o65iTxbaogMFtM755DkKMfUZqGbxpNsAtrKNHzyZHLjH0GKn+zsfU2hb1a/wA7nyOLUZ/CzuIo6txR15rL4z1N4ika20THo6ISR+ZI/Sqc3ijWZomja+cKepRVQ/mACKa4fx1T4nFfN/oj53EZXUrbNI9XvtNh1KwltLkMYpRg7TgjnII+hArx3W9Mn0jUprS4VgVPyMRjeueGH1/+t2ok1fUpI2jk1C8eNgVZWnYgg9QRmqNe7lGWYjAOSnUTi+luve9/0Ncsy6rgpSvO8X0t17hUiTyooVJZFA7BiKjor25RUlaSue3TqzpO9OTT8tB0kjyHMjs5xjLHNNooppJKyJlJzfNJ3YUUUUCCiiigAooooAKKKKAP/9k="
|
||||
},
|
||||
"gl2.unmasked": {
|
||||
"s": "[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"]"
|
||||
},
|
||||
"gpu.webgpu.features": {
|
||||
"s": "{\"depth-clip-control\":true,\"depth32float-stencil8\":true,\"texture-compression-bc\":true,\"texture-compression-bc-sliced-3d\":true,\"texture-compression-etc2\":false,\"texture-compression-astc\":false,\"texture-compression-astc-sliced-3d\":false,\"timestamp-query\":true,\"indirect-first-instance\":true,\"shader-f16\":true,\"rg11b10ufloat-renderable\":true,\"bgra8unorm-storage\":true,\"float32-filterable\":true,\"float32-blendable\":true,\"clip-distances\":false,\"dual-source-blending\":true,\"subgroups\":false}"
|
||||
},
|
||||
"gpu.webgpu.info": {
|
||||
"s": "{\"vendor\":\"\",\"architecture\":\"\",\"device\":\"\",\"description\":\"\"}"
|
||||
},
|
||||
"gpu.webgpu.limits": {
|
||||
"s": "{\"maxTextureDimension1D\":16384,\"maxTextureDimension2D\":16384,\"maxTextureDimension3D\":2048,\"maxTextureArrayLayers\":2048,\"maxBindGroups\":8,\"maxBindGroupsPlusVertexBuffers\":24,\"maxBindingsPerBindGroup\":4294967295,\"maxDynamicUniformBuffersPerPipelineLayout\":8,\"maxDynamicStorageBuffersPerPipelineLayout\":4,\"maxSampledTexturesPerShaderStage\":64,\"maxSamplersPerShaderStage\":64,\"maxStorageBuffersPerShaderStage\":64,\"maxStorageTexturesPerShaderStage\":64,\"maxUniformBuffersPerShaderStage\":64,\"maxUniformBufferBindingSize\":65536,\"maxStorageBufferBindingSize\":2147483644,\"minUniformBufferOffsetAlignment\":256,\"minStorageBufferOffsetAlignment\":32,\"maxVertexBuffers\":16,\"maxBufferSize\":2147483644,\"maxVertexAttributes\":30,\"maxVertexBufferArrayStride\":2048,\"maxInterStageShaderVariables\":31,\"maxColorAttachments\":8,\"maxColorAttachmentBytesPerSample\":128,\"maxComputeWorkgroupStorageSize\":32768,\"maxComputeInvocationsPerWorkgroup\":1024,\"maxComputeWorkgroupSizeX\":1024,\"maxComputeWorkgroupSizeY\":1024,\"maxComputeWorkgroupSizeZ\":64,\"maxComputeWorkgroupsPerDimension\":65535}"
|
||||
},
|
||||
"worker.webgl": {
|
||||
"s": "{\"vendor\":\"Mozilla\",\"renderer\":\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\",\"unmasked\":[\"Google Inc. (Intel)\",\"ANGLE (Intel, Intel(R) HD Graphics Direct3D11 vs_5_0 ps_5_0), or similar\"],\"exts\":[\"ANGLE_instanced_arrays\",\"EXT_blend_minmax\",\"EXT_clip_control\",\"EXT_color_buffer_half_float\",\"EXT_depth_clamp\",\"EXT_float_blend\",\"EXT_frag_depth\",\"EXT_polygon_offset_clamp\",\"EXT_shader_texture_lod\",\"EXT_sRGB\",\"EXT_texture_compression_bptc\",\"EXT_texture_compression_rgtc\",\"EXT_texture_filter_anisotropic\",\"EXT_texture_mirror_clamp_to_edge\",\"OES_element_index_uint\",\"OES_fbo_render_mipmap\",\"OES_standard_derivatives\",\"OES_texture_float\",\"OES_texture_float_linear\",\"OES_texture_half_float\",\"OES_texture_half_float_linear\",\"OES_vertex_array_object\",\"WEBGL_color_buffer_float\",\"WEBGL_compressed_texture_s3tc\",\"WEBGL_compressed_texture_s3tc_srgb\",\"WEBGL_debug_renderer_info\",\"WEBGL_debug_shaders\",\"WEBGL_depth_texture\",\"WEBGL_draw_buffers\",\"WEBGL_lose_context\",\"WEBGL_provoking_vertex\"],\"px\":[64,128,191,255,64,128,191,255,64,128,191,255,64,128,191,255]}"
|
||||
}
|
||||
},
|
||||
"pngs": {
|
||||
"c2d.composite.png": {
|
||||
"n": 2414,
|
||||
"w": 256,
|
||||
"h": 128,
|
||||
"ct": 6,
|
||||
"sha256": "fb585f18240eb1a787a5b146d6332a0376dae76f8c8716e99f68fbbf9eff905e"
|
||||
},
|
||||
"c2d.composite.toBlob": {
|
||||
"n": 1794,
|
||||
"w": 256,
|
||||
"h": 128,
|
||||
"ct": 6,
|
||||
"sha256": "fb585f18240eb1a787a5b146d6332a0376dae76f8c8716e99f68fbbf9eff905e"
|
||||
},
|
||||
"c2d.gradtext.png": {
|
||||
"n": 55210,
|
||||
"w": 420,
|
||||
"h": 210,
|
||||
"ct": 6,
|
||||
"sha256": "1ce15c9ea557be69b62b4893b148345a694a93222c721b1bbb21cdcedebba5a0"
|
||||
},
|
||||
"c2d.image.png": {
|
||||
"n": 19502,
|
||||
"w": 160,
|
||||
"h": 120,
|
||||
"ct": 6,
|
||||
"sha256": "51bc3789f2e238dfbf8899eb7a965a4f04d3e0e7f2246b1bd3cfdc9597bd2a77"
|
||||
},
|
||||
"c2d.image.toBlob": {
|
||||
"n": 14610,
|
||||
"w": 160,
|
||||
"h": 120,
|
||||
"ct": 6,
|
||||
"sha256": "51bc3789f2e238dfbf8899eb7a965a4f04d3e0e7f2246b1bd3cfdc9597bd2a77"
|
||||
},
|
||||
"c2d.offscreen.convertToBlob": {
|
||||
"n": 2251,
|
||||
"w": 160,
|
||||
"h": 80,
|
||||
"ct": 6,
|
||||
"sha256": "55b4c78cd7b05627e9b2767477d61063b6849a7636c5be2ce0a62c6a2c6c9cc4"
|
||||
},
|
||||
"c2d.scale.high.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.low.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.medium.png": {
|
||||
"n": 47314,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "8672b8676f90d662b4809e56c55da58e05be4e72b2f7c543b33da4bdafb0ce21"
|
||||
},
|
||||
"c2d.scale.off.png": {
|
||||
"n": 20890,
|
||||
"w": 220,
|
||||
"h": 130,
|
||||
"ct": 6,
|
||||
"sha256": "c28700e28636d69dfe9bf293fadebae1fdf970949ac90147836ab1837065f46d"
|
||||
},
|
||||
"c2d.shapes.png": {
|
||||
"n": 19226,
|
||||
"w": 256,
|
||||
"h": 160,
|
||||
"ct": 6,
|
||||
"sha256": "89ee57c100f4682099bd3a5f2de56c5b31091dae253bd7e3db4f254fb8b9e6a3"
|
||||
},
|
||||
"c2d.shapes.toBlob": {
|
||||
"n": 14402,
|
||||
"w": 256,
|
||||
"h": 160,
|
||||
"ct": 6,
|
||||
"sha256": "89ee57c100f4682099bd3a5f2de56c5b31091dae253bd7e3db4f254fb8b9e6a3"
|
||||
},
|
||||
"c2d.text.png": {
|
||||
"n": 42670,
|
||||
"w": 520,
|
||||
"h": 412,
|
||||
"ct": 6,
|
||||
"sha256": "93d6fc37d2263e52e7b1b46f77c65d9e607faf577eb7c255dc38cbce8b7d7602"
|
||||
},
|
||||
"c2d.text.toBlob": {
|
||||
"n": 31986,
|
||||
"w": 520,
|
||||
"h": 412,
|
||||
"ct": 6,
|
||||
"sha256": "93d6fc37d2263e52e7b1b46f77c65d9e607faf577eb7c255dc38cbce8b7d7602"
|
||||
},
|
||||
"gl1.triangle.toDataURL": {
|
||||
"n": 7474,
|
||||
"w": 96,
|
||||
"h": 96,
|
||||
"ct": 6,
|
||||
"sha256": "9989d00c92e8ae035dede9b81b1c9942223799c0ccc4d4875c8eca9efaca776c"
|
||||
},
|
||||
"gl2.triangle.toDataURL": {
|
||||
"n": 7474,
|
||||
"w": 96,
|
||||
"h": 96,
|
||||
"ct": 6,
|
||||
"sha256": "9989d00c92e8ae035dede9b81b1c9942223799c0ccc4d4875c8eca9efaca776c"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"_why": "The four rules the Node driver's user.js writer follows, FROZEN. Until 2026-08-28 prefs_byte_parity.py read them out of src/invisible_playwright/_driver/package/lib/coreBundle.js on every run, deliberately, so that an upstream change moved the gate with it instead of leaving it comparing against a stale transcription. The bundle is being deleted with the Node driver, so the derived fact becomes a recorded one - and this file exists to make that visible rather than silent.",
|
||||
"_how_to_verify": "While a bundle is still reachable, prefs_byte_parity.py re-extracts and compares against these values, and FAILS on a mismatch. To reach one after the deletion: git worktree add <dir> <the last commit that carried _driver/>, then point the gate at it with INVPW_DRIVER_BUNDLE=<dir>/src/invisible_playwright/_driver/package/lib/coreBundle.js.",
|
||||
"_what_a_stale_copy_would_cost": "The gate would compare our writer against our own idea of the driver, which always agrees. That is the failure mode the run-time read existed to prevent, and it is why the provenance below is recorded to the byte instead of just being dated.",
|
||||
"rules": {
|
||||
"sorts": false,
|
||||
"header": false,
|
||||
"separator": true,
|
||||
"integer_bare": true
|
||||
},
|
||||
"provenance": {
|
||||
"frozen_on": "2026-08-28",
|
||||
"file": "src/invisible_playwright/_driver/package/lib/coreBundle.js",
|
||||
"bundle_bytes": 2780363,
|
||||
"bundle_sha256_16": "97d55ec7f856966d",
|
||||
"marker": "__ipwLit",
|
||||
"marker_offset": 1775227,
|
||||
"window_bytes": 1200,
|
||||
"window_sha256_16": "4891de086d6625f6"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
{
|
||||
"version": 1,
|
||||
"entries": [
|
||||
{"file": "_doh_servers.py", "scope": "<module>.DOH_PORT", "rule": "port", "nth": 1, "kind": "virtual-port", "reason": "A port number that nothing binds: the gateway of the test answers for the name or address by itself, so no worker can collide on it."},
|
||||
{"file": "_doh_servers.py", "scope": "DohGateway._handle", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "_doh_servers.py", "scope": "FakeDoh._serve_h1", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "_doh_servers.py", "scope": "relay", "rule": "timeout", "nth": 1, "kind": "instrument", "reason": "Teardown of the test's own server: join(timeout=N) returns as soon as the thread ends, and a thread that is late is a daemon the process leaves behind; no verdict reads whether it ended in time, so a slow machine can never make it red."},
|
||||
{"file": "_fission_frames.py", "scope": "spin_trial", "rule": "js-timer", "nth": 1, "kind": "instrument", "reason": "The 10 ms ticker of the observer frame is the measuring tool of the proof: what is judged is how many of its ticks ran inside the spin of the other frame, and the spins go on until one shows ticks (30 s), so a starved spin is a trial that proves nothing and never a red."},
|
||||
{"file": "_fission_frames.py", "scope": "spin_trial", "rule": "js-timer", "nth": 2, "kind": "stimulus", "reason": "The spin of the other frame starts 50 ms after the call that asks for it has returned, so that call does not block on its own spin; the test then waits for the frame to say the spin is over, with a deadline of 30 s, and no verdict reads when the timer fired."},
|
||||
{"file": "_h3_server.py", "scope": "H3Server.__init__.run", "rule": "sleep", "nth": 1, "kind": "instrument", "reason": "The pause lets the loop of the test's own HTTP/3 server end at its close; it is teardown of the instrument and no verdict is based on it."},
|
||||
{"file": "_leaks.py", "scope": "Watcher.stop", "rule": "timeout", "nth": 1, "kind": "instrument", "reason": "Teardown of the test's own server: join(timeout=N) returns as soon as the thread ends, and a thread that is late is a daemon the process leaves behind; no verdict reads whether it ended in time, so a slow machine can never make it red."},
|
||||
{"file": "_page_work.py", "scope": "<module>.CASES", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "_page_work.py", "scope": "<module>.CASES", "rule": "js-timer", "nth": 2, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "_realness_support.py", "scope": "<module>.PAGE_JS", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "_socks_servers.py", "scope": "<module>.STUN_PORT", "rule": "port", "nth": 1, "kind": "virtual-port", "reason": "A port number that nothing binds: the gateway of the test answers for the name or address by itself, so no worker can collide on it."},
|
||||
{"file": "_socks_servers.py", "scope": "FakeStun.close", "rule": "timeout", "nth": 1, "kind": "instrument", "reason": "Teardown of the test's own server: join(timeout=N) returns as soon as the thread ends, and a thread that is late is a daemon the process leaves behind; no verdict reads whether it ended in time, so a slow machine can never make it red."},
|
||||
{"file": "_socks_servers.py", "scope": "Gateway._connect", "rule": "timeout", "nth": 1, "kind": "instrument", "reason": "Teardown of the test's own server: join(timeout=N) returns as soon as the thread ends, and a thread that is late is a daemon the process leaves behind; no verdict reads whether it ended in time, so a slow machine can never make it red."},
|
||||
{"file": "_socks_servers.py", "scope": "Gateway._send", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "The round trip of a gateway that is far away (rtt_ms) is the input of the tests that use it: they judge what the gateway recorded (which association carried a datagram, in which order, how many rounds the road cost), never how long a step took, and every wait that leads up to a verdict has a deadline of 30 s."},
|
||||
{"file": "_turn_chain.py", "scope": "<module>.PAGE_HTML", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The 2 s tick is the model of a leak test's page and decides nothing: a srflx that comes after it is still read and posted, the status of the page is final (DONE or REFUSED) in the same step that says `posted`, and the verdict is read from the stamps of the gateway, the DoH and the TURN server, never from when the tick fired."},
|
||||
{"file": "_turn_chain.py", "scope": "<module>.TURN_PORT", "rule": "port", "nth": 1, "kind": "virtual-port", "reason": "A port number that nothing binds: the gateway of the test answers for the name or address by itself, so no worker can collide on it."},
|
||||
{"file": "test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "scope": "<module>.READ", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a read of the position that never answers: the answer is a position or an error as soon as the engine gives one, and no verdict reads when the timer fired."},
|
||||
{"file": "test_a_page_cannot_probe_the_juggler_e2e.py", "scope": "<module>._CHANNELS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The 30 s of each channel are the deadline of its wait (`no answer` is a channel that stays silent). Every channel of a URL is asked at once and a name that is nowhere answers all of them, so on a healthy run no silence is waited for, and a stall of the machine cannot make one URL answer and the other not."},
|
||||
{"file": "test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "scope": "<module>._GATHER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s is the deadline of the wait for the end of the ICE gathering: the wait ends when the page says `complete`, a gathering that never completes returns what it has and fails the assertions on the candidates, and no verdict reads when the timer fired."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "_replace_after_load", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer moves the page 0, 50 or 300 ms after the load, and the reads made while it moves accept both states (the page before the move or the page it moved to) and never an engine error; nothing reads when the timer fired, and the waits that lead up to the reads have a deadline of 30 s."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "test_reads_wait_as_playwright_s_do", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer adds the element 500 ms after the call; the read waits for it with a deadline of 30 s, and the verdict is the text read, never when the timer fired."},
|
||||
{"file": "test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "scope": "test_a_destination_that_commits_nothing_gives_no_popup_event.body", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_a_popup_of_a_link_reaches_the_client_e2e.py", "scope": "_router.route", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py", "scope": "<module>._PROBE_JS", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "scope": "<module>.TURN_PORT", "rule": "port", "nth": 1, "kind": "virtual-port", "reason": "A port number that nothing binds: the gateway of the test answers for the name or address by itself, so no worker can collide on it."},
|
||||
{"file": "test_caller_world_handles_e2e.py", "scope": "test_a_node_that_appears_later_ends_the_wait", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_caller_world_handles_e2e.py", "scope": "test_a_wait_for_function_object_handle_reads_in_the_page_world", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_declared_host_network_e2e.py", "scope": "<module>._GATHER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s is the deadline of the wait for the end of the ICE gathering: the wait ends when the page says `complete`, a gathering that never completes returns what it has and fails the assertions on the candidates, and no verdict reads when the timer fired."},
|
||||
{"file": "test_declared_host_network_e2e.py", "scope": "<module>._LOOPBACK_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The 5 ms step of the page's own wait for the data channel to open and echo, which ends at 30 s; the same loop keeps the longest time it did not run, so the time the connection took is judged only when the page itself was not stopped by the machine (`_e2e_verdicts.opened_at_the_retry_problem`)."},
|
||||
{"file": "test_detectors_e2e.py", "scope": "test_enumerate_devices_resolves_promptly", "rule": "bound", "nth": 1, "kind": "hang-detector", "reason": "The limit is the larger of 30 s and 2000 times a load reference (microtasks) measured in the same page just before, and never reaches the 120 s at which the call is held to be hung, so it ends a call that never comes and is relative to the machine's own load."},
|
||||
{"file": "test_detectors_e2e.py", "scope": "test_enumerate_devices_resolves_promptly", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_doh_through_the_proxy_e2e.py", "scope": "test_no_helper_process_starts", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_doh_through_the_proxy_e2e.py", "scope": "test_no_helper_process_starts", "rule": "sleep", "nth": 2, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_fingerprint_consistency.py", "scope": "_worker_navigator_dict", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a worker that never answers: the answer is the worker's message as soon as it runs, and no verdict reads when the timer fired."},
|
||||
{"file": "test_fission_frames_dialogs_downloads_popups_e2e.py", "scope": "test_a_dialog_of_a_frame_reaches_the_page_and_the_answer_goes_back", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_fission_frames_dialogs_downloads_popups_e2e.py", "scope": "test_two_dialogs_one_after_the_other_from_different_frames", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_fission_frames_dialogs_downloads_popups_e2e.py", "scope": "test_two_dialogs_one_after_the_other_from_different_frames", "rule": "js-timer", "nth": 2, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_fission_frames_history_and_processes_e2e.py", "scope": "traverse", "rule": "timeout", "nth": 1, "kind": "negative-window", "reason": "The call is EXPECTED to give up with a TimeoutError when the entry belongs to a frame (no navigation of the main frame follows, as in stock Firefox), so 3 s is the window in which that navigation must NOT come; a slow machine can only make it a weaker check, and the tests judge where the page and its frame are after."},
|
||||
{"file": "test_fission_frames_route_and_bindings_e2e.py", "scope": "test_networkidle_waits_for_the_late_requests_of_a_frame_of_another_site", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_fission_frames_tree_input_and_pixels_e2e.py", "scope": "<module>.LATE", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The three timers of the test's own page add, hide and show elements 300 ms, 700 ms and 1 s after the load; every wait that reads them has a deadline of 30 s and takes the element whether it was there already or not, so no verdict reads when a timer fired."},
|
||||
{"file": "test_fission_frames_tree_input_and_pixels_e2e.py", "scope": "<module>.LATE", "rule": "js-timer", "nth": 2, "kind": "stimulus", "reason": "The three timers of the test's own page add, hide and show elements 300 ms, 700 ms and 1 s after the load; every wait that reads them has a deadline of 30 s and takes the element whether it was there already or not, so no verdict reads when a timer fired."},
|
||||
{"file": "test_fission_frames_tree_input_and_pixels_e2e.py", "scope": "<module>.LATE", "rule": "js-timer", "nth": 3, "kind": "stimulus", "reason": "The three timers of the test's own page add, hide and show elements 300 ms, 700 ms and 1 s after the load; every wait that reads them has a deadline of 30 s and takes the element whether it was there already or not, so no verdict reads when a timer fired."},
|
||||
{"file": "test_fission_frames_workers_storage_and_special_frames_e2e.py", "scope": "<module>.SERVICE_WORKER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a service worker that never registers or answers; the outcome is read as soon as the worker says it, and no verdict reads when the timer fired."},
|
||||
{"file": "test_fission_frames_workers_storage_and_special_frames_e2e.py", "scope": "<module>.SHARED_WORKER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a shared worker that never answers; the outcome is read as soon as the worker says it, and no verdict reads when the timer fired."},
|
||||
{"file": "test_fission_frames_workers_storage_and_special_frames_e2e.py", "scope": "<module>.WORKER_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a dedicated worker that never answers; the identity is read as soon as the worker posts it, and no verdict reads when the timer fired."},
|
||||
{"file": "test_fission_identity_parity_e2e.py", "scope": "<module>.SPIN_PROBE_JS", "rule": "js-timer", "nth": 1, "kind": "instrument", "reason": "The 10 ms ticker of the top document is the measuring tool of the proof: strategy 1 needs ticks inside the spin of the iframe and the spins go on until one shows them (30 s); strategy 0 asserts there is none in any spin, which no machine can fake because one thread cannot tick while it spins."},
|
||||
{"file": "test_fission_identity_parity_e2e.py", "scope": "<module>.SPIN_PROBE_JS", "rule": "js-timer", "nth": 2, "kind": "hang-detector", "reason": "The timer of 30 s ends a spin the iframe never reports (an empty trial that proves nothing, and the spins go on until one shows ticks or 30 s have passed); the spin ends the trial as soon as the iframe says so, with no further timer."},
|
||||
{"file": "test_goto_and_every_way_it_is_stopped_e2e.py", "scope": "_hold", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "The server keeps the answer of the goto that must LAND for 1.5 s on purpose, so the goto is in flight while the old page acts; the verdict reads only a lower bound on how long the goto waited (a slow machine cannot make that red) and where the page ended."},
|
||||
{"file": "test_goto_and_every_way_it_is_stopped_e2e.py", "scope": "_when_the_goto_arrives", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The 50 ms poll only asks the server whether the request of the goto has arrived. For the cases that must be stopped the server keeps the goto's page until the test has seen the goto return, so a late poll lengthens the wait and cannot let the goto land (it ends at its timeout of 30 s); for the cases that must land, what the poll does changes where the goto ends and the assertions accept both."},
|
||||
{"file": "test_http3_through_the_proxy_e2e.py", "scope": "_visits", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "The pause spaces the visits of a page the way the retail method does (visit, pause, visit); it is the minimum between two events the test generates, the UDP-free roads wait for the browser's own QUIC connection as a condition (30 s) before it, and the protocols the visits read do not depend on a longer pause."},
|
||||
{"file": "test_injected_node_surface.py", "scope": "<module>.PAGE", "rule": "js-timer", "nth": 1, "kind": "instrument", "reason": "The watcher of the page (an interval of 50 ms) is the measuring tool: it counts its own looks in window.__looks, and each test waits for the count to move past the call it checks, so no verdict is read before the watcher has looked at the page as the call left it."},
|
||||
{"file": "test_input_is_born_before_the_page_sees_it_e2e.py", "scope": "test_every_key_and_move_is_born_before_its_handler_runs", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "The pause between two events the test generates is part of the stimulus; the assertion reads the events after every call has returned, not the time between them."},
|
||||
{"file": "test_juggler_injected.py", "scope": "test_OUR_CLIENT_DOES_NOT_CROSS_into_the_page_realm.read", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_the_public_API_WAITS_for_an_element_that_arrives_late", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The timer is started by the test AFTER it has seen the element absent, and the wait for the element has a deadline of 30 s: nothing arrives before the check, and the verdict is the element's text, never when the timer fired."},
|
||||
{"file": "test_navigation_across_processes_e2e.py", "scope": "test_a_goto_to_another_site_stopped_by_the_page_it_leaves_raises_aborted.scenario", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The 50 ms poll only asks the server whether the request of the goto has arrived, and the server holds that request until the test has seen the goto return, so a late poll lengthens the wait and cannot let the goto land; the goto ends at its timeout of 30 s and the verdict is the error it raised and where the page is."},
|
||||
{"file": "test_navigation_across_processes_e2e.py", "scope": "test_an_iframe_removed_while_it_loads_is_aborted_then_gone.scenario", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page removes the iframe 1 s after inserting it while the server holds the frame's document for 3 s; the test waits (30 s) for the frame to have been attached and detached and for the page to be the only frame, which is the same end whether the removal came before or after the document loaded, so no verdict reads when the timer fired."},
|
||||
{"file": "test_networkidle_through_a_served_browser_with_routes_e2e.py", "scope": "_router.route", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_networkidle_through_a_served_browser_with_routes_e2e.py", "scope": "test_a_plain_route_handler_is_not_poisoned_by_a_request_the_page_cancelled.plain", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_networkidle_through_a_served_browser_with_routes_e2e.py", "scope": "test_networkidle_arrives_when_the_client_answers_all_requests_concurrently_and_slowly.run.route", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_nothing_leaves_but_the_proxy_e2e.py", "scope": "test_a_kind_of_page_work_leaves_only_through_the_proxy_of_its_context", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_nothing_leaves_but_the_proxy_e2e.py", "scope": "test_a_kind_of_page_work_leaves_only_through_the_proxy_of_its_context", "rule": "sleep", "nth": 2, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "scope": "<module>._WINDOW_ICE_JS", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_popup_pages.py", "scope": "test_a_popup_the_site_closes_is_closed", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "The window of 300 ms is left only for a SECOND close event, after the test has waited (30 s) for the popup to be closed; a slow machine only makes the window weaker, never red."},
|
||||
{"file": "test_popup_pages.py", "scope": "test_popup_document_reaches_the_context", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "The window of 500 ms is left only for a DUPLICATE of the document's request or response, after the test has waited (30 s) for the first of each to be heard; a slow machine only makes the window weaker, never red."},
|
||||
{"file": "test_popup_pages.py", "scope": "test_window_open_with_a_size_keeps_that_size", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "The pause of 1 s is the window in which a LATE resize of the popup (the defect) would show: the size read before it and after it must be the same, and both are read after the popup's load was waited for with a deadline of 30 s; a slow machine only makes the window weaker in effect, it cannot change either size."},
|
||||
{"file": "test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "scope": "_remote_types", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "The window of 10 s (only in the case that asks for the preload off) in which a privileged-about process that must NOT be born would show, left after the log of the engine already holds lines (a condition waited for with a deadline of 30 s); a slow machine only makes the window weaker, never red."},
|
||||
{"file": "test_requestless_navigation.py", "scope": "test_navigation_wait", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer starts the navigation 100 ms after the call, and wait_for_url waits for the destination with a deadline of 30 s; the verdict is where the page is, never when the timer fired."},
|
||||
{"file": "test_screencast_stop_e2e.py", "scope": "test_every_screencast_stop_returns_and_the_browser_still_answers", "rule": "bound", "nth": 1, "kind": "hang-detector", "reason": "The 30 s budget of one start or stop of a screencast only ends the wait on a browser that is wedged (a call that answers takes well under a tenth of a second, measured over hundreds); it judges a hang, never a speed."},
|
||||
{"file": "test_screencast_stop_e2e.py", "scope": "test_every_screencast_stop_returns_and_the_browser_still_answers.drive", "rule": "sleep", "nth": 1, "kind": "stimulus", "reason": "Slowness on purpose: this test server, relay or client answers late as the input of the test, and the product waits for it under a deadline; nothing here judges the machine."},
|
||||
{"file": "test_screenshot_of_text_returns_linux_e2e.py", "scope": "test_a_screenshot_of_a_page_with_text_returns", "rule": "bound", "nth": 1, "kind": "hang-detector", "reason": "The limit is the timeout of the screenshot call itself (the same constant, 30 s), so the assertion only ends a call that hangs and judges no speed."},
|
||||
{"file": "test_software_compositing_is_declared_e2e.py", "scope": "<module>.SCENE", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s is the limit of the scene's wait for the end of the ICE gathering of a PeerConnection with no servers; the scene resolves as soon as the gathering completes, and the test asserts the states reached (`complete` in every round), which no clock decides."},
|
||||
{"file": "test_software_compositing_is_declared_e2e.py", "scope": "test_the_gpu_process_is_idle_on_a_fixed_scene", "rule": "bound", "nth": 1, "kind": "cpu-budget", "reason": "The bound is on the CPU seconds of the GPU process (user + kernel, over ten scenes), not on elapsed time: 1.5 s is 4.7 times what the declared engine used on the Windows runner (0.32 s, run 43652292533) and 0.55 times the least the undeclared one used (2.7 s), so a runner that stops or is slow stretches the clock and not the CPU."},
|
||||
{"file": "test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "scope": "<module>._PC_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The 5 ms step of the page's wait for the server-reflexive candidate, which ends at 30 s; the verdict compares which association carried the first datagram with the moment the PeerConnection was born (an order of events the gateway recorded), not how long the candidate took."},
|
||||
{"file": "test_the_callers_code_runs_once_e2e.py", "scope": "test_a_read_declared_free_of_effects_answers_from_the_page_that_replaced_it", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_the_callers_code_runs_once_e2e.py", "scope": "test_eval_on_selector_all_interrupted_by_its_navigation_runs_once", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_the_callers_code_runs_once_e2e.py", "scope": "test_evaluate_interrupted_by_its_navigation_runs_once", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_the_callers_code_runs_once_e2e.py", "scope": "test_wait_for_function_goes_on_through_a_navigation", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "The page's own timer navigates 300 ms after the call, and wait_for_function waits for the new document with a deadline of 30 s; the verdict is the title of the page, never when the timer fired."},
|
||||
{"file": "test_the_favicon_stays_out_of_sight_e2e.py", "scope": "test_the_favicon_goes_to_the_site_and_nothing_of_it_to_the_client", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "The window of 500 ms is left only for an event about the favicon that must NOT reach the client, after the test has waited (30 s) for the site to have written the answer; a slow machine only makes the window weaker, never red."},
|
||||
{"file": "test_the_hosts_file_of_the_host_is_never_read_e2e.py", "scope": "test_the_hosts_file_of_the_host_is_never_read", "rule": "sleep", "nth": 1, "kind": "negative-window", "reason": "A fixed observation window for something that must NOT happen: a slow machine can only make this check weaker (a false green), it cannot make it red."},
|
||||
{"file": "test_the_socket_process_is_sandboxed_e2e.py", "scope": "test_the_socket_process_and_a_tab_process_have_a_seccomp_filter", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."},
|
||||
{"file": "test_turn_over_tcp_is_tried_for_real_e2e.py", "scope": "<module>._JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer is the deadline of the wait for the end of the gathering (30 s, DEADLINE_MS), which ends after the TURN error; the verdict is the order of the events the page records, never when the timer fired."},
|
||||
{"file": "test_voices_e2e.py", "scope": "<module>.READ", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s only ends a read of the voices that is never told the list changed (`voiceschanged`); the list is read as soon as the engine has it, and no verdict reads when the timer fired."},
|
||||
{"file": "test_wait_for_timeout.py", "scope": "test_the_wait_takes_the_time_it_was_asked_for", "rule": "sleep", "nth": 1, "kind": "instrument", "reason": "This is the test of wait_for_timeout itself: the pause is the behaviour under test and the assertion is made on the pause it asked for."},
|
||||
{"file": "test_webrtc_realness.py", "scope": "<module>._PROBE_JS", "rule": "js-timer", "nth": 1, "kind": "hang-detector", "reason": "The timer of 30 s is the deadline of the wait for the end of the gathering (what the page reads is the whole of it); the wait ends when the page says `complete`, and no verdict depends on when the timer fired."},
|
||||
{"file": "test_webrtc_realness.py", "scope": "<module>._RELAY_PROBE_JS", "rule": "js-timer", "nth": 1, "kind": "stimulus", "reason": "A timer of the test's own page is the stimulus (the thing appears later); the product waits for it with a deadline and the verdict does not read when it fired."}
|
||||
],
|
||||
"debt": [
|
||||
{"file": "_doh_servers.py", "scope": "DohGateway._connect", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_http_proxy.py", "scope": "HttpProxy._connect", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_http_proxy.py", "scope": "HttpProxy._forward", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_ports.py", "scope": "who_holds", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_realness_support.py", "scope": "ExitGateway._connect", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_socks_servers.py", "scope": "Gateway._open_upstream", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_socks_servers.py", "scope": "Socks5TcpOnly._handle", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "_udp_line.py", "scope": "judge_visits", "rule": "bound", "nth": 1, "class": "B", "reason": "An absolute upper bound on a duration is a verdict on the machine: compare with a control measured in the same run, or assert the order of the events."},
|
||||
{"file": "test_a_left_documents_body_is_evicted_e2e.py", "scope": "test_nothing_else_is_lost_when_the_bodies_go", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_left_documents_body_is_evicted_e2e.py", "scope": "test_nothing_else_is_lost_when_the_bodies_go", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_left_documents_body_is_evicted_e2e.py", "scope": "test_nothing_else_is_lost_when_the_bodies_go", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_left_documents_body_is_evicted_e2e.py", "scope": "test_the_body_of_a_document_the_tab_left_is_evicted", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_left_documents_body_is_evicted_e2e.py", "scope": "test_the_body_of_a_document_the_tab_left_is_evicted", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "test_expect_reads_the_state_it_names", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "test_expect_reads_the_state_it_names", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_page_that_moves_on_e2e.py", "scope": "test_expect_reads_the_state_it_names", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "scope": "test_a_listener_registered_in_the_page_handler_hears_the_load_of_the_popup.body", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "scope": "test_a_listener_registered_in_the_page_handler_hears_the_load_of_the_popup.body.on_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "scope": "test_a_slow_popup_is_reported_with_the_address_of_its_destination.body", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_popup_of_a_link_reaches_the_client_e2e.py", "scope": "_check", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_request_says_what_it_is_e2e.py", "scope": "test_each_kind_of_request_is_named_by_the_engine", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_request_says_what_it_is_e2e.py", "scope": "test_each_kind_of_request_is_named_by_the_engine", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "scope": "test_ten_tiny_downloads_of_each_size_are_saved_through_a_served_browser", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "scope": "_assert_a_new_page_with_a_new_worker", "rule": "sleep", "nth": 1, "class": "A", "reason": "A fixed pause and then a read judges the speed of the machine: wait for the condition with a deadline (tests/_waits.py wait_until) and read after it."},
|
||||
{"file": "test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "scope": "test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same", "rule": "sleep", "nth": 1, "class": "A", "reason": "A fixed pause and then a read judges the speed of the machine: wait for the condition with a deadline (tests/_waits.py wait_until) and read after it."},
|
||||
{"file": "test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "scope": "test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_accept_language_on_the_wire_e2e.py", "scope": "test_every_request_of_a_session_carries_the_retail_accept_language", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_actions_without_a_point.py", "scope": "test_hidden_elements_take_the_actions_playwright_allows", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_actions_without_a_point.py", "scope": "test_hidden_elements_take_the_actions_playwright_allows", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_actions_without_a_point.py", "scope": "test_hidden_elements_take_the_actions_playwright_allows", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_add_script_tag.py", "scope": "page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_an_isolated_page_and_the_next_e2e.py", "scope": "test_reads_after_the_isolated_page_answer", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_an_isolated_page_and_the_next_e2e.py", "scope": "test_reads_after_the_isolated_page_answer", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_an_isolated_page_and_the_next_e2e.py", "scope": "test_reads_after_the_isolated_page_answer", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_an_isolated_page_and_the_next_e2e.py", "scope": "test_reads_after_the_isolated_page_answer", "rule": "timeout", "nth": 4, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_caller_world_handles_e2e.py", "scope": "page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_context_locale_e2e.py", "scope": "test_a_context_locale_reaches_navigator_intl_and_the_header", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_context_locale_e2e.py", "scope": "test_a_context_locale_reaches_navigator_intl_and_the_header", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_context_locale_e2e.py", "scope": "test_a_context_locale_reaches_navigator_intl_and_the_header", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_context_locale_e2e.py", "scope": "test_a_context_locale_reaches_navigator_intl_and_the_header", "rule": "timeout", "nth": 4, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_context_locale_e2e.py", "scope": "test_a_context_locale_reaches_navigator_intl_and_the_header", "rule": "timeout", "nth": 5, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_content_frame_resolves", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_dispatch_event_click_works", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_evaluate_returns_real_values", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_frame_locator_resolves_button", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_frame_locator_resolves_button", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_cross_origin_iframe_url_appears_in_page_frames", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_the_geometry_invariant_holds_inside_a_nested_frame", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_cross_origin_iframe.py", "scope": "test_the_iframe_runs_in_another_process", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_download_is_intercepted_e2e.py", "scope": "test_a_clicked_download_is_reported_and_saved", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_download_is_intercepted_e2e.py", "scope": "test_a_navigation_that_ends_in_a_download_is_reported", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_file_chooser.py", "scope": "test_a_hidden_input_takes_files_by_selector", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_file_chooser.py", "scope": "test_a_hidden_input_takes_files_through_its_chooser", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_file_chooser.py", "scope": "test_a_hidden_input_takes_files_through_its_chooser", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_file_chooser.py", "scope": "test_expect_file_chooser_receives_the_event", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_file_chooser.py", "scope": "test_the_chosen_files_arrive_at_the_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_fission_iframe_crash_e2e.py", "scope": "test_the_crash_of_an_iframe_s_process_leaves_the_tab", "rule": "count", "nth": 1, "class": "E", "reason": "The number of processes is not something the product promises: count by site name or against the pool the product keeps (tests/_processes.py, tests/_waits.py)."},
|
||||
{"file": "test_fission_strategy1_bench.py", "scope": "page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_fission_strategy1_bench.py", "scope": "page", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_fontconfig_reads_nothing_of_the_host_linux_e2e.py", "scope": "test_a_killed_stand_in_leaves_neither_strace_nor_the_browser", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_networkidle_after_spa_e2e.py", "scope": "test_networkidle_goto_leaves_a_quiet_spa_and_answers_for_the_new_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_networkidle_after_spa_e2e.py", "scope": "test_networkidle_goto_leaves_a_quiet_spa_and_answers_for_the_new_page", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_script_redirect_e2e.py", "scope": "test_goto_returns_on_the_page_that_replaced_itself_from_script", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_script_redirect_e2e.py", "scope": "test_goto_returns_on_the_page_that_replaced_itself_from_script", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_to_the_same_url_e2e.py", "scope": "test_a_goto_to_the_address_the_page_is_at_ends_every_time.scenario", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_to_the_same_url_e2e.py", "scope": "test_a_goto_to_the_address_the_page_is_at_ends_every_time.scenario", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_to_the_same_url_e2e.py", "scope": "test_a_goto_to_the_same_address_with_a_query_ends_the_second_time_too.scenario", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_goto_to_the_same_url_e2e.py", "scope": "test_a_goto_to_the_same_address_with_a_query_ends_the_second_time_too.scenario", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_http3_through_the_proxy_e2e.py", "scope": "test_a_page_behind_an_http_proxy_reads_h2_on_every_visit_and_loads_without_delay.ProxyToTheServer._connect", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ignore_https_errors_e2e.py", "scope": "test_ignore_https_errors_loads_a_self_signed_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_actions.py", "scope": "test_the_lifecycle_WAITS_for_an_element_that_appears_later", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_going_BACK_then_FORWARD_leaves_the_page_readable", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_going_BACK_then_FORWARD_leaves_the_page_readable", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_going_BACK_then_FORWARD_leaves_the_page_readable", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_going_back_over_a_page_the_script_left_without_a_gesture", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_juggler_transport.py", "scope": "test_going_back_over_a_page_the_script_left_without_a_gesture", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_mouse.py", "scope": "test_hover_triggers_mouseenter", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_navigation_response.py", "scope": "test_navigation_answers_with_a_real_response", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_nested_frame_actions.py", "scope": "_timed", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_nested_frame_actions.py", "scope": "_timed", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 4, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 5, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_networkidle_reaches_the_client_e2e.py", "scope": "test_the_client_side_networkidle_waits_resolve", "rule": "timeout", "nth": 6, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "scope": "test_the_native_sink_hears_a_native_lookup", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_oop_frame_element.py", "scope": "oop_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_oop_frame_element.py", "scope": "oop_page", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_oop_frame_geometry.py", "scope": "open_page.open_", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_oop_frame_geometry.py", "scope": "open_page.open_", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_page_number_follows_the_call.py", "scope": "_Page.wait_until_ready", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_page_number_follows_the_call.py", "scope": "_new_page_in_thread", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_popup_destinations_e2e.py", "scope": "test_a_popup_to_a_slow_page_is_announced_when_it_answers", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_popups_reach_the_client_e2e.py", "scope": "_the_process_case_in", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_popups_reach_the_client_e2e.py", "scope": "_the_process_case_in", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_popups_reach_the_client_e2e.py", "scope": "test_a_popup_reaches_the_client", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_popups_reach_the_client_e2e.py", "scope": "test_a_popup_reaches_the_client", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_proxy_socks_auth_e2e.py", "scope": "_Socks5AuthRecorder._handle", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_resolver_race_e2e.py", "scope": "_beside_a_proxied_context", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_resolver_race_e2e.py", "scope": "_beside_a_proxied_context", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_resolver_race_e2e.py", "scope": "_beside_a_proxied_context", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_resolver_race_e2e.py", "scope": "_navigate_at_once", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_e2e.py", "scope": "test_a_route_guard_sees_and_stops_every_post", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_e2e.py", "scope": "test_a_route_guard_sees_and_stops_every_post", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_post_data_e2e.py", "scope": "test_a_routed_post_carries_its_body", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_post_data_e2e.py", "scope": "test_a_routed_post_carries_its_body", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_post_data_e2e.py", "scope": "test_without_a_route_the_request_still_carries_its_body", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_post_data_e2e.py", "scope": "test_without_a_route_the_request_still_carries_its_body", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_superseded_e2e.py", "scope": "test_answering_a_route_the_next_navigation_aborted_does_not_raise", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_superseded_e2e.py", "scope": "test_answering_a_route_the_next_navigation_aborted_does_not_raise", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_route_superseded_e2e.py", "scope": "test_sequential_routed_gotos_neither_hang_nor_raise", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_same_document_goto_e2e.py", "scope": "test_goto_to_a_fragment_answers_with_the_new_url", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_same_document_goto_e2e.py", "scope": "test_goto_to_a_fragment_answers_with_the_new_url", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_same_document_navigation.py", "scope": "test_pushState_updates_page_url_and_wakes_wait_for_url", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_same_document_navigation.py", "scope": "test_pushState_updates_page_url_and_wakes_wait_for_url", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_scroll_into_view.py", "scope": "test_it_scrolls_ONLY_IF_NEEDED_and_then_centres", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_scroll_into_view.py", "scope": "test_it_scrolls_ONLY_IF_NEEDED_and_then_centres", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_scroll_into_view.py", "scope": "test_scroll_into_view_puts_the_element_in_the_viewport", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_fetch_through_sw_returns_sw_synthesized_response", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_fetch_through_sw_returns_sw_synthesized_response", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_page_with_sw_can_navigate_repeatedly", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_page_with_sw_can_navigate_repeatedly", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_page_with_sw_can_navigate_repeatedly", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_service_worker_registration_does_not_crash_page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_service_worker_registration_does_not_crash_page", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_sw_fall_through_to_network_does_not_crash", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_sw_fall_through_to_network_does_not_crash", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_sw_unregister_then_register_again", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker.py", "scope": "test_sw_unregister_then_register_again", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker_controller_e2e.py", "scope": "test_a_reloaded_page_is_controlled_by_its_service_worker", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker_controller_e2e.py", "scope": "test_a_reloaded_page_is_controlled_by_its_service_worker", "rule": "timeout", "nth": 2, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_worker_controller_e2e.py", "scope": "test_a_reloaded_page_is_controlled_by_its_service_worker", "rule": "timeout", "nth": 3, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_service_workers_blocked.py", "scope": "_install", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_set_input_files_payloads.py", "scope": "test_a_payload_reaches_the_page_as_a_file", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_set_offline_e2e.py", "scope": "test_set_offline_stops_loads_and_set_online_resumes_them", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_shadow_trusted_input.py", "scope": "page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_strict_and_force.py", "scope": "test_force_turns_a_refusal_into_an_attempt", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_the_callers_code_is_not_counted_e2e.py", "scope": "page", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ua_widget_not_selectable.py", "scope": "test_a_comma_selector_returns_only_author_elements", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ua_widget_not_selectable.py", "scope": "test_a_simple_selector_returns_only_author_elements", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ua_widget_not_selectable.py", "scope": "test_an_author_closed_shadow_root_is_still_reachable", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ua_widget_not_selectable.py", "scope": "test_the_order_is_author_document_order_in_both_forms", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_ua_widget_not_selectable.py", "scope": "test_the_page_itself_still_sees_null_on_both_kinds_of_closed_root", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_wait_for_function.py", "scope": "test_it_also_sees_the_dom", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "test_wait_for_function.py", "scope": "test_it_sees_a_global_the_PAGE_defined", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "webfont_probe.py", "scope": "_Marionette.__init__", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."},
|
||||
{"file": "webfont_probe.py", "scope": "fonts_mb", "rule": "sleep", "nth": 1, "class": "A", "reason": "A fixed pause and then a read judges the speed of the machine: wait for the condition with a deadline (tests/_waits.py wait_until) and read after it."},
|
||||
{"file": "webfont_probe.py", "scope": "run", "rule": "env", "nth": 1, "class": "C", "reason": "os.environ written directly is not undone when the test ends or fails: use monkeypatch.setenv, which restores it."},
|
||||
{"file": "webfont_probe.py", "scope": "run", "rule": "timeout", "nth": 1, "class": "F", "reason": "A deadline under 30 s on a wait for something that must happen is a verdict on the machine: a loaded runner is slower than the one it was written on. Give it 30 s (or the deadline the product itself has), and read the result after it."}
|
||||
]
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
"""The two writers must produce the SAME `user.js`, byte for byte.
|
||||
|
||||
⛔ THIS IS THE CRITERION ITEM 1 WAS WRITTEN WITH, and it is stricter than
|
||||
"both work" on purpose. Two prefs files can each be valid, each configure the
|
||||
browser, and differ - a header comment, a different order, an integer written
|
||||
as a string. Every one of those differences is invisible in a running browser
|
||||
and every one of them means the Python path is configuring a browser the Node
|
||||
path never configured. The whole point of keeping the driver as a judge is that
|
||||
this comparison is possible; a looser check throws that away.
|
||||
|
||||
⛔ AND IT NEEDS NO BROWSER. Both writers are pure functions of the prefs dict:
|
||||
the driver's is a JavaScript literal builder inside `coreBundle.js`, ours is
|
||||
`invisible_core.launch.write_user_js`, the one writer since 0.30.0. The driver's rules are re-implemented here FROM ITS SOURCE,
|
||||
read at run time rather than copied - so if upstream's writer changes, this gate
|
||||
changes with it instead of silently comparing against a stale transcription.
|
||||
|
||||
python tests/gates/prefs_byte_parity.py
|
||||
python tests/gates/prefs_byte_parity.py --selftest # 6 mutations, 3 that must not fire
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.insert(0, str(ROOT / "src"))
|
||||
|
||||
BUNDLE = ROOT / "src/invisible_playwright/_driver/package/lib/coreBundle.js"
|
||||
|
||||
#: A prefs dict shaped like a real one: the four value kinds that matter, a
|
||||
#: name with a character JSON has to escape, and a deliberately unsorted order.
|
||||
#: ⛔ THE ORDER IS PART OF THE FIXTURE. The driver uses `Object.keys()`, so a
|
||||
#: writer that sorts produces a file that is equally correct and not identical,
|
||||
#: and that is precisely the class of difference this gate exists to catch.
|
||||
SAMPLE = {
|
||||
"zoom.stealth.screen.width": 1920,
|
||||
"app.update.auto": False,
|
||||
"layout.css.devPixelsPerPx": "1.25",
|
||||
"ui.textScaleFactor": 1.0,
|
||||
"general.useragent.override": 'Mozilla/5.0 "quoted" \\ backslash',
|
||||
"browser.startup.homepage": "about:blank",
|
||||
}
|
||||
|
||||
|
||||
class DriverRulesMissing(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
#: The frozen copy, with its provenance. See the file itself for why.
|
||||
FROZEN = pathlib.Path(__file__).resolve().parent / "driver_prefs_rules.json"
|
||||
|
||||
#: Where to find a bundle after the deletion: a git worktree at the last commit
|
||||
#: that carried `_driver/`. Named here so the gate can say it out loud instead
|
||||
#: of leaving the reader to work it out.
|
||||
BUNDLE_ENV = "INVPW_DRIVER_BUNDLE"
|
||||
|
||||
|
||||
def _bundle():
|
||||
"""A reachable bundle, or None. Never raises: absence is a state."""
|
||||
named = os.environ.get(BUNDLE_ENV)
|
||||
if named:
|
||||
candidate = pathlib.Path(named)
|
||||
return candidate if candidate.exists() else None
|
||||
return BUNDLE if BUNDLE.exists() else None
|
||||
|
||||
|
||||
def driver_rules() -> dict:
|
||||
"""The driver's literal rules: frozen, and re-checked whenever possible.
|
||||
|
||||
⛔ IT USED TO READ THE BUNDLE ON EVERY RUN, deliberately, so an upstream
|
||||
change moved this gate with it instead of leaving it comparing against a
|
||||
stale transcription. The bundle goes with the Node driver, so the rules are
|
||||
now RECORDED - in `driver_prefs_rules.json`, with the sha of the bundle and
|
||||
of the exact 1200-byte window they came from.
|
||||
|
||||
⛔ AND THE RE-CHECK IS THE WHOLE POINT OF FREEZING THEM THIS WAY. Whenever a
|
||||
bundle IS reachable - still in the tree, or named by `INVPW_DRIVER_BUNDLE`
|
||||
from a git worktree - the rules are extracted again and compared against the
|
||||
frozen copy, and a mismatch FAILS. A recorded fact nobody can re-derive is a
|
||||
transcription, and a transcription this gate cannot check is exactly what
|
||||
the original design refused to have.
|
||||
"""
|
||||
frozen = json.loads(FROZEN.read_text(encoding="utf-8"))["rules"]
|
||||
bundle = _bundle()
|
||||
if bundle is None:
|
||||
return frozen
|
||||
live = _extract(bundle.read_text(encoding="utf-8", errors="replace"))
|
||||
if live != frozen:
|
||||
raise DriverRulesMissing(
|
||||
"the frozen driver rules disagree with the bundle at %s.\n"
|
||||
" frozen: %s\n bundle: %s\n"
|
||||
"The frozen copy is stale: re-freeze it with the new provenance, "
|
||||
"rather than loosening this comparison." % (bundle, frozen, live))
|
||||
return frozen
|
||||
|
||||
|
||||
def _extract(text: str) -> dict:
|
||||
start = text.find("__ipwLit")
|
||||
if start < 0:
|
||||
raise DriverRulesMissing(
|
||||
"the driver's pref writer is not in the bundle: it was renamed or "
|
||||
"removed, and this gate cannot compare against something it "
|
||||
"cannot read")
|
||||
window = text[start:start + 1200]
|
||||
return {
|
||||
"sorts": "sort()" in window,
|
||||
"header": bool(re.search(r'"//[^"]*"\s*\+', window)),
|
||||
"separator": "String.fromCharCode(10)" in window or "\\n" in window,
|
||||
"integer_bare": "Number.isInteger" in window,
|
||||
}
|
||||
|
||||
|
||||
def driver_user_js(prefs: dict) -> str:
|
||||
"""What the driver writes, in Python, following the rules read above."""
|
||||
rules = driver_rules()
|
||||
names = sorted(prefs) if rules["sorts"] else list(prefs)
|
||||
lines = []
|
||||
for name in names:
|
||||
value = prefs[name]
|
||||
if isinstance(value, bool):
|
||||
literal = "true" if value else "false"
|
||||
elif isinstance(value, int):
|
||||
literal = str(value)
|
||||
elif isinstance(value, float):
|
||||
# ⛔ Not an integer, so the driver quotes it: Gecko has no float
|
||||
# pref type, and a bare fraction makes the parser fail and IGNORE
|
||||
# EVERY LINE AFTER IT.
|
||||
literal = json.dumps(str(value))
|
||||
else:
|
||||
literal = json.dumps(str(value))
|
||||
lines.append("user_pref(%s, %s);" % (json.dumps(name), literal))
|
||||
head = "// header\n" if rules["header"] else ""
|
||||
return head + "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def ours(prefs: dict) -> str:
|
||||
from invisible_core.launch import write_user_js
|
||||
directory = tempfile.mkdtemp(prefix="prefs_parity_")
|
||||
write_user_js(directory, prefs)
|
||||
return (pathlib.Path(directory) / "user.js").read_bytes().decode("utf-8")
|
||||
|
||||
|
||||
def compare(prefs: dict) -> list:
|
||||
theirs = driver_user_js(prefs)
|
||||
mine = ours(prefs)
|
||||
if theirs == mine:
|
||||
return []
|
||||
faults = []
|
||||
a, b = theirs.splitlines(), mine.splitlines()
|
||||
if len(a) != len(b):
|
||||
faults.append("line count: driver %d, ours %d" % (len(a), len(b)))
|
||||
for i, (x, y) in enumerate(zip(a, b)):
|
||||
if x != y:
|
||||
faults.append("line %d:\n driver: %s\n ours : %s"
|
||||
% (i + 1, x, y))
|
||||
if not faults:
|
||||
faults.append("same lines, different bytes: trailing newline or "
|
||||
"encoding")
|
||||
return faults
|
||||
|
||||
|
||||
# ── the selftest ────────────────────────────────────────────────────────────
|
||||
def selftest() -> int:
|
||||
bad = 0
|
||||
|
||||
def expect(name, produce, should_fire):
|
||||
nonlocal bad
|
||||
theirs = driver_user_js(SAMPLE)
|
||||
mine = produce(theirs)
|
||||
differs = theirs != mine
|
||||
if differs != should_fire:
|
||||
print(" %s: %s" % ("SURVIVED" if should_fire else "FALSE POSITIVE",
|
||||
name))
|
||||
bad += 1
|
||||
else:
|
||||
print(" %s: %s" % ("killed" if should_fire else "silent", name))
|
||||
|
||||
print("--- mutations that MUST fire ---")
|
||||
expect("a header comment is added",
|
||||
lambda t: "// written by us\n" + t, True)
|
||||
expect("the lines are sorted",
|
||||
lambda t: "\n".join(sorted(t.splitlines())) + "\n", True)
|
||||
expect("an integer is quoted",
|
||||
lambda t: t.replace("user_pref(\"zoom.stealth.screen.width\", 1920)",
|
||||
"user_pref(\"zoom.stealth.screen.width\", \"1920\")"),
|
||||
True)
|
||||
expect("a boolean becomes a string",
|
||||
lambda t: t.replace(", false)", ", \"false\")"), True)
|
||||
expect("the trailing newline is dropped",
|
||||
lambda t: t.rstrip("\n"), True)
|
||||
expect("one pref goes missing",
|
||||
lambda t: "\n".join(t.splitlines()[1:]) + "\n", True)
|
||||
|
||||
print("--- cases that must NOT fire ---")
|
||||
expect("the same text", lambda t: t, False)
|
||||
expect("the same text built twice", lambda t: driver_user_js(SAMPLE), False)
|
||||
expect("a float stays quoted",
|
||||
lambda t: t.replace('"1.0"', '"1.0"'), False)
|
||||
|
||||
print()
|
||||
print("selftest: %s" % ("ALL GOOD" if not bad else "%d PROBLEMS" % bad))
|
||||
return 1 if bad else 0
|
||||
|
||||
|
||||
def main() -> int:
|
||||
p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
p.add_argument("--selftest", action="store_true")
|
||||
a = p.parse_args()
|
||||
if a.selftest:
|
||||
return selftest()
|
||||
try:
|
||||
rules = driver_rules()
|
||||
except DriverRulesMissing as failure:
|
||||
print("NOT COMPARABLE: %s" % failure)
|
||||
return 2
|
||||
# ⛔ IT SAYS WHICH SOURCE IT USED. The line used to read "driver rules read
|
||||
# from the bundle" unconditionally, and after the freeze that sentence was
|
||||
# simply false half the time - a gate that misreports where its own
|
||||
# reference came from is worse than one with no message, because the reader
|
||||
# stops looking.
|
||||
bundle = _bundle()
|
||||
print("driver rules %s: %s"
|
||||
% ("re-checked against %s" % bundle if bundle
|
||||
else "from the FROZEN copy (%s) - no bundle reachable, so nothing "
|
||||
"re-derived them this run" % FROZEN.name,
|
||||
", ".join("%s=%s" % kv for kv in sorted(rules.items()))))
|
||||
faults = compare(SAMPLE)
|
||||
if not faults:
|
||||
print("PREFS BYTE PARITY: identical (%d prefs)" % len(SAMPLE))
|
||||
return 0
|
||||
print("the two writers DISAGREE:")
|
||||
for f in faults:
|
||||
print(" " + f)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,475 @@
|
||||
// The probe of tests/test_the_bytes_a_page_reads_do_not_change_e2e.py: one expression that resolves to a flat object
|
||||
// {key: {s: "a short string"} | {h, n, s0} | {h, n, w, b64}} of everything a page can read about drawing and text:
|
||||
// c2d.* canvas 2D: getImageData bytes, toDataURL (png, jpeg, webp), toBlob, OffscreenCanvas.convertToBlob, measureText; drawImage scaled up
|
||||
// and down with imageSmoothing off and on at every imageSmoothingQuality (c2d.scale.*); gradients (linear, radial, conic) filling and
|
||||
// stroking text (c2d.gradtext)
|
||||
// gl1.* WebGL 1 and gl2.* WebGL 2: strings, extensions, limits, precision formats, readPixels bytes of several scenes, toDataURL, drawImage of the canvas
|
||||
// worker.* an OffscreenCanvas WebGL context in a worker
|
||||
// gpu.* the WebGPU adapter
|
||||
// dom.* text layout: the boxes of spans in many fonts, wrapped paragraphs, system colours
|
||||
// env.* the values the persona declares around it
|
||||
// A PNG the page reads (toDataURL, toBlob, convertToBlob) keeps its bytes in `b64`: the test compares the pixels it decodes to, because the engine
|
||||
// writes a per-launch ancillary chunk into every PNG (tests/_page_bytes.py). Every scene is wrapped: an exception becomes `<scene>.error` and is
|
||||
// compared like any other value, so every launch gives the same keys.
|
||||
// Taken from the hunt that measured the Windows reference (scripts/hunt_page_bytes_probe.js of run 43652292533), with its encoding mode removed.
|
||||
(async () => {
|
||||
const out = {};
|
||||
const enc = new TextEncoder();
|
||||
function hashBytes(u8) { // cyrb53 over bytes: no crypto.subtle (it needs a secure context)
|
||||
let h1 = 0xdeadbeef ^ u8.length, h2 = 0x41c6ce57 ^ u8.length;
|
||||
for (let i = 0; i < u8.length; i++) { const ch = u8[i]; h1 = Math.imul(h1 ^ ch, 2654435761); h2 = Math.imul(h2 ^ ch, 1597334677); }
|
||||
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
||||
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
||||
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16);
|
||||
}
|
||||
function b64(u8) {
|
||||
let s = "";
|
||||
for (let i = 0; i < u8.length; i += 0x8000) s += String.fromCharCode.apply(null, u8.subarray(i, i + 0x8000));
|
||||
return btoa(s);
|
||||
}
|
||||
function put(k, v, w) {
|
||||
if (ArrayBuffer.isView(v) || v instanceof ArrayBuffer) {
|
||||
const u8 = v instanceof ArrayBuffer ? new Uint8Array(v) : new Uint8Array(v.buffer, v.byteOffset, v.byteLength);
|
||||
out[k] = { h: hashBytes(u8), n: u8.length };
|
||||
if (w) { out[k].w = w; out[k].bpp = 4 * (v.BYTES_PER_ELEMENT || 1); } // pixels per row, bytes per pixel (RGBA)
|
||||
if (u8.length <= 400 * 1024) out[k].b64 = b64(u8);
|
||||
} else {
|
||||
const s = typeof v === "string" ? v : JSON.stringify(v);
|
||||
out[k] = s.length <= 3000 ? { s } : { h: hashBytes(enc.encode(s)), n: s.length, s0: s.slice(0, 200) };
|
||||
if (s.length > 3000 && s.startsWith("data:image/png;base64,") && s.length <= 600 * 1024) out[k].b64 = s.slice(22);
|
||||
}
|
||||
}
|
||||
async function scene(k, fn) {
|
||||
try { await fn(); } catch (e) { put(k + ".error", String((e && e.message) || e)); }
|
||||
}
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------ env
|
||||
await scene("env", async () => {
|
||||
put("env.ua", navigator.userAgent);
|
||||
put("env.platform", navigator.platform);
|
||||
put("env.oscpu", navigator.oscpu || "");
|
||||
put("env.hw", navigator.hardwareConcurrency);
|
||||
put("env.lang", navigator.languages);
|
||||
put("env.dpr", window.devicePixelRatio);
|
||||
put("env.screen", [screen.width, screen.height, screen.availWidth, screen.availHeight, screen.colorDepth, screen.pixelDepth]);
|
||||
put("env.mq", ["(color-gamut: srgb)", "(color-gamut: p3)", "(dynamic-range: high)", "(prefers-color-scheme: dark)", "(prefers-reduced-motion: reduce)",
|
||||
"(forced-colors: active)", "(inverted-colors: inverted)"].map((q) => matchMedia(q).matches));
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------- canvas 2D
|
||||
function c2d(w, h) { const c = document.createElement("canvas"); c.width = w; c.height = h; return [c, c.getContext("2d")]; }
|
||||
function dataUrlBytes(url) {
|
||||
const bin = atob(url.split(",")[1]);
|
||||
const u = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; i++) u[i] = bin.charCodeAt(i);
|
||||
return u;
|
||||
}
|
||||
async function read2d(k, c, g) {
|
||||
put(k + ".getImageData", g.getImageData(0, 0, c.width, c.height).data, c.width);
|
||||
put(k + ".png", c.toDataURL());
|
||||
put(k + ".jpeg", c.toDataURL("image/jpeg", 0.8));
|
||||
put(k + ".webp", c.toDataURL("image/webp", 0.8));
|
||||
const blob = await new Promise((r) => c.toBlob(r));
|
||||
put(k + ".toBlob", blob ? new Uint8Array(await blob.arrayBuffer()) : "null");
|
||||
}
|
||||
await scene("c2d.shapes", async () => {
|
||||
const [c, g] = c2d(256, 160);
|
||||
g.fillStyle = "#fff"; g.fillRect(0, 0, 256, 160);
|
||||
const lg = g.createLinearGradient(0, 0, 256, 0);
|
||||
lg.addColorStop(0, "#f00"); lg.addColorStop(0.5, "rgba(0,200,0,.5)"); lg.addColorStop(1, "#00f");
|
||||
g.fillStyle = lg; g.fillRect(8, 8, 240, 40);
|
||||
const rg = g.createRadialGradient(60, 100, 4, 60, 100, 50);
|
||||
rg.addColorStop(0, "#ff0"); rg.addColorStop(1, "rgba(255,0,255,.2)");
|
||||
g.fillStyle = rg; g.beginPath(); g.arc(60, 100, 50, 0, Math.PI * 2); g.fill();
|
||||
g.strokeStyle = "#123"; g.lineWidth = 1.5; g.beginPath(); g.moveTo(130, 60); g.bezierCurveTo(160, 20, 200, 140, 240, 70); g.stroke();
|
||||
g.lineWidth = 0.7; g.beginPath(); g.ellipse(190, 110, 40, 20, 0.5, 0, Math.PI * 2); g.stroke();
|
||||
g.save(); g.shadowColor = "rgba(0,0,0,.6)"; g.shadowBlur = 6; g.shadowOffsetX = 3; g.shadowOffsetY = 3; g.fillStyle = "#38c"; g.fillRect(120, 100, 50, 30); g.restore();
|
||||
g.save(); g.translate(30, 140); g.rotate(0.3); g.scale(1.3, 0.8); g.fillStyle = "#a40"; g.fillRect(0, 0, 40, 20); g.restore();
|
||||
if (g.createConicGradient) {
|
||||
const cg = g.createConicGradient(0.5, 215, 140);
|
||||
cg.addColorStop(0, "#f80"); cg.addColorStop(0.5, "#08f"); cg.addColorStop(1, "#f80");
|
||||
g.fillStyle = cg; g.fillRect(190, 120, 60, 36);
|
||||
}
|
||||
await read2d("c2d.shapes", c, g);
|
||||
});
|
||||
await scene("c2d.composite", async () => {
|
||||
const ops = ["source-over", "source-in", "source-out", "source-atop", "destination-over", "destination-in", "destination-out", "destination-atop",
|
||||
"lighter", "copy", "xor", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light",
|
||||
"difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
||||
const [c, g] = c2d(8 * 32, 4 * 32);
|
||||
ops.forEach((op, i) => {
|
||||
const x = (i % 8) * 32, y = Math.floor(i / 8) * 32;
|
||||
g.save(); g.beginPath(); g.rect(x, y, 32, 32); g.clip();
|
||||
g.globalCompositeOperation = "source-over";
|
||||
g.fillStyle = "rgba(200,60,40,.8)"; g.fillRect(x + 2, y + 2, 20, 20);
|
||||
g.globalCompositeOperation = op;
|
||||
g.fillStyle = "rgba(30,90,220,.6)"; g.fillRect(x + 10, y + 10, 20, 20);
|
||||
g.restore();
|
||||
});
|
||||
await read2d("c2d.composite", c, g);
|
||||
});
|
||||
await scene("c2d.filter_draw_image", async () => {
|
||||
const [c, g] = c2d(160, 120);
|
||||
const [s, sg] = c2d(10, 10);
|
||||
for (let i = 0; i < 100; i++) { sg.fillStyle = "hsl(" + ((i * 37) % 360) + ",70%,50%)"; sg.fillRect(i % 10, Math.floor(i / 10), 1, 1); }
|
||||
g.imageSmoothingEnabled = true; g.imageSmoothingQuality = "high";
|
||||
g.drawImage(s, 0, 0, 10, 10, 5.5, 5.5, 70.3, 70.3);
|
||||
g.imageSmoothingEnabled = false; g.drawImage(s, 80, 5, 60, 60);
|
||||
if ("filter" in g) { g.filter = "blur(2px) saturate(1.4)"; g.drawImage(s, 5, 70, 40, 40); g.filter = "none"; }
|
||||
const p = g.createPattern(s, "repeat"); g.fillStyle = p; g.fillRect(60, 70, 90, 40);
|
||||
const d = g.getImageData(0, 0, 40, 40); g.putImageData(d, 100, 80);
|
||||
await read2d("c2d.image", c, g);
|
||||
});
|
||||
const FONTS = ["16px sans-serif", "20px serif", "18px monospace", "bold 16px Arial", "italic 15px 'Segoe UI'", "16px 'Times New Roman'", "16px Calibri",
|
||||
"14px Consolas", "16px Verdana", "16px Tahoma", "17px Georgia", "16px 'Segoe UI Emoji'", "16px 'Microsoft YaHei'", "16px 'Yu Gothic'"];
|
||||
const TEXTS = ["Hamburgefonstiv 0123456789", "The quick brown fox jumps over the lazy dog", "ÀÉÎÕÜ ß fi fl ffl", "日本語のテキスト 漢字", "😀🚀👍🏽", "مرحبا بالعالم"];
|
||||
await scene("c2d.text", async () => {
|
||||
const [c, g] = c2d(520, FONTS.length * 28 + 20);
|
||||
g.fillStyle = "#fff"; g.fillRect(0, 0, c.width, c.height);
|
||||
FONTS.forEach((f, i) => {
|
||||
g.font = f; g.fillStyle = "#101820"; g.textBaseline = "alphabetic";
|
||||
g.fillText(TEXTS[i % TEXTS.length], 6, 22 + i * 28);
|
||||
g.strokeStyle = "rgba(200,0,0,.8)"; g.lineWidth = 0.6; g.strokeText("Ag", 470, 22 + i * 28);
|
||||
});
|
||||
await read2d("c2d.text", c, g);
|
||||
const m = [];
|
||||
for (const f of FONTS) {
|
||||
g.font = f;
|
||||
for (const t of TEXTS) {
|
||||
const r = g.measureText(t);
|
||||
m.push([f, t, r.width, r.actualBoundingBoxLeft, r.actualBoundingBoxRight, r.actualBoundingBoxAscent, r.actualBoundingBoxDescent,
|
||||
r.fontBoundingBoxAscent, r.fontBoundingBoxDescent]);
|
||||
}
|
||||
}
|
||||
put("c2d.measure", m);
|
||||
});
|
||||
await scene("c2d.offscreen", async () => {
|
||||
if (typeof OffscreenCanvas === "undefined") { put("c2d.offscreen", "no OffscreenCanvas"); return; }
|
||||
const oc = new OffscreenCanvas(160, 80), g = oc.getContext("2d");
|
||||
g.fillStyle = "#fed"; g.fillRect(0, 0, 160, 80); g.fillStyle = "rgba(10,120,200,.7)"; g.beginPath(); g.arc(50, 40, 30, 0, 6.2); g.fill();
|
||||
g.font = "bold 18px sans-serif"; g.fillStyle = "#222"; g.fillText("offscreen 2d", 70, 45);
|
||||
put("c2d.offscreen.getImageData", g.getImageData(0, 0, 160, 80).data, 160);
|
||||
const blob = await oc.convertToBlob();
|
||||
put("c2d.offscreen.convertToBlob", new Uint8Array(await blob.arrayBuffer()));
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------------------- drawImage scaled, smoothing and quality
|
||||
// A 24x24 source with hard edges and a ramp, a 200x200 one (to scale down), each drawn up and down, rotated and not, with imageSmoothing off and
|
||||
// on at low, medium and high. The pixels (getImageData) and the PNG of the same canvas, which the test compares decoded.
|
||||
await scene("c2d.scale", async () => {
|
||||
const [s1, sg1] = c2d(24, 24);
|
||||
for (let y = 0; y < 24; y++) for (let x = 0; x < 24; x++) {
|
||||
sg1.fillStyle = (x + y) % 5 === 0 ? "#000" : "hsl(" + ((x * 13 + y * 7) % 360) + "," + (40 + (y * 2)) + "%," + (30 + x) + "%)";
|
||||
sg1.fillRect(x, y, 1, 1);
|
||||
}
|
||||
const [s2, sg2] = c2d(200, 200);
|
||||
for (let i = 0; i < 40; i++) {
|
||||
sg2.fillStyle = "hsl(" + (i * 9) + ",70%,50%)"; sg2.fillRect((i * 17) % 190, (i * 29) % 190, 23 + (i % 7), 11 + (i % 5));
|
||||
sg2.strokeStyle = i % 2 ? "#fff" : "#111"; sg2.lineWidth = 1; sg2.beginPath(); sg2.moveTo(i * 5, 0); sg2.lineTo(200 - i * 4, 200); sg2.stroke();
|
||||
}
|
||||
const configs = [["off", false, "low"], ["low", true, "low"], ["medium", true, "medium"], ["high", true, "high"]];
|
||||
for (const [name, on, quality] of configs) {
|
||||
const [c, g] = c2d(220, 130);
|
||||
g.fillStyle = "#fff"; g.fillRect(0, 0, 220, 130);
|
||||
g.imageSmoothingEnabled = on; g.imageSmoothingQuality = quality;
|
||||
g.drawImage(s1, 0, 0, 24, 24, 3.25, 3.25, 97.3, 97.3); // up, not an integer factor
|
||||
g.drawImage(s2, 0, 0, 200, 200, 110.5, 4.5, 37, 37); // down, far
|
||||
g.drawImage(s2, 20, 20, 120, 120, 150, 4, 61, 61); // down, near, a part of the source
|
||||
g.drawImage(s1, 0, 0, 24, 24, 110, 50, 24, 24); // 1:1 at a whole pixel
|
||||
g.save(); g.translate(180, 95); g.rotate(0.35); g.drawImage(s1, 0, 0, 24, 24, -20, -20, 40, 40); g.restore(); // rotated and scaled up
|
||||
g.save(); g.translate(60, 118); g.scale(1.7, 0.45); g.drawImage(s2, 0, 0, 200, 200, 0, -20, 30, 30); g.restore(); // scaled by a transform
|
||||
put("c2d.scale." + name + ".getImageData", g.getImageData(0, 0, 220, 130).data, 220);
|
||||
put("c2d.scale." + name + ".png", c.toDataURL());
|
||||
}
|
||||
});
|
||||
// Text filled and stroked with gradients of the three kinds, with a shadow and with a global alpha: the paths the canvas takes for a gradient
|
||||
// over glyphs.
|
||||
await scene("c2d.gradtext", async () => {
|
||||
const [c, g] = c2d(420, 210);
|
||||
g.fillStyle = "#fff"; g.fillRect(0, 0, 420, 210);
|
||||
const lin = g.createLinearGradient(10, 0, 400, 0);
|
||||
lin.addColorStop(0, "#d00"); lin.addColorStop(0.4, "#fc0"); lin.addColorStop(0.7, "rgba(0,160,60,.6)"); lin.addColorStop(1, "#04d");
|
||||
const rad = g.createRadialGradient(100, 90, 4, 130, 100, 90);
|
||||
rad.addColorStop(0, "#fff"); rad.addColorStop(0.5, "#c0c"); rad.addColorStop(1, "#036");
|
||||
const rad2 = g.createRadialGradient(300, 60, 30, 340, 80, 8); // the focal circle outside the start circle
|
||||
rad2.addColorStop(0, "#f60"); rad2.addColorStop(1, "#0af");
|
||||
const con = g.createConicGradient ? g.createConicGradient(0.6, 210, 150) : lin;
|
||||
con.addColorStop(0, "#f80"); con.addColorStop(0.33, "#0c8"); con.addColorStop(0.66, "#80f"); con.addColorStop(1, "#f80");
|
||||
g.textBaseline = "alphabetic";
|
||||
g.font = "bold 40px sans-serif"; g.fillStyle = lin; g.fillText("Gradient 0123", 10, 44);
|
||||
g.font = "italic 34px serif"; g.fillStyle = rad; g.fillText("Hamburgefonstiv", 10, 90);
|
||||
g.font = "28px monospace"; g.fillStyle = rad2; g.fillText("radial focal 1/2", 220, 40);
|
||||
g.font = "bold 44px Arial"; g.strokeStyle = lin; g.lineWidth = 2.5; g.strokeText("Stroke", 10, 140);
|
||||
g.font = "36px 'Times New Roman'"; g.fillStyle = con; g.fillText("Conic text", 150, 150);
|
||||
g.save(); g.shadowColor = "rgba(0,0,0,.55)"; g.shadowBlur = 4; g.shadowOffsetX = 2; g.shadowOffsetY = 3; g.globalAlpha = 0.8;
|
||||
g.font = "30px 'Segoe UI'"; g.fillStyle = lin; g.fillText("Shadow and alpha", 10, 190); g.restore();
|
||||
g.font = "20px sans-serif"; g.fillStyle = con; g.fillRect(300, 150, 110, 50); g.fillStyle = "#fff"; g.fillText("on conic", 310, 180);
|
||||
put("c2d.gradtext.getImageData", g.getImageData(0, 0, 420, 210).data, 420);
|
||||
put("c2d.gradtext.png", c.toDataURL());
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------ WebGL
|
||||
const P1 = ["VERSION", "SHADING_LANGUAGE_VERSION", "VENDOR", "RENDERER", "MAX_TEXTURE_SIZE", "MAX_CUBE_MAP_TEXTURE_SIZE", "MAX_RENDERBUFFER_SIZE",
|
||||
"MAX_VIEWPORT_DIMS", "ALIASED_LINE_WIDTH_RANGE", "ALIASED_POINT_SIZE_RANGE", "MAX_VERTEX_ATTRIBS", "MAX_VARYING_VECTORS",
|
||||
"MAX_COMBINED_TEXTURE_IMAGE_UNITS", "MAX_VERTEX_TEXTURE_IMAGE_UNITS", "MAX_TEXTURE_IMAGE_UNITS", "MAX_VERTEX_UNIFORM_VECTORS",
|
||||
"MAX_FRAGMENT_UNIFORM_VECTORS", "RED_BITS", "GREEN_BITS", "BLUE_BITS", "ALPHA_BITS", "DEPTH_BITS", "STENCIL_BITS", "SAMPLES",
|
||||
"SAMPLE_BUFFERS", "SUBPIXEL_BITS"];
|
||||
const P2 = ["MAX_3D_TEXTURE_SIZE", "MAX_ARRAY_TEXTURE_LAYERS", "MAX_COLOR_ATTACHMENTS", "MAX_DRAW_BUFFERS", "MAX_ELEMENTS_INDICES", "MAX_ELEMENTS_VERTICES",
|
||||
"MAX_FRAGMENT_INPUT_COMPONENTS", "MAX_FRAGMENT_UNIFORM_BLOCKS", "MAX_FRAGMENT_UNIFORM_COMPONENTS", "MAX_PROGRAM_TEXEL_OFFSET", "MAX_SAMPLES",
|
||||
"MAX_SERVER_WAIT_TIMEOUT", "MAX_TEXTURE_LOD_BIAS", "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
|
||||
"MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", "MAX_UNIFORM_BLOCK_SIZE", "MAX_UNIFORM_BUFFER_BINDINGS", "MAX_VARYING_COMPONENTS",
|
||||
"MAX_VERTEX_OUTPUT_COMPONENTS", "MAX_VERTEX_UNIFORM_BLOCKS", "MAX_VERTEX_UNIFORM_COMPONENTS", "MIN_PROGRAM_TEXEL_OFFSET",
|
||||
"MAX_COMBINED_UNIFORM_BLOCKS", "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", "UNIFORM_BUFFER_OFFSET_ALIGNMENT"];
|
||||
function glInfo(p, gl, v2) {
|
||||
const params = {};
|
||||
for (const n of P1.concat(v2 ? P2 : [])) {
|
||||
try { let v = gl.getParameter(gl[n]); if (ArrayBuffer.isView(v)) v = Array.from(v); params[n] = v; } catch (e) { params[n] = "ERR " + e.message; }
|
||||
}
|
||||
put(p + ".params", params);
|
||||
const exts = gl.getSupportedExtensions() || [];
|
||||
put(p + ".extensions", exts);
|
||||
const eo = [];
|
||||
for (const e of exts) {
|
||||
try { const o = gl.getExtension(e); eo.push([e, o ? Object.keys(Object.getPrototypeOf(o)).length : -1]); } catch (er) { eo.push([e, "ERR"]); }
|
||||
}
|
||||
put(p + ".extension_objects", eo);
|
||||
const dbg = gl.getExtension("WEBGL_debug_renderer_info");
|
||||
put(p + ".unmasked", dbg ? [gl.getParameter(dbg.UNMASKED_VENDOR_WEBGL), gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL)] : "no WEBGL_debug_renderer_info");
|
||||
const an = gl.getExtension("EXT_texture_filter_anisotropic");
|
||||
put(p + ".anisotropy", an ? gl.getParameter(an.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : "none");
|
||||
const prec = [];
|
||||
for (const sh of ["VERTEX_SHADER", "FRAGMENT_SHADER"]) for (const lv of ["LOW_FLOAT", "MEDIUM_FLOAT", "HIGH_FLOAT", "LOW_INT", "MEDIUM_INT", "HIGH_INT"]) {
|
||||
const f = gl.getShaderPrecisionFormat(gl[sh], gl[lv]);
|
||||
prec.push([sh, lv, f && f.rangeMin, f && f.rangeMax, f && f.precision]);
|
||||
}
|
||||
put(p + ".precision", prec);
|
||||
put(p + ".attributes", gl.getContextAttributes());
|
||||
}
|
||||
function program(gl, vs, fs) {
|
||||
const mk = (type, src) => {
|
||||
const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s);
|
||||
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error("shader: " + gl.getShaderInfoLog(s));
|
||||
return s;
|
||||
};
|
||||
const pr = gl.createProgram();
|
||||
gl.attachShader(pr, mk(gl.VERTEX_SHADER, vs)); gl.attachShader(pr, mk(gl.FRAGMENT_SHADER, fs));
|
||||
gl.bindAttribLocation(pr, 0, "p"); gl.bindAttribLocation(pr, 1, "c");
|
||||
gl.linkProgram(pr);
|
||||
if (!gl.getProgramParameter(pr, gl.LINK_STATUS)) throw new Error("link: " + gl.getProgramInfoLog(pr));
|
||||
gl.useProgram(pr);
|
||||
return pr;
|
||||
}
|
||||
function buffer(gl, loc, data, size) {
|
||||
const b = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, b); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.STATIC_DRAW);
|
||||
gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, size, gl.FLOAT, false, 0, 0);
|
||||
return b;
|
||||
}
|
||||
function pixels(gl, w, h) { const u = new Uint8Array(w * h * 4); gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, u); return u; }
|
||||
const VS = "attribute vec2 p; attribute vec4 c; varying vec4 v; varying vec2 uv; void main(){ v=c; uv=p*0.5+0.5; gl_Position=vec4(p,0.,1.); gl_PointSize=7.5; }";
|
||||
const FS_COLOR = "precision mediump float; varying vec4 v; void main(){ gl_FragColor=v; }";
|
||||
const QUAD = [-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1];
|
||||
|
||||
async function glScenes(p, v2) {
|
||||
const kind = v2 ? "webgl2" : "webgl";
|
||||
const mkctx = (w, h, attrs) => {
|
||||
const c = document.createElement("canvas"); c.width = w; c.height = h;
|
||||
return [c, c.getContext(kind, Object.assign({ preserveDrawingBuffer: true }, attrs || {}))];
|
||||
};
|
||||
let [c0, gl0] = mkctx(64, 64);
|
||||
if (!gl0) { put(p + ".context", "null"); return; }
|
||||
glInfo(p, gl0, v2);
|
||||
await scene(p + ".triangle", async () => {
|
||||
const [c, gl] = mkctx(96, 96, { antialias: false });
|
||||
gl.viewport(0, 0, 96, 96); gl.clearColor(0.1, 0.2, 0.3, 0.4); gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
program(gl, VS, FS_COLOR);
|
||||
buffer(gl, 0, [-0.8, -0.7, 0.9, -0.5, -0.1, 0.85], 2);
|
||||
buffer(gl, 1, [1, 0, 0, 1, 0, 1, 0, 0.7, 0, 0, 1, 0.3], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
put(p + ".triangle.readPixels", pixels(gl, 96, 96), 96);
|
||||
put(p + ".triangle.toDataURL", c.toDataURL());
|
||||
put(p + ".triangle.toDataURL_jpeg", c.toDataURL("image/jpeg", 0.8));
|
||||
const [d, g2] = c2d(96, 96); g2.drawImage(c, 0, 0);
|
||||
put(p + ".triangle.drawImage", g2.getImageData(0, 0, 96, 96).data, 96);
|
||||
});
|
||||
await scene(p + ".antialias", async () => {
|
||||
for (const aa of [true, false]) {
|
||||
const [c, gl] = mkctx(96, 96, { antialias: aa });
|
||||
gl.viewport(0, 0, 96, 96); gl.clearColor(1, 1, 1, 1); gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
program(gl, VS, FS_COLOR);
|
||||
buffer(gl, 0, [-0.83, -0.71, 0.77, -0.43, -0.1, 0.89, 0.3, 0.9, 0.9, 0.2, 0.6, 0.95], 2);
|
||||
buffer(gl, 1, [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 0, 1, 0.8, 0, 0, 1, 0.8, 0, 0, 1], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
put(p + ".antialias." + aa + ".samples", gl.getParameter(gl.SAMPLES));
|
||||
put(p + ".antialias." + aa + ".readPixels", pixels(gl, 96, 96), 96);
|
||||
}
|
||||
});
|
||||
for (const prec of ["highp", "mediump"]) await scene(p + ".math." + prec, async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false });
|
||||
const fp = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
|
||||
const use = prec === "highp" && !(fp && fp.precision) ? "mediump" : prec;
|
||||
gl.viewport(0, 0, 64, 64);
|
||||
program(gl, VS, "precision " + use + " float; varying vec2 uv;" +
|
||||
"void main(){ float x=uv.x*6.0; gl_FragColor=vec4(fract(sin(x)*43758.5453), fract(exp(uv.y*3.0)), fract(pow(uv.x+0.5, 2.2+uv.y)), fract(sqrt(uv.x*uv.y)*17.0)); }");
|
||||
buffer(gl, 0, QUAD, 2); gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
put(p + ".math." + prec + ".readPixels", pixels(gl, 64, 64), 64);
|
||||
});
|
||||
await scene(p + ".texture", async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false });
|
||||
gl.viewport(0, 0, 64, 64);
|
||||
program(gl, VS, "precision mediump float; varying vec2 uv; uniform sampler2D t; void main(){ gl_FragColor=texture2D(t, uv*0.9+0.03); }");
|
||||
const tex = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, tex);
|
||||
const d = new Uint8Array(32 * 32 * 4); let s = 12345;
|
||||
for (let i = 0; i < d.length; i++) { s = (s * 1103515245 + 12345) & 0x7fffffff; d[i] = (s >> 16) & 255; }
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, d);
|
||||
gl.generateMipmap(gl.TEXTURE_2D);
|
||||
for (const [name, mag, min] of [["linear", gl.LINEAR, gl.LINEAR], ["mip", gl.LINEAR, gl.LINEAR_MIPMAP_LINEAR], ["nearest", gl.NEAREST, gl.NEAREST]]) {
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, mag); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, min);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
buffer(gl, 0, QUAD, 2); gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
put(p + ".texture." + name + ".readPixels", pixels(gl, 64, 64), 64);
|
||||
}
|
||||
});
|
||||
await scene(p + ".blend", async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false, premultipliedAlpha: false });
|
||||
gl.viewport(0, 0, 64, 64); gl.clearColor(0.2, 0.4, 0.6, 0.5); gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
program(gl, VS, FS_COLOR); gl.enable(gl.BLEND);
|
||||
for (const [src, dst] of [[gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA], [gl.ONE, gl.ONE_MINUS_SRC_ALPHA], [gl.DST_COLOR, gl.ZERO]]) {
|
||||
gl.blendFunc(src, dst);
|
||||
buffer(gl, 0, [-0.9, -0.9, 0.3, -0.5, -0.3, 0.7], 2);
|
||||
buffer(gl, 1, [0.9, 0.2, 0.1, 0.37, 0.1, 0.8, 0.3, 0.55, 0.2, 0.3, 0.9, 0.21], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
}
|
||||
put(p + ".blend.readPixels", pixels(gl, 64, 64), 64);
|
||||
});
|
||||
await scene(p + ".lines_points", async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false });
|
||||
gl.viewport(0, 0, 64, 64); gl.clearColor(1, 1, 1, 1); gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
program(gl, VS, FS_COLOR);
|
||||
buffer(gl, 1, [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1], 4);
|
||||
buffer(gl, 0, [-0.9, -0.3, 0.9, 0.5, -0.9, 0.6, 0.2, -0.9], 2);
|
||||
gl.lineWidth(1); gl.drawArrays(gl.LINES, 0, 4);
|
||||
gl.lineWidth(3); buffer(gl, 0, [-0.6, -0.8, 0.8, 0.9], 2); gl.drawArrays(gl.LINES, 0, 2);
|
||||
buffer(gl, 0, [-0.5, 0.5, 0.4, -0.2], 2); gl.drawArrays(gl.POINTS, 0, 2);
|
||||
put(p + ".lines_points.readPixels", pixels(gl, 64, 64), 64);
|
||||
});
|
||||
await scene(p + ".depth_stencil", async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false, depth: true, stencil: true });
|
||||
gl.viewport(0, 0, 64, 64); gl.clearColor(0, 0, 0, 1); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
|
||||
program(gl, "attribute vec3 p; attribute vec4 c; varying vec4 v; void main(){ v=c; gl_Position=vec4(p,1.); }", FS_COLOR);
|
||||
gl.enable(gl.DEPTH_TEST); gl.enable(gl.STENCIL_TEST); gl.stencilFunc(gl.ALWAYS, 1, 255); gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
|
||||
buffer(gl, 0, [-0.9, -0.9, 0.2, 0.9, -0.5, -0.4, 0.0, 0.9, 0.6], 3);
|
||||
buffer(gl, 1, [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
buffer(gl, 0, [-0.9, 0.9, 0.0, 0.9, 0.9, 0.0, 0.0, -0.9, 0.5], 3);
|
||||
buffer(gl, 1, [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
put(p + ".depth_stencil.readPixels", pixels(gl, 64, 64), 64);
|
||||
});
|
||||
if (v2) {
|
||||
await scene(p + ".msaa_resolve", async () => {
|
||||
const [c, gl] = mkctx(64, 64, { antialias: false });
|
||||
const rb = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
|
||||
gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, 64, 64);
|
||||
const fb = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
|
||||
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rb);
|
||||
const tx = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, tx);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 64, 64, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||
const fb2 = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
|
||||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tx, 0);
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, fb); gl.viewport(0, 0, 64, 64); gl.clearColor(1, 1, 1, 1); gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
program(gl, VS, FS_COLOR);
|
||||
buffer(gl, 0, [-0.83, -0.71, 0.77, -0.43, -0.1, 0.89], 2);
|
||||
buffer(gl, 1, [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1], 4);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fb); gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, fb2);
|
||||
gl.blitFramebuffer(0, 0, 64, 64, 0, 0, 64, 64, gl.COLOR_BUFFER_BIT, gl.NEAREST);
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, fb2);
|
||||
put(p + ".msaa_resolve.readPixels", pixels(gl, 64, 64), 64);
|
||||
});
|
||||
await scene(p + ".float_target", async () => {
|
||||
const [c, gl] = mkctx(32, 32, { antialias: false });
|
||||
if (!gl.getExtension("EXT_color_buffer_float")) { put(p + ".float_target", "no EXT_color_buffer_float"); return; }
|
||||
const tx = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, tx);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, 32, 32, 0, gl.RGBA, gl.FLOAT, null);
|
||||
const fb = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
|
||||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tx, 0);
|
||||
gl.viewport(0, 0, 32, 32);
|
||||
program(gl, VS, "precision highp float; varying vec2 uv; void main(){ gl_FragColor=vec4(sin(uv.x*9.0)*exp(uv.y), pow(uv.x+0.1, 1.7), sqrt(uv.y), uv.x/(uv.y+0.37)); }");
|
||||
buffer(gl, 0, QUAD, 2); gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
const f = new Float32Array(32 * 32 * 4); gl.readPixels(0, 0, 32, 32, gl.RGBA, gl.FLOAT, f);
|
||||
put(p + ".float_target.readPixels", f, 32);
|
||||
});
|
||||
}
|
||||
}
|
||||
await scene("gl1", () => glScenes("gl1", false));
|
||||
await scene("gl2", () => glScenes("gl2", true));
|
||||
|
||||
await scene("worker.webgl", async () => {
|
||||
if (typeof Worker === "undefined" || typeof OffscreenCanvas === "undefined") { put("worker.webgl", "no worker or OffscreenCanvas"); return; }
|
||||
const src = "onmessage = () => { try { const c = new OffscreenCanvas(32, 32), gl = c.getContext('webgl'); if (!gl) { postMessage({err: 'no webgl'}); return; }" +
|
||||
"const d = gl.getExtension('WEBGL_debug_renderer_info');" +
|
||||
"gl.clearColor(0.25, 0.5, 0.75, 1); gl.clear(gl.COLOR_BUFFER_BIT); const u = new Uint8Array(32*32*4); gl.readPixels(0,0,32,32,gl.RGBA,gl.UNSIGNED_BYTE,u);" +
|
||||
"postMessage({vendor: gl.getParameter(gl.VENDOR), renderer: gl.getParameter(gl.RENDERER), unmasked: d ? [gl.getParameter(d.UNMASKED_VENDOR_WEBGL), gl.getParameter(d.UNMASKED_RENDERER_WEBGL)] : null," +
|
||||
"exts: gl.getSupportedExtensions(), px: Array.from(u.subarray(0, 16))}); } catch (e) { postMessage({err: String(e)}); } };";
|
||||
const w = new Worker(URL.createObjectURL(new Blob([src])));
|
||||
const r = await Promise.race([new Promise((res) => { w.onmessage = (e) => res(e.data); w.onerror = (e) => res({ err: "worker error " + e.message }); w.postMessage(1); }),
|
||||
sleep(10000).then(() => ({ err: "timeout" }))]);
|
||||
w.terminate();
|
||||
put("worker.webgl", r);
|
||||
});
|
||||
await scene("gpu.webgpu", async () => {
|
||||
if (!navigator.gpu) { put("gpu.webgpu", "no navigator.gpu"); return; }
|
||||
const a = await Promise.race([navigator.gpu.requestAdapter(), sleep(10000).then(() => "timeout")]);
|
||||
if (!a || a === "timeout") { put("gpu.webgpu", String(a)); return; }
|
||||
const info = a.info || (a.requestAdapterInfo ? await a.requestAdapterInfo() : {});
|
||||
// Features and limits are read by NAME, never by iterating them: the expression runs with the page's objects behind Xray wrappers, and
|
||||
// `Array.from(a.features)` / `for (k in a.limits)` threw "Xray wrapping of iterators not supported" there (run 43652292533). `has` and a property
|
||||
// read are plain calls. The names are those of the WebGPU specification (limits table and GPUFeatureName); one the engine does not know reads
|
||||
// false / undefined, which is a value like any other.
|
||||
const featureNames = ["depth-clip-control", "depth32float-stencil8", "texture-compression-bc", "texture-compression-bc-sliced-3d",
|
||||
"texture-compression-etc2", "texture-compression-astc", "texture-compression-astc-sliced-3d", "timestamp-query", "indirect-first-instance",
|
||||
"shader-f16", "rg11b10ufloat-renderable", "bgra8unorm-storage", "float32-filterable", "float32-blendable", "clip-distances",
|
||||
"dual-source-blending", "subgroups"];
|
||||
const limitNames = ["maxTextureDimension1D", "maxTextureDimension2D", "maxTextureDimension3D", "maxTextureArrayLayers", "maxBindGroups",
|
||||
"maxBindGroupsPlusVertexBuffers", "maxBindingsPerBindGroup", "maxDynamicUniformBuffersPerPipelineLayout",
|
||||
"maxDynamicStorageBuffersPerPipelineLayout", "maxSampledTexturesPerShaderStage", "maxSamplersPerShaderStage",
|
||||
"maxStorageBuffersPerShaderStage", "maxStorageTexturesPerShaderStage", "maxUniformBuffersPerShaderStage", "maxUniformBufferBindingSize",
|
||||
"maxStorageBufferBindingSize", "minUniformBufferOffsetAlignment", "minStorageBufferOffsetAlignment", "maxVertexBuffers", "maxBufferSize",
|
||||
"maxVertexAttributes", "maxVertexBufferArrayStride", "maxInterStageShaderVariables", "maxColorAttachments",
|
||||
"maxColorAttachmentBytesPerSample", "maxComputeWorkgroupStorageSize", "maxComputeInvocationsPerWorkgroup", "maxComputeWorkgroupSizeX",
|
||||
"maxComputeWorkgroupSizeY", "maxComputeWorkgroupSizeZ", "maxComputeWorkgroupsPerDimension"];
|
||||
const lim = {}, feat = {};
|
||||
for (const k of limitNames) { try { lim[k] = a.limits[k]; } catch (e) { lim[k] = "ERR " + e.message; } }
|
||||
for (const f of featureNames) { try { feat[f] = a.features.has(f); } catch (e) { feat[f] = "ERR " + e.message; } }
|
||||
put("gpu.webgpu.info", { vendor: info.vendor, architecture: info.architecture, device: info.device, description: info.description });
|
||||
put("gpu.webgpu.features", feat);
|
||||
put("gpu.webgpu.limits", lim);
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------ DOM text
|
||||
await scene("dom.text", async () => {
|
||||
const box = document.createElement("div"); box.style.cssText = "position:absolute;left:0;top:0;white-space:nowrap";
|
||||
document.body.appendChild(box);
|
||||
const rows = [];
|
||||
for (const f of FONTS) for (const t of TEXTS) {
|
||||
const s = document.createElement("span"); s.style.font = f; s.textContent = t; box.appendChild(s);
|
||||
const r = s.getBoundingClientRect();
|
||||
rows.push([f, t, r.width, r.height, s.offsetWidth, s.offsetHeight]);
|
||||
box.removeChild(s);
|
||||
}
|
||||
put("dom.span_boxes", rows);
|
||||
const para = [];
|
||||
for (const f of ["16px sans-serif", "15px 'Times New Roman'", "14px Consolas"]) {
|
||||
const d = document.createElement("div"); d.style.cssText = "width:200px;font:" + f; d.textContent = TEXTS.join(" · ") + " " + TEXTS.join(" · ");
|
||||
box.appendChild(d); const r = d.getBoundingClientRect(); para.push([f, r.width, r.height]); box.removeChild(d);
|
||||
}
|
||||
put("dom.paragraphs", para);
|
||||
put("dom.fonts_check", FONTS.map((f) => [f, document.fonts.check(f)]));
|
||||
const colors = ["Canvas", "CanvasText", "ButtonFace", "ButtonText", "ButtonBorder", "Field", "FieldText", "Highlight", "HighlightText", "GrayText", "LinkText",
|
||||
"VisitedText", "ActiveText", "Mark", "MarkText", "AccentColor", "AccentColorText", "SelectedItem", "SelectedItemText"];
|
||||
put("dom.system_colors", colors.map((c) => { const e = document.createElement("i"); e.style.color = c; box.appendChild(e); const v = getComputedStyle(e).color; box.removeChild(e); return [c, v]; }));
|
||||
document.body.removeChild(box);
|
||||
});
|
||||
return out;
|
||||
})()
|
||||
@@ -0,0 +1,31 @@
|
||||
"""`context.add_init_script` added after a page exists runs once in each document, not twice.
|
||||
|
||||
The context-level script was registered on both sides: in the browser (`Browser.setInitScripts`, which the engine applies to every
|
||||
page of the context, the ones already open included) and, for the pages already open, again in each page's own list. A page that
|
||||
existed when the script was added ran it twice in every later document; a page opened afterwards ran it once, so the test that adds the
|
||||
script first passed. Playwright runs a context script once in each document of each page.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
PAGE = ("<!doctype html><title>t</title><script>window.__seen = JSON.stringify(window.__o || []);</script>")
|
||||
|
||||
|
||||
def test_a_context_script_added_after_the_page_exists_runs_once(firefox_binary, tmp_path):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
(tmp_path / "p.html").write_text(PAGE, encoding="utf-8")
|
||||
url = (tmp_path / "p.html").as_uri()
|
||||
with InvisiblePlaywright(seed=4261, binary_path=firefox_binary, headless=True) as browser:
|
||||
context = browser.new_context()
|
||||
existing = context.new_page() # the page exists BEFORE the script
|
||||
context.add_init_script("(window.__o = window.__o || []).push('init');")
|
||||
later = context.new_page() # and a page opened AFTER it
|
||||
for page in (existing, later):
|
||||
page.goto(url, wait_until="load")
|
||||
assert page.evaluate("window.__o") == ["init"], "the script ran %r" % page.evaluate("window.__o")
|
||||
page.goto(url + "?again", wait_until="load") # the next document of the same page, too
|
||||
assert page.evaluate("window.__o") == ["init"], "the second document ran %r" % page.evaluate("window.__o")
|
||||
@@ -8,8 +8,8 @@ BrowserContext now waits a few seconds for the processes of its container once i
|
||||
ones that stay.
|
||||
|
||||
The test closes five such contexts in a row. While each page is open it counts the processes that host a site
|
||||
(at least one: the page's, or the count would prove nothing), and once `close` has answered it waits a few
|
||||
seconds for them to be gone: none may be left (on the old engine every context leaves its own, one more each
|
||||
(at least one: the page's, or the count would prove nothing), and once `close` has answered it waits, with a deadline of 30 s
|
||||
that only a process that never goes reaches, for them to be gone: none may be left (on the old engine every context leaves its own, one more each
|
||||
time). Only the processes of the page's site are counted, asked for by name (tests/_processes.py): the browser is
|
||||
launched with `fission.processSiteNames`, which names a content process by the site it hosts (the page is served
|
||||
from `http://127.0.0.1:<port>`; a site never includes the port). The browser starts processes of its own, and
|
||||
@@ -26,7 +26,6 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -35,6 +34,7 @@ from websockets.asyncio.client import connect # noqa: E402
|
||||
|
||||
from _processes import NAMED_BY_SITE, site_processes_below # noqa: E402
|
||||
from _servers import LocalServer # noqa: E402
|
||||
from _waits import awatch # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
@@ -89,6 +89,13 @@ class _Client:
|
||||
await self.call("", "initialize", {"sdkLanguage": "python"})
|
||||
self.browser = [g for g, o in self.objects.items() if o["type"] == "Browser"][0]
|
||||
|
||||
async def evaluate(self, frame, expression):
|
||||
"""The value of a JavaScript expression in the frame (a promise is awaited by the protocol)."""
|
||||
result = await self.call(frame, "evaluateExpression", {
|
||||
"expression": expression, "isFunction": False, "arg": {"value": {"v": "undefined"}, "handles": []}})
|
||||
value = result["value"]
|
||||
return value["b"] if "b" in value else value # the protocol's own tag of a boolean
|
||||
|
||||
async def new_page(self):
|
||||
context = (await self.call(self.browser, "newContext", {}))["context"]["guid"]
|
||||
page = (await self.call(context, "newPage", {}))["page"]["guid"]
|
||||
@@ -96,6 +103,13 @@ class _Client:
|
||||
return context, frame
|
||||
|
||||
|
||||
#: A deadline no healthy run comes near: every wait below ends on its condition, not on this.
|
||||
DEADLINE_S = 30
|
||||
|
||||
#: The page asked for a service worker and the browser has taken it (the install handler is the endless loop).
|
||||
REGISTERED = ("navigator.serviceWorker.getRegistration().then(r => !!r && !!(r.installing || r.waiting || r.active))")
|
||||
|
||||
|
||||
def test_closed_contexts_with_a_never_stopping_service_worker_leave_no_process(firefox_binary, engine_at_least):
|
||||
engine_at_least(ENGINE_WITH_THE_FIX)
|
||||
from invisible_playwright import launch_server
|
||||
@@ -116,13 +130,24 @@ def test_closed_contexts_with_a_never_stopping_service_worker_leave_no_process(f
|
||||
for i in range(5):
|
||||
context, frame = await client.new_page()
|
||||
await client.call(frame, "goto", {"url": "%s/?i=%d" % (base, i), "waitUntil": "load", "timeout": 30000})
|
||||
await asyncio.sleep(1.0) # the worker is registered, its install loop is running
|
||||
opened.append(len(sites()))
|
||||
# the worker is registered (asked of the page, not slept for), so its install loop is running
|
||||
state = {"registered": False}
|
||||
|
||||
async def ask():
|
||||
state["registered"] = await client.evaluate(frame, REGISTERED)
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
known = await awatch(lambda: state["registered"], bool, DEADLINE_S, ask)
|
||||
assert known.ok, "the service worker of the page was never registered (round %d): %s" % (i, known.render())
|
||||
|
||||
async def look():
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
seen = await awatch(lambda: len(sites()), lambda n: n > 0, DEADLINE_S, look)
|
||||
opened.append(seen.history[-1][1])
|
||||
await client.call(context, "close") # the engine waits for the context's processes, then kills
|
||||
deadline = time.time() + 5
|
||||
while sites() and time.time() < deadline:
|
||||
await asyncio.sleep(0.25)
|
||||
left.append(len(sites()))
|
||||
gone = await awatch(lambda: len(sites()), lambda n: n == 0, DEADLINE_S, lambda: asyncio.sleep(0.25))
|
||||
left.append(gone.history[-1][1])
|
||||
return opened, left
|
||||
|
||||
try:
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
"""A CORS preflight is not a request the client hears of, as on stock Firefox.
|
||||
|
||||
A page at one origin fetches another origin with a header that needs a preflight: the browser sends an OPTIONS request first. Playwright's
|
||||
own server drops an OPTIONS request that no route holds before the client can see it (ffNetworkManager `_onRequestWillBeSent`);
|
||||
ours reported it, so a page with preflighted fetches showed more requests than on stock (measured on cnbc.com and scmp.com: 10 and
|
||||
18 OPTIONS requests a page, none on stock). The test counts what the client hears: the document and the two fetches, no OPTIONS, with
|
||||
and without a context route (a route that holds the request is another story and keeps it).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
|
||||
class _Api(BaseHTTPRequestHandler):
|
||||
hits: list = []
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def _cors(self):
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
self.send_header("Access-Control-Allow-Headers", "x-test")
|
||||
self.send_header("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||
|
||||
def do_OPTIONS(self):
|
||||
_Api.hits.append(("OPTIONS", self.path))
|
||||
self.send_response(204)
|
||||
self._cors()
|
||||
self.end_headers()
|
||||
|
||||
def do_GET(self):
|
||||
_Api.hits.append(("GET", self.path))
|
||||
body = b'{"ok":1}'
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self._cors()
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
|
||||
def _page(api_origin):
|
||||
return ("<!doctype html><title>preflight</title><script>"
|
||||
"fetch('%s/one', {headers: {'x-test': '1'}}); fetch('%s/two', {headers: {'x-test': '2'}});"
|
||||
"</script>" % (api_origin, api_origin)).encode()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def two_origins():
|
||||
_Api.hits = []
|
||||
|
||||
class Page(BaseHTTPRequestHandler):
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
body = _page(self.server.api_origin)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
api = LocalServer(("127.0.0.1", 0), _Api)
|
||||
page = LocalServer(("127.0.0.1", 0), Page)
|
||||
page.api_origin = "http://localhost:%d" % api.server_address[1]
|
||||
for srv in (api, page):
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
try:
|
||||
yield "http://127.0.0.1:%d/" % page.server_address[1]
|
||||
finally:
|
||||
for srv in (api, page):
|
||||
srv.shutdown()
|
||||
srv.server_close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("route", [False, True])
|
||||
def test_the_client_hears_the_document_and_the_fetches_and_no_preflight(firefox_binary, two_origins, route):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
heard = []
|
||||
with InvisiblePlaywright(seed=4261, binary_path=firefox_binary, headless=True) as browser:
|
||||
context = browser.new_context()
|
||||
if route:
|
||||
context.route("**/*", lambda r: r.continue_())
|
||||
page = context.new_page()
|
||||
page.on("request", lambda r: heard.append((r.method, r.url.rsplit("/", 1)[-1] or "page")))
|
||||
page.goto(two_origins, wait_until="load")
|
||||
def pump():
|
||||
page.wait_for_timeout(100) # the events of a sync client are delivered while it calls the browser
|
||||
|
||||
# The fetches are the page's own; each one's preflight reaches the server BEFORE its GET, so once the server
|
||||
# has seen both GETs every OPTIONS the browser would make has been made.
|
||||
assert wait_until(lambda: sum(1 for m, _ in list(_Api.hits) if m == "GET") >= 2, 30, pump), (
|
||||
"the page's two fetches never reached the server: %r" % _Api.hits)
|
||||
# An absence is asserted after a sentinel: a request made only now, after everything above. The client hears
|
||||
# its events in the order they happened, so when it hears the sentinel it has heard every event before it, and
|
||||
# a preflight that was going to be reported is in `heard` by then (no clock decides what "nothing came" means).
|
||||
page.evaluate("() => fetch('/sentinel').then((r) => r.status)") # same origin as the page: no preflight
|
||||
assert wait_until(lambda: any(name == "sentinel" for _m, name in heard), 30, pump), (
|
||||
"the client never heard the sentinel request; it heard %r" % heard)
|
||||
heard[:] = [(m, name) for m, name in heard if name != "sentinel"]
|
||||
assert ("OPTIONS", "/one") in _Api.hits or ("OPTIONS", "/two") in _Api.hits, "the browser made no preflight: %r" % _Api.hits
|
||||
methods = sorted(m for m, _ in heard)
|
||||
assert methods == ["GET", "GET", "GET"], "the client heard %r (the server saw %r)" % (heard, _Api.hits)
|
||||
@@ -20,7 +20,6 @@ from __future__ import annotations
|
||||
import dataclasses
|
||||
import http.server
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -291,8 +290,9 @@ STORE_PAGE = b"""<!doctype html><html><body>
|
||||
<input id="store">
|
||||
<script>
|
||||
window.__events = [];
|
||||
// e.timeStamp: when the browser made the event, not when this handler ran (a loaded machine runs two handlers together)
|
||||
for (const k of ['focus', 'keydown'])
|
||||
document.addEventListener(k, e => __events.push([k, performance.now()]), true);
|
||||
document.addEventListener(k, e => __events.push([k, e.timeStamp]), true);
|
||||
const answer = +(new URLSearchParams(location.search).get('answer') || 600);
|
||||
store.addEventListener('focus', () => setTimeout(() => { store.value = ''; }, answer));
|
||||
</script></body></html>"""
|
||||
@@ -343,9 +343,7 @@ def test_a_store_that_answers_the_focus_does_not_eat_the_text(firefox_binary, st
|
||||
with InvisiblePlaywright(seed=seed, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(store_url)
|
||||
started = time.monotonic()
|
||||
getattr(page.locator("#store"), how)(TEXT)
|
||||
took = time.monotonic() - started
|
||||
value = page.input_value("#store")
|
||||
events = page.evaluate("__events")
|
||||
assert value == TEXT, "the field holds %r after %s" % (value, how)
|
||||
@@ -354,7 +352,11 @@ def test_a_store_that_answers_the_focus_does_not_eat_the_text(firefox_binary, st
|
||||
assert (first - focus) / 1000 >= ANSWER_MS / 1000, (
|
||||
"the first key came %.0f ms after the focus, before the store's "
|
||||
"answer at %d ms" % (first - focus, ANSWER_MS))
|
||||
# The pause is a pause, not a stall: one hesitation (restarted once, by
|
||||
# the store's write) on top of the typing itself.
|
||||
assert took < 2 * pause + ANSWER_MS / 1000 + 0.4 * len(TEXT), (
|
||||
"%s took %.1f s" % (how, took))
|
||||
# The pause is a pause, not a stall: one hesitation (restarted once, by the store's write) on top of the store's
|
||||
# answer. Judged on the browser's own stamps of the focus and of the first key, so the speed of the machine that
|
||||
# drives the browser (which made the duration of the whole call, typing included, 11.3 s against a bound of
|
||||
# 10.3 s on a loaded Windows runner) is not in the verdict; a pause that stalls (three hesitations, or the pause
|
||||
# taken again at every key) is still past this bound. How fast the text is typed is the rhythm tests' business.
|
||||
assert (first - focus) / 1000 <= ANSWER_MS / 1000 + 2 * pause, (
|
||||
"%s: the first key came %.0f ms after the focus; the store answers at %d ms and one hesitation is %.0f ms, "
|
||||
"restarted at most once" % (how, first - focus, ANSWER_MS, pause * 1000))
|
||||
@@ -23,7 +23,7 @@ import pytest
|
||||
from _servers import LocalServer
|
||||
|
||||
READ = """() => new Promise(resolve => {
|
||||
const timer = setTimeout(() => resolve({timeout: true}), 8000);
|
||||
const timer = setTimeout(() => resolve({timeout: true}), 30000);
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
p => { clearTimeout(timer); resolve({lat: p.coords.latitude, lon: p.coords.longitude}); },
|
||||
e => { clearTimeout(timer); resolve({error: e.code, message: e.message}); });
|
||||
|
||||
@@ -6,18 +6,30 @@ network by those events (tf-fetch's network recorder does) never knew the reques
|
||||
|
||||
The page asks for the same address four ways. `plain` is the control (a fetch without keepalive), `keepalive` and
|
||||
`beacon` are the two that the engine runs in the parent process, and each must give exactly one `request` and one end.
|
||||
|
||||
The test waits for what the product promises, not for a time: until every request that began has its end (and the four
|
||||
have begun), with a deadline of 15 s that no healthy run comes near. A product that loses an end stays red, because the
|
||||
deadline passes; a slow machine only takes longer. The message gives every event with the time it was heard, from the
|
||||
goto, so a red run says whether the end came late or never.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import Timeline, wait_until, without_end
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
EXPECTED = ["/seen/beacon", "/seen/keepalive", "/seen/keepalive-nocors", "/seen/plain"]
|
||||
|
||||
#: Far beyond what a healthy run needs (a few hundred ms); it is the only clock the verdict has.
|
||||
DEADLINE = 15.0
|
||||
|
||||
PAGE = b"""<!doctype html><title>keepalive</title><script>
|
||||
addEventListener('load', () => {
|
||||
fetch('/seen/plain', {method: 'POST', body: 'x'});
|
||||
@@ -40,13 +52,18 @@ class _Handler(BaseHTTPRequestHandler):
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def _heard(self):
|
||||
self.server.timeline.add("server", "%s %s" % (self.command, self.path))
|
||||
|
||||
def do_GET(self):
|
||||
self._heard()
|
||||
if self.path == "/":
|
||||
self._answer(PAGE, "text/html; charset=utf-8")
|
||||
else:
|
||||
self._answer(b"ok")
|
||||
|
||||
def do_POST(self):
|
||||
self._heard()
|
||||
self.rfile.read(int(self.headers.get("Content-Length") or 0))
|
||||
self._answer(b"ok")
|
||||
|
||||
@@ -54,9 +71,10 @@ class _Handler(BaseHTTPRequestHandler):
|
||||
@pytest.fixture
|
||||
def site():
|
||||
srv = LocalServer(("127.0.0.1", 0), _Handler)
|
||||
srv.timeline = Timeline()
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
try:
|
||||
yield "http://127.0.0.1:%d" % srv.server_address[1]
|
||||
yield SimpleNamespace(url="http://127.0.0.1:%d" % srv.server_address[1], timeline=srv.timeline)
|
||||
finally:
|
||||
srv.shutdown()
|
||||
srv.server_close()
|
||||
@@ -66,19 +84,36 @@ def site():
|
||||
def test_every_request_of_the_page_reaches_the_client_with_its_end(firefox_binary, site, route):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
started, ended = [], []
|
||||
timeline = site.timeline
|
||||
|
||||
def short(url):
|
||||
return url.replace(site.url, "")
|
||||
|
||||
with InvisiblePlaywright(seed=4261, binary_path=firefox_binary, headless=True) as browser:
|
||||
context = browser.new_context()
|
||||
if route:
|
||||
context.route("**/*", lambda r: r.continue_())
|
||||
def handler(r):
|
||||
timeline.add("route", short(r.request.url))
|
||||
r.continue_()
|
||||
context.route("**/*", handler)
|
||||
page = context.new_page()
|
||||
page.on("request", lambda r: started.append(r.url.replace(site, "")))
|
||||
page.on("requestfinished", lambda r: ended.append(r.url.replace(site, "")))
|
||||
page.on("requestfailed", lambda r: ended.append(r.url.replace(site, "")))
|
||||
page.goto(site + "/", wait_until="load")
|
||||
page.wait_for_timeout(2000) # the client is a sync one: events are delivered while it calls the browser
|
||||
seen = sorted(u for u in started if u.startswith("/seen/"))
|
||||
assert seen == ["/seen/beacon", "/seen/keepalive", "/seen/keepalive-nocors", "/seen/plain"], \
|
||||
"the client heard these requests: %r" % started
|
||||
assert sorted(u for u in ended if u.startswith("/seen/")) == seen, \
|
||||
"requests without an end for the client: %r" % sorted(set(seen) - set(ended))
|
||||
page.on("request", lambda r: timeline.add("request", short(r.url)))
|
||||
page.on("requestfinished", lambda r: timeline.add("finished", short(r.url)))
|
||||
page.on("requestfailed", lambda r: timeline.add("failed", short(r.url)))
|
||||
|
||||
def of_the_page(kinds):
|
||||
return [u for u in timeline.of(*kinds) if u.startswith("/seen/")]
|
||||
|
||||
timeline.begin()
|
||||
page.goto(site.url + "/", wait_until="load")
|
||||
# The client is a sync one: events are delivered while it calls the browser, so the wait is a call.
|
||||
# What is awaited: the four requests have begun, and every request that began has its end.
|
||||
wait_until(lambda: sorted(set(of_the_page(["request"]))) == EXPECTED
|
||||
and not without_end(of_the_page(["request"]), of_the_page(["finished", "failed"])),
|
||||
DEADLINE, lambda: page.wait_for_timeout(50))
|
||||
started, ended = of_the_page(["request"]), of_the_page(["finished", "failed"])
|
||||
events = "\nevents, from the goto:\n" + timeline.render()
|
||||
assert sorted(started) == EXPECTED, "the client heard these requests: %r (after %.0f s)%s" % (
|
||||
started, DEADLINE, events)
|
||||
assert sorted(ended) == sorted(started), "requests without an end for the client: %r%s" % (
|
||||
without_end(started, ended), events)
|
||||
@@ -0,0 +1,154 @@
|
||||
"""A launch of an e2e test is told where it leaves from; no service of the internet is asked (no browser).
|
||||
|
||||
The core's ``prepare_session_geo`` asks ``discover_egress_ip`` for the exit of a session, and with no proxy that is an HTTP request to three "what is my
|
||||
address" services. ``tests/_lab_egress.py`` and the session fixture ``_the_lab_declares_the_exit`` of ``tests/conftest.py`` declare the exit of the lab
|
||||
instead, so that the 222 launches that name neither ``timezone=`` nor ``proxy=`` depend on nothing outside the machine. This file is the proof, on the
|
||||
real composition of a session and with every way out of the process closed:
|
||||
|
||||
* a session composed with the declared exit asks the core's discovery once, gets the zone and the language of the lab database, and opens no
|
||||
connection and resolves no name (the socket and the resolver raise, and ``requests`` is not called);
|
||||
* the same with a zone named by the caller: the question is still asked, and still answered here;
|
||||
* a question behind a proxy is not answered here: it goes to what answered it before (the gateways of the tests answer it themselves);
|
||||
* the test that must prove the discovery itself gets the real function against an echo service on loopback, and the three services are not asked;
|
||||
* the conftest holds the declaration for the whole session, and a module-scoped browser is launched after it.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import socket
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import _lab_egress
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
class _Closed(AssertionError):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def no_way_out(monkeypatch):
|
||||
"""Every way out of the process raises: the connect, the name lookup, the request. What an offline runner does, said loudly."""
|
||||
tried = []
|
||||
|
||||
def closed(what):
|
||||
def refuse(*args, **kwargs):
|
||||
tried.append(what)
|
||||
raise _Closed("%s was asked: a launch of an e2e test must not leave the machine" % what)
|
||||
return refuse
|
||||
|
||||
monkeypatch.setattr(socket.socket, "connect", closed("socket.connect"))
|
||||
monkeypatch.setattr(socket, "create_connection", closed("socket.create_connection"))
|
||||
monkeypatch.setattr(socket, "getaddrinfo", closed("socket.getaddrinfo"))
|
||||
import requests
|
||||
|
||||
monkeypatch.setattr(requests.sessions.Session, "request", closed("requests"))
|
||||
return tried
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def declared(monkeypatch, tmp_path):
|
||||
"""What the session fixture of the conftest installs, installed for one test (the same function, with the patch of the test)."""
|
||||
monkeypatch.delenv("STEALTHFOX_GEOIP_MMDB", raising=False)
|
||||
exit_ = _lab_egress.install(monkeypatch, tmp_path)
|
||||
assert exit_ is not None
|
||||
return exit_
|
||||
|
||||
|
||||
def test_a_session_composed_with_the_declared_exit_opens_no_connection_and_gets_the_zone_of_the_lab(declared, no_way_out):
|
||||
from invisible_core import prepare_session_geo
|
||||
|
||||
geo = prepare_session_geo("", None, "auto", seed=7)
|
||||
assert no_way_out == [], "the composition left the machine: %s" % no_way_out
|
||||
assert declared.direct_questions == 1 and declared.proxied_questions == []
|
||||
assert geo.egress_ip == _lab_egress.LAB_EGRESS_IP
|
||||
assert geo.timezone == "America/New_York" and geo.locale.primary == "en-US", (geo.timezone, geo.locale)
|
||||
|
||||
|
||||
def test_a_zone_named_by_the_caller_does_not_make_the_launch_ask_the_internet(declared, no_way_out):
|
||||
from invisible_core import prepare_session_geo
|
||||
|
||||
geo = prepare_session_geo("Europe/Rome", None, "auto", seed=7)
|
||||
assert no_way_out == []
|
||||
assert declared.direct_questions == 1, "the core asks for the exit even when the zone is named: the question must be answered here"
|
||||
assert geo.timezone == "Europe/Rome" and geo.egress_ip == _lab_egress.LAB_EGRESS_IP
|
||||
|
||||
|
||||
def test_the_lab_exit_is_a_public_address_the_lab_database_answers_as_new_york(tmp_path):
|
||||
import ipaddress
|
||||
|
||||
import maxminddb
|
||||
|
||||
assert ipaddress.ip_address(_lab_egress.LAB_EGRESS_IP).is_global, "a reserved address is refused by the core as not routable"
|
||||
path = tmp_path / "lab.mmdb"
|
||||
path.write_bytes(_lab_egress.lab_database_bytes())
|
||||
with maxminddb.open_database(str(path)) as reader:
|
||||
record = reader.get(_lab_egress.LAB_EGRESS_IP)
|
||||
assert record["country"]["iso_code"] == "US" and record["location"]["time_zone"] == "America/New_York", record
|
||||
|
||||
|
||||
def test_a_question_behind_a_proxy_goes_to_what_answered_it_before(monkeypatch):
|
||||
asked = []
|
||||
|
||||
def before(proxy=None, *args, **kwargs):
|
||||
asked.append(proxy)
|
||||
return "203.0.113.9"
|
||||
|
||||
exit_ = _lab_egress.DeclaredExit(before)
|
||||
proxy = {"server": "socks5://127.0.0.1:9"}
|
||||
assert exit_(None) == _lab_egress.LAB_EGRESS_IP and asked == []
|
||||
assert exit_({}) == _lab_egress.LAB_EGRESS_IP and asked == []
|
||||
assert exit_(proxy, timeout=3) == "203.0.113.9" and asked == [proxy]
|
||||
assert exit_.direct_questions == 2 and exit_.proxied_questions == ["socks5://127.0.0.1:9"]
|
||||
|
||||
|
||||
def test_a_test_that_replaces_the_question_goes_back_to_the_declared_exit_not_to_the_network(monkeypatch, tmp_path):
|
||||
"""The order a session makes: the fixture of the session installs first, the test's own ``monkeypatch`` replaces and then undoes."""
|
||||
from invisible_core import _geo
|
||||
|
||||
with pytest.MonkeyPatch.context() as session:
|
||||
session.setenv("STEALTHFOX_GEOIP_MMDB", str(tmp_path / "set-by-a-leg"))
|
||||
declared = _lab_egress.install(session, tmp_path)
|
||||
with pytest.MonkeyPatch.context() as test:
|
||||
test.setattr(_geo, "discover_egress_ip", lambda *a, **k: "203.0.113.5")
|
||||
assert _geo.discover_egress_ip(None) == "203.0.113.5"
|
||||
assert _geo.discover_egress_ip(None) == _lab_egress.LAB_EGRESS_IP and declared.direct_questions == 1
|
||||
|
||||
|
||||
def test_a_database_set_by_a_leg_is_left_alone_and_none_is_made_when_not_set(monkeypatch, tmp_path):
|
||||
monkeypatch.setenv("STEALTHFOX_GEOIP_MMDB", str(tmp_path / "pinned.mmdb"))
|
||||
assert _lab_egress.use_the_lab_database(monkeypatch, tmp_path / "made") is None and not (tmp_path / "made").exists()
|
||||
monkeypatch.delenv("STEALTHFOX_GEOIP_MMDB")
|
||||
made = _lab_egress.use_the_lab_database(monkeypatch, tmp_path / "made")
|
||||
import os
|
||||
|
||||
assert made is not None and made.read_bytes() == _lab_egress.lab_database_bytes() and os.environ["STEALTHFOX_GEOIP_MMDB"] == str(made)
|
||||
|
||||
|
||||
def test_the_real_discovery_is_proved_against_an_echo_service_on_loopback(local_egress_echo):
|
||||
from invisible_core import _geo
|
||||
|
||||
found = _geo.discover_egress_ip(None)
|
||||
assert found == _lab_egress.LAB_EGRESS_IP
|
||||
assert local_egress_echo.questions == 1, "the real function asked %d time(s) and only the echo of the test may be asked" % local_egress_echo.questions
|
||||
assert all(url.startswith("http://127.0.0.1:") for url in _geo._IP_ECHO_ENDPOINTS)
|
||||
|
||||
|
||||
def test_the_conftest_declares_the_exit_for_the_whole_session_and_before_any_module_browser():
|
||||
tree = ast.parse((TESTS / "conftest.py").read_text(encoding="utf-8"))
|
||||
fixtures = {}
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.FunctionDef):
|
||||
for decorator in node.decorator_list:
|
||||
if isinstance(decorator, ast.Call) and getattr(decorator.func, "attr", "") == "fixture":
|
||||
fixtures[node.name] = {kw.arg: getattr(kw.value, "value", None) for kw in decorator.keywords}
|
||||
declaration = fixtures.get("_the_lab_declares_the_exit")
|
||||
assert declaration == {"scope": "session", "autouse": True}, (
|
||||
"the exit of the lab is declared by an autouse fixture of SESSION scope (a module-scoped browser is launched before any function-scoped one): %r"
|
||||
% (declaration,))
|
||||
assert fixtures["browser"].get("scope") == "module", "the conftest's module browser is the reason for the scope above"
|
||||
@@ -105,7 +105,7 @@ def test_a_bare_launch_behind_a_proxy_is_composed_through_it(firefox_binary, mon
|
||||
from invisible_core._geo import SessionGeo
|
||||
from invisible_playwright import _session
|
||||
from invisible_playwright._pw.sync_api import sync_playwright
|
||||
from _socks_servers import Socks5TcpOnly
|
||||
from _socks_servers import STUN_NUMBER, STUN_PORT, Socks5TcpOnly
|
||||
from test_webrtc_realness import _PROBE_JS, candidates, host_is_mdns
|
||||
|
||||
egress = "203.0.113.7"
|
||||
@@ -141,7 +141,7 @@ def test_a_bare_launch_behind_a_proxy_is_composed_through_it(firefox_binary, mon
|
||||
try:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto("http://127.0.0.1:%d/" % httpd.server_address[1], wait_until="domcontentloaded")
|
||||
res = page.evaluate(_PROBE_JS)
|
||||
res = page.evaluate(_PROBE_JS, "stun:%s:%d" % (STUN_NUMBER, STUN_PORT))
|
||||
finally:
|
||||
browser.close()
|
||||
finally:
|
||||
|
||||
@@ -23,6 +23,7 @@ import threading
|
||||
import pytest
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
@@ -57,6 +58,13 @@ def _serve():
|
||||
return server, "http://127.0.0.1:%d" % server.server_address[1]
|
||||
|
||||
|
||||
def _heard(page, responses, names):
|
||||
"""Until the client has heard the response of each name (the events of a sync client are delivered while it calls
|
||||
the browser), with a deadline far beyond a healthy run: a machine's speed is not the verdict."""
|
||||
assert wait_until(lambda: all(name in responses for name in names), 30, lambda: page.wait_for_timeout(100)), (
|
||||
"the client never heard %r; it heard %r" % ([n for n in names if n not in responses], sorted(responses)))
|
||||
|
||||
|
||||
def test_the_body_of_a_document_the_tab_left_is_evicted(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-60")
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
@@ -69,12 +77,12 @@ def test_the_body_of_a_document_the_tab_left_is_evicted(firefox_binary, engine_a
|
||||
page.on("response", lambda r: responses.setdefault(r.url.rsplit("/", 1)[-1], r))
|
||||
|
||||
page.goto(base + "/a.html", wait_until="load", timeout=20_000)
|
||||
page.wait_for_timeout(300)
|
||||
_heard(page, responses, ("a.html", "a.css", "a.js"))
|
||||
assert b"document A" in responses["a.html"].body()
|
||||
assert b"/* A */" in responses["a.css"].body(), "the current document's sub-resource is readable"
|
||||
|
||||
page.goto(base + "/b.html", wait_until="load", timeout=20_000)
|
||||
page.wait_for_timeout(300)
|
||||
_heard(page, responses, ("b.html", "b.js"))
|
||||
assert b"document B" in responses["b.html"].body(), "the document that committed keeps its body"
|
||||
assert b"fromB" in responses["b.js"].body()
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ ON_WINDOWS = sys.platform == "win32"
|
||||
@pytest.mark.skipif(ON_WINDOWS, reason="the system theme is declared, and its absence refused, on Linux only")
|
||||
@pytest.mark.parametrize("pref", MISSING)
|
||||
def test_a_missing_pref_refuses_the_launch(firefox_binary, engine_at_least, pref):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
with pytest.raises(RuntimeError) as err:
|
||||
c, profile_dir = _launch(firefox_binary, pref)
|
||||
# Not reached when the engine refuses: close what must not be running.
|
||||
@@ -88,7 +88,7 @@ def test_a_missing_pref_refuses_the_launch(firefox_binary, engine_at_least, pref
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_every_pref_declared_the_launch_succeeds(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
c, profile_dir = _launch(firefox_binary, None)
|
||||
try:
|
||||
assert c.ready_seen, "the browser did not announce the protocol"
|
||||
|
||||
@@ -11,9 +11,9 @@ from pathlib import Path
|
||||
TESTS = str(Path(__file__).resolve().parent)
|
||||
|
||||
_BUILD = """
|
||||
from invisible_playwright._juggler.server import _ThreadStarter
|
||||
from invisible_playwright._juggler._threads import ThreadStarter
|
||||
def build():
|
||||
return _ThreadStarter(on_error=lambda message: None)
|
||||
return ThreadStarter(on_error=lambda message: None)
|
||||
"""
|
||||
|
||||
|
||||
@@ -81,3 +81,29 @@ def test_a_browser_shared_by_the_tests_of_a_module_may_stay_open_until_the_modul
|
||||
out = done.stdout + done.stderr
|
||||
assert done.returncode == 0, out
|
||||
assert "2 passed" in out, out
|
||||
|
||||
|
||||
def test_the_census_counts_a_starter_whose_thread_has_not_begun(monkeypatch):
|
||||
"""The starter's thread is begun without waiting for it, so right after the constructor it can be in no `threading.enumerate()`:
|
||||
the census must still count it (it missed both leaks of a module on a Linux runner, 3 of 3 jobs)."""
|
||||
import threading
|
||||
import time
|
||||
|
||||
sys.path.insert(0, TESTS)
|
||||
import _browser_census as census
|
||||
from invisible_playwright._juggler._threads import ThreadStarter
|
||||
|
||||
original = threading.Thread.start
|
||||
|
||||
def slow_start(self):
|
||||
time.sleep(0.3)
|
||||
return original(self)
|
||||
monkeypatch.setattr(threading.Thread, "start", slow_start)
|
||||
|
||||
before = len(census.starters_alive())
|
||||
starter = ThreadStarter(on_error=lambda message: None)
|
||||
try:
|
||||
assert len(census.starters_alive()) == before + 1
|
||||
finally:
|
||||
starter.stop()
|
||||
assert census.wait_until_back_to(before) == 0
|
||||
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from _waits import wait_until
|
||||
from stroke_shape import stroke_problems
|
||||
|
||||
PAGE = """<!doctype html><html><body style="margin:0">
|
||||
@@ -44,7 +45,6 @@ def test_a_stroke_from_standstill_does_not_open_with_the_point_it_stands_on(fire
|
||||
"""After a move that stopped on (500, 300) and a pause, the click's stroke
|
||||
begins at its first real step: the page's next `mousemove` is not (500, 300)
|
||||
again."""
|
||||
import time
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4252, binary_path=firefox_binary, headless=True,
|
||||
@@ -52,7 +52,9 @@ def test_a_stroke_from_standstill_does_not_open_with_the_point_it_stands_on(fire
|
||||
page = browser.new_context().new_page()
|
||||
page.set_content(PAGE)
|
||||
page.mouse.move(500, 300)
|
||||
time.sleep(0.3)
|
||||
# until the page has heard the move end on its point (a condition with a deadline, not 0.3 s): the click below starts from a pointer at rest
|
||||
assert wait_until(lambda: (page.evaluate("window.moves") or [None])[-1] == [500, 300], 30,
|
||||
lambda: page.wait_for_timeout(50)), page.evaluate("window.moves")
|
||||
seen = len(page.evaluate("window.moves"))
|
||||
assert page.evaluate("window.moves")[-1] == [500, 300]
|
||||
page.mouse.click(400, 240)
|
||||
|
||||
@@ -77,12 +77,16 @@ class _Page:
|
||||
def test_a_page_the_engine_answers_after_35_s_is_still_a_page(monkeypatch):
|
||||
monkeypatch.setattr(srv, "PageDispatcher", _Page)
|
||||
engine = _SlowEngine()
|
||||
browser = BrowserDispatcher(Server(), None, engine, "151.0", session_seed=1)
|
||||
server = Server()
|
||||
browser = BrowserDispatcher(server, None, engine, "151.0", session_seed=1)
|
||||
engine.browser = browser
|
||||
context = BrowserContextDispatcher(browser.server, browser, {}, "C1")
|
||||
browser.contexts.append(context)
|
||||
|
||||
result = context.op_new_page({"pageNumber": 0})
|
||||
try:
|
||||
result = context.op_new_page({"pageNumber": 0})
|
||||
finally:
|
||||
server.shutdown() # the connection's one starter ends with its server
|
||||
|
||||
assert result == {"page": {"guid": "page-T0"}}
|
||||
assert engine.bounds == [None], (
|
||||
|
||||
@@ -55,29 +55,31 @@ _WORKER = r"""(urls) => {
|
||||
#: same security check before anything is read, so what can differ is the
|
||||
#: answer, and the answer is compared.
|
||||
_CHANNELS = r"""async (url) => {
|
||||
const settle = (p, ms = 3000) => Promise.race([p, new Promise(r => setTimeout(() => r("no answer"), ms))]);
|
||||
const out = {};
|
||||
out.worker = await settle(new Promise(r => {
|
||||
// Every channel is asked at once and each has 30 s to answer: "no answer" is a channel that stays silent, and the deadline is the wait's, far beyond any
|
||||
// healthy run. A name that is nowhere answers every channel (an error, a throw, a rejection), so no silence is waited for when the engine's file looks like it.
|
||||
const settle = (p, ms = 30000) => Promise.race([p, new Promise(r => setTimeout(() => r("no answer"), ms))]);
|
||||
const channels = {};
|
||||
channels.worker = new Promise(r => {
|
||||
try {
|
||||
const w = new Worker(url);
|
||||
w.onerror = e => { e.preventDefault(); r("error event: " + (e.message || "")); };
|
||||
w.onmessage = () => r("message");
|
||||
} catch (e) { r("throws " + e.name); }
|
||||
}));
|
||||
out.module_worker = await settle(new Promise(r => {
|
||||
});
|
||||
channels.module_worker = new Promise(r => {
|
||||
try {
|
||||
const w = new Worker(url, {type: "module"});
|
||||
w.onerror = e => { e.preventDefault(); r("error event: " + (e.message || "")); };
|
||||
} catch (e) { r("throws " + e.name); }
|
||||
}));
|
||||
out.shared_worker = await settle(new Promise(r => {
|
||||
});
|
||||
channels.shared_worker = new Promise(r => {
|
||||
try {
|
||||
const w = new SharedWorker(url);
|
||||
w.onerror = e => { e.preventDefault(); r("error event"); };
|
||||
} catch (e) { r("throws " + e.name); }
|
||||
}));
|
||||
out.fetch = await settle(fetch(url).then(res => "status " + res.status, e => "rejects " + e.name));
|
||||
out.xhr = await settle(new Promise(r => {
|
||||
});
|
||||
channels.fetch = fetch(url).then(res => "status " + res.status, e => "rejects " + e.name);
|
||||
channels.xhr = new Promise(r => {
|
||||
const seen = [];
|
||||
try {
|
||||
const x = new XMLHttpRequest();
|
||||
@@ -86,18 +88,22 @@ _CHANNELS = r"""async (url) => {
|
||||
x.open("GET", url);
|
||||
x.send();
|
||||
} catch (e) { r("throws " + e.name); }
|
||||
}));
|
||||
out.import = await settle(import(url).then(() => "loaded", e => "rejects " + e.name));
|
||||
});
|
||||
channels.import = import(url).then(() => "loaded", e => "rejects " + e.name);
|
||||
for (const [tag, attr] of [["script", "src"], ["img", "src"], ["link", "href"], ["iframe", "src"]]) {
|
||||
out[tag] = await settle(new Promise(r => {
|
||||
channels[tag] = new Promise(r => {
|
||||
const el = document.createElement(tag);
|
||||
if (tag === "link") el.rel = "stylesheet";
|
||||
el.onload = () => r("load");
|
||||
el.onerror = () => r("error");
|
||||
el[attr] = url;
|
||||
document.body.appendChild(el);
|
||||
}), 1500);
|
||||
});
|
||||
}
|
||||
const names = Object.keys(channels);
|
||||
const answers = await Promise.all(names.map(n => settle(channels[n])));
|
||||
const out = {};
|
||||
names.forEach((n, i) => { out[n] = answers[i]; });
|
||||
return out;
|
||||
}"""
|
||||
|
||||
|
||||
@@ -30,7 +30,14 @@ _GATHER_JS = r"""async () => {
|
||||
const cands = [];
|
||||
pc.addEventListener('icecandidate', e => { if (e.candidate && e.candidate.candidate) cands.push(e.candidate.candidate); });
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await new Promise(r => setTimeout(r, 2500));
|
||||
// Until the gathering says it is over, not for a fixed time: how long a gathering takes is the speed of the machine, whether it ends is the product.
|
||||
// The deadline is far beyond any healthy run; a gathering that never completes returns what it has, and the assertions on the candidates fail on it.
|
||||
await new Promise(resolve => {
|
||||
const timer = setTimeout(resolve, 30000);
|
||||
const done = () => { if (pc.iceGatheringState === 'complete') { clearTimeout(timer); resolve(); } };
|
||||
pc.addEventListener('icegatheringstatechange', done);
|
||||
done();
|
||||
});
|
||||
try { pc.close(); } catch (e) {}
|
||||
return cands;
|
||||
}"""
|
||||
|
||||
@@ -43,7 +43,6 @@ from __future__ import annotations
|
||||
|
||||
import http.server
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -54,20 +53,19 @@ ROUNDS = 5
|
||||
|
||||
def _goto(page, url, **kwargs):
|
||||
"""`page.goto`, which may answer that the previous page's own redirect won
|
||||
(module docstring). Either answer comes in seconds."""
|
||||
(module docstring). The detector of a navigation that never answers is the timeout of the `goto` itself (each caller passes
|
||||
one): a bound of the test stricter than it only judged the speed of the machine."""
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
started = time.monotonic()
|
||||
try:
|
||||
page.goto(url, **kwargs)
|
||||
except Error as e:
|
||||
if "NS_BINDING_ABORTED" in str(e):
|
||||
# The page's own replace stopped ours: it is where it sent itself.
|
||||
page.wait_for_url("**/landed", timeout=10_000)
|
||||
page.wait_for_url("**/landed", timeout=30_000)
|
||||
else:
|
||||
assert "is interrupted by another navigation to" in str(e), e
|
||||
assert "/landed" in str(e).split("another navigation to")[1], e
|
||||
assert time.monotonic() - started < 10, url
|
||||
|
||||
|
||||
def _replace_after_load(ms: int, cross_site: bool) -> bytes:
|
||||
@@ -79,6 +77,24 @@ def _replace_after_load(ms: int, cross_site: bool) -> bytes:
|
||||
% (target, ms)).encode()
|
||||
|
||||
|
||||
def _replace_without_a_timer(held: bool, cross_site: bool) -> bytes:
|
||||
"""The page of a `networkidle` case: it replaces itself with no timer in it, so how fast the machine is cannot
|
||||
decide whether the move comes before the half second of quiet that `networkidle` waits for.
|
||||
|
||||
- ``held`` False: from inside the `load` handler itself, before `load` is even reported;
|
||||
- ``held`` True: when the first bytes of a response the server holds open arrive. That request is in flight until
|
||||
the navigation aborts it, so the network is not quiet for as long as the page has not moved, whatever the load
|
||||
on the machine."""
|
||||
target = ("location.origin.replace('127.0.0.1','localhost')+'/landed'"
|
||||
if cross_site else "'/landed'")
|
||||
if held:
|
||||
script = ("addEventListener('load', () => fetch('/hold').then(r => r.body.getReader().read())"
|
||||
".then(() => location.replace(%s)))" % target)
|
||||
else:
|
||||
script = "addEventListener('load', () => location.replace(%s))" % target
|
||||
return ("<!doctype html><html><body><p id=p>first</p><script>%s</script></body></html>" % script).encode()
|
||||
|
||||
|
||||
PAGES = {
|
||||
"/head": (b"<!doctype html><html><head><script>location.replace('/landed')"
|
||||
b"</script></head><body><p id=p>head</p></body></html>"),
|
||||
@@ -89,12 +105,33 @@ PAGES = {
|
||||
for _ms in (0, 50, 300):
|
||||
PAGES["/r%d" % _ms] = _replace_after_load(_ms, False)
|
||||
PAGES["/x%d" % _ms] = _replace_after_load(_ms, True)
|
||||
# the networkidle cases: "/ir0" and "/ix0" move inside the load handler, "/ir50" and "/ix50" when the held response
|
||||
# starts to arrive (the 0 and the 50 of the names are the cases of the old timers)
|
||||
for _name, _held in (("0", False), ("50", True)):
|
||||
PAGES["/ir" + _name] = _replace_without_a_timer(_held, False)
|
||||
PAGES["/ix" + _name] = _replace_without_a_timer(_held, True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def site():
|
||||
release = threading.Event()
|
||||
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path.split("?")[0] == "/hold":
|
||||
# a response that has begun and does not end: 16 KiB so the first chunk is delivered at once,
|
||||
# then it stays open until the page that asked for it moves away (or the module's teardown)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.end_headers()
|
||||
try:
|
||||
self.wfile.write(b"x" * 16384)
|
||||
self.wfile.flush()
|
||||
except OSError:
|
||||
return
|
||||
release.wait(60)
|
||||
return
|
||||
body = PAGES.get(self.path.split("?")[0], PAGES["/landed"])
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
@@ -111,6 +148,7 @@ def site():
|
||||
srv.daemon_threads = True
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
yield "http://127.0.0.1:%d" % srv.server_address[1]
|
||||
release.set()
|
||||
srv.shutdown()
|
||||
|
||||
|
||||
@@ -128,7 +166,7 @@ def page(firefox_binary):
|
||||
def test_a_read_right_after_goto_answers(page, site, path):
|
||||
for i in range(ROUNDS):
|
||||
_goto(page, "%s%s?i=%d" % (site, path, i), wait_until="domcontentloaded",
|
||||
timeout=15_000)
|
||||
timeout=30_000)
|
||||
# Each read is made at once, while the page may still be moving: none
|
||||
# of them may surface the engine's refusal of a vanished world. A count
|
||||
# is of the page as it is NOW, and that can be the replacing document
|
||||
@@ -142,7 +180,7 @@ def test_a_read_right_after_goto_answers(page, site, path):
|
||||
texts = ([], ["first"], ["head"], ["landed"])
|
||||
assert page.locator("#p").all_inner_texts() in texts
|
||||
assert page.locator("#p").all_text_contents() in texts
|
||||
assert page.inner_text("#p", timeout=10_000) in ("first", "head",
|
||||
assert page.inner_text("#p", timeout=30_000) in ("first", "head",
|
||||
"landed")
|
||||
# The caller's code is NOT a read: it is sent once ([B285]). On a page
|
||||
# still moving - `/x50` replaces itself after the read above - it
|
||||
@@ -158,9 +196,12 @@ def test_a_read_right_after_goto_answers(page, site, path):
|
||||
|
||||
@pytest.mark.parametrize("path", ["/r0", "/r50", "/x0", "/x50"])
|
||||
def test_networkidle_is_reached_on_the_page_that_replaced_ours(page, site, path):
|
||||
"""The page moves with no timer (`_replace_without_a_timer`): `networkidle` promises half a second without
|
||||
network, and that cannot pass before the move however slow the machine is. A `networkidle` that comes back on the
|
||||
first page, or never comes back because the new frame forgot the navigation, is still red."""
|
||||
for i in range(ROUNDS):
|
||||
_goto(page, "%s%s?n=%d" % (site, path, i), wait_until="networkidle",
|
||||
timeout=15_000)
|
||||
_goto(page, "%s/i%s?n=%d" % (site, path[1:], i), wait_until="networkidle",
|
||||
timeout=30_000)
|
||||
assert page.url.endswith("/landed"), page.url
|
||||
|
||||
|
||||
@@ -192,7 +233,7 @@ def test_reads_wait_as_playwright_s_do(page, site):
|
||||
page.evaluate("setTimeout(() => { const b = document.createElement('b');"
|
||||
" b.id = 'late'; b.textContent = 'late';"
|
||||
" document.body.appendChild(b); }, 500)")
|
||||
assert page.inner_text("#late", timeout=5_000) == "late"
|
||||
assert page.inner_text("#late", timeout=30_000) == "late"
|
||||
from invisible_playwright.sync_api import TimeoutError as PlaywrightTimeout
|
||||
with pytest.raises(PlaywrightTimeout, match="Timeout 300ms exceeded"):
|
||||
page.inner_text("#never", timeout=300)
|
||||
|
||||
@@ -22,6 +22,8 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from _waits import wait_until
|
||||
|
||||
PAGE = """<!doctype html><html><body style="margin:0">
|
||||
<button id="b" style="width:300px;height:200px">b</button>
|
||||
<script>
|
||||
@@ -62,13 +64,16 @@ def test_each_pointer_call_answers_after_the_page_handled_its_event(firefox_bina
|
||||
"not wait for the page" % (step, took * 1000))
|
||||
|
||||
|
||||
@pytest.mark.wall_clock
|
||||
@pytest.mark.e2e
|
||||
def test_a_click_that_opens_a_dialog_still_answers(firefox_binary):
|
||||
"""The wait ends when the event's handler opens a dialog: the handler runs
|
||||
the dialog inside itself, so the page handles the event only once the
|
||||
dialog is closed - and closing it is the caller's business, after the call
|
||||
has answered. Without that end, this click would hang until the bound."""
|
||||
has answered. Without that end, this click would hang until the engine's
|
||||
bound, which is 5 s and an error (`PageHandler._awaitBounded`): the call
|
||||
raises instead of answering. The dialog stays open until the call has
|
||||
returned, so the call can have answered only by the dialog's end of the
|
||||
wait, not because the handler finished; no clock is read."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4248, binary_path=firefox_binary, headless=True,
|
||||
@@ -76,11 +81,13 @@ def test_a_click_that_opens_a_dialog_still_answers(firefox_binary):
|
||||
page = browser.new_context().new_page()
|
||||
page.set_content('<button id="b" style="width:300px;height:200px" '
|
||||
'onclick="alert(1); window.after = true">b</button>')
|
||||
seen = []
|
||||
page.on("dialog", lambda d: (seen.append(d.message), d.dismiss()))
|
||||
started = time.perf_counter()
|
||||
opened = []
|
||||
page.on("dialog", lambda dialog: opened.append(dialog)) # a plain function: the client tags its handlers
|
||||
# raises (the engine's "did not handle ... within 5 s") if the call waited for the handler
|
||||
page.mouse.click(150, 100)
|
||||
took = time.perf_counter() - started
|
||||
page.wait_for_function("window.after === true", timeout=5_000)
|
||||
assert seen == ["1"], seen
|
||||
assert took < 4.0, "the click waited %.1f s for a page held by its dialog" % took
|
||||
# the dialog event comes before the reply of the call; the pump only lets a late one be read
|
||||
assert wait_until(lambda: opened, 30, lambda: page.wait_for_timeout(50)), (
|
||||
"the click answered without the dialog having been heard")
|
||||
assert [d.message for d in opened] == ["1"], opened
|
||||
opened[0].dismiss()
|
||||
page.wait_for_function("window.after === true", timeout=30_000)
|
||||
+8
-3
@@ -140,7 +140,10 @@ def test_a_popup_whose_destination_answers_after_25_seconds_is_reported_then(fir
|
||||
with page.expect_popup(timeout=45000) as info:
|
||||
page.click("#open25000")
|
||||
took = time.monotonic() - t0
|
||||
assert 24.0 < took < 40.0, "reported after %.1f s" % took
|
||||
# The lower bound is the server's: it answers after 25 s, so a popup announced before 24 s was announced
|
||||
# before it was ready. There is no upper bound of ours: the limit above is expect_popup's 45 s (a popup
|
||||
# dropped at 20 s, the defect this test is red on, ends in its timeout).
|
||||
assert took > 24.0, "reported after %.1f s, before the destination had answered" % took
|
||||
assert info.value.url == site + "slow?ms=25000"
|
||||
info.value.close()
|
||||
|
||||
@@ -166,11 +169,13 @@ def test_a_listener_registered_in_the_page_handler_hears_the_load_of_the_popup(f
|
||||
ctx.on("page", on_page)
|
||||
with page.expect_popup(timeout=20000) as info:
|
||||
page.click(opener)
|
||||
deadline = time.monotonic() + 5
|
||||
deadline = time.monotonic() + 30
|
||||
while not heard and time.monotonic() < deadline:
|
||||
page.wait_for_timeout(50)
|
||||
assert heard, "the listener registered in the handler of the page event never heard the load of the popup"
|
||||
assert waited and waited[0] < 8.0, "wait_for_load_state in the handler took %r" % (waited,) # at once; the limit is the machine's
|
||||
# wait_for_load_state in the handler has its own deadline (10 s, above): a wait that never returns raises
|
||||
# there and `waited` stays empty, which is red here. How long it took is the machine's, not a verdict.
|
||||
assert waited, "wait_for_load_state in the handler never returned"
|
||||
info.value.close()
|
||||
|
||||
_drive(mode, firefox_binary, body)
|
||||
@@ -0,0 +1,84 @@
|
||||
"""A port number of the harness is held on TCP and on UDP from the first look at it to its use, shown on real loopback sockets.
|
||||
|
||||
The picker used to prove that a number binds on UDP, keep the TCP server and CLOSE the UDP probe ("whoever needs the UDP socket binds it next":
|
||||
the HTTP/3 server did, after it had read its certificate and started its loop). In that window the number was held on TCP only: another picker of
|
||||
the harness could not take it (every picker binds TCP first), but any other bind of that UDP number could, the system's own pick of an ephemeral
|
||||
UDP port for another process first among them, and the caller's bind was refused (EADDRINUSE / WinError 10048) in a test that did nothing wrong.
|
||||
``bind_tcp_and_hold_udp`` returns the UDP socket too; the caller owns it. No browser.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import socketserver
|
||||
|
||||
import pytest
|
||||
|
||||
import _ports
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ADDRESS = "127.0.0.1"
|
||||
|
||||
|
||||
class _Handler(socketserver.BaseRequestHandler):
|
||||
def handle(self):
|
||||
pass
|
||||
|
||||
|
||||
def _tcp(address, number):
|
||||
return socketserver.TCPServer((address, number), _Handler)
|
||||
|
||||
|
||||
def _udp_bind(port):
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
sock.bind((ADDRESS, port))
|
||||
except OSError:
|
||||
sock.close()
|
||||
raise
|
||||
return sock
|
||||
|
||||
|
||||
def test_the_hold_variant_keeps_the_number_on_udp_and_tcp_until_the_caller_uses_it():
|
||||
tcp, port, udp = _ports.bind_tcp_and_hold_udp(ADDRESS, _tcp)
|
||||
try:
|
||||
assert udp.getsockname() == (ADDRESS, port) and tcp.server_address[1] == port
|
||||
with pytest.raises(OSError):
|
||||
_udp_bind(port) # nobody else can take the UDP number...
|
||||
with pytest.raises(OSError):
|
||||
_tcp(ADDRESS, port) # ...nor the TCP one
|
||||
udp.sendto(b"x", (ADDRESS, port)) # and the socket the caller got is a working one, bound to that number
|
||||
udp.settimeout(30)
|
||||
assert udp.recvfrom(10)[0] == b"x"
|
||||
finally:
|
||||
udp.close()
|
||||
tcp.server_close()
|
||||
|
||||
|
||||
class _Probe:
|
||||
closed = False
|
||||
|
||||
def bind(self, pair):
|
||||
raise OSError(10013, "forbidden by its access permissions")
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
|
||||
class _Refusing:
|
||||
AF_INET, SOCK_DGRAM = 2, 2
|
||||
|
||||
def __init__(self):
|
||||
self.opened = []
|
||||
|
||||
def socket(self, family, kind):
|
||||
self.opened.append(_Probe())
|
||||
return self.opened[-1]
|
||||
|
||||
|
||||
def test_the_hold_variant_closes_what_it_refused_and_says_why_when_it_finds_none(monkeypatch):
|
||||
layer = _Refusing()
|
||||
monkeypatch.setattr(_ports, "who_holds", lambda port: "; held by: nothing listed")
|
||||
with pytest.raises(RuntimeError, match="no port free for both TCP and UDP"):
|
||||
_ports.bind_tcp_and_hold_udp(ADDRESS, _tcp, tries=3, socket_module=layer)
|
||||
assert len(layer.opened) == 3 and all(probe.closed for probe in layer.opened), "a probe that was refused is closed, not kept"
|
||||
@@ -43,21 +43,23 @@ TURN_NUMBER = "198.51.100.7"
|
||||
TURN_NAME = "turn-a.test"
|
||||
TURN_PORT = 3478
|
||||
TURN_ZONE = {**ZONE, TURN_NAME: TURN_NUMBER}
|
||||
#: How long the page waits for the ICE agent to try the server, in milliseconds.
|
||||
WAIT_MS = 6000
|
||||
#: How long to wait for the DoH to be asked and for the gateway to be handed the address, in seconds.
|
||||
ASKED_SECONDS = 25
|
||||
#: How long to wait for the DoH to be asked and for the gateway to be handed the address, in seconds (the deadline of the wait).
|
||||
ASKED_SECONDS = 30
|
||||
|
||||
_PROBE_JS = """async ([url, waitMs]) => {
|
||||
const errors = [], found = [];
|
||||
const pc = new RTCPeerConnection({iceServers: [{urls: url, username: 'u', credential: 'p'}]});
|
||||
#: The page starts the ICE agent and leaves it alive; the test closes it AFTER it has seen the DoH asked and the gateway handed the address, so the agent is never
|
||||
#: closed before it has tried the server, whatever the speed of the machine (a timer of the page that closed it would judge that speed).
|
||||
_START_JS = """async (url) => {
|
||||
const probe = window.__probe = {errors: [], found: [], pc: null};
|
||||
const pc = probe.pc = new RTCPeerConnection({iceServers: [{urls: url, username: 'u', credential: 'p'}]});
|
||||
pc.createDataChannel('d');
|
||||
pc.onicecandidateerror = (e) => errors.push(e.errorCode);
|
||||
pc.onicecandidate = (e) => { if (e.candidate) found.push(e.candidate.candidate); };
|
||||
pc.onicecandidateerror = (e) => probe.errors.push(e.errorCode);
|
||||
pc.onicecandidate = (e) => { if (e.candidate) probe.found.push(e.candidate.candidate); };
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
||||
pc.close();
|
||||
return {errors, candidates: found.length};
|
||||
}"""
|
||||
_END_JS = """() => {
|
||||
const probe = window.__probe;
|
||||
probe.pc.close();
|
||||
return {errors: probe.errors, candidates: probe.found.length};
|
||||
}"""
|
||||
|
||||
|
||||
@@ -81,9 +83,10 @@ def test_a_turn_server_named_over_tcp_is_resolved_by_the_doh_through_the_proxy_o
|
||||
with _launch(firefox_binary, gw_launch.proxy if gw_launch else None) as browser:
|
||||
context, page = _page_in(browser, proxy=gw_context.proxy)
|
||||
page.goto(pages.url("page-a.test"), wait_until="load", timeout=30000)
|
||||
result = page.evaluate(_PROBE_JS, ["turn:%s:%d?transport=tcp" % (TURN_NAME, TURN_PORT), WAIT_MS])
|
||||
page.evaluate(_START_JS, "turn:%s:%d?transport=tcp" % (TURN_NAME, TURN_PORT))
|
||||
asked = ds.wait_until(lambda: doh.queries_for(TURN_NAME, QTYPE_A), ASKED_SECONDS)
|
||||
handed = ds.wait_until(lambda: (TURN_NUMBER, TURN_PORT) in gw_context.connects, ASKED_SECONDS)
|
||||
result = page.evaluate(_END_JS)
|
||||
context.close()
|
||||
watcher.stop()
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ from http.server import BaseHTTPRequestHandler
|
||||
|
||||
import pytest
|
||||
|
||||
from _bfcache_evidence import decide_outcome, read_after_go_back, wait_cacheable
|
||||
from _servers import LocalServer
|
||||
|
||||
STRATEGY_1 = {
|
||||
@@ -37,6 +38,21 @@ STRATEGY_1 = {
|
||||
"network.dns.localDomains": "a.test,b.test,c.test",
|
||||
}
|
||||
|
||||
# The lab holds still the two things of the HOST that decide whether a page the cache took is still there when the test goes back, so that the
|
||||
# memory of the runner does not decide whether the cache holds (a red then would say something about the machine, not about the engine):
|
||||
# * how many pages the cache keeps: by default `nsSHistory` computes it from the PHYSICAL memory of the machine (at most 8; nsSHistory.cpp
|
||||
# CalcMaxTotalViewers), here it is 8;
|
||||
# * the low-memory watcher: on Linux Firefox reads /proc/meminfo every second and, when what is available is under 5% of the total or under 200 MB,
|
||||
# sends memory-pressure, which evicts EVERY page of the cache (AvailableMemoryWatcherLinux.cpp, nsSHistory.cpp). Both thresholds at 0 here
|
||||
# (they are static prefs; the percent one exists on Linux only and is ignored elsewhere).
|
||||
# Nothing of this is in the product: a user's Firefox keeps both defaults, and so does ours.
|
||||
LAB_PREFS = {
|
||||
**STRATEGY_1,
|
||||
"browser.sessionhistory.max_total_viewers": 8,
|
||||
"browser.low_commit_space_threshold_percent": 0,
|
||||
"browser.low_commit_space_threshold_mb": 0,
|
||||
}
|
||||
|
||||
# What a document with a worker runs: the worker answers every message with its count.
|
||||
OWNER = """<script>
|
||||
window.__shown = [];
|
||||
@@ -113,6 +129,16 @@ def events(monkeypatch):
|
||||
return seen
|
||||
|
||||
|
||||
def _commit_order_is_promised():
|
||||
"""Whether the engine under test ends the workers of a document BEFORE it announces the commit that replaces it. Juggler f284ca703e
|
||||
(PageHandler._commitNow ends the workers below the frame first) is in firefox-63; the published firefox-62 does not promise the order, and
|
||||
main's e2e runs on both (run 43193233155: `Page.navigationCommitted` before `Page.workerDestroyed` on the published engine)."""
|
||||
from conftest import _engine_number
|
||||
from invisible_core.seal import active_seal
|
||||
|
||||
return (_engine_number(active_seal().tag) or 0) >= 63
|
||||
|
||||
|
||||
def _wait(check, seconds=10.0):
|
||||
end = time.monotonic() + seconds
|
||||
while time.monotonic() < end:
|
||||
@@ -144,7 +170,7 @@ def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(fir
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary, humanize=False,
|
||||
headless=True, extra_prefs=STRATEGY_1) as browser:
|
||||
headless=True, extra_prefs=LAB_PREFS) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.set_default_timeout(10000)
|
||||
page.goto(sites[where]["page"], wait_until="load")
|
||||
@@ -159,6 +185,7 @@ def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(fir
|
||||
"the frame of the worker is not listed with its url: %r" % [f.url for f in page.frames])
|
||||
assert _ask(page, where) == 1
|
||||
assert _ask(page, where) == 2
|
||||
wait_cacheable(page) # the cache takes a page only after the `pageshow` of every document of it, however slow the machine is
|
||||
|
||||
# 2. the top goes forward: the worker ends for the client, before the new page commits
|
||||
forward = len(events)
|
||||
@@ -169,15 +196,25 @@ def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(fir
|
||||
page.evaluate("url => { location.href = url; }", sites[away])
|
||||
committed = _index(events, forward, "Page.navigationCommitted", lambda p: p.get("url", "").endswith("/other"))
|
||||
assert committed is not None, "no commit of the new page was seen"
|
||||
promised = _commit_order_is_promised()
|
||||
if not promised: # an engine that does not promise the order still tells the worker ended, a moment later
|
||||
_wait(lambda: _index(events, forward, "Page.workerDestroyed", lambda p: p["workerId"] == wid) is not None)
|
||||
ended = _index(events, forward, "Page.workerDestroyed", lambda p: p["workerId"] == wid)
|
||||
assert ended is not None, "the worker was not told ended when its page left: %r" % _methods(events, forward)
|
||||
assert ended < committed, "the worker was told ended only after the new page committed: %r" % _methods(events, forward)
|
||||
if promised:
|
||||
assert ended < committed, "the worker was told ended only after the new page committed: %r" % _methods(events, forward)
|
||||
|
||||
# 3. back from the cache: the same worker, told once, after the restored document's contexts are cleared
|
||||
back = len(events)
|
||||
page.go_back(wait_until="load")
|
||||
assert page.evaluate("window.__shown") == [False, True], (
|
||||
"the page was loaded again instead of restored from the back-forward cache, so this test proves nothing")
|
||||
# What it knows is written down BEFORE anything is asserted. A goto is started by the PARENT and Firefox may refuse the cache for it,
|
||||
# to the same site or to another (measured: the navigation's own channel is still in the old document's loadgroup when the parent
|
||||
# checks: SHIPBFCache log, CanonicalBrowsingContext::AllowedInBFCache); then the document is built again and the contract is the one
|
||||
# of a new page, asserted whole. The page's own navigation (`location`) is never refused: a restore is required there.
|
||||
outcome = decide_outcome(read_after_go_back(page, events, back), may_reload=(how == "goto"))
|
||||
if outcome == "reloaded":
|
||||
_assert_a_new_page_with_a_new_worker(page, events, where, wid, back)
|
||||
return
|
||||
if not _wait(lambda: _index(events, back, "Page.workerCreated", lambda p: p["workerId"] == wid) is not None):
|
||||
other = [p["workerId"] for m, p in events[back:] if m == "Page.workerCreated"]
|
||||
raise AssertionError(("the restored worker was announced under a NEW id %s, not %s: " % (other, wid)
|
||||
@@ -213,3 +250,27 @@ def _methods(events, start):
|
||||
for m, p in events[start:] if m.startswith(("Page.worker", "Page.navigationCommitted", "Page.frameDocument",
|
||||
"Runtime.executionContextsCleared", "Page.frameDetached",
|
||||
"Page.frameAttached"))]
|
||||
|
||||
|
||||
def _assert_a_new_page_with_a_new_worker(page, events, where, old, back):
|
||||
"""The document was built again after go_back (the cache was not used): the contract of a page that loads. The old worker has been told
|
||||
ended once (asserted before), ONE new worker is announced with a NEW id, it is not told ended, it is the only live one, and it is a fresh
|
||||
worker (it answers 1)."""
|
||||
def created():
|
||||
return [p["workerId"] for m, p in events[back:] if m == "Page.workerCreated" and p["url"].endswith("/worker.js")]
|
||||
|
||||
assert _wait(lambda: bool(created())), "the page built again did not announce its worker: %r" % _methods(events, back)
|
||||
time.sleep(1.0) # what comes in excess comes now
|
||||
new = created()
|
||||
assert len(new) == 1 and new[0] != old, "expected one NEW worker, got %r (the old one was %s): %r" % (new, old, _methods(events, back))
|
||||
assert not [p for m, p in events[back:] if m == "Page.workerDestroyed" and p["workerId"] == new[0]], (
|
||||
"the new worker was told ended: %r" % _methods(events, back))
|
||||
live = {}
|
||||
for m, p in events:
|
||||
if m == "Page.workerCreated":
|
||||
live[p["workerId"]] = p
|
||||
elif m == "Page.workerDestroyed":
|
||||
live.pop(p["workerId"], None)
|
||||
assert list(live) == [new[0]], "live workers after the page was built again: %r" % list(live.values())
|
||||
assert _wait(lambda: where == "top" or any(f.url.endswith("/frame-worker") for f in page.frames)), "the frame of the new page is missing"
|
||||
assert _ask(page, where) == 1, "the worker of the page built again is not a fresh worker"
|
||||
@@ -22,6 +22,11 @@ from invisible_core.juggler.connection import (
|
||||
Connection, ProcessOutput, TargetClosedError, _READY)
|
||||
|
||||
|
||||
#: How long a test looks for what a local thread of this process does (a read of a pipe, a write that ends): 30 s, the far end of
|
||||
#: any stall of a loaded runner. Only a thread that never does it makes the test wait this long, and then it is red.
|
||||
_LOOK_FOR = 30
|
||||
|
||||
|
||||
class _Alive:
|
||||
"""A process that has not exited."""
|
||||
|
||||
@@ -49,11 +54,12 @@ def test_output_after_readiness_is_still_read_so_the_writer_never_blocks():
|
||||
done = threading.Event()
|
||||
threading.Thread(target=_writer, args=(w, lines, done), daemon=True).start()
|
||||
|
||||
assert output.wait_for_ready(_Alive(), 5.0) is True
|
||||
assert done.wait(10), (
|
||||
# 30 s is the hang detector, not a speed: a reader that never reads leaves the wait running to it and the test red.
|
||||
assert output.wait_for_ready(_Alive(), _LOOK_FOR) is True
|
||||
assert done.wait(_LOOK_FOR), (
|
||||
"the writer is still blocked: nobody read the pipe after the readiness "
|
||||
"line, which is how the browser froze ([B229])")
|
||||
deadline = time.monotonic() + 5
|
||||
deadline = time.monotonic() + _LOOK_FOR
|
||||
while output.tail(1) != ["the last one"] and time.monotonic() < deadline:
|
||||
time.sleep(0.02)
|
||||
assert output.tail(1) == ["the last one"], output.tail(3)
|
||||
@@ -64,10 +70,24 @@ def test_readiness_that_never_comes_is_answered_with_false_not_a_hang():
|
||||
r, w = os.pipe()
|
||||
output = ProcessOutput(os.fdopen(r, "rb"))
|
||||
os.write(w, b"something else\n")
|
||||
# The wait runs on a thread of its own so that "a hang" is a join that does not come back, whatever the speed of the
|
||||
# machine; the verdict is "False, after the 0.3 s it was given", never a stopwatch on how late it came.
|
||||
asked: dict = {}
|
||||
|
||||
def ask():
|
||||
asked["answer"] = output.wait_for_ready(_Alive(), 0.3)
|
||||
asked["at"] = time.monotonic()
|
||||
|
||||
started = time.monotonic()
|
||||
assert output.wait_for_ready(_Alive(), 0.3) is False
|
||||
assert time.monotonic() - started < 2
|
||||
os.close(w)
|
||||
waiter = threading.Thread(target=ask, daemon=True)
|
||||
waiter.start()
|
||||
waiter.join(_LOOK_FOR)
|
||||
try:
|
||||
assert not waiter.is_alive(), "wait_for_ready(0.3 s) was still waiting after %d s: a hang, not an answer" % _LOOK_FOR
|
||||
assert asked["answer"] is False
|
||||
assert asked["at"] - started >= 0.3, "answered False before the 0.3 s it was given"
|
||||
finally:
|
||||
os.close(w)
|
||||
|
||||
|
||||
def test_a_pipe_that_closes_mid_session_says_what_the_browser_printed():
|
||||
@@ -81,11 +101,11 @@ def test_a_pipe_that_closes_mid_session_says_what_the_browser_printed():
|
||||
from_browser_r, from_browser_w = os.pipe()
|
||||
c = Connection(to_browser_w, from_browser_r, None)
|
||||
c.output = output
|
||||
deadline = time.monotonic() + 5
|
||||
deadline = time.monotonic() + _LOOK_FOR
|
||||
while not output.tail() and time.monotonic() < deadline:
|
||||
time.sleep(0.02)
|
||||
os.close(from_browser_w) # the browser side goes away
|
||||
deadline = time.monotonic() + 5
|
||||
deadline = time.monotonic() + _LOOK_FOR
|
||||
while not c._closed and time.monotonic() < deadline:
|
||||
time.sleep(0.02)
|
||||
with pytest.raises(TargetClosedError) as e:
|
||||
|
||||
@@ -113,7 +113,7 @@ def _serve(imgs, listing):
|
||||
@pytest.mark.e2e
|
||||
@pytest.mark.timeout(300, method="thread")
|
||||
def test_tagged_images_read_back_as_retail_windows_reads_them(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
refs_path = DATA / "refs.json"
|
||||
if not refs_path.is_file():
|
||||
pytest.fail("tests/data/canvas_icc_ref/refs.json is missing: it is the reference "
|
||||
|
||||
@@ -104,7 +104,7 @@ def _want(cases):
|
||||
@pytest.mark.e2e
|
||||
@pytest.mark.timeout(600, method="thread")
|
||||
def test_coloured_text_is_what_retail_windows_draws(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
refs = _refs()
|
||||
assert refs["colors"]["count"] == len(refs["colors"]["cases"]) == 14
|
||||
got = _launch(firefox_binary, refs, None, {})
|
||||
@@ -128,7 +128,7 @@ def _keys():
|
||||
@pytest.mark.parametrize("tag", _keys())
|
||||
def test_text_under_a_cleartype_key_is_what_retail_windows_draws(
|
||||
tag, firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
refs = _refs()
|
||||
k = refs["keys"][tag]
|
||||
want_black, want_colors = _want(k["black"]), _want(k["colors"])
|
||||
|
||||
@@ -58,7 +58,7 @@ from invisible_playwright import InvisiblePlaywright
|
||||
@pytest.mark.e2e
|
||||
@pytest.mark.timeout(1800, method="thread")
|
||||
def test_canvas_text_is_what_retail_windows_draws(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
refs_path = DATA / "refs.json"
|
||||
if not refs_path.is_file():
|
||||
pytest.fail("tests/data/canvas_text_ref/refs.json is missing: it is the reference "
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
"""Closing one of four browsers in one process does not hold the event loop that serves the other three.
|
||||
|
||||
The close of a browser WAITS (for its processes to exit, for its profile to be removed): that is the contract, Playwright's `close()`
|
||||
returns once the processes are gone. What was wrong was WHO waited. In the async API the user's own event loop did, three times:
|
||||
|
||||
* `InProcessTransport.request_stop` ran `server.shutdown()` (the hooks that close the engine's pipe and wait for its tree, and the
|
||||
removal of the profile) on the loop that asked for the stop;
|
||||
* `InProcessTransport.wait_until_stopped` joined the four `juggler-N` workers on the loop, up to 5 s each, and a worker is busy
|
||||
for as long as the engine's `conn.close()` waits (`BrowserDispatcher.op_close`);
|
||||
* `InvisiblePlaywright._teardown` reaped the session's token (`reap` waits for the tree) on the loop.
|
||||
|
||||
Measured with py-spy on four browsers in one Python process: closing one stopped the loop that serves the other three for as long as
|
||||
it waited. Now the same waits run in threads of their own (`invisible_core._offloop.off_the_loop`, from invisible-core 64.72.0).
|
||||
|
||||
The test runs the real engine, four of them, in a client program of its own (the loop under test is that program's main thread). A
|
||||
sentinel task asks to wake every 5 ms; a watcher thread notes how late it woke and where the main thread was: waiting in the
|
||||
selector (the machine did not run the loop: on a loaded host an idle loop is 100 ms late now and then, which is not the close's
|
||||
doing and is not counted) or INSIDE something (held). The instrument is the one of the core's
|
||||
`tests/test_a_close_does_not_hold_the_loop.py`. A control with the same instrument holds the loop on purpose first, so a watcher
|
||||
that could not see a held loop does not pass the test for nothing.
|
||||
|
||||
Nothing here is judged by how long it took (that is a verdict on the runner: a loop that a starved machine runs late is late without
|
||||
a defect). The loop is held when its thread was SEEN inside a step of the close that waits (`_close_loop_verdicts.blocked_by`), and the
|
||||
other browsers keep answering when, in the order of the events, a call of each began and ended while the close was in flight and
|
||||
while the removal of the closing browser's profile was held until every one of them had answered (a removal made on the loop would
|
||||
wait for the answers that only the loop can read). The milliseconds are printed, never judged.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
from _close_loop_verdicts import (
|
||||
blind_instrument_problem,
|
||||
charged_more_than_ran_problem,
|
||||
close_on_the_loop_problem,
|
||||
others_answered_problem,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The client. Four browsers by the async API, each with a page; one is closed while a sentinel measures the loop and one pinger per
|
||||
#: other browser keeps asking its page a question. Prints one JSON line.
|
||||
_CLIENT = textwrap.dedent("""
|
||||
import asyncio, json, os, shutil, sys, threading, time, traceback
|
||||
import psutil
|
||||
from invisible_playwright.async_api import InvisiblePlaywright
|
||||
|
||||
BINARY = sys.argv[1]
|
||||
main_id = threading.get_ident()
|
||||
|
||||
|
||||
class Instrument:
|
||||
\"\"\"A sentinel on the loop and a watcher thread. `held` is the longest wake that was late while the main thread was INSIDE
|
||||
something, not idle in the loop's selector.\"\"\"
|
||||
|
||||
def __init__(self):
|
||||
self.gaps, self.holes, self.held = [], [], 0.0
|
||||
#: The longest stretch the watcher saw the main thread running something without a pause in the selector, and every
|
||||
#: frame that was on its stack in those samples (file:function -> samples, and the innermost frames of the first stack
|
||||
#: it was seen in): WHERE the thread was, which is the cause, where `held` only says for how long.
|
||||
self.busy_run, self.inside = 0.0, {}
|
||||
self.beat = [time.monotonic()]
|
||||
self.stop = asyncio.Event()
|
||||
self.over = threading.Event()
|
||||
self.on_the_loop = []
|
||||
self._real = {}
|
||||
#: Set to make the sentinel's next wait that long: the loop then waits in its selector, late by that much, as on a loaded
|
||||
#: machine that does not schedule it.
|
||||
self.pause_once = 0
|
||||
|
||||
async def sentinel(self):
|
||||
last = time.monotonic()
|
||||
while not self.stop.is_set():
|
||||
wait, self.pause_once = self.pause_once or 0.005, 0
|
||||
await asyncio.sleep(wait)
|
||||
now = time.monotonic()
|
||||
self.gaps.append(now - last)
|
||||
last = self.beat[0] = now
|
||||
|
||||
@staticmethod
|
||||
def idle(frame):
|
||||
# True when the main thread is waiting in the event loop's selector: it is not running anything of anybody's.
|
||||
for _ in range(3):
|
||||
if frame is None:
|
||||
return False
|
||||
code = frame.f_code
|
||||
if code.co_name in ("_poll", "select") and code.co_filename.endswith(("windows_events.py", "selectors.py")):
|
||||
return True
|
||||
frame = frame.f_back
|
||||
return False
|
||||
|
||||
def stacks(self):
|
||||
frames = sys._current_frames()
|
||||
names = {t.ident: t.name for t in threading.enumerate()}
|
||||
return {
|
||||
"main": "".join(traceback.format_stack(frames[main_id])[-6:]),
|
||||
"others": {names.get(i, str(i)): "".join(traceback.format_stack(f)[-3:])
|
||||
for i, f in frames.items() if i != main_id and i != threading.get_ident()}}
|
||||
|
||||
def note(self, frame):
|
||||
names = []
|
||||
while frame is not None:
|
||||
names.append("%s:%s" % (frame.f_code.co_filename.replace(os.sep, "/"), frame.f_code.co_name))
|
||||
frame = frame.f_back
|
||||
names.reverse()
|
||||
for name in names:
|
||||
entry = self.inside.get(name)
|
||||
if entry is None:
|
||||
self.inside[name] = {"n": 1, "stack": names[-6:]}
|
||||
else:
|
||||
entry["n"] += 1
|
||||
|
||||
def watcher(self):
|
||||
# Only the part of a lateness during which the loop's thread was RUNNING counts. A loop the machine did not schedule waits in
|
||||
# the selector and then, once woken, runs the callbacks that queued meanwhile (the pingers' replies): counting the whole
|
||||
# lateness at that moment charged the machine's 90 ms to whoever ran first (candidate 43727128285, Windows: 94 ms, the main
|
||||
# thread in `self._selector.select`, no blocking call on it). `busy_since` is when the thread last left the selector.
|
||||
looked, busy_since = 0, None
|
||||
while not self.over.is_set():
|
||||
time.sleep(0.003)
|
||||
now = time.monotonic()
|
||||
late = now - self.beat[0]
|
||||
level = int(late / 0.03)
|
||||
frame = sys._current_frames().get(main_id)
|
||||
if self.idle(frame):
|
||||
busy_since = None
|
||||
else:
|
||||
if busy_since is None:
|
||||
busy_since = now
|
||||
self.busy_run = max(self.busy_run, now - busy_since)
|
||||
self.note(frame)
|
||||
held = now - max(self.beat[0], busy_since)
|
||||
if held > 0.03:
|
||||
self.held = max(self.held, held)
|
||||
if level > looked:
|
||||
self.holes.append({"late_ms": round(late * 1000), **self.stacks()})
|
||||
looked = level
|
||||
|
||||
def watched(self, owner, name):
|
||||
self._real[(owner, name)] = original = getattr(owner, name)
|
||||
|
||||
def call(*x, **k):
|
||||
if threading.get_ident() == main_id and not self.over.is_set():
|
||||
self.on_the_loop.append(name)
|
||||
return original(*x, **k)
|
||||
setattr(owner, name, call)
|
||||
|
||||
async def start(self):
|
||||
self.watched(time, "sleep")
|
||||
self.watched(shutil, "rmtree")
|
||||
self.watched(psutil, "wait_procs")
|
||||
self.watched(threading.Thread, "join")
|
||||
threading.Thread(target=self.watcher, daemon=True, name="the-watcher").start()
|
||||
self.task = asyncio.create_task(self.sentinel())
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
async def finish(self):
|
||||
self.stop.set()
|
||||
await self.task
|
||||
self.over.set()
|
||||
for (owner, name), original in self._real.items():
|
||||
setattr(owner, name, original)
|
||||
self._real.clear()
|
||||
|
||||
def report(self):
|
||||
return {"held": self.held, "busy_run": self.busy_run, "inside": self.inside, "gap": max(self.gaps),
|
||||
"holes": self.holes[:4], "on_the_loop": sorted(set(self.on_the_loop))}
|
||||
|
||||
|
||||
def engines():
|
||||
out = []
|
||||
for child in psutil.Process().children(recursive=True):
|
||||
try:
|
||||
if "firefox" in child.name().lower():
|
||||
out.append(child.pid)
|
||||
except psutil.Error:
|
||||
pass
|
||||
return out
|
||||
|
||||
|
||||
async def pinger(page, record, closing, gate, records):
|
||||
# A call counts as answered DURING the close when it began after the close began and ended before it ended, and as answered
|
||||
# DURING THE REMOVAL when it began after the removal of the profile did: the order of the events, not how long it took.
|
||||
while not record["stop"]:
|
||||
while_closing = closing.is_set()
|
||||
started = time.monotonic()
|
||||
await page.evaluate("1 + 1")
|
||||
took = time.monotonic() - started
|
||||
if while_closing and closing.is_set():
|
||||
record["inside"] += 1
|
||||
record["slowest"] = max(record["slowest"], took) # printed, never judged
|
||||
since = gate["since"]
|
||||
if since is not None and started >= since and gate["released_by"] is None:
|
||||
record["during_removal"] += 1
|
||||
if all(r["during_removal"] >= 1 for r in records):
|
||||
gate["all_answered"].set()
|
||||
await asyncio.sleep(0.02)
|
||||
|
||||
|
||||
def hold_the_loop(seconds):
|
||||
time.sleep(seconds)
|
||||
|
||||
|
||||
async def main():
|
||||
# The control: the same instrument on a loop that is held on purpose.
|
||||
control = Instrument()
|
||||
await control.start()
|
||||
await asyncio.sleep(0.05)
|
||||
hold_the_loop(0.4)
|
||||
await asyncio.sleep(0.05)
|
||||
await control.finish()
|
||||
|
||||
# The second control: a loop that is LATE without being held. The sentinel's next wake is 300 ms away, so the loop waits in its
|
||||
# selector (as when the machine does not schedule it), and 150 ms in it runs 45 ms of a callback that was due then, while the
|
||||
# sentinel is still about 145 ms late. Only those 45 ms are the loop's thread at work (45, not less: a watcher on Windows sleeps
|
||||
# in 15.6 ms ticks and would not see a shorter one): the 145 ms before them must not count.
|
||||
unscheduled = Instrument()
|
||||
await unscheduled.start()
|
||||
await asyncio.sleep(0.05)
|
||||
unscheduled.pause_once = 0.3
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
def burst():
|
||||
end = time.monotonic() + 0.045
|
||||
while time.monotonic() < end:
|
||||
pass
|
||||
loop.call_later(0.15, burst)
|
||||
await asyncio.sleep(0.5)
|
||||
await unscheduled.finish()
|
||||
|
||||
# A slow disk: removing a profile takes 150 ms more (a scanner of files at work, a spinning disk, a loaded runner). On a fast
|
||||
# disk the removal of a profile is a few ms and a close made on the loop hides in the noise; with a disk that is slow the
|
||||
# wait is what the loop pays, wherever it is made. Every thread pays it the same.
|
||||
#
|
||||
# And the first removal inside the close waits until every other browser has answered a call that began after it did (30 s
|
||||
# at most, the deadline of a hang): the removal that runs in a thread of its own lets the loop serve them and goes on at once;
|
||||
# one that runs ON the loop stops the only thread that could read their answers, and goes on only at the deadline. How the
|
||||
# hold ended (`released_by`) is the verdict; a slow machine only makes the answers come later.
|
||||
real_rmtree = shutil.rmtree
|
||||
gate = {"since": None, "released_by": None, "all_answered": threading.Event()}
|
||||
gate_lock = threading.Lock()
|
||||
|
||||
def slow_rmtree(*x, **k):
|
||||
time.sleep(0.15)
|
||||
first = False
|
||||
if closing.is_set():
|
||||
with gate_lock:
|
||||
if gate["since"] is None:
|
||||
gate["since"], first = time.monotonic(), True
|
||||
if first:
|
||||
answered = gate["all_answered"].wait(30)
|
||||
gate["released_by"] = "answered" if answered else "deadline"
|
||||
return real_rmtree(*x, **k)
|
||||
|
||||
shutil.rmtree = slow_rmtree
|
||||
|
||||
sessions = [InvisiblePlaywright(seed=7100 + i, binary_path=BINARY, headless=True) for i in range(4)]
|
||||
browsers = []
|
||||
for session in sessions:
|
||||
browsers.append(await session.__aenter__())
|
||||
pages = [await b.new_page() for b in browsers]
|
||||
for i, page in enumerate(pages):
|
||||
await page.set_content("<p id=n>browser %d</p>" % i)
|
||||
launched = len(engines())
|
||||
|
||||
closing, records = asyncio.Event(), []
|
||||
tasks = []
|
||||
for page in pages[1:]:
|
||||
record = {"stop": False, "inside": 0, "during_removal": 0, "slowest": 0.0}
|
||||
records.append(record)
|
||||
tasks.append(asyncio.create_task(pinger(page, record, closing, gate, records)))
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
instrument = Instrument()
|
||||
await instrument.start()
|
||||
closing.set()
|
||||
started = time.monotonic()
|
||||
await sessions[0].__aexit__(None, None, None)
|
||||
took = time.monotonic() - started
|
||||
closing.clear()
|
||||
await instrument.finish()
|
||||
report = instrument.report()
|
||||
report.update({
|
||||
"took": took, "launched": launched,
|
||||
"control": control.report(),
|
||||
"unscheduled": unscheduled.report(),
|
||||
"others": [{"inside": r["inside"], "during_removal": r["during_removal"], "slowest": r["slowest"]} for r in records],
|
||||
"gate": {"reached": gate["since"] is not None, "released_by": gate["released_by"]},
|
||||
})
|
||||
# The other three still work after it.
|
||||
shutil.rmtree = real_rmtree
|
||||
report["texts"] = [await p.text_content("#n") for p in pages[1:]]
|
||||
for record in records:
|
||||
record["stop"] = True
|
||||
await asyncio.gather(*tasks)
|
||||
for session in sessions[1:]:
|
||||
await session.__aexit__(None, None, None)
|
||||
time.sleep(0.5)
|
||||
report["left"] = engines()
|
||||
print("REPORT", json.dumps(report), flush=True)
|
||||
|
||||
try:
|
||||
asyncio.run(asyncio.wait_for(main(), 240))
|
||||
finally:
|
||||
for pid in engines():
|
||||
try:
|
||||
psutil.Process(pid).kill()
|
||||
except psutil.Error:
|
||||
pass
|
||||
""")
|
||||
|
||||
|
||||
def _holes(report):
|
||||
out = []
|
||||
for hole in report.get("holes") or []:
|
||||
out.append("--- the loop was %d ms late. MAIN THREAD:\n%s" % (hole["late_ms"], hole["main"]))
|
||||
for name, stack in hole["others"].items():
|
||||
out.append("--- thread %s:\n%s" % (name, stack))
|
||||
return "\n".join(out) or "(no look was taken)"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def report(firefox_binary, tmp_path_factory):
|
||||
"""One run of the client: its numbers are asserted one claim at a time below."""
|
||||
script = tmp_path_factory.mktemp("close-loop") / "client.py"
|
||||
script.write_text(_CLIENT, encoding="utf-8")
|
||||
import invisible_playwright
|
||||
|
||||
# The client imports the checkout under test, the one this run imported.
|
||||
source = os.path.dirname(os.path.dirname(os.path.abspath(invisible_playwright.__file__)))
|
||||
env = dict(os.environ, PYTHONPATH=os.pathsep.join([source, os.environ.get("PYTHONPATH", "")]).rstrip(os.pathsep))
|
||||
done = subprocess.run([sys.executable, str(script), str(firefox_binary)], capture_output=True, text=True, timeout=300, env=env)
|
||||
lines = [x for x in done.stdout.splitlines() if x.startswith("REPORT ")]
|
||||
assert done.returncode == 0 and lines, (
|
||||
"the client failed (%s):\n%s\n%s" % (done.returncode, done.stdout[-2000:], done.stderr[-4000:]))
|
||||
return json.loads(lines[-1][len("REPORT "):])
|
||||
|
||||
|
||||
#: The function the client holds its loop in on purpose (the control), in the script the test writes.
|
||||
_HOLDER = (("/client.py", ("hold_the_loop",)),)
|
||||
|
||||
|
||||
@pytest.mark.wall_clock
|
||||
def test_the_instrument_sees_a_loop_that_is_held(report):
|
||||
"""The control: the loop held on purpose for 400 ms is seen as held, and seen INSIDE the function that holds it. Without this, a
|
||||
watcher that could not tell a held loop from a starved one, or could not read where the thread was, would pass the test below for
|
||||
nothing."""
|
||||
control = report["control"]
|
||||
assert control["held"] > 0.3, (
|
||||
"the watcher did not see a loop held for 400 ms: held %.0f ms" % (control["held"] * 1000))
|
||||
assert "sleep" in control["on_the_loop"]
|
||||
assert blind_instrument_problem(control["inside"], _HOLDER) is None, blind_instrument_problem(control["inside"], _HOLDER)
|
||||
|
||||
|
||||
@pytest.mark.wall_clock
|
||||
def test_the_instrument_does_not_charge_a_loop_the_machine_did_not_schedule(report):
|
||||
"""The second control: a loop that waited 150 ms in its selector and then ran a 45 ms callback was held for those 45 ms, not 195.
|
||||
Charging it the whole lateness made a loaded Windows runner fail a bound of 90 ms with 94 ms and nothing on the loop's thread
|
||||
(candidate 43727128285). What is charged is judged against what the same samples saw run, not against a number of milliseconds:
|
||||
a held time greater than the longest stretch the thread was seen running counted a wait that was not the loop's."""
|
||||
unscheduled = report["unscheduled"]
|
||||
assert unscheduled["gap"] > 0.25, "the sentinel was not late: %r" % unscheduled
|
||||
assert charged_more_than_ran_problem(unscheduled["held"], unscheduled["busy_run"]) is None, charged_more_than_ran_problem(
|
||||
unscheduled["held"], unscheduled["busy_run"])
|
||||
|
||||
|
||||
def test_the_removal_of_the_profile_ran_inside_the_close(report):
|
||||
"""The slow disk of the client is only a stimulus if the removal of the profile ran, through `shutil.rmtree`, while the first
|
||||
browser closed: the hold of the removal until the others answer is made there. Without this a close that removed nothing through it
|
||||
would pass the test of the others by not being gated."""
|
||||
assert report["gate"]["reached"], "no `shutil.rmtree` ran while the first browser closed: %r" % report["gate"]
|
||||
|
||||
|
||||
@pytest.mark.wall_clock
|
||||
def test_closing_one_of_four_browsers_does_not_hold_the_loop(report):
|
||||
"""Four browsers, one closes: the thread that runs the loop of the program is never seen inside a step of the close that waits
|
||||
(the shutdown of the server, the join of its workers, the reaping of the tree, the removal of the profile)."""
|
||||
assert report["launched"] >= 4, "fewer than four engines were running before the close: %r" % report["launched"]
|
||||
assert report["took"] > 0.3, "the close finished before the engine could have exited: nothing was waited for"
|
||||
problem = close_on_the_loop_problem(report["inside"])
|
||||
assert problem is None, (
|
||||
"%s\n(printed, not judged: the loop was held %.0f ms while one of four browsers closed, the close took %.0f ms, the longest "
|
||||
"wake was %.0f ms late; calls made by the loop's own thread: %s). Where the threads were while it was late:\n%s"
|
||||
% (problem, report["held"] * 1000, report["took"] * 1000, report["gap"] * 1000, report["on_the_loop"], _holes(report)))
|
||||
|
||||
|
||||
def test_no_blocking_step_of_the_close_runs_on_the_loop_s_thread(report):
|
||||
"""The cause, asked directly and without the clock: `time.sleep`, `rmtree`, `psutil.wait_procs` and `Thread.join` are what a close
|
||||
does while it waits and removes, and none of them may be called by the thread that runs the loop. Red on a close made on it."""
|
||||
assert report["on_the_loop"] == [], "the loop's own thread made these calls while it awaited the close: %s" % report["on_the_loop"]
|
||||
|
||||
|
||||
def test_the_other_three_keep_answering_during_the_close(report):
|
||||
"""Each of the other three browsers answers a call that began and ended while the first one closes, the removal of the first one's
|
||||
profile is held until every one of them has answered, and the three are alive after. The order of the events decides; the
|
||||
seconds a call took are printed."""
|
||||
problem = others_answered_problem(report["others"], report["gate"])
|
||||
assert problem is None, "%s\n(printed, not judged: the slowest call of each browser inside the close, in s: %s)" % (
|
||||
problem, [round(r["slowest"], 3) for r in report["others"]])
|
||||
assert report["texts"] == ["browser 1", "browser 2", "browser 3"]
|
||||
|
||||
|
||||
def test_every_engine_is_gone_when_the_four_have_closed(report):
|
||||
assert report["left"] == [], "engine processes are left after every browser closed: %r" % report["left"]
|
||||
@@ -0,0 +1,125 @@
|
||||
"""`InProcessTransport.connect` returns without waiting for any thread to start.
|
||||
|
||||
`connect` is a coroutine of the user's event loop, and `Thread.start` does not return until the new thread is running. Measured with
|
||||
four browsers in one process under CPU load on Windows, the four worker starts held the loop ~200 ms per launch (4.4% of the main
|
||||
thread's wall time). The workers are now started by a bootstrapper that is not the loop (and is itself begun without a
|
||||
`Thread.start`), and a message sent right after `connect` waits in the queue until a worker runs.
|
||||
|
||||
NO BROWSER HERE: a scripted server behind the real transport, with `Thread.start` slowed to 300 ms, the way a loaded machine slows it.
|
||||
|
||||
Known-bad input: workers started inside `connect` -> `connect` takes 4 x 300 ms and fails the 50 ms bound.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from invisible_playwright._juggler.dispatcher import Server
|
||||
from invisible_playwright._juggler.transport import InProcessTransport
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
START_DELAY_S = 0.3
|
||||
|
||||
|
||||
class _Server(Server):
|
||||
"""The registry's base class, whose `thread_starter` the transport starts its workers through, answering every call with its id."""
|
||||
|
||||
def handle(self, message):
|
||||
return {"echo": message["id"]}
|
||||
|
||||
|
||||
def test_connect_returns_before_any_worker_has_started_and_a_message_is_still_answered(monkeypatch):
|
||||
original = threading.Thread.start
|
||||
|
||||
def slow_start(self):
|
||||
time.sleep(START_DELAY_S)
|
||||
return original(self)
|
||||
monkeypatch.setattr(threading.Thread, "start", slow_start)
|
||||
|
||||
async def scenario():
|
||||
loop = asyncio.get_running_loop()
|
||||
transport = InProcessTransport(loop, _Server())
|
||||
replies: "asyncio.Queue" = asyncio.Queue()
|
||||
transport.on_message = replies.put_nowait
|
||||
|
||||
began = time.perf_counter()
|
||||
await transport.connect()
|
||||
took = time.perf_counter() - began
|
||||
|
||||
transport.send({"id": 7, "guid": "g", "method": "m", "params": {}})
|
||||
reply = await asyncio.wait_for(replies.get(), 10)
|
||||
transport.request_stop()
|
||||
await asyncio.wait_for(transport.wait_until_stopped(), 10)
|
||||
return took, reply
|
||||
|
||||
took, reply = asyncio.run(scenario())
|
||||
assert took < 0.05, "connect() waited %.0f ms: a thread was started on the loop" % (took * 1000)
|
||||
assert reply == {"id": 7, "result": {"echo": 7}}
|
||||
|
||||
|
||||
def test_a_transport_stopped_before_its_workers_started_ends_without_error(monkeypatch):
|
||||
original = threading.Thread.start
|
||||
|
||||
def slow_start(self):
|
||||
time.sleep(START_DELAY_S)
|
||||
return original(self)
|
||||
monkeypatch.setattr(threading.Thread, "start", slow_start)
|
||||
|
||||
async def scenario():
|
||||
transport = InProcessTransport(asyncio.get_running_loop(), _Server())
|
||||
await transport.connect()
|
||||
transport.request_stop()
|
||||
await asyncio.wait_for(transport.wait_until_stopped(), 10)
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_building_the_shared_starter_waits_for_no_thread_start(monkeypatch):
|
||||
"""The starter every caller of `ThreadStarter` builds on its own thread must not itself cost a `Thread.start` there."""
|
||||
from invisible_playwright._juggler._threads import ThreadStarter
|
||||
|
||||
original = threading.Thread.start
|
||||
|
||||
def slow_start(self):
|
||||
time.sleep(START_DELAY_S)
|
||||
return original(self)
|
||||
monkeypatch.setattr(threading.Thread, "start", slow_start)
|
||||
|
||||
began = time.perf_counter()
|
||||
starter = ThreadStarter(on_error=lambda why: None)
|
||||
ran = threading.Event()
|
||||
starter.start(target=ran.set, name="invpw-test-started")
|
||||
took = time.perf_counter() - began
|
||||
try:
|
||||
assert took < 0.05, "building the starter and queueing a thread waited %.0f ms" % (took * 1000)
|
||||
assert ran.wait(10), "the queued thread never ran"
|
||||
finally:
|
||||
starter.stop()
|
||||
|
||||
|
||||
def test_a_browsers_reader_and_the_transports_workers_share_ONE_starter():
|
||||
"""Each browser costs one starter thread, not two: the transport's workers and the browser's lease both go through the server's."""
|
||||
from invisible_playwright._juggler._threads import ThreadStarter, ThreadStarterLease
|
||||
|
||||
async def scenario():
|
||||
server = _Server()
|
||||
transport = InProcessTransport(asyncio.get_running_loop(), server)
|
||||
# The starters of THIS scenario, by identity: the registry is the process's, and a starter an earlier test of the
|
||||
# same worker is still closing (or one it left) moved a count taken before and after (red in a pre-push of 15/11).
|
||||
before = set(ThreadStarter.open_starters())
|
||||
await transport.connect()
|
||||
lease = ThreadStarterLease(lambda: server.thread_starter)
|
||||
ran = threading.Event()
|
||||
lease.start(target=ran.set, name="invpw-test-started")
|
||||
assert ran.wait(30)
|
||||
opened, mine = [s for s in ThreadStarter.open_starters() if s not in before], server.thread_starter
|
||||
transport.request_stop()
|
||||
await asyncio.wait_for(transport.wait_until_stopped(), 30)
|
||||
return opened, mine
|
||||
|
||||
opened, the_servers = asyncio.run(scenario())
|
||||
assert opened == [the_servers], opened
|
||||
@@ -0,0 +1,54 @@
|
||||
"""The window of ``CpuSampler`` ends where ``end()`` is called, not a moment later.
|
||||
|
||||
``end()`` used to sleep 0.3 s before its last sample, so the CPU of a window included a third of a second of what the browser did AFTER the
|
||||
work the test measured (more on a slower machine: the sleep is a clock, the CPU is not). The cumulative counters need no wait.
|
||||
|
||||
No browser and no process: ``engine_processes`` is a stand-in whose CPU is the time of a fake clock that ``time.sleep`` advances, so a sleep inside
|
||||
the window shows as CPU seconds that the test never spent.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
import _cpu_by_type as cpu
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
class _Clock:
|
||||
def __init__(self) -> None:
|
||||
self.now = 0.0
|
||||
|
||||
def sleep(self, seconds: float) -> None:
|
||||
self.now += seconds
|
||||
|
||||
|
||||
def test_the_window_holds_the_cpu_until_end_is_called_and_not_a_sleep_more(monkeypatch):
|
||||
clock = _Clock()
|
||||
monkeypatch.setattr(cpu, "time", types.SimpleNamespace(sleep=clock.sleep))
|
||||
monkeypatch.setattr(cpu, "engine_processes", lambda _root: {7: ("parent", clock.now)})
|
||||
|
||||
sampler = cpu.CpuSampler(root_pid=1, period=3600) # the thread's own samples are not the subject: it waits for the stop
|
||||
sampler.begin()
|
||||
clock.now += 2.0 # the measured work: the process used 2.0 s of CPU
|
||||
delta = sampler.end()
|
||||
|
||||
assert delta["parent"] == pytest.approx(2.0), (
|
||||
"the window of the sampler held %.2f s of CPU for 2.0 s of work: end() waited before its last sample" % delta["parent"])
|
||||
|
||||
|
||||
def test_a_process_born_in_the_window_counts_from_zero_and_one_that_ended_keeps_its_last_value(monkeypatch):
|
||||
clock = _Clock()
|
||||
monkeypatch.setattr(cpu, "time", types.SimpleNamespace(sleep=clock.sleep))
|
||||
seen = {"processes": {7: ("parent", 5.0), 8: ("tab", 1.0)}}
|
||||
monkeypatch.setattr(cpu, "engine_processes", lambda _root: dict(seen["processes"]))
|
||||
|
||||
sampler = cpu.CpuSampler(root_pid=1, period=3600)
|
||||
sampler.begin()
|
||||
seen["processes"] = {7: ("parent", 6.5), 9: ("tab", 0.75)} # 8 ended (its last value stays), 9 was born after the start
|
||||
delta = sampler.end()
|
||||
|
||||
assert delta["parent"] == pytest.approx(1.5)
|
||||
assert delta["tab"] == pytest.approx(0.75)
|
||||
@@ -27,18 +27,22 @@ needs an ``invisible-core`` that declares them.
|
||||
|
||||
Layers:
|
||||
* ``unit`` - ``_BASELINE`` contains the prefs with the right values. No browser.
|
||||
* ``e2e`` - launch the real binary against a LOCAL HTTP harness on
|
||||
``127.0.0.1`` and verify the four protocol operations that
|
||||
regressed: frame URL tracking, ``handle.content_frame()``,
|
||||
``frame.evaluate()``, and ``frame_locator(...).locator(...)``
|
||||
element resolution. The harness uses two ports of one host,
|
||||
which is one SITE: those iframes stay in the process of the
|
||||
page even at strategy 1. The iframes that leave the process
|
||||
(different hosts) are held by ``test_fission_strategy1_bench.py``.
|
||||
* ``e2e`` - launch the real binary against a LOCAL HTTP harness and
|
||||
verify the four protocol operations that regressed: frame URL
|
||||
tracking, ``handle.content_frame()``, ``frame.evaluate()``, and
|
||||
``frame_locator(...).locator(...)`` element resolution. The page
|
||||
is served from ``127.0.0.1`` and its iframes from ``localhost``:
|
||||
two hosts are two SITES, so at strategy 1 each iframe runs in a
|
||||
content process of its own. (Two ports of one host would be one
|
||||
site, and those iframes would stay in the process of the page.)
|
||||
``test_the_iframe_runs_in_another_process`` proves it from
|
||||
inside the pages, so this file cannot fall back to the process
|
||||
of the page unnoticed. The bench with its own hosts and
|
||||
process counts is ``test_fission_strategy1_bench.py``.
|
||||
|
||||
The e2e tests run entirely offline. They never call out to a real site;
|
||||
the cross-origin shape is reproduced with two local HTTP servers on
|
||||
random free ports.
|
||||
the cross-site shape is reproduced with two local HTTP servers on random
|
||||
free ports, reached by two names of the loopback interface.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -51,6 +55,8 @@ import pytest
|
||||
from invisible_core._fpforge import generate_profile
|
||||
from invisible_core.prefs import _BASELINE, translate_profile_to_prefs
|
||||
|
||||
from _waits import wait_until
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────────────
|
||||
# Unit layer - fast, no browser, runs on every CI
|
||||
@@ -168,12 +174,13 @@ def _serve(payload: bytes) -> tuple[ThreadingHTTPServer, int]:
|
||||
|
||||
@pytest.fixture
|
||||
def cross_origin_harness():
|
||||
"""Spin up TWO local HTTP servers on different localhost ports.
|
||||
"""Spin up TWO local HTTP servers: the page on ``127.0.0.1``, the iframes on ``localhost``.
|
||||
|
||||
Two ports = two distinct origins under SOP (same host, different port
|
||||
→ different origin). The parent page on port A embeds an iframe with
|
||||
src pointing at port B. Same cross-origin browsing-context shape as
|
||||
a parent-page-plus-third-party-iframe layout, fully offline.
|
||||
Two hosts = two SITES (and two origins under SOP). The parent page
|
||||
embeds iframes with src pointing at the other host, which at strategy 1
|
||||
puts them in another content process. Same cross-site browsing-context
|
||||
shape as a parent-page-plus-third-party-iframe layout, fully offline.
|
||||
The servers listen on 127.0.0.1 and the child is named ``localhost``.
|
||||
"""
|
||||
# The CHILD goes up first, because the parent's markup has to name the
|
||||
# child's port and there is no longer a way to learn that number without
|
||||
@@ -186,20 +193,49 @@ def cross_origin_harness():
|
||||
sb, pb = _serve(child_html)
|
||||
parent_html = f"""<!doctype html><html><head><title>parent</title></head><body>
|
||||
<h1>parent</h1>
|
||||
<iframe id="ifr_plain" src="http://127.0.0.1:{pb}/child" width="300" height="120"></iframe>
|
||||
<iframe id="ifr_sandbox" src="http://127.0.0.1:{pb}/child" width="300" height="120"
|
||||
<iframe id="ifr_plain" src="http://localhost:{pb}/child" width="300" height="120"></iframe>
|
||||
<iframe id="ifr_sandbox" src="http://localhost:{pb}/child" width="300" height="120"
|
||||
sandbox="allow-scripts allow-same-origin"></iframe>
|
||||
<iframe id="ifr_titled" src="http://127.0.0.1:{pb}/child" width="300" height="120"
|
||||
<iframe id="ifr_titled" src="http://localhost:{pb}/child" width="300" height="120"
|
||||
title="cross-origin titled iframe"></iframe>
|
||||
</body></html>""".encode("utf-8")
|
||||
sa, pa = _serve(parent_html)
|
||||
try:
|
||||
yield {"parent_url": f"http://127.0.0.1:{pa}/", "child_origin": f"http://127.0.0.1:{pb}"}
|
||||
yield {"parent_url": f"http://127.0.0.1:{pa}/", "child_origin": f"http://localhost:{pb}"}
|
||||
finally:
|
||||
sa.shutdown()
|
||||
sb.shutdown()
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_iframe_runs_in_another_process(firefox_binary, cross_origin_harness):
|
||||
"""The harness of this file really crosses a process: a spin in the iframe does not stall the page.
|
||||
|
||||
The iframe spins for 600 ms and the page times a 10 ms timer; the timer
|
||||
stalls only when both share a content process. Without this, a harness
|
||||
that went back to two ports of one host would keep every test below green
|
||||
while testing a same-process iframe.
|
||||
"""
|
||||
from _fission_frames import assert_other_process
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary, humanize=False) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
# ⛔ `load`, NOT `domcontentloaded`. The `domcontentloaded` of a page says nothing about its frames: the
|
||||
# frame of another site is listed as soon as it is attached, and its url is the one of its navigation,
|
||||
# which commits in the frame's own process, usually AFTER the page's domcontentloaded. Read straight after
|
||||
# a `domcontentloaded` goto the url was empty in 26 reads of 30 on firefox-62 (stock Playwright Firefox,
|
||||
# whose frames commit in the process of the page, had it 30 of 30). After the `load` of the page the url
|
||||
# was there 30 of 30 on both, with no wait: that is what is asserted here, so a `goto` that returns
|
||||
# with a cross-site frame still without its url fails this test.
|
||||
page.goto(cross_origin_harness["parent_url"], wait_until="load", timeout=30_000)
|
||||
page.wait_for_selector("iframe#ifr_plain", timeout=10_000)
|
||||
frame = page.query_selector("iframe#ifr_plain").content_frame()
|
||||
assert frame is not None and cross_origin_harness["child_origin"] in frame.url, (
|
||||
f"after the load of the page the iframe of the other site has url {getattr(frame, 'url', None)!r}")
|
||||
assert_other_process(page.main_frame, frame)
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_cross_origin_iframe_url_appears_in_page_frames(firefox_binary, cross_origin_harness):
|
||||
"""``page.frames`` must list the cross-origin iframe with its real URL.
|
||||
@@ -252,6 +288,18 @@ def test_cross_origin_iframe_url_appears_in_page_frames(firefox_binary, cross_or
|
||||
)
|
||||
|
||||
|
||||
def _child_frame_of(page, handle, child_origin):
|
||||
"""The frame of an iframe handle once it has NAVIGATED to the child origin (a frame of another process is attached
|
||||
before it has an address), or whatever it is when the deadline of 30 s, far beyond a healthy run, passes: the
|
||||
caller's assertions then say what was wrong. A condition is waited for, not a duration."""
|
||||
def navigated():
|
||||
frame = handle.content_frame()
|
||||
return frame is not None and child_origin in (frame.url or "")
|
||||
|
||||
wait_until(navigated, 30, lambda: page.wait_for_timeout(100))
|
||||
return handle.content_frame()
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_cross_origin_iframe_content_frame_resolves(firefox_binary, cross_origin_harness):
|
||||
"""``handle.content_frame()`` must return a Frame (not None) for every
|
||||
@@ -264,12 +312,11 @@ def test_cross_origin_iframe_content_frame_resolves(firefox_binary, cross_origin
|
||||
page = ctx.new_page()
|
||||
page.goto(cross_origin_harness["parent_url"], wait_until="domcontentloaded", timeout=30_000)
|
||||
page.wait_for_selector("iframe#ifr_plain", timeout=10_000)
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
for sel in ("iframe#ifr_plain", "iframe#ifr_sandbox", "iframe#ifr_titled"):
|
||||
handle = page.query_selector(sel)
|
||||
assert handle is not None, f"{sel!r} not found in DOM"
|
||||
cf = handle.content_frame()
|
||||
cf = _child_frame_of(page, handle, cross_origin_harness["child_origin"])
|
||||
assert cf is not None, f"{sel!r}: content_frame() returned None"
|
||||
assert cross_origin_harness["child_origin"] in (cf.url or ""), (
|
||||
f"{sel!r}: content_frame().url = {cf.url!r}, "
|
||||
@@ -291,9 +338,8 @@ def test_cross_origin_iframe_evaluate_returns_real_values(firefox_binary, cross_
|
||||
page = ctx.new_page()
|
||||
page.goto(cross_origin_harness["parent_url"], wait_until="domcontentloaded", timeout=30_000)
|
||||
page.wait_for_selector("iframe#ifr_plain", timeout=10_000)
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
cf = page.query_selector("iframe#ifr_plain").content_frame()
|
||||
cf = _child_frame_of(page, page.query_selector("iframe#ifr_plain"), cross_origin_harness["child_origin"])
|
||||
assert cf is not None
|
||||
href = cf.evaluate("() => location.href")
|
||||
assert cross_origin_harness["child_origin"] in href
|
||||
@@ -340,9 +386,11 @@ def test_cross_origin_iframe_dispatch_event_click_works(firefox_binary, cross_or
|
||||
page.goto(cross_origin_harness["parent_url"], wait_until="domcontentloaded", timeout=30_000)
|
||||
page.wait_for_selector("iframe#ifr_plain", timeout=10_000)
|
||||
|
||||
page.frame_locator("iframe#ifr_plain").locator("button#ok").dispatch_event(
|
||||
"click", timeout=4_000
|
||||
)
|
||||
# the button of a document in another process can come later on a loaded runner: wait for it as a script would
|
||||
# (Windows CI of 13/11, run 43383366904: "found 0 elements"), then act, both with a deadline of 30 s
|
||||
button = page.frame_locator("iframe#ifr_plain").locator("button#ok")
|
||||
button.wait_for(timeout=30_000)
|
||||
button.dispatch_event("click", timeout=30_000)
|
||||
cf = page.query_selector("iframe#ifr_plain").content_frame()
|
||||
assert cf.evaluate("() => document.title") == "clicked"
|
||||
|
||||
@@ -443,7 +491,9 @@ def test_the_geometry_invariant_holds_inside_a_nested_frame(firefox_binary):
|
||||
frame = page.frame_locator("#f")
|
||||
page.frames[1].evaluate("() => { window.__ev = []; }")
|
||||
frame.locator("#g").hover(timeout=10000)
|
||||
page.wait_for_timeout(400)
|
||||
# until the frame has heard the pointer (its events come from another process, after the hover returned)
|
||||
wait_until(lambda: page.frames[1].evaluate("() => window.__ev.length") > 0, 30,
|
||||
lambda: page.wait_for_timeout(100))
|
||||
ev = page.frames[1].evaluate("() => window.__ev")
|
||||
inner = page.frames[1].evaluate("() => window.__inner()")
|
||||
assert ev, "no event received in the iframe: coverage absent, and this is NOT a pass"
|
||||
|
||||
@@ -73,7 +73,7 @@ def test_the_data_has_every_function_and_the_inputs_that_tell_the_libraries_apar
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_css_calc_functions_are_ucrtbase_bytes(firefox_binary, engine_at_least):
|
||||
engine_at_least("firefox-65")
|
||||
engine_at_least("firefox-66")
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
cases = _cases()
|
||||
|
||||
@@ -29,6 +29,7 @@ import statistics
|
||||
|
||||
import pytest
|
||||
|
||||
from _e2e_verdicts import MDNS_RETRY_MS, opened_at_the_retry_problem
|
||||
from test_webrtc_realness import _e2e_binary, _launch, candidates, decode_priority, host_candidates, is_mdns # noqa: F401
|
||||
|
||||
pytestmark = [pytest.mark.e2e, pytest.mark.usefixtures("the_udp_line")]
|
||||
@@ -50,7 +51,14 @@ _GATHER_JS = r"""async () => {
|
||||
const cands = [];
|
||||
pc.addEventListener('icecandidate', e => { if (e.candidate && e.candidate.candidate) cands.push(e.candidate.candidate); });
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await new Promise(r => setTimeout(r, 2500));
|
||||
// Until the gathering says it is over, not for a fixed time: how long a gathering takes is the speed of the machine, whether it ends is the product.
|
||||
// The deadline is far beyond any healthy run; a gathering that never completes returns what it has, and the assertions on the candidates fail on it.
|
||||
await new Promise(resolve => {
|
||||
const timer = setTimeout(resolve, 30000);
|
||||
const done = () => { if (pc.iceGatheringState === 'complete') { clearTimeout(timer); resolve(); } };
|
||||
pc.addEventListener('icegatheringstatechange', done);
|
||||
done();
|
||||
});
|
||||
try { pc.close(); } catch (e) {}
|
||||
return cands;
|
||||
}"""
|
||||
@@ -74,8 +82,16 @@ _LOOPBACK_JS = r"""async () => {
|
||||
await pc2.setRemoteDescription(pc1.localDescription);
|
||||
await pc2.setLocalDescription(await pc2.createAnswer());
|
||||
await pc1.setRemoteDescription(pc2.localDescription);
|
||||
const deadline = performance.now() + 8000;
|
||||
while (performance.now() < deadline && !(opened !== null && echoed)) await new Promise(r => setTimeout(r, 5));
|
||||
// Until the channel has opened and echoed, for 30 s (the deadline of the wait). The loop also keeps the longest time it did not run: a page that
|
||||
// was stopped by the machine says so, and the time the connection took is not judged then (`_e2e_verdicts.opened_at_the_retry_problem`).
|
||||
const deadline = performance.now() + 30000;
|
||||
let stalled = 0, last = performance.now();
|
||||
while (performance.now() < deadline && !(opened !== null && echoed)) {
|
||||
await new Promise(r => setTimeout(r, 5));
|
||||
const now = performance.now();
|
||||
stalled = Math.max(stalled, now - last);
|
||||
last = now;
|
||||
}
|
||||
// The road the connection took, read from the browser's own statistics: the nominated pair, and the protocol of each end.
|
||||
let pair = null;
|
||||
try {
|
||||
@@ -91,7 +107,7 @@ _LOOPBACK_JS = r"""async () => {
|
||||
});
|
||||
} catch (e) {}
|
||||
pc1.close(); pc2.close();
|
||||
return {opened, echoed, pair, gathered};
|
||||
return {opened, echoed, pair, gathered, stalled: Math.round(stalled)};
|
||||
}"""
|
||||
|
||||
# Retail 159 on Windows, 12 cold launches (``captures/mdns-loopback/retail-159-win-12``): 37-52 ms in ten of twelve, two
|
||||
@@ -101,7 +117,6 @@ _LOOPBACK_JS = r"""async () => {
|
||||
# the machine. What the test judges is the ROAD, which the machine cannot change (see the test), and a ceiling under the
|
||||
# first retry of the mDNS responder (3 s), which no machine is slow enough to reach by being slow.
|
||||
RETAIL_MEDIAN_WINDOW_MS = (30, 55) # printed beside the measure, for the reader
|
||||
MDNS_RETRY_MS = 3000 # the responder asks again after 3 s: a run that opens only then took the slow road
|
||||
|
||||
|
||||
def _session(declaration, socks, page_url, monkeypatch, seed, script):
|
||||
@@ -210,7 +225,8 @@ def test_two_connections_on_one_page_connect_in_the_time_of_retail(local_https_p
|
||||
socket could not bind and the connection fell back to TCP, about 600 ms on average);
|
||||
* the nominated pair is direct and local over UDP at both ends: host or peer-reflexive, never relay or server-reflexive, never
|
||||
TCP (a peer-reflexive end is legitimate: the other connection's mDNS name was not resolved yet and its check came first);
|
||||
* it opens in less than the responder's first retry (3 s): a name that does not come back opens only at the retry.
|
||||
* it opens in less than the responder's first retry (3 s) unless the page itself was stopped for a second or more in the meantime: a name that does
|
||||
not come back opens only at the retry, and a machine that stops for seconds opens late on any road.
|
||||
|
||||
The time itself is printed with the retail window beside it: a fast machine shows 30-55 ms, a runner shows more, and
|
||||
neither is a verdict (an absolute time failed on both GitHub runners with a healthy engine)."""
|
||||
@@ -236,7 +252,8 @@ def test_two_connections_on_one_page_connect_in_the_time_of_retail(local_https_p
|
||||
# network), and never TCP (checked above).
|
||||
assert pair["localType"] in ("host", "prflx") and pair["remoteType"] in ("host", "prflx"), (
|
||||
"run %d: the pair is not direct and local (a relay or a server-reflexive road): %r" % (n, pair))
|
||||
assert res["opened"] < MDNS_RETRY_MS, "run %d: opened after %d ms, at the responder's retry" % (n, res["opened"])
|
||||
problem = opened_at_the_retry_problem(res["opened"], res["stalled"], MDNS_RETRY_MS)
|
||||
assert problem is None, "run %d: %s" % (n, problem)
|
||||
times = sorted(r["opened"] for r in runs)
|
||||
low, high = RETAIL_MEDIAN_WINDOW_MS
|
||||
with capsys.disabled():
|
||||
|
||||
@@ -13,19 +13,20 @@ knows the names used here, so a page loads only if the lookup went to the DoH).
|
||||
measures). In global mode 0 `TRRService::GetRequestTimeout` returns `network.trr.request_timeout_ms` (1.5 s); in global
|
||||
mode 3 it returns `network.trr.request_timeout_mode_trronly_ms` (30 s). A request made TRR_ONLY per request under a global
|
||||
mode 0 would keep the 1.5 s one and fail a lookup whose answer is only 2 s away, with nothing to fall back to. The page
|
||||
must load, within 20 s, and the FakeDoh log must show the queries answered after the delay.
|
||||
must load, within 30 s, and the FakeDoh log must show the queries answered after the delay.
|
||||
* `test_a_name_the_doh_refused_once_resolves_on_the_next_request`: the FakeDoh refuses the FIRST query of each type for
|
||||
`flaky-a.test` by ending the exchange with no answer (a reset h2 stream: a failure of the CHANNEL, the kind
|
||||
`ConfirmationContext::RecordTRRStatus` counts; `_doh_servers.FAILURE_KINDS` has the other two) and serves it afterwards.
|
||||
The first navigation may fail (NS_ERROR_UNKNOWN_HOST) or load; then a retry loop (up to 5 navigations 2 s apart, each in a
|
||||
fresh page of the same context, nothing cleared) must load within 15 s AND the FakeDoh must have been asked a second time:
|
||||
fresh page of the same context, nothing cleared) must load at one of them AND the FakeDoh must have been asked a second time:
|
||||
the browser asks again instead of serving the failure from a cache or from a temporary block that a global TRR-only
|
||||
mode would not have (`IsTemporarilyBlocked` returns false under global mode 3, and its blocklist is fed by failures
|
||||
counted under the global modes).
|
||||
|
||||
Red on an engine with the 1.5 s DoH timeout (the giro-2 and giro-3 binaries before the timeout fix) for the first test:
|
||||
the lookup of `slow-a.test` fails after 1.5 s, the navigation ends in NS_ERROR_UNKNOWN_HOST and the page never loads. The
|
||||
second test is red if the failure of the first lookup sticks (negative cache or temporary block) longer than the retry loop.
|
||||
second test is red if the failure of the first lookup sticks (negative cache or temporary block) through all the attempts of the retry loop
|
||||
(a count of navigations 2 s apart, not a stopwatch: a slow machine lengthens the loop and never shortens what it tries).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -47,11 +48,14 @@ pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The latency of the slow DoH, and what a page behind it may take at most.
|
||||
DOH_LATENCY_S = 2.0
|
||||
SLOW_LOAD_LIMIT_S = 20.0
|
||||
#: The retries after a refusal: how many, how far apart, and the time they all have.
|
||||
SLOW_LOAD_LIMIT_S = 30.0
|
||||
#: The retries after a refusal: how many and how far apart (more than the 1 s negative cache). The loop is a COUNT of navigations, so
|
||||
#: a runner that stalls for seconds between two of them lengthens the test and never takes an attempt away from it.
|
||||
RETRIES = 5
|
||||
RETRY_GAP_S = 2.0
|
||||
RETRY_WINDOW_S = 15.0
|
||||
#: What one navigation of that loop may take: far beyond any healthy run (the product's own limits are 1.5 s for a DoH request and
|
||||
#: the 30 s of the slow page); a navigation that reaches it is a page that never ends, and is reported as that attempt's error.
|
||||
NAVIGATION_LIMIT_MS = 30000
|
||||
|
||||
|
||||
#: Firefox keeps the failure of ANY lookup (a refused DoH query included) in the DNS cache for network.dnsNegativeCacheExpiration
|
||||
@@ -111,7 +115,7 @@ def _only_the_doh_road_was_used(doh, gw, watcher):
|
||||
def test_a_slow_doh_still_resolves_the_name_of_a_proxied_context(firefox_binary, doh, pages, gateway, watcher,
|
||||
record_property):
|
||||
"""`slow-a.test` is known only to the FakeDoh, which answers it 2 s after the query. The page of a context with a
|
||||
proxy of its own must load within 20 s, reached by address through that proxy."""
|
||||
proxy of its own must load within 30 s, reached by address through that proxy."""
|
||||
doh.names["slow-a.test"] = "127.0.0.1"
|
||||
doh.delay_names["slow-a.test"] = DOH_LATENCY_S
|
||||
gw = gateway("gw")
|
||||
@@ -122,10 +126,11 @@ def test_a_slow_doh_still_resolves_the_name_of_a_proxied_context(firefox_binary,
|
||||
started = time.monotonic()
|
||||
try:
|
||||
page.goto(pages.url("slow-a.test"), wait_until="load", timeout=int(SLOW_LOAD_LIMIT_S * 1000))
|
||||
seconds = time.monotonic() - started # the load, as the limit judges it: the read of the text is not part of it
|
||||
text = _text(page)
|
||||
except Exception as exc: # noqa: BLE001 - reported below with what the FakeDoh saw
|
||||
error = "%s: %s" % (type(exc).__name__, str(exc).splitlines()[0] if str(exc) else "")
|
||||
seconds = time.monotonic() - started
|
||||
seconds = time.monotonic() - started
|
||||
context.close()
|
||||
watcher.stop()
|
||||
record_property("goto_seconds", "%.2f" % seconds)
|
||||
@@ -137,7 +142,6 @@ def test_a_slow_doh_still_resolves_the_name_of_a_proxied_context(firefox_binary,
|
||||
"the page behind a DoH that answers in %.0f s did not load (%s): the DoH request of a lookup made TRR_ONLY per "
|
||||
"request gave up before the answer (the 1.5 s timeout of global mode 0?)" % (DOH_LATENCY_S, error) + why)
|
||||
assert "HOST=slow-a.test:%d" % pages.port in text, "the page is not the page of the name: %r" % text + why
|
||||
assert seconds < SLOW_LOAD_LIMIT_S, "the page took %.1f s to load, the limit is %.0f s" % (seconds, SLOW_LOAD_LIMIT_S) + why
|
||||
assert seconds >= DOH_LATENCY_S - 0.2, (
|
||||
"the page loaded in %.2f s, before the DoH could have answered (%.0f s): the name was not resolved by it"
|
||||
% (seconds, DOH_LATENCY_S) + why)
|
||||
@@ -177,17 +181,12 @@ def test_a_name_the_doh_refused_once_resolves_on_the_next_request(firefox_binary
|
||||
with _launch_with_a_short_negative_cache(firefox_binary) as browser:
|
||||
context, page = _page_in(browser, proxy=gw.proxy)
|
||||
page.close()
|
||||
attempts.append(_navigate(context, url, 20000))
|
||||
window_starts = time.monotonic()
|
||||
while attempts[-1][0] is None and len(attempts) <= RETRIES:
|
||||
remaining = RETRY_WINDOW_S - (time.monotonic() - window_starts)
|
||||
if remaining <= 0:
|
||||
attempts.append(_navigate(context, url, NAVIGATION_LIMIT_MS))
|
||||
for _retry in range(RETRIES):
|
||||
if attempts[-1][0] is not None:
|
||||
break
|
||||
time.sleep(min(RETRY_GAP_S, remaining))
|
||||
remaining = RETRY_WINDOW_S - (time.monotonic() - window_starts)
|
||||
if remaining <= 0:
|
||||
break
|
||||
attempts.append(_navigate(context, url, int(min(8.0, remaining) * 1000)))
|
||||
time.sleep(RETRY_GAP_S)
|
||||
attempts.append(_navigate(context, url, NAVIGATION_LIMIT_MS))
|
||||
context.close()
|
||||
watcher.stop()
|
||||
record_property("attempts", str([(ok is not None, err, round(s, 2)) for ok, err, s in attempts]))
|
||||
@@ -203,8 +202,8 @@ def test_a_name_the_doh_refused_once_resolves_on_the_next_request(firefox_binary
|
||||
"the FakeDoh never refused the first A query of the name: the test did not exercise a refusal" + why)
|
||||
loaded = [a for a in attempts if a[0] is not None]
|
||||
assert loaded, (
|
||||
"no navigation to a name the DoH refused once loaded in %d attempts / %.0f s: the failure of the first lookup "
|
||||
"sticks (a cached failure or a temporary block)" % (len(attempts), RETRY_WINDOW_S) + why)
|
||||
"no navigation to a name the DoH refused once loaded in %d attempts, %.0f s apart: the failure of the first lookup "
|
||||
"sticks (a cached failure or a temporary block)" % (len(attempts), RETRY_GAP_S) + why)
|
||||
assert "HOST=flaky-a.test:%d" % pages.port in loaded[0][0], "the page is not the page of the name: %r" % loaded[0][0] + why
|
||||
assert len(queries) >= 2, (
|
||||
"the DoH was asked for the A record of the name %d time(s): the browser must ask again after a refusal, not serve "
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
"""`Locator.screenshot()` / `ElementHandle.screenshot()` photograph the element: its size, its pixels, wherever it is.
|
||||
|
||||
The wrapper had no `screenshot` on an element handle ("ElementHandle has no method 'screenshot'"). The picture is the page's own
|
||||
screenshot of the element's box, so the checks are the ones that can go wrong with a box: an element below the fold (it has to be
|
||||
scrolled in and the document scroll added to a box that is in viewport coordinates), an element inside a frame that the page has
|
||||
scrolled, an `<iframe>` element itself, and the size of the picture being the size of the box.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
GREEN, PINK = (0, 204, 68), (255, 0, 170)
|
||||
|
||||
PAGE = (
|
||||
"<!doctype html><title>shot</title><body style='margin:0;background:#fff'>"
|
||||
"<div id='top' style='position:absolute;left:20px;top:10px;width:30px;height:20px;background:#ff00aa'></div>"
|
||||
"<div id='below' style='position:absolute;left:40px;top:2500px;width:80px;height:60px;background:#00cc44'></div>"
|
||||
"<iframe id='f' style='position:absolute;left:100px;top:900px;width:200px;height:120px;border:0' srcdoc=\""
|
||||
"<body style='margin:0;background:#ff00aa'><div style='height:600px'></div>"
|
||||
"<div id='inner' style='margin-left:15px;width:50px;height:40px;background:#00cc44'></div>"
|
||||
"<div style='height:900px'></div>\"></iframe>"
|
||||
"<div style='position:absolute;top:4000px;width:1px;height:1px'></div>"
|
||||
)
|
||||
|
||||
|
||||
def decode_png(data: bytes):
|
||||
"""(width, height, pixel(x, y)) of an 8-bit RGB/RGBA PNG without interlacing."""
|
||||
assert data[:8] == b"\x89PNG\r\n\x1a\n", "not a PNG"
|
||||
pos, idat, width = 8, b"", 0
|
||||
while pos < len(data):
|
||||
length, kind = struct.unpack(">I4s", data[pos:pos + 8])
|
||||
body = data[pos + 8:pos + 8 + length]
|
||||
if kind == b"IHDR":
|
||||
width, height, depth, color, _c, _f, interlace = struct.unpack(">IIBBBBB", body)
|
||||
assert depth == 8 and color in (2, 6) and interlace == 0, (depth, color, interlace)
|
||||
step = 3 if color == 2 else 4
|
||||
elif kind == b"IDAT":
|
||||
idat += body
|
||||
pos += 12 + length
|
||||
raw, stride, rows, prev = zlib.decompress(idat), width * step, [], bytearray(width * step)
|
||||
for y in range(height):
|
||||
ft, line = raw[y * (stride + 1)], bytearray(raw[y * (stride + 1) + 1:(y + 1) * (stride + 1)])
|
||||
for i in range(stride):
|
||||
a = line[i - step] if i >= step else 0
|
||||
b = prev[i]
|
||||
c = prev[i - step] if i >= step else 0
|
||||
if ft == 1:
|
||||
line[i] = (line[i] + a) & 255
|
||||
elif ft == 2:
|
||||
line[i] = (line[i] + b) & 255
|
||||
elif ft == 3:
|
||||
line[i] = (line[i] + (a + b) // 2) & 255
|
||||
elif ft == 4:
|
||||
p = a + b - c
|
||||
pa, pb, pc = abs(p - a), abs(p - b), abs(p - c)
|
||||
line[i] = (line[i] + (a if pa <= pb and pa <= pc else b if pb <= pc else c)) & 255
|
||||
rows.append(line)
|
||||
prev = line
|
||||
return width, height, lambda x, y: tuple(rows[y][x * step:x * step + 3])
|
||||
|
||||
|
||||
def _near(a, b, tol=6):
|
||||
return all(abs(p - q) <= tol for p, q in zip(a, b))
|
||||
|
||||
|
||||
def _whole(png, color):
|
||||
width, height, pixel = decode_png(png)
|
||||
for x, y in ((0, 0), (width - 1, 0), (0, height - 1), (width - 1, height - 1), (width // 2, height // 2)):
|
||||
assert _near(pixel(x, y), color), ((x, y), pixel(x, y), color)
|
||||
return width, height
|
||||
|
||||
|
||||
def test_an_element_screenshot_is_the_element_wherever_it_is(firefox_binary, tmp_path):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
(tmp_path / "p.html").write_text(PAGE, encoding="utf-8")
|
||||
with InvisiblePlaywright(seed=4262, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto((tmp_path / "p.html").as_uri(), wait_until="load")
|
||||
# in view
|
||||
assert _whole(page.locator("#top").screenshot(scale="css"), PINK) == (30, 20)
|
||||
# far below the fold: scrolled in, then the document scroll is added to its viewport box
|
||||
assert page.evaluate("window.scrollY") == 0
|
||||
assert _whole(page.locator("#below").screenshot(scale="css"), GREEN) == (80, 60)
|
||||
# the same element again, now that the page has scrolled to it
|
||||
assert _whole(page.locator("#below").screenshot(scale="css"), GREEN) == (80, 60)
|
||||
# an element in a frame, below that frame's fold, in a page that is scrolled: size and pixels
|
||||
frame = page.frames[1]
|
||||
assert _whole(frame.locator("#inner").screenshot(scale="css"), GREEN) == (50, 40)
|
||||
# the <iframe> element is the frame: pink around, the green swatch inside it
|
||||
width, height, pixel = decode_png(page.locator("#f").screenshot(scale="css"))
|
||||
assert (width, height) == (200, 120)
|
||||
assert _near(pixel(3, 3), PINK)
|
||||
|
||||
|
||||
def test_an_element_that_is_not_there_has_no_screenshot(firefox_binary, tmp_path):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
(tmp_path / "p.html").write_text("<!doctype html><div id='gone' style='display:none'>x</div>", encoding="utf-8")
|
||||
with InvisiblePlaywright(seed=4263, binary_path=firefox_binary, headless=True) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto((tmp_path / "p.html").as_uri(), wait_until="load")
|
||||
with pytest.raises(Exception, match="not visible"):
|
||||
page.locator("#gone").screenshot(timeout=2000)
|
||||
@@ -0,0 +1,295 @@
|
||||
"""`page.expose_function` / `page.expose_binding` / `context.expose_function` / `context.expose_binding`.
|
||||
|
||||
They used to refuse ("not wired" / "no method 'exposeBinding'"). The page calls a Python function and gets its answer as a
|
||||
promise: the value, a rejection when the Python function raised, an await when it is async.
|
||||
|
||||
THE RULE THAT MATTERS MORE THAN THE FEATURE: A PAGE SEES `foo` AND NOTHING ELSE. A page can list the names on its window, so a
|
||||
transport left there is the driver's signature. These tests read what the page reads: the own properties of `window` (names and
|
||||
symbols) with and without an exposed function, in the top, in a frame of another site (another process), in the document born
|
||||
after a navigation and after `document.open()`; what `foo.toString()` and the stack of an error from `foo` say; and that `foo`
|
||||
looks like a function the page defined itself (name, length, descriptor, own properties, position among the keys).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import http.server
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
||||
from _waits import wait_until
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
PAGE = "<!doctype html><title>t</title><body><iframe id='f' srcdoc='<p>frame</p>'></iframe>"
|
||||
|
||||
# What a page can read of its own window: every own name, own symbols, and the enumeration order.
|
||||
WINDOW = ("(() => ({names: Object.getOwnPropertyNames(window).sort(), keys: Object.keys(window),"
|
||||
" symbols: Object.getOwnPropertySymbols(window).map(String)}))()")
|
||||
|
||||
#: Words that would give the driver away, in anything the page can read.
|
||||
TELLS = ("playwright", "binding", "juggler", "invisible", "chrome://", "resource://", "moz-src", "debugger eval")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def browser(firefox_binary):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4264, binary_path=firefox_binary, headless=True) as b:
|
||||
yield b
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def url(tmp_path):
|
||||
(tmp_path / "p.html").write_text(PAGE, encoding="utf-8")
|
||||
return (tmp_path / "p.html").as_uri()
|
||||
|
||||
|
||||
def _extra(seen, base):
|
||||
return sorted(set(seen["names"]) - set(base["names"])), sorted(set(seen["symbols"]) - set(base["symbols"]))
|
||||
|
||||
|
||||
def test_a_page_function_exposed_before_the_load_answers_and_survives_a_navigation(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
page.expose_function("add", lambda a, b: a + b)
|
||||
for target in (url, url + "?again"):
|
||||
page.goto(target, wait_until="load")
|
||||
assert page.evaluate("add(2, 3)") == 5
|
||||
|
||||
|
||||
def test_a_page_function_exposed_after_the_load_reaches_the_document_that_exists(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
page.goto(url, wait_until="load")
|
||||
page.expose_function("twice", lambda x: x * 2)
|
||||
assert page.evaluate("twice(21)") == 42
|
||||
|
||||
|
||||
def test_two_functions_on_one_page_answer_each_its_own_calls(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
page.expose_function("one", lambda: "one")
|
||||
page.expose_function("two", lambda: "two")
|
||||
page.goto(url, wait_until="load")
|
||||
assert page.evaluate("Promise.all([one(), two(), two(), one()])") == ["one", "two", "two", "one"]
|
||||
|
||||
|
||||
def test_the_answer_is_awaited_and_a_python_error_rejects_the_promise(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
|
||||
def boom(_):
|
||||
raise ValueError("nope from python")
|
||||
|
||||
async def slow(x):
|
||||
return {"got": x, "list": [1, 2]}
|
||||
|
||||
page.expose_function("boom", boom)
|
||||
page.expose_function("slow", slow)
|
||||
page.goto(url, wait_until="load")
|
||||
assert page.evaluate("slow('a')") == {"got": "a", "list": [1, 2]}
|
||||
assert "nope from python" in page.evaluate("boom(1).then(() => 'resolved', e => String(e.message))")
|
||||
|
||||
|
||||
def test_a_binding_gets_the_source_page_and_frame(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
seen = {}
|
||||
|
||||
def binding(source, value):
|
||||
seen.update(page=source["page"], frame=source["frame"], context=source["context"])
|
||||
return value
|
||||
|
||||
page.expose_binding("who", binding)
|
||||
page.goto(url, wait_until="load")
|
||||
assert page.evaluate("who('x')") == "x"
|
||||
assert seen["page"] is page and seen["frame"] is page.main_frame and seen["context"] is page.context
|
||||
|
||||
|
||||
def test_a_page_function_is_not_on_another_page_of_the_context(browser, url):
|
||||
context = browser.new_context()
|
||||
first, second = context.new_page(), context.new_page()
|
||||
first.expose_function("mine", lambda: "first")
|
||||
first.goto(url, wait_until="load")
|
||||
second.goto(url, wait_until="load")
|
||||
assert first.evaluate("typeof mine") == "function"
|
||||
assert second.evaluate("typeof mine") == "undefined"
|
||||
|
||||
|
||||
def test_a_context_function_is_on_the_page_that_exists_the_page_to_come_and_their_frames(browser, url):
|
||||
context = browser.new_context()
|
||||
existing = context.new_page()
|
||||
existing.goto(url, wait_until="load")
|
||||
context.expose_function("ctx", lambda x: "ctx:" + x)
|
||||
later = context.new_page()
|
||||
later.goto(url, wait_until="load")
|
||||
for page in (existing, later):
|
||||
assert page.evaluate("ctx('a')") == "ctx:a"
|
||||
frame = page.frames[1]
|
||||
assert frame.evaluate("ctx('b')") == "ctx:b"
|
||||
existing.goto(url + "?again", wait_until="load")
|
||||
assert existing.evaluate("ctx('c')") == "ctx:c"
|
||||
|
||||
|
||||
def test_a_disposed_function_is_gone_now_and_in_the_documents_to_come(browser, url):
|
||||
page = browser.new_context().new_page()
|
||||
page.goto(url, wait_until="load")
|
||||
handle = page.expose_function("gone", lambda: 1)
|
||||
assert page.evaluate("gone()") == 1
|
||||
handle.dispose()
|
||||
assert page.evaluate("typeof gone") == "undefined"
|
||||
page.goto(url + "?again", wait_until="load")
|
||||
assert page.evaluate("typeof gone") == "undefined"
|
||||
|
||||
|
||||
# ── what the page can read ──────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
def test_without_an_exposed_function_nothing_is_added_and_with_one_only_its_name(browser, url):
|
||||
"""No `expose_*`: the engine installs nothing, and the window has no name that is ours. After `expose_function('foo')` the
|
||||
window has `foo` more, and no symbol more: the transport is not reachable."""
|
||||
plain = browser.new_context().new_page()
|
||||
plain.goto(url, wait_until="load")
|
||||
base = plain.evaluate(WINDOW)
|
||||
assert not [n for n in base["names"] if any(t in n.lower() for t in ("playwright", "binding", "juggler"))]
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
context.expose_function("foo", lambda x: x)
|
||||
page.goto(url, wait_until="load")
|
||||
seen = page.evaluate(WINDOW)
|
||||
assert _extra(seen, base) == (["foo"], [])
|
||||
assert seen["keys"][: len(base["keys"])] == base["keys"], "the order of the keys moved"
|
||||
assert seen["keys"][-1] == "foo"
|
||||
|
||||
|
||||
def _all_frames_there(page, wanted):
|
||||
"""Until the page lists exactly the frames of the three documents (the frames of other processes are announced
|
||||
after the load of the top), with a deadline far beyond a healthy run: a machine's speed is not the verdict."""
|
||||
def listed():
|
||||
return sorted(f.url.split("?")[0] for f in page.frames)
|
||||
|
||||
assert wait_until(lambda: listed() == wanted, 30, lambda: page.wait_for_timeout(100)), (
|
||||
"the page never listed the three frames %r; it lists %r" % (wanted, listed()))
|
||||
|
||||
|
||||
def test_the_only_name_is_foo_in_a_frame_of_another_site_and_in_the_document_after_a_navigation(browser, tmp_path):
|
||||
"""127.0.0.1 and localhost are two sites, so two processes. The frame of the other site, a nested frame, the document the
|
||||
page navigates to and the one a `document.open()` rewrites: each shows `foo` and nothing else."""
|
||||
class Handler(http.server.BaseHTTPRequestHandler):
|
||||
pages = {}
|
||||
|
||||
def do_GET(self):
|
||||
body = self.pages.get(self.path.split("?")[0], "<!doctype html><title>t</title>").encode()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *_):
|
||||
pass
|
||||
|
||||
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
port = server.server_address[1]
|
||||
Handler.pages = {
|
||||
"/top": "<!doctype html><title>top</title><iframe src='http://localhost:%d/child'></iframe>" % port,
|
||||
"/child": "<!doctype html><title>child</title><iframe src='http://127.0.0.1:%d/grand'></iframe>" % port,
|
||||
"/grand": "<!doctype html><title>grand</title>",
|
||||
}
|
||||
wanted = sorted(["http://127.0.0.1:%d/top" % port, "http://localhost:%d/child" % port, "http://127.0.0.1:%d/grand" % port])
|
||||
try:
|
||||
plain = browser.new_context().new_page()
|
||||
plain.goto("http://127.0.0.1:%d/top" % port, wait_until="load")
|
||||
_all_frames_there(plain, wanted)
|
||||
base = {f.url: f.evaluate(WINDOW) for f in plain.frames}
|
||||
assert len(base) == 3, sorted(base)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
context.expose_function("foo", lambda x: x)
|
||||
for target in ("http://127.0.0.1:%d/top" % port, "http://127.0.0.1:%d/top?again" % port):
|
||||
page.goto(target, wait_until="load")
|
||||
_all_frames_there(page, wanted)
|
||||
seen = {f.url.split("?")[0]: f.evaluate(WINDOW) for f in page.frames}
|
||||
assert sorted(seen) == sorted(base)
|
||||
for frame_url, window in seen.items():
|
||||
assert _extra(window, base[frame_url]) == (["foo"], []), frame_url
|
||||
# a child that reads its parent and its top finds no name of ours either
|
||||
child = next(f for f in page.frames if f.url.startswith("http://localhost"))
|
||||
# (cross-site: the parent is opaque to the child, which is the point; the same-origin case is the srcdoc test below)
|
||||
assert child.evaluate("typeof foo") == "function"
|
||||
# after document.open() the window of the document is the one it was
|
||||
page.evaluate("document.open(); document.write('<!doctype html><p>again</p>'); document.close()")
|
||||
after = page.evaluate(WINDOW)
|
||||
assert _extra(after, base[sorted(base)[0]]) == (["foo"], []) or "foo" in after["names"]
|
||||
assert not [n for n in after["names"] if any(t in n.lower() for t in ("playwright", "binding", "juggler"))]
|
||||
finally:
|
||||
server.shutdown()
|
||||
|
||||
|
||||
def test_a_same_origin_child_reading_parent_and_top_finds_nothing_more_than_foo(browser, url):
|
||||
plain = browser.new_context().new_page()
|
||||
plain.goto(url, wait_until="load")
|
||||
base = plain.evaluate(WINDOW)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.expose_function("foo", lambda x: x)
|
||||
page.goto(url, wait_until="load")
|
||||
child = page.frames[1]
|
||||
for reach in ("parent", "top"):
|
||||
seen = child.evaluate("(() => ({names: Object.getOwnPropertyNames(%s).sort(), symbols: Object.getOwnPropertySymbols(%s).length}))()"
|
||||
% (reach, reach))
|
||||
assert _extra({"names": seen["names"], "symbols": []}, base) == (["foo"], []), reach
|
||||
assert seen["symbols"] == 0
|
||||
page.evaluate("document.open(); document.write('<!doctype html><p>again</p>'); document.close()")
|
||||
assert _extra(page.evaluate(WINDOW), base) == (["foo"], [])
|
||||
|
||||
|
||||
def test_foo_reads_as_a_function_the_page_defined(browser, url):
|
||||
"""Its source, its name, its length, its own properties, its descriptor on the window and its place among the keys are those of
|
||||
`window.bar = function (...args) { ... }` written by the page, and nothing in what it says or in the stack of an error raised
|
||||
from it names the driver."""
|
||||
page = browser.new_context().new_page()
|
||||
page.expose_function("foo", lambda x: x)
|
||||
page.expose_function("raises", lambda x: (_ for _ in ()).throw(ValueError("python said no")))
|
||||
page.goto(url, wait_until="load")
|
||||
# a script tag runs in the page's own realm (an evaluate runs in the caller's, whose Function.prototype is another one)
|
||||
page.add_script_tag(content="window.bar = function (...args) { return args; }")
|
||||
read = page.evaluate("""(() => {
|
||||
const d = n => { const x = Object.getOwnPropertyDescriptor(window, n); return {w: x.writable, e: x.enumerable, c: x.configurable, t: typeof x.value}; };
|
||||
// the own properties FIRST: reading `name` or `length` resolves them and moves them in the list
|
||||
const own = Object.getOwnPropertyNames(foo), ownBar = Object.getOwnPropertyNames(bar);
|
||||
return {
|
||||
own, ownBar, name: foo.name, length: foo.length,
|
||||
desc: d('foo'), descBar: d('bar'), proto: Object.getPrototypeOf(foo) === Object.getPrototypeOf(bar),
|
||||
source: foo.toString(), symbols: Object.getOwnPropertySymbols(foo).length,
|
||||
keys: Object.keys(window).filter(k => k === 'foo' || k === 'bar' || k === 'raises'),
|
||||
ctor: foo.constructor === bar.constructor,
|
||||
};
|
||||
})()""")
|
||||
assert read["name"] == "foo" and read["length"] == 0
|
||||
assert read["own"] == read["ownBar"]
|
||||
assert read["desc"] == read["descBar"] and read["symbols"] == 0 and read["proto"] and read["ctor"]
|
||||
assert read["keys"] == ["foo", "raises", "bar"], read["keys"]
|
||||
assert not [t for t in TELLS if t in read["source"].lower()], read["source"]
|
||||
# the stack of an error thrown by the call itself (a value that cannot be sent) and of a rejection from Python
|
||||
stacks = page.evaluate("""(async () => {
|
||||
const out = [];
|
||||
try { await foo(1n); } catch (e) { out.push(String(e.stack), String(e.message), e.name); }
|
||||
try { await raises(1); } catch (e) { out.push(String(e.stack), String(e.message), e.name); }
|
||||
return out;
|
||||
})()""")
|
||||
assert len(stacks) == 6
|
||||
for text in stacks:
|
||||
assert not [t for t in TELLS if t in text.lower()], text
|
||||
assert "python said no" in stacks[4]
|
||||
|
||||
|
||||
def test_a_worker_gets_nothing(browser, url):
|
||||
"""The engine installs a binding in the frames of a page, as Playwright's does: a worker has no `foo`, and its global
|
||||
has nothing more than a worker of a page without one."""
|
||||
page = browser.new_context().new_page()
|
||||
probe = ("new Promise(r => { const w = new Worker(URL.createObjectURL(new Blob(["
|
||||
"'postMessage(JSON.stringify({foo: typeof foo, names: Object.getOwnPropertyNames(self).sort()}))'])));"
|
||||
" w.onmessage = e => r(JSON.parse(e.data)); })")
|
||||
page.goto(url, wait_until="load")
|
||||
base = page.evaluate(probe)
|
||||
page.expose_function("foo", lambda: 1)
|
||||
page.goto(url + "?again", wait_until="load")
|
||||
seen = page.evaluate(probe)
|
||||
assert seen == base and seen["foo"] == "undefined"
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Exposed functions need an engine that hands the page-side end of a binding over and has `Page.addBinding`.
|
||||
|
||||
No fallback to a name on the window: an engine without them is refused with a sentence that says so, before anything is installed.
|
||||
(No browser: the engine is read from its files.)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def test_an_engine_without_what_the_functions_need_refuses_and_leaves_no_name(tmp_path):
|
||||
"""No fallback to a name on the window: an engine without `Page.addBinding` and the binding that hands its end over is
|
||||
refused with a sentence that says so."""
|
||||
from invisible_playwright._juggler import _bindings
|
||||
from invisible_playwright._juggler.dispatcher import ProtocolException
|
||||
from invisible_playwright._juggler.server import BrowserContextDispatcher
|
||||
|
||||
loose = tmp_path / "modules" / "juggler" / "protocol"
|
||||
loose.mkdir(parents=True)
|
||||
(loose / "Protocol.js").write_text("'addBinding': { params: {} },", encoding="utf-8")
|
||||
assert _bindings.engine_supports(str(tmp_path)) is False # one addBinding: the browser's only
|
||||
assert _bindings.engine_supports("") is False
|
||||
(loose / "Protocol.js").write_text("'addBinding': { params: {} },\n'addBinding': { params: {} },", encoding="utf-8")
|
||||
_bindings.engine_supports.cache_clear()
|
||||
assert _bindings.engine_supports(str(tmp_path)) is True
|
||||
|
||||
class Browser:
|
||||
engine_dir = str(tmp_path / "old")
|
||||
|
||||
context = object.__new__(BrowserContextDispatcher)
|
||||
context.__dict__["browser"] = Browser()
|
||||
with pytest.raises(ProtocolException, match="newer engine"):
|
||||
BrowserContextDispatcher.require_binding_engine(context)
|
||||
@@ -32,6 +32,7 @@ import pytest
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
from _servers import LocalServer
|
||||
from _waits import wait_until
|
||||
|
||||
PAGE = b"""<!DOCTYPE html><html><body>
|
||||
<input id="f" type="file">
|
||||
@@ -61,6 +62,13 @@ class _Handler(http.server.BaseHTTPRequestHandler):
|
||||
pass
|
||||
|
||||
|
||||
def _change_heard(page):
|
||||
"""Until the page has written its `change` (`#out` is empty until then), with a deadline far beyond a healthy run:
|
||||
a machine's speed is not the verdict. What it wrote is then judged by the caller's assertion."""
|
||||
assert wait_until(lambda: page.inner_text("#out") != "", 30, lambda: page.wait_for_timeout(100)), (
|
||||
"the page never saw a `change` event; #out is %r" % page.inner_text("#out"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_page():
|
||||
"""A real page from 127.0.0.1: `data:` URLs carry their own CSP."""
|
||||
@@ -130,7 +138,7 @@ def test_the_chosen_files_arrive_at_the_page(firefox_binary, local_page,
|
||||
with page.expect_file_chooser(timeout=15000) as info:
|
||||
page.click("#b")
|
||||
info.value.set_files(sample_file)
|
||||
page.wait_for_timeout(400)
|
||||
_change_heard(page)
|
||||
assert "sample.txt" in page.inner_text("#out")
|
||||
|
||||
|
||||
@@ -151,7 +159,7 @@ def test_without_interception_the_file_inputs_remain_normal(firefox_binary,
|
||||
page = browser.new_page()
|
||||
page.goto(local_page, wait_until="load")
|
||||
page.set_input_files("#f", sample_file)
|
||||
page.wait_for_timeout(300)
|
||||
_change_heard(page)
|
||||
assert "sample.txt" in page.inner_text("#out")
|
||||
|
||||
|
||||
@@ -173,7 +181,7 @@ def test_a_hidden_input_takes_files_through_its_chooser(firefox_binary,
|
||||
with page.expect_file_chooser(timeout=15000) as info:
|
||||
page.click("#hb")
|
||||
info.value.set_files(sample_file, timeout=5000)
|
||||
page.wait_for_timeout(400)
|
||||
_change_heard(page)
|
||||
assert page.inner_text("#out") == "change:h:sample.txt"
|
||||
|
||||
|
||||
@@ -186,5 +194,5 @@ def test_a_hidden_input_takes_files_by_selector(firefox_binary, local_page,
|
||||
page = browser.new_page()
|
||||
page.goto(local_page, wait_until="load")
|
||||
page.set_input_files("#h", sample_file, timeout=5000)
|
||||
page.wait_for_timeout(300)
|
||||
_change_heard(page)
|
||||
assert page.inner_text("#out") == "change:h:sample.txt"
|
||||
@@ -146,7 +146,7 @@ def _worker_navigator_dict(page, props):
|
||||
worker.onmessage = (e) => resolve(e.data);
|
||||
worker.onerror = (e) => reject(new Error(e.message));
|
||||
worker.postMessage(props);
|
||||
setTimeout(() => reject(new Error('worker timeout')), 5000);
|
||||
setTimeout(() => reject(new Error('worker timeout')), 30000);
|
||||
});
|
||||
return result;
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
"""What a frame of another site starts reaches the page, and the answer reaches back.
|
||||
|
||||
A page of site A holds a frame of site B, which holds a frame of site C. From inside each of those two frames a
|
||||
script opens a dialog (`alert`, `confirm`, `prompt`), a link starts a download, and `window.open` or a
|
||||
`target=_blank` link opens a popup. In Fission the frame's process is not the page's, and each of these crosses
|
||||
back to the browser process: the dialog is raised by the frame's process and answered by the driver, the download
|
||||
belongs to the frame's channel, the popup is created by the frame's window with the frame's origin as its opener.
|
||||
|
||||
Asserted, and the same as stock Playwright Firefox does it:
|
||||
|
||||
* the `dialog` event of the PAGE fires for a dialog of a frame, with its type, message and default value, and what
|
||||
the handler decides is what the frame's script gets back (`confirm` true or false, `prompt` the text or null);
|
||||
* `page.expect_download()` fires for a link of the frame, with the file name, the url and the bytes served;
|
||||
* `page.expect_popup()` fires for `window.open` and for a `target=_blank` link of the frame; the popup is at the
|
||||
url asked for and `popup.opener()` is the page whose frame opened it; its `window.opener` is there for
|
||||
`window.open` and absent for a `target=_blank` link, with or without `rel=noopener` (a link to a new tab is
|
||||
`noopener` by default).
|
||||
|
||||
The first test proves the frames are in other processes (`_fission_frames.assert_other_process`), so the file
|
||||
cannot turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from _fission_frames import Sites, assert_other_process, launch, new_page, wait_frame
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
PAYLOAD = b"fission-frame-download\x00\x01\x02" * 50
|
||||
|
||||
#: The controls of a document that starts things; `%s` is the url of the popup it opens.
|
||||
CONTROLS = ("<button id='open' onclick=\"window.__win = window.open(%(popup)s)\">open</button>"
|
||||
"<a id='blank' href=%(popup)s target='_blank'>blank</a>"
|
||||
"<a id='noopener' href=%(popup)s target='_blank' rel='noopener'>noopener</a>"
|
||||
"<a id='dl' href='/file.bin' download>download</a>"
|
||||
"<a id='dl-header' href='/attachment.bin'>download by header</a>")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sites():
|
||||
with Sites() as s:
|
||||
popup = "'%s'" % s.url("C", "/popup")
|
||||
s.route("A", "/top", "<!doctype html><title>top</title><iframe id='b' src='%s' width='600' height='300'>"
|
||||
"</iframe>" % s.url("B", "/frame"))
|
||||
s.route("B", "/frame", "<!doctype html><title>frame</title>" + CONTROLS % {"popup": popup}
|
||||
+ "<iframe id='c' src='%s' width='450' height='150'></iframe>" % s.url("C", "/nested"))
|
||||
s.route("C", "/nested", "<!doctype html><title>nested</title>" + CONTROLS % {"popup": popup})
|
||||
s.route("C", "/popup", "<!doctype html><title>popup</title><body>popup at C"
|
||||
"<script>window.__opener = window.opener !== null;</script>")
|
||||
for site in ("B", "C"):
|
||||
s.route(site, "/file.bin", PAYLOAD, ctype="application/octet-stream")
|
||||
s.route(site, "/attachment.bin", PAYLOAD, ctype="application/octet-stream",
|
||||
headers=[("Content-Disposition", 'attachment; filename="by-header.bin"')])
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser(firefox_binary):
|
||||
with launch(firefox_binary) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser):
|
||||
context, page = new_page(browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def opened(page, sites):
|
||||
"""The page loaded, and the frame of B and the frame of C nested in it."""
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b = wait_frame(page, sites.url("B"), "/frame")
|
||||
c = wait_frame(page, sites.url("C"), "/nested")
|
||||
return page, {"frame": b, "nested": c}
|
||||
|
||||
|
||||
def test_the_frames_are_in_other_processes(opened):
|
||||
page, frames = opened
|
||||
assert_other_process(page.main_frame, frames["frame"])
|
||||
assert_other_process(frames["frame"], frames["nested"])
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# dialogs
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
@pytest.mark.parametrize("kind,accept,text,expected", [
|
||||
("alert", True, None, "returned"),
|
||||
("confirm", True, None, True),
|
||||
("confirm", False, None, False),
|
||||
("prompt", True, "typed answer", "typed answer"),
|
||||
("prompt", False, None, None),
|
||||
])
|
||||
def test_a_dialog_of_a_frame_reaches_the_page_and_the_answer_goes_back(opened, target, kind, accept, text,
|
||||
expected):
|
||||
page, frames = opened
|
||||
frame = frames[target]
|
||||
seen = []
|
||||
|
||||
def on_dialog(dialog):
|
||||
seen.append((dialog.type, dialog.message, dialog.default_value))
|
||||
if accept:
|
||||
dialog.accept(text) if text is not None else dialog.accept()
|
||||
else:
|
||||
dialog.dismiss()
|
||||
|
||||
page.on("dialog", on_dialog)
|
||||
call = {"alert": "alert('hello from the frame'); window.__r = {v: 'returned'}",
|
||||
"confirm": "window.__r = {v: confirm('sure?')}",
|
||||
"prompt": "window.__r = {v: prompt('name?', 'default text')}"}[kind]
|
||||
frame.evaluate("() => { window.__r = null; setTimeout(() => { %s }, 0); }" % call)
|
||||
frame.wait_for_function("window.__r !== null")
|
||||
assert frame.evaluate("window.__r.v") == expected
|
||||
message, default = {"alert": ("hello from the frame", ""), "confirm": ("sure?", ""),
|
||||
"prompt": ("name?", "default text")}[kind]
|
||||
assert seen == [(kind, message, default)]
|
||||
|
||||
|
||||
def test_two_dialogs_one_after_the_other_from_different_frames(opened):
|
||||
"""The dialog of the nested frame, then the one of its parent: each answered in turn by the same handler."""
|
||||
page, frames = opened
|
||||
answers = iter([True, False])
|
||||
page.on("dialog", lambda dialog: dialog.accept() if next(answers) else dialog.dismiss())
|
||||
nested, frame = frames["nested"], frames["frame"]
|
||||
nested.evaluate("() => { window.__r = null; setTimeout(() => { window.__r = confirm('one'); }, 0); }")
|
||||
nested.wait_for_function("window.__r !== null")
|
||||
frame.evaluate("() => { window.__r = null; setTimeout(() => { window.__r = confirm('two'); }, 0); }")
|
||||
frame.wait_for_function("window.__r !== null")
|
||||
assert nested.evaluate("window.__r") is True
|
||||
assert frame.evaluate("window.__r") is False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# downloads
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
@pytest.mark.parametrize("link,filename", [("#dl", "file.bin"), ("#dl-header", "by-header.bin")])
|
||||
def test_a_download_started_in_a_frame_reaches_expect_download(opened, sites, target, link, filename):
|
||||
page, frames = opened
|
||||
frame = frames[target]
|
||||
site, base = ("B", "/frame") if target == "frame" else ("C", "/nested")
|
||||
with page.expect_download() as info:
|
||||
frame.locator(link).click()
|
||||
download = info.value
|
||||
assert download.suggested_filename == filename
|
||||
assert download.url.startswith(sites.url(site) + "/")
|
||||
assert download.failure() is None
|
||||
with open(download.path(), "rb") as saved:
|
||||
assert saved.read() == PAYLOAD
|
||||
assert frame.url == sites.url(site, base), "the frame stayed where it was"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# popups
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
@pytest.mark.parametrize("opener_control,has_opener", [("#open", True), ("#blank", False), ("#noopener", False)])
|
||||
def test_a_popup_opened_from_a_frame_reaches_expect_popup(opened, sites, target, opener_control, has_opener):
|
||||
page, frames = opened
|
||||
with page.expect_popup() as info:
|
||||
frames[target].locator(opener_control).click()
|
||||
popup = info.value
|
||||
popup.wait_for_load_state("load")
|
||||
assert popup.url == sites.url("C", "/popup")
|
||||
assert popup.evaluate("document.title") == "popup"
|
||||
assert popup.evaluate("window.__opener") is has_opener
|
||||
assert popup.opener() == page, "the popup's opener is the page whose frame opened it, noopener or not"
|
||||
assert popup in page.context.pages
|
||||
popup.close()
|
||||
@@ -0,0 +1,235 @@
|
||||
"""History across a frame of another site, and the processes a context leaves behind.
|
||||
|
||||
Three sites (see `_fission_frames.py`): the top is A (`127.0.0.1`), the frame B (`localhost`), the frame C
|
||||
(`127.0.0.2`). With Fission each site is a content process of its own, and a navigation of the frame to another
|
||||
site changes its process.
|
||||
|
||||
* History. The page holds a frame of B. A navigation inside the frame adds a session-history entry, so
|
||||
`page.go_back()` moves the FRAME back (the top url does not change, the frame is at the url it had) and
|
||||
`go_forward()` restores it; the same when the frame went to a third site (a new process). A top-level
|
||||
navigation and `go_back()` restore the page with its frame of another site, and the frame answers `evaluate`.
|
||||
The outcome asserted is what stock Firefox does (see the docstrings).
|
||||
* Processes. A context whose page had frames of other sites leaves no content process behind once it is closed:
|
||||
the count of web content processes under the engine, read after each of several such contexts, stays within the
|
||||
pool of spare processes retail Firefox keeps (see the test).
|
||||
|
||||
The first test proves the frame is in another process, so the file cannot turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from _fission_frames import Sites, assert_other_process, launch, new_page, wait_for, wait_frame
|
||||
from _waits import spare_processes, watch
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sites():
|
||||
with Sites() as s:
|
||||
s.route("A", "/h-top", "<!doctype html><title>h-top</title><iframe id='b' name='b' src='%s' width='500' "
|
||||
"height='200'></iframe>" % s.url("B", "/h1"))
|
||||
for n in (1, 2):
|
||||
s.route("B", "/h%d" % n, "<!doctype html><title>h%d</title><p id='p'>h%d" % (n, n))
|
||||
s.route("C", "/h3", "<!doctype html><title>h3</title><p id='p'>h3")
|
||||
s.route("A", "/other", "<!doctype html><title>other</title><p>other")
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def browser(firefox_binary):
|
||||
with launch(firefox_binary) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser):
|
||||
context, page = new_page(browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
def traverse(page, direction):
|
||||
"""``page.go_back()`` or ``page.go_forward()``. When the entry belongs to a frame, no navigation of the main
|
||||
frame follows, and the call gives up with a ``TimeoutError`` after the history has moved: as stock Firefox
|
||||
does. A call that returns is just as good; what the tests judge is where the page and its frame are after."""
|
||||
try:
|
||||
getattr(page, direction)(timeout=3000)
|
||||
except Exception as error: # the client's own TimeoutError class: the wrapper ships its own copy
|
||||
if type(error).__name__ != "TimeoutError":
|
||||
raise
|
||||
|
||||
|
||||
def _frame_url(page):
|
||||
"""The url of the one frame of the page, once there is one."""
|
||||
wait_for(page, lambda: len(page.frames) == 2)
|
||||
return page.frames[1].url
|
||||
|
||||
|
||||
def test_the_frame_is_in_another_process(page, sites):
|
||||
page.goto(sites.url("A", "/h-top"), wait_until="load")
|
||||
assert_other_process(page.main_frame, wait_frame(page, sites.url("B"), "/h1"))
|
||||
|
||||
|
||||
def test_back_and_forward_move_the_frame_not_the_top_after_a_navigation_inside_it(page, sites):
|
||||
"""The frame goes h1 -> h2 (same site). Back: the top is where it was, the frame is at h1. Forward: at h2."""
|
||||
page.goto(sites.url("A", "/h-top"), wait_until="load")
|
||||
frame = wait_frame(page, sites.url("B"), "/h1")
|
||||
frame.goto(sites.url("B", "/h2"))
|
||||
assert frame.url == sites.url("B", "/h2") and page.url == sites.url("A", "/h-top")
|
||||
traverse(page, "go_back")
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url("B", "/h1")), _frame_url(page)
|
||||
assert page.url == sites.url("A", "/h-top")
|
||||
assert page.frames[1].evaluate("document.title") == "h1"
|
||||
traverse(page, "go_forward")
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url("B", "/h2")), _frame_url(page)
|
||||
assert page.url == sites.url("A", "/h-top")
|
||||
assert page.frames[1].evaluate("document.title") == "h2"
|
||||
|
||||
|
||||
def test_back_and_forward_across_a_frame_that_went_to_a_third_site(page, sites):
|
||||
"""The frame goes h1 (B) -> h2 (B) -> h3 (C: a change of site and of process). Each back moves it one entry; forward goes the way back came."""
|
||||
page.goto(sites.url("A", "/h-top"), wait_until="load")
|
||||
frame = wait_frame(page, sites.url("B"), "/h1")
|
||||
frame.goto(sites.url("B", "/h2"))
|
||||
frame.goto(sites.url("C", "/h3"))
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url("C", "/h3")), _frame_url(page)
|
||||
assert_other_process(page.main_frame, page.frames[1])
|
||||
for expected in ("B/h2", "B/h1"):
|
||||
traverse(page, "go_back")
|
||||
site, path = expected.split("/")
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url(site, "/" + path)), (expected, _frame_url(page))
|
||||
assert page.url == sites.url("A", "/h-top")
|
||||
assert page.frames[1].evaluate("document.title") == path
|
||||
traverse(page, "go_forward")
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url("B", "/h2")), _frame_url(page)
|
||||
traverse(page, "go_forward")
|
||||
assert wait_for(page, lambda: _frame_url(page) == sites.url("C", "/h3")), _frame_url(page)
|
||||
assert page.frames[1].evaluate("document.title") == "h3"
|
||||
assert page.url == sites.url("A", "/h-top")
|
||||
|
||||
|
||||
def test_a_top_level_navigation_and_back_restore_the_page_with_its_frame_usable(page, sites):
|
||||
page.goto(sites.url("A", "/h-top"), wait_until="load")
|
||||
frame = wait_frame(page, sites.url("B"), "/h1")
|
||||
frame.goto(sites.url("B", "/h2"))
|
||||
page.goto(sites.url("A", "/other"), wait_until="load")
|
||||
assert page.url == sites.url("A", "/other")
|
||||
traverse(page, "go_back")
|
||||
assert page.url == sites.url("A", "/h-top")
|
||||
assert wait_for(page, lambda: len(page.frames) == 2 and page.frames[1].url.startswith(sites.url("B"))), \
|
||||
[f.url for f in page.frames]
|
||||
restored = page.frames[1]
|
||||
# the frame is where it was when the page was left (h2), as stock Firefox restores it
|
||||
assert restored.url == sites.url("B", "/h2")
|
||||
assert restored.evaluate("document.title") == "h2"
|
||||
assert restored.evaluate("location.origin") == sites.url("B")
|
||||
assert restored.locator("#p").inner_text() == "h2"
|
||||
assert_other_process(page.main_frame, restored)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# processes
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _content_processes(engine_dir):
|
||||
"""The pids of the engine's web content processes (`-contentproc ... tab`) below this test."""
|
||||
import psutil
|
||||
|
||||
found = set()
|
||||
for child in psutil.Process(os.getpid()).children(recursive=True):
|
||||
try:
|
||||
if not os.path.normcase(child.exe()).startswith(os.path.normcase(engine_dir)):
|
||||
continue
|
||||
command = child.cmdline()
|
||||
except psutil.Error:
|
||||
continue
|
||||
if "-contentproc" in command and command[-1] == "tab":
|
||||
found.add(child.pid)
|
||||
return found
|
||||
|
||||
|
||||
def _settled(engine_dir, seconds=2.0, limit=25.0):
|
||||
"""The set of content processes once it has not changed for ``seconds``."""
|
||||
end = time.monotonic() + limit
|
||||
last, since = _content_processes(engine_dir), time.monotonic()
|
||||
while time.monotonic() < end:
|
||||
time.sleep(0.25)
|
||||
now = _content_processes(engine_dir)
|
||||
if now != last:
|
||||
last, since = now, time.monotonic()
|
||||
elif time.monotonic() - since >= seconds:
|
||||
break
|
||||
return last
|
||||
|
||||
|
||||
CONTEXTS = 5
|
||||
#: How long a count of processes may take to reach what it must be (a process starts or ends in well under a
|
||||
#: second; this is the only clock the verdict has).
|
||||
DEADLINE = 25.0
|
||||
|
||||
|
||||
def test_a_closed_context_with_frames_of_other_sites_leaves_no_content_process(firefox_binary, sites):
|
||||
"""Five contexts in a row, each with a page whose frames are on B and (nested) on C. The processes the frames
|
||||
took are gone once the context is closed.
|
||||
|
||||
What retail Firefox does, and so what is allowed: with Fission on it keeps a pool of preallocated content
|
||||
processes, `dom.ipc.processPrelaunch.fission.number` of them (3 on desktop, 1 on a machine of 4 GB or less),
|
||||
refilled one at a time after a page takes one (`_waits.spare_processes` has the source). So between two looks
|
||||
the number of content processes moves by up to that pool and no more: after the first context is closed
|
||||
(``counts[0]``) every later count is at most ``counts[0]`` plus the pool, and a frame process that is never
|
||||
released grows the count by at least one per context, so it passes the bound within the five (a pool that is
|
||||
emptier at the last look than at the first could hide it: the bound is as wide as the pool, no wider). While a context
|
||||
is open the count rises above ``counts[0]``: the frames' processes are on top of a refilled pool.
|
||||
|
||||
Each count is a WAIT for that bound (up to 25 s), not a look after a fixed pause; the message gives the counts
|
||||
over time of every context."""
|
||||
import psutil
|
||||
|
||||
sites.route("B", "/leak-b", "<!doctype html><title>b</title><iframe src='%s'></iframe>" % sites.url("C", "/h3"))
|
||||
sites.route("A", "/leak", "<!doctype html><title>leak</title><iframe id='b' src='%s'></iframe>"
|
||||
% sites.url("B", "/leak-b"))
|
||||
engine_dir = str(Path(firefox_binary).resolve().parent)
|
||||
spare = spare_processes(psutil.virtual_memory().total)
|
||||
|
||||
def number():
|
||||
return len(_content_processes(engine_dir))
|
||||
|
||||
def pause():
|
||||
time.sleep(0.25)
|
||||
|
||||
with launch(firefox_binary) as browser:
|
||||
counts, during, trail = [], [], []
|
||||
for n in range(CONTEXTS):
|
||||
context, page = new_page(browser)
|
||||
page.goto(sites.url("A", "/leak"), wait_until="load")
|
||||
wait_frame(page, sites.url("C"), "/h3")
|
||||
if not counts:
|
||||
during.append(len(_settled(engine_dir)))
|
||||
trail.append("context %d open: %d" % (n, during[-1]))
|
||||
else:
|
||||
opened = watch(number, lambda count: count > counts[0], DEADLINE, pause)
|
||||
during.append(opened.history[-1][1])
|
||||
trail.append("context %d open, waiting for more than %d: %s" % (n, counts[0], opened.render()))
|
||||
assert opened.ok, (
|
||||
"the frames of other sites took no process of their own: %r while open, %r after; %s" % (
|
||||
during, counts, " | ".join(trail)))
|
||||
context.close()
|
||||
if not counts:
|
||||
counts.append(len(_settled(engine_dir)))
|
||||
trail.append("context %d closed: %d (the reference)" % (n, counts[0]))
|
||||
else:
|
||||
closed = watch(number, lambda count: count <= counts[0] + spare, DEADLINE, pause)
|
||||
counts.append(closed.history[-1][1])
|
||||
trail.append("context %d closed, waiting for at most %d (%d + a pool of %d): %s" % (
|
||||
n, counts[0] + spare, counts[0], spare, closed.render()))
|
||||
assert closed.ok, (
|
||||
"web content processes after each closed context: %r (open: %r); more than the %d the first "
|
||||
"left plus the pool of %d the engine keeps: %s" % (counts, during, counts[0], spare,
|
||||
" | ".join(trail)))
|
||||
@@ -0,0 +1,377 @@
|
||||
"""Routes, exposed functions, init scripts and postMessage, for an iframe of another site and one nested in it.
|
||||
|
||||
Fission puts a frame of another site in a content process of its own. What a script written against the Playwright
|
||||
API does with such a frame is the same as with any other, and this file holds the parts that go through the
|
||||
frame's own process:
|
||||
|
||||
* `page.route` and `context.route` see the requests the frame makes, `request.frame` is that frame (the same
|
||||
object `page.frames` lists, with the url of its document), and fulfill, abort and continue each take effect in the
|
||||
frame; `wait_for_load_state("networkidle")` waits for the late requests of the frame;
|
||||
* `expose_function` and `expose_binding` are callable from the frame and from a frame nested in it, and the
|
||||
binding's `source["frame"]` is the frame that called;
|
||||
* an init script runs before the frame's own scripts, in the frame, in the nested frame, and again in the document
|
||||
the frame navigates to (a third site);
|
||||
* `postMessage` crosses between the top and a frame of another site both ways, and between two sibling frames of
|
||||
other sites through the top: `event.origin` is the sender's, `event.source` answers.
|
||||
|
||||
The sites are told apart by host (see `_fission_frames.py`): the top is A (`127.0.0.1`), the frame is B
|
||||
(`localhost`) and the frame nested in it is C (`127.0.0.2`).
|
||||
|
||||
The outcome asserted is the one of stock Playwright Firefox; none of it depends on the process model, and the
|
||||
first test proves the frame is not in the process of the page, so the file cannot turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from _fission_frames import Sites, assert_other_process, launch, new_page, wait_frame
|
||||
from _waits import quiet_problem
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sites():
|
||||
with Sites() as s:
|
||||
# A top page with a frame of B; the frame of B holds a frame of C. Each document reports through
|
||||
# window.__log what it did, so a test reads it with evaluate.
|
||||
s.route("A", "/top", '<!doctype html><title>top</title><iframe id="b" name="b" src="%s" '
|
||||
'width="500" height="300"></iframe>' % s.url("B", "/frame"))
|
||||
s.route("B", "/frame", '<!doctype html><title>frame</title><iframe id="c" name="c" src="%s" '
|
||||
'width="300" height="150"></iframe>'
|
||||
"<script>window.__got = [];"
|
||||
"fetch('/api/b?from=load').then(r => r.text()).then(t => __got.push(['load', t]))"
|
||||
".catch(e => __got.push(['load-error', String(e)]));</script>" % s.url("C", "/nested"))
|
||||
s.route("C", "/nested", "<!doctype html><title>nested</title>"
|
||||
"<script>window.__got = [];"
|
||||
"fetch('/api/c?from=load').then(r => r.text()).then(t => __got.push(['load', t]))"
|
||||
".catch(e => __got.push(['load-error', String(e)]));</script>")
|
||||
s.route("B", "/api/b", "from-server-b", ctype="text/plain")
|
||||
s.route("C", "/api/c", "from-server-c", ctype="text/plain")
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser(firefox_binary):
|
||||
with launch(firefox_binary) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser):
|
||||
context, page = new_page(browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
def _frames(page, sites):
|
||||
"""The frame of B and the frame of C nested in it, once both have a document."""
|
||||
b = wait_frame(page, sites.url("B"), "/frame")
|
||||
c = wait_frame(page, sites.url("C"), "/nested")
|
||||
return b, c
|
||||
|
||||
|
||||
def test_the_frame_is_in_another_process_and_the_nested_one_in_a_third(page, sites):
|
||||
"""The precondition of this file: B is not in the process of A, and C is not in the one of B."""
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, c = _frames(page, sites)
|
||||
assert b.parent_frame == page.main_frame and c.parent_frame == b
|
||||
assert_other_process(page.main_frame, b)
|
||||
assert_other_process(b, c)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# page.route and context.route
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("where", ["page", "context"])
|
||||
def test_a_route_sees_the_requests_of_a_frame_of_another_site_and_of_a_nested_one(page, sites, where):
|
||||
"""The handler is called for the fetch of the frame of B and the one of the frame of C nested in it,
|
||||
`request.frame` is the frame that made it (the object of `page.frames`, with its url), the request is a
|
||||
sub-resource of that frame's document, and continuing it gives the page the server's answer."""
|
||||
context = page.context
|
||||
seen = []
|
||||
|
||||
def handler(route):
|
||||
request = route.request
|
||||
seen.append((request.url, request.frame, request.resource_type))
|
||||
route.continue_()
|
||||
|
||||
(page if where == "page" else context).route("**/api/**", handler)
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, c = _frames(page, sites)
|
||||
for frame in (b, c):
|
||||
frame.wait_for_function("window.__got.length > 0")
|
||||
assert b.evaluate("window.__got") == [["load", "from-server-b"]]
|
||||
assert c.evaluate("window.__got") == [["load", "from-server-c"]]
|
||||
by_url = {url.split("?")[0]: (frame, kind) for url, frame, kind in seen}
|
||||
assert set(by_url) == {sites.url("B", "/api/b"), sites.url("C", "/api/c")}, seen
|
||||
frame_of_b, kind_b = by_url[sites.url("B", "/api/b")]
|
||||
frame_of_c, kind_c = by_url[sites.url("C", "/api/c")]
|
||||
assert frame_of_b is b and frame_of_b.url == sites.url("B", "/frame")
|
||||
assert frame_of_c is c and frame_of_c.url == sites.url("C", "/nested")
|
||||
assert frame_of_c.parent_frame is b
|
||||
assert kind_b == kind_c == "fetch"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("action", ["fulfill", "abort", "continue"])
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
def test_fulfill_abort_and_continue_take_effect_in_a_frame_of_another_site(page, sites, action, target):
|
||||
"""What the route decides is what the frame's fetch gets: the body and status given to `fulfill`, a rejected
|
||||
fetch for `abort`, the server's answer for `continue`. A fetch the frame makes AFTER the load, to a url the
|
||||
route covers."""
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, c = _frames(page, sites)
|
||||
frame, site = (b, "B") if target == "frame" else (c, "C")
|
||||
sites.route(site, "/api/late", "from-server", ctype="text/plain")
|
||||
routed = []
|
||||
|
||||
def handler(route):
|
||||
routed.append(route.request.frame)
|
||||
if action == "fulfill":
|
||||
route.fulfill(status=201, body="from-route", content_type="text/plain",
|
||||
headers={"access-control-allow-origin": "*"})
|
||||
elif action == "abort":
|
||||
route.abort()
|
||||
else:
|
||||
route.continue_()
|
||||
|
||||
page.route("**/api/late", handler)
|
||||
result = frame.evaluate("""() => fetch('/api/late').then(
|
||||
r => r.text().then(t => ({ok: true, status: r.status, body: t})),
|
||||
e => ({ok: false, error: e.name}))""")
|
||||
assert routed == [frame], routed
|
||||
if action == "fulfill":
|
||||
assert result == {"ok": True, "status": 201, "body": "from-route"}
|
||||
elif action == "abort":
|
||||
assert result["ok"] is False and result["error"] == "TypeError", result
|
||||
assert not sites.seen(site, "/api/late"), "an aborted request reached the server"
|
||||
else:
|
||||
assert result == {"ok": True, "status": 200, "body": "from-server"}
|
||||
assert len(sites.seen(site, "/api/late")) == 1
|
||||
|
||||
|
||||
def test_a_route_set_before_the_load_fulfills_what_the_frame_asks_while_loading(page, sites):
|
||||
"""The first request of the frame of another site is covered: the route is in place before the page goes to
|
||||
its url, and the fetch the frame makes while loading is answered by the route."""
|
||||
page.route("**/api/b**", lambda route: route.fulfill(body="routed-b", content_type="text/plain"))
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, _ = _frames(page, sites)
|
||||
b.wait_for_function("window.__got.length > 0")
|
||||
assert b.evaluate("window.__got") == [["load", "routed-b"]]
|
||||
assert not sites.seen("B", "/api/b"), "the request reached the server through the route"
|
||||
|
||||
|
||||
#: `networkidle` promises half a second WITHOUT network. The test below measures the silence on the server's clock and asks
|
||||
#: for this much, 100 ms under the promise: the two clocks are one process's, but the client hears about an end a little
|
||||
#: after the server writes it.
|
||||
QUIET = 0.4
|
||||
|
||||
|
||||
def test_networkidle_waits_for_the_late_requests_of_a_frame_of_another_site(page, sites):
|
||||
"""The frame makes a request 200 ms after it loads, and the next one as soon as that answers (the server holds
|
||||
each for 300 ms): there is never half a second without a request, so `networkidle` of the PAGE is not reached
|
||||
before both are done.
|
||||
|
||||
"Never half a second" is made by the page's own timer and promise chain, and a loaded machine can stretch them:
|
||||
when the 200 ms timer fires after 500 ms the page IS idle, and `networkidle` is right to come first. So the test
|
||||
does not assume the late requests came in time; it asks what `networkidle` promises, with the server's clock
|
||||
(each request's arrival and end are stamped in the test process): when `goto` returned, no request of the page
|
||||
was in flight and the network had been quiet for `QUIET`. A product that comes before the late requests of the
|
||||
frame returns while one is in flight, or less than that after the last end, and fails; a slow machine that
|
||||
delays the frame's script returns after a real silence and passes. The message gives the four requests on the
|
||||
server's clock and when `goto` returned."""
|
||||
chain = ("<!doctype html><title>late</title><script>window.__done = [];"
|
||||
"addEventListener('load', () => setTimeout(() => fetch('/late/1').then(r => r.text())"
|
||||
".then(t => { __done.push(t); return fetch('/late/2'); }).then(r => r.text())"
|
||||
".then(t => __done.push(t)), 200));</script>")
|
||||
sites.route("B", "/late-frame", chain)
|
||||
sites.route("B", "/late/1", "one", ctype="text/plain", delay=0.3)
|
||||
sites.route("B", "/late/2", "two", ctype="text/plain", delay=0.3)
|
||||
sites.route("A", "/late-top", '<!doctype html><title>late top</title>'
|
||||
'<iframe src="%s" width="300" height="100"></iframe>' % sites.url("B", "/late-frame"))
|
||||
page.goto(sites.url("A", "/late-top"), wait_until="networkidle", timeout=30000)
|
||||
returned = time.monotonic()
|
||||
paths = ("/late-top", "/late-frame", "/late/1", "/late/2")
|
||||
stamps = [(r["path"], r["at"], r["done"]) for r in list(sites.requests) if r["path"] in paths]
|
||||
wait_frame(page, sites.url("B"), "/late-frame")
|
||||
began = min(at for _path, at, _done in stamps)
|
||||
timeline = "; ".join("%s +%.3fs..%s" % (path, at - began, "+%.3fs" % (done - began) if done is not None else "in flight")
|
||||
for path, at, done in sorted(stamps, key=lambda stamp: stamp[1]))
|
||||
explain = "the requests on the server's clock: %s; goto returned at +%.3fs" % (timeline, returned - began)
|
||||
assert {"/late-top", "/late-frame"} <= {path for path, _at, _done in stamps}, explain
|
||||
problem = quiet_problem(stamps, returned, QUIET)
|
||||
assert problem is None, "%s: %s" % (problem, explain)
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# expose_function, expose_binding and init scripts
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("where", ["page", "context"])
|
||||
def test_an_exposed_function_is_callable_from_a_frame_of_another_site_and_a_nested_one(page, sites, where):
|
||||
context = page.context
|
||||
(page if where == "page" else context).expose_function("add", lambda a, b: a + b)
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, c = _frames(page, sites)
|
||||
assert b.evaluate("add(2, 3)") == 5
|
||||
assert c.evaluate("add(40, 2)") == 42
|
||||
assert c.evaluate("typeof window.add") == "function"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("where", ["page", "context"])
|
||||
def test_a_binding_knows_which_frame_called_it(page, sites, where):
|
||||
"""`source["frame"]` is the frame that called: the frame of B, then the frame of C nested in it, then the
|
||||
top; `source["page"]` is the page."""
|
||||
context = page.context
|
||||
calls = []
|
||||
|
||||
def binding(source, value):
|
||||
calls.append((source["frame"], source["page"], value))
|
||||
return "ack:%s" % value
|
||||
|
||||
(page if where == "page" else context).expose_binding("report", binding)
|
||||
page.goto(sites.url("A", "/top"), wait_until="load")
|
||||
b, c = _frames(page, sites)
|
||||
assert c.evaluate("report('from-c')") == "ack:from-c"
|
||||
assert b.evaluate("report('from-b')") == "ack:from-b"
|
||||
assert page.main_frame.evaluate("report('from-top')") == "ack:from-top"
|
||||
assert [(f, p is page, v) for f, p, v in calls] == [(c, True, "from-c"), (b, True, "from-b"),
|
||||
(page.main_frame, True, "from-top")]
|
||||
assert calls[0][0].url == sites.url("C", "/nested")
|
||||
assert calls[1][0].url == sites.url("B", "/frame")
|
||||
|
||||
|
||||
def test_a_binding_called_by_a_script_of_the_frame_while_it_loads(page, sites):
|
||||
"""A page script of the frame of B calls the binding in its own first script, before any `evaluate`: the
|
||||
binding is already there and knows the frame."""
|
||||
sites.route("B", "/binds", "<!doctype html><title>binds</title><script>window.__ack = null;"
|
||||
"report('while-loading').then(v => window.__ack = v);</script>")
|
||||
sites.route("A", "/binds-top", '<!doctype html><iframe src="%s"></iframe>' % sites.url("B", "/binds"))
|
||||
calls = []
|
||||
|
||||
def binding(source, value):
|
||||
calls.append((source["frame"].url, value))
|
||||
return "ack"
|
||||
|
||||
page.expose_binding("report", binding)
|
||||
page.goto(sites.url("A", "/binds-top"), wait_until="load")
|
||||
frame = wait_frame(page, sites.url("B"), "/binds")
|
||||
frame.wait_for_function("window.__ack !== null")
|
||||
assert calls == [(sites.url("B", "/binds"), "while-loading")]
|
||||
|
||||
|
||||
ORDER_PAGE = ("<!doctype html><title>%s</title><script>"
|
||||
"window.__seen = JSON.stringify(window.__o || []);"
|
||||
"(window.__o = window.__o || []).push('page');</script>")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("where", ["page", "context"])
|
||||
def test_an_init_script_runs_before_the_scripts_of_a_frame_of_another_site(page, sites, where):
|
||||
"""In the top, in the frame of B and in the frame of C: the init script has pushed 'init' before the
|
||||
document's own first script reads the list. The same, again, in the document the frame of B navigates to on a
|
||||
third site (C): the new document in the new process gets the script before its own."""
|
||||
context = page.context
|
||||
script = "(window.__o = window.__o || []).push('init');"
|
||||
(page if where == "page" else context).add_init_script(script)
|
||||
sites.route("A", "/order-top", ORDER_PAGE.replace("%s", "top")
|
||||
+ '<iframe src="%s"></iframe>' % sites.url("B", "/order-b"))
|
||||
sites.route("B", "/order-b", ORDER_PAGE.replace("%s", "b")
|
||||
+ '<iframe src="%s"></iframe>' % sites.url("C", "/order-c"))
|
||||
sites.route("C", "/order-c", ORDER_PAGE.replace("%s", "c"))
|
||||
sites.route("C", "/order-moved", ORDER_PAGE.replace("%s", "moved"))
|
||||
page.goto(sites.url("A", "/order-top"), wait_until="load")
|
||||
b = wait_frame(page, sites.url("B"), "/order-b")
|
||||
c = wait_frame(page, sites.url("C"), "/order-c")
|
||||
for frame in (page.main_frame, b, c):
|
||||
assert frame.evaluate("window.__seen") == '["init"]', frame.url
|
||||
assert frame.evaluate("window.__o") == ["init", "page"], frame.url
|
||||
b.goto(sites.url("C", "/order-moved"))
|
||||
assert b.url == sites.url("C", "/order-moved")
|
||||
assert b.evaluate("window.__seen") == '["init"]'
|
||||
assert b.evaluate("window.__o") == ["init", "page"]
|
||||
# and the process changed with the site: the moved frame is not in the top's process either
|
||||
assert_other_process(page.main_frame, b)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# postMessage
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
ECHO = ("<!doctype html><title>%(name)s</title><script>window.__in = [];"
|
||||
"addEventListener('message', e => { __in.push({origin: e.origin, data: e.data, "
|
||||
"fromParent: e.source === parent});"
|
||||
"if (e.data && e.data.ping) e.source.postMessage({pong: e.data.ping, by: %(name)s}, e.origin); });"
|
||||
"</script>")
|
||||
|
||||
|
||||
def test_post_message_crosses_between_the_top_and_a_frame_of_another_site_both_ways(page, sites):
|
||||
"""The top asks the frame of B, the frame answers on `event.source`, the top reads the answer with the origin
|
||||
of B and `event.source` equal to the frame's window; and the frame speaks first to its parent."""
|
||||
sites.route("B", "/echo", ECHO % {"name": '"b"'} +
|
||||
"<script>parent.postMessage({hello: 'from-b'}, '*');</script>")
|
||||
sites.route("A", "/msg-top", "<!doctype html><title>top</title><iframe id='f' src='%s'></iframe><script>"
|
||||
"window.__in = []; addEventListener('message', e => __in.push({origin: e.origin, data: e.data, "
|
||||
"fromFrame: e.source === document.getElementById('f').contentWindow}));</script>"
|
||||
% sites.url("B", "/echo"))
|
||||
page.goto(sites.url("A", "/msg-top"), wait_until="load")
|
||||
frame = wait_frame(page, sites.url("B"), "/echo")
|
||||
page.wait_for_function("window.__in.length >= 1")
|
||||
assert page.evaluate("window.__in[0]") == {"origin": sites.url("B"), "data": {"hello": "from-b"},
|
||||
"fromFrame": True}
|
||||
page.evaluate("document.getElementById('f').contentWindow.postMessage({ping: 7}, %s)" % json.dumps(sites.url("B")))
|
||||
page.wait_for_function("window.__in.length >= 2")
|
||||
assert page.evaluate("window.__in[1]") == {"origin": sites.url("B"), "data": {"pong": 7, "by": "b"},
|
||||
"fromFrame": True}
|
||||
assert frame.evaluate("window.__in") == [{"origin": sites.url("A"), "data": {"ping": 7}, "fromParent": True}]
|
||||
|
||||
|
||||
def test_post_message_between_two_sibling_frames_of_other_sites_goes_through_the_top(page, sites):
|
||||
"""Frames of B and C side by side, in a page of A. They cannot see each other, only the top: B writes to the
|
||||
top, the top relays to C naming the sender, C answers the top on `event.source`, the top relays back. Every
|
||||
hop shows the origin of the document that sent it."""
|
||||
sites.route("B", "/left", "<!doctype html><title>left</title><script>window.__in = [];"
|
||||
"addEventListener('message', e => __in.push({origin: e.origin, data: e.data}));"
|
||||
"parent.postMessage({to: 'right', text: 'hi from left'}, '*');</script>")
|
||||
sites.route("C", "/right", "<!doctype html><title>right</title><script>window.__in = [];"
|
||||
"addEventListener('message', e => { __in.push({origin: e.origin, data: e.data});"
|
||||
"e.source.postMessage({to: 'left', text: 'hi from right'}, e.origin); });</script>")
|
||||
# The top relays a message only once the frame it is for has loaded: the two frames load in two processes, in no
|
||||
# fixed order, and a message posted to a frame whose document is not there yet is lost in any browser. The first
|
||||
# version relayed at once, and one CI run in three never saw the answer.
|
||||
sites.route("A", "/relay", "<!doctype html><title>relay</title><script>"
|
||||
"window.__hops = []; window.__loaded = {}; window.__waiting = [];"
|
||||
"const win = id => document.getElementById(id).contentWindow;"
|
||||
"function deliver() { __waiting = __waiting.filter(m => {"
|
||||
" if (!__loaded[m.to]) return true; win(m.to).postMessage(m.message, m.origin); return false; }); }"
|
||||
"function loaded(id) { __loaded[id] = true; deliver(); }"
|
||||
"addEventListener('message', e => {"
|
||||
" const from = e.source === win('left') ? 'left' : e.source === win('right') ? 'right' : '?';"
|
||||
" __hops.push({from, origin: e.origin, data: e.data});"
|
||||
" if (e.data.to) { __waiting.push({to: e.data.to, message: {relayed: e.data.text, by: from},"
|
||||
" origin: from === 'left' ? %s : %s}); deliver(); }"
|
||||
"});</script>"
|
||||
"<iframe id='left' onload=\"loaded('left')\" src='%s'></iframe>"
|
||||
"<iframe id='right' onload=\"loaded('right')\" src='%s'></iframe>"
|
||||
% (json.dumps(sites.url("C")), json.dumps(sites.url("B")),
|
||||
sites.url("B", "/left"), sites.url("C", "/right")))
|
||||
page.goto(sites.url("A", "/relay"), wait_until="load")
|
||||
left = wait_frame(page, sites.url("B"), "/left")
|
||||
right = wait_frame(page, sites.url("C"), "/right")
|
||||
page.wait_for_function("window.__hops.length >= 2")
|
||||
left.wait_for_function("window.__in.length >= 1")
|
||||
assert page.evaluate("window.__hops") == [
|
||||
{"from": "left", "origin": sites.url("B"), "data": {"to": "right", "text": "hi from left"}},
|
||||
{"from": "right", "origin": sites.url("C"), "data": {"to": "left", "text": "hi from right"}},
|
||||
]
|
||||
assert right.evaluate("window.__in") == [
|
||||
{"origin": sites.url("A"), "data": {"relayed": "hi from left", "by": "left"}}]
|
||||
assert left.evaluate("window.__in") == [
|
||||
{"origin": sites.url("A"), "data": {"relayed": "hi from right", "by": "right"}}]
|
||||
assert_other_process(left, right)
|
||||
@@ -0,0 +1,395 @@
|
||||
"""The frame tree, typing, trusted clicks and screenshots, with frames in other processes.
|
||||
|
||||
Three sites (see `_fission_frames.py`): the top is A (`127.0.0.1`), the frame B (`localhost`), the frame C
|
||||
(`127.0.0.2`). With Fission each site is a content process of its own, and the page the script drives is made of
|
||||
documents that live in different ones. What a script written against the Playwright API does with such a page is
|
||||
what it does with any other:
|
||||
|
||||
* the frame tree A > B > A > C (the second A is the site of the top again, below a frame of another site): every
|
||||
level is in `page.frames` with its url and name, and `parent_frame` / `child_frames` give the same chain;
|
||||
* typing into an input of a frame of another site and of a frame nested in it (`press_sequentially`,
|
||||
`keyboard.type` after a focus, `press`): the keys are trusted and reach that input; `wait_for_selector` and
|
||||
`Locator.wait_for` see an element that appears there later;
|
||||
* a click by selector on an element inside such a frame lands on THAT element when the iframe is under a CSS
|
||||
transform (scale and translate) and after the top page and the frame have both been scrolled (the page
|
||||
records which element got the trusted click);
|
||||
* `page.screenshot()` of a page whose frame of another site paints a known colour shows that colour inside the
|
||||
frame's box, and `locator.screenshot()` of an element inside the frame, and inside a nested one, has the
|
||||
element's size and colour.
|
||||
|
||||
Every test with a frame of B is run for the frame nested in it (C) as well where the scenario has one. The first
|
||||
test of the file proves the frames are in other processes, so it cannot turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from _fission_frames import (Sites, assert_other_process, decode_png, launch, near, new_page, wait_for,
|
||||
wait_frame)
|
||||
from _waits import watch
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sites():
|
||||
with Sites() as s:
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def browser(firefox_binary):
|
||||
with launch(firefox_binary) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser):
|
||||
context, page = new_page(browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. the frame tree A > B > A > C
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tree(sites):
|
||||
sites.route("A", "/tree", "<!doctype html><title>level 0</title><iframe id='one' name='one' src='%s' "
|
||||
"width='700' height='500'></iframe>" % sites.url("B", "/level1"))
|
||||
sites.route("B", "/level1", "<!doctype html><title>level 1</title><iframe id='two' name='two' src='%s' "
|
||||
"width='600' height='400'></iframe>" % sites.url("A", "/level2"))
|
||||
sites.route("A", "/level2", "<!doctype html><title>level 2</title><iframe id='three' name='three' src='%s' "
|
||||
"width='500' height='300'></iframe>" % sites.url("C", "/level3"))
|
||||
sites.route("C", "/level3", "<!doctype html><title>level 3</title><p id='leaf'>leaf of the tree")
|
||||
return sites
|
||||
|
||||
|
||||
def test_the_tree_a_b_a_c_is_listed_at_every_level(page, tree):
|
||||
page.goto(tree.url("A", "/tree"), wait_until="load")
|
||||
wait_frame(page, tree.url("C"), "/level3")
|
||||
expected = [("", tree.url("A", "/tree")), ("one", tree.url("B", "/level1")),
|
||||
("two", tree.url("A", "/level2")), ("three", tree.url("C", "/level3"))]
|
||||
assert wait_for(page, lambda: [(f.name, f.url) for f in page.frames] == expected), \
|
||||
[(f.name, f.url) for f in page.frames]
|
||||
main, one, two, three = page.frames
|
||||
assert main == page.main_frame
|
||||
assert [f.parent_frame for f in (main, one, two, three)] == [None, main, one, two]
|
||||
assert [f.child_frames for f in (main, one, two, three)] == [[one], [two], [three], []]
|
||||
assert all(f.page is page for f in page.frames)
|
||||
assert [f.is_detached() for f in page.frames] == [False] * 4
|
||||
# the lookups by name and by url find the same objects
|
||||
assert page.frame(name="three") is three and page.frame(url=tree.url("A", "/level2")) is two
|
||||
# and the document of each level answers for itself
|
||||
assert [f.evaluate("location.href") for f in page.frames] == [u for _, u in expected]
|
||||
assert [f.evaluate("document.title") for f in page.frames] == ["level 0", "level 1", "level 2", "level 3"]
|
||||
assert [f.evaluate("window.name") for f in page.frames] == ["", "one", "two", "three"]
|
||||
assert three.locator("#leaf").inner_text() == "leaf of the tree"
|
||||
# the frames are in other processes: B is not A, and C is neither B nor the second A
|
||||
assert_other_process(main, one)
|
||||
assert_other_process(two, three)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. typing, and waiting for what appears later
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
TYPING = ("<input id='t' autocomplete='off'><script>window.keys = [];"
|
||||
"t.addEventListener('keydown', e => keys.push([e.key, e.isTrusted]));</script>")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def typing(sites):
|
||||
sites.route("A", "/typing", "<!doctype html><title>top</title><iframe id='b' src='%s' width='600' height='400'>"
|
||||
"</iframe>" % sites.url("B", "/typing-b"))
|
||||
sites.route("B", "/typing-b", "<!doctype html><title>b</title>" + TYPING +
|
||||
"<iframe id='c' src='%s' width='400' height='150'></iframe>" % sites.url("C", "/typing-c"))
|
||||
sites.route("C", "/typing-c", "<!doctype html><title>c</title>" + TYPING)
|
||||
return sites
|
||||
|
||||
|
||||
def _typing_frames(page, typing):
|
||||
page.goto(typing.url("A", "/typing"), wait_until="load")
|
||||
return {"frame": wait_frame(page, typing.url("B"), "/typing-b"),
|
||||
"nested": wait_frame(page, typing.url("C"), "/typing-c")}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
@pytest.mark.parametrize("how", ["press_sequentially", "keyboard_type", "press_keys"])
|
||||
def test_typing_into_an_input_of_a_frame_of_another_site(page, typing, target, how):
|
||||
frame = _typing_frames(page, typing)[target]
|
||||
field = frame.locator("#t")
|
||||
if how == "press_sequentially":
|
||||
field.press_sequentially("Hello 42")
|
||||
expected, keys = "Hello 42", list("Hello 42")
|
||||
elif how == "keyboard_type":
|
||||
field.focus()
|
||||
assert frame.evaluate("document.activeElement.id") == "t"
|
||||
page.keyboard.type("Typed text")
|
||||
expected, keys = "Typed text", list("Typed text")
|
||||
else:
|
||||
field.focus()
|
||||
for key in ("a", "b", "c", "Backspace", "d"):
|
||||
page.keyboard.press(key)
|
||||
field.press("e")
|
||||
expected, keys = "abde", ["a", "b", "c", "Backspace", "d", "e"]
|
||||
assert field.input_value() == expected
|
||||
seen = frame.evaluate("window.keys")
|
||||
# a capital letter is typed with the Shift key held, as on a keyboard: its own keydown comes first
|
||||
assert [k for k, _ in seen if k != "Shift"] == keys
|
||||
assert all(trusted for _, trusted in seen), seen
|
||||
|
||||
|
||||
def test_the_other_frames_are_not_typed_into(page, typing):
|
||||
"""The keys go to the focused input and to no other document: the input of the nested frame and the one of
|
||||
its parent each keep only what was typed in them."""
|
||||
frames = _typing_frames(page, typing)
|
||||
frames["frame"].locator("#t").press_sequentially("outer")
|
||||
frames["nested"].locator("#t").press_sequentially("inner")
|
||||
assert frames["frame"].locator("#t").input_value() == "outer"
|
||||
assert frames["nested"].locator("#t").input_value() == "inner"
|
||||
assert [k for k, _ in frames["frame"].evaluate("window.keys")] == list("outer")
|
||||
assert [k for k, _ in frames["nested"].evaluate("window.keys")] == list("inner")
|
||||
|
||||
|
||||
LATE = ("<p id='anchor'>anchor</p><script>"
|
||||
"setTimeout(() => { const d = document.createElement('div'); d.id = 'late'; d.textContent = 'arrived';"
|
||||
"document.body.appendChild(d); }, 700);"
|
||||
"setTimeout(() => { const d = document.createElement('div'); d.id = 'shown'; d.textContent = 'shown';"
|
||||
"d.style.display = 'none'; document.body.appendChild(d); }, 300);"
|
||||
"setTimeout(() => { document.getElementById('shown').style.display = 'block'; }, 1000);</script>")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def late(sites):
|
||||
sites.route("A", "/late", "<!doctype html><title>top</title><iframe id='b' src='%s' width='600' height='400'>"
|
||||
"</iframe>" % sites.url("B", "/late-b"))
|
||||
sites.route("B", "/late-b", "<!doctype html><title>b</title>" + LATE +
|
||||
"<iframe id='c' src='%s' width='400' height='150'></iframe>" % sites.url("C", "/late-c"))
|
||||
sites.route("C", "/late-c", "<!doctype html><title>c</title>" + LATE)
|
||||
return sites
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["frame", "nested"])
|
||||
def test_waiting_for_an_element_that_appears_later_in_a_frame_of_another_site(page, late, target):
|
||||
page.goto(late.url("A", "/late"), wait_until="load")
|
||||
frame = {"frame": wait_frame(page, late.url("B"), "/late-b"),
|
||||
"nested": wait_frame(page, late.url("C"), "/late-c")}[target]
|
||||
# the element is not there yet when the wait starts, or it is by now: either way the wait returns it
|
||||
handle = frame.wait_for_selector("#late", timeout=30000)
|
||||
try:
|
||||
assert handle.inner_text() == "arrived"
|
||||
assert handle.owner_frame() is frame
|
||||
finally:
|
||||
handle.dispose()
|
||||
# the same, by the locator of the frame and by the frame locator of the page
|
||||
frame.locator("#shown").wait_for(state="visible", timeout=30000)
|
||||
outer = page.frame_locator("#b")
|
||||
scoped = outer.locator("#late") if target == "frame" else outer.frame_locator("#c").locator("#late")
|
||||
scoped.wait_for(state="attached", timeout=30000)
|
||||
assert scoped.inner_text() == "arrived"
|
||||
|
||||
|
||||
def test_waiting_in_a_frame_of_another_site_times_out_on_what_never_comes(page, late):
|
||||
"""The wait is not satisfied by an element of another document: `#nothing` is in none, and the error is the
|
||||
wait's TimeoutError naming the selector, not a protocol error about the frame."""
|
||||
page.goto(late.url("A", "/late"), wait_until="load")
|
||||
frame = wait_frame(page, late.url("B"), "/late-b")
|
||||
with pytest.raises(Exception) as error:
|
||||
frame.wait_for_selector("#nothing", timeout=1500)
|
||||
assert type(error.value).__name__ == "TimeoutError" and "#nothing" in str(error.value), error.value
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. a click by selector under a transform and after scrolling
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
GRID = ("<style>html,body{margin:0}button{position:absolute;width:60px;height:40px;margin:0;padding:0}"
|
||||
"%s</style>%s<script>window.landed = [];"
|
||||
"addEventListener('click', e => landed.push({id: e.target.id || e.target.tagName, "
|
||||
"trusted: e.isTrusted}), true);</script>")
|
||||
|
||||
|
||||
def _grid(rows=4, cols=4, tall=0):
|
||||
css = "".join("#r%dc%d{left:%dpx;top:%dpx}" % (r, c, 20 + c * 90, 20 + r * 70) for r in range(rows)
|
||||
for c in range(cols))
|
||||
buttons = "".join("<button id='r%dc%d'>%d,%d</button>" % (r, c, r, c) for r in range(rows)
|
||||
for c in range(cols))
|
||||
if tall:
|
||||
buttons += "<div style='position:absolute;left:0;top:%dpx;width:10px;height:10px'></div>" % tall
|
||||
return GRID % (css, buttons)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def transformed(sites):
|
||||
"""The frame of B inside a transformed box; the frame of C inside that one, transformed as well."""
|
||||
sites.route("B", "/grid", "<!doctype html>" + _grid() +
|
||||
"<iframe id='c' src='%s' style='position:absolute;left:400px;top:20px;width:420px;height:320px;"
|
||||
"border:0;transform:translate(10px, 15px) scale(0.75);transform-origin:0 0'></iframe>"
|
||||
% sites.url("C", "/grid"))
|
||||
sites.route("C", "/grid", "<!doctype html>" + _grid(3, 3))
|
||||
return sites
|
||||
|
||||
|
||||
TRANSFORMS = [("scale", "translate(40px, 30px) scale(0.5)"), ("scale-up", "translate(10px, 10px) scale(1.4)"),
|
||||
("rotate-ish", "translate(60px, 20px) scale(0.8) skewX(-8deg)")]
|
||||
|
||||
|
||||
@pytest.fixture(params=[False, True], ids=["plain", "humanized"])
|
||||
def pointer_browser(request, firefox_binary):
|
||||
"""A browser per way of moving the pointer: a click of the humanized one lands off the centre of the element."""
|
||||
with launch(firefox_binary, humanize=request.param) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pointer_page(pointer_browser):
|
||||
context, page = new_page(pointer_browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name,transform", TRANSFORMS, ids=[t[0] for t in TRANSFORMS])
|
||||
def test_a_click_by_selector_in_a_frame_under_a_transform_lands_on_that_element(pointer_page, transformed, name,
|
||||
transform):
|
||||
"""The iframe sits in a box under `transform` (translate and scale, and a skew). One click per button, by
|
||||
selector, in the frame of B and in the frame of C nested in it (which is transformed as well): each is
|
||||
recorded by the document it landed in, as a trusted click on the button that was asked for, and by that
|
||||
document only."""
|
||||
page = pointer_page
|
||||
transformed.route("A", "/t", "<!doctype html><title>t</title><body style='margin:0;height:2000px'>"
|
||||
"<div style='transform:%s;transform-origin:0 0;position:absolute;left:30px;top:20px'>"
|
||||
"<iframe id='b' src='%s' width='900' height='450' style='border:0'></iframe></div>"
|
||||
% (transform, transformed.url("B", "/grid")))
|
||||
page.goto(transformed.url("A", "/t"), wait_until="load")
|
||||
frames = {"frame": wait_frame(page, transformed.url("B"), "/grid"),
|
||||
"nested": wait_frame(page, transformed.url("C"), "/grid")}
|
||||
expected = {"frame": [], "nested": []}
|
||||
for target, button in (("frame", "r2c1"), ("nested", "r1c1"), ("frame", "r3c3"), ("nested", "r2c2"),
|
||||
("frame", "r0c0")):
|
||||
frames[target].locator("#" + button).click()
|
||||
expected[target].append({"id": button, "trusted": True})
|
||||
for name_, frame in frames.items():
|
||||
assert frame.evaluate("window.landed") == expected[name_], (target, button, name_)
|
||||
|
||||
|
||||
def test_the_transformed_frames_are_in_other_processes(pointer_page, transformed):
|
||||
page = pointer_page
|
||||
transformed.route("A", "/t", "<!doctype html><title>t</title><div style='transform:scale(0.5)'>"
|
||||
"<iframe id='b' src='%s' width='900' height='450'></iframe></div>"
|
||||
% transformed.url("B", "/grid"))
|
||||
page.goto(transformed.url("A", "/t"), wait_until="load")
|
||||
b = wait_frame(page, transformed.url("B"), "/grid")
|
||||
assert_other_process(page.main_frame, b)
|
||||
assert_other_process(b, wait_frame(page, transformed.url("C"), "/grid"))
|
||||
|
||||
|
||||
def test_a_click_by_selector_after_scrolling_the_page_and_the_frame(pointer_page, sites):
|
||||
"""The page and the frame are both scrolled, so the element is where neither document's own coordinates say:
|
||||
the click still lands on it. Below the fold of the frame, which is below the fold of the page; once in the
|
||||
frame of B and once in the frame of C nested in it (scrolled too)."""
|
||||
page = pointer_page
|
||||
sites.route("B", "/tall", "<!doctype html>" + _grid(rows=14, cols=2) +
|
||||
"<iframe id='c' src='%s' style='position:absolute;left:300px;top:20px;width:400px;height:300px;"
|
||||
"border:0'></iframe><div style='position:absolute;top:1500px;width:1px;height:1px'></div>"
|
||||
% sites.url("C", "/tall-c"))
|
||||
sites.route("C", "/tall-c", "<!doctype html>" + _grid(rows=14, cols=2))
|
||||
sites.route("A", "/scrolled", "<!doctype html><title>scrolled</title><body style='margin:0'>"
|
||||
"<div style='height:900px'>spacer</div><iframe id='b' src='%s' width='900' height='400' "
|
||||
"style='border:0'></iframe><div style='height:1200px'></div>" % sites.url("B", "/tall"))
|
||||
page.goto(sites.url("A", "/scrolled"), wait_until="load")
|
||||
outer = wait_frame(page, sites.url("B"), "/tall")
|
||||
inner = wait_frame(page, sites.url("C"), "/tall-c")
|
||||
page.evaluate("window.scrollTo(0, 700)")
|
||||
outer.evaluate("window.scrollTo(0, 500)")
|
||||
assert page.evaluate("window.scrollY") == 700 and outer.evaluate("window.scrollY") == 500
|
||||
outer.locator("#r12c1").click()
|
||||
assert outer.evaluate("window.landed") == [{"id": "r12c1", "trusted": True}]
|
||||
inner.evaluate("window.scrollTo(0, 400)")
|
||||
inner.locator("#r12c0").click()
|
||||
assert inner.evaluate("window.landed") == [{"id": "r12c0", "trusted": True}]
|
||||
assert outer.evaluate("window.landed") == [{"id": "r12c1", "trusted": True}]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 8. screenshots
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PINK, GREEN, BLUE, GOLD = (255, 0, 170), (0, 204, 68), (34, 85, 238), (255, 204, 0)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def painted(sites):
|
||||
sites.route("A", "/paint", "<!doctype html><title>paint</title><body style='margin:0;background:#fff'>"
|
||||
"<iframe id='b' src='%s' style='position:absolute;left:50px;top:40px;width:300px;height:200px;"
|
||||
"border:0'></iframe>" % sites.url("B", "/paint"))
|
||||
sites.route("B", "/paint", "<!doctype html><body style='margin:0;background:#ff00aa'>"
|
||||
"<div id='swatch' style='position:absolute;left:20px;top:30px;width:80px;height:60px;"
|
||||
"background:#00cc44'></div>"
|
||||
"<iframe id='c' src='%s' style='position:absolute;left:120px;top:20px;width:150px;height:120px;"
|
||||
"border:0'></iframe>" % sites.url("C", "/paint"))
|
||||
sites.route("C", "/paint", "<!doctype html><body style='margin:0;background:#2255ee'>"
|
||||
"<div id='swatch' style='position:absolute;left:10px;top:10px;width:50px;height:40px;"
|
||||
"background:#ffcc00'></div>")
|
||||
return sites
|
||||
|
||||
|
||||
def painted_shot(page, take, probes, seconds=30.0):
|
||||
"""``decode_png`` of the first screenshot whose pixel at every probe ``((x, y), colour)`` is the colour asked.
|
||||
|
||||
The frame of another site is painted by its own process, and when that happens depends on the machine (half a second
|
||||
after the frame is listed was not enough on a loaded Windows runner), so the screenshot is taken again until the
|
||||
paint is there, with a deadline; a frame that is never painted is red at the deadline, with the colours seen at each
|
||||
probe on the way. The caller then asserts on the image returned, as before."""
|
||||
last = {}
|
||||
|
||||
def sample():
|
||||
last["png"] = decode_png(take())
|
||||
_, _, pixel = last["png"]
|
||||
return tuple(pixel(*point) for point, _ in probes)
|
||||
|
||||
seen = watch(sample, lambda colours: all(near(c, want) for c, (_, want) in zip(colours, probes)), seconds,
|
||||
lambda: page.wait_for_timeout(100))
|
||||
assert seen.ok, "the frames were never painted as asked within %.0f s; the colours at %s were: %s" % (
|
||||
seconds, [point for point, _ in probes], seen.render())
|
||||
return last["png"]
|
||||
|
||||
|
||||
def test_a_page_screenshot_shows_the_content_of_the_frames_of_other_sites(page, painted):
|
||||
page.goto(painted.url("A", "/paint"), wait_until="load")
|
||||
wait_frame(page, painted.url("C"), "/paint")
|
||||
assert_other_process(page.main_frame, wait_frame(page, painted.url("B"), "/paint"))
|
||||
_, _, pixel = painted_shot(page, lambda: page.screenshot(scale="css"), [
|
||||
((10, 10), (255, 255, 255)), ((50 + 5, 40 + 5), PINK), ((50 + 20 + 40, 40 + 30 + 30), GREEN),
|
||||
((50 + 120 + 5, 40 + 20 + 5), BLUE), ((50 + 120 + 10 + 25, 40 + 20 + 10 + 20), GOLD)])
|
||||
# outside the frame the page's own white; inside it the frame's pink; its swatch; the nested frame's blue
|
||||
assert near(pixel(10, 10), (255, 255, 255)), pixel(10, 10)
|
||||
assert near(pixel(50 + 5, 40 + 5), PINK), pixel(55, 45)
|
||||
assert near(pixel(50 + 20 + 40, 40 + 30 + 30), GREEN), pixel(110, 100)
|
||||
assert near(pixel(50 + 120 + 5, 40 + 20 + 5), BLUE), pixel(175, 65)
|
||||
assert near(pixel(50 + 120 + 10 + 25, 40 + 20 + 10 + 20), GOLD), pixel(205, 90)
|
||||
assert near(pixel(50 + 300 + 10, 40 + 10), (255, 255, 255)), "right of the frame"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target,size,color", [("frame", (80, 60), GREEN), ("nested", (50, 40), GOLD)])
|
||||
def test_a_locator_screenshot_of_an_element_in_a_frame_of_another_site(page, painted, target, size, color):
|
||||
page.goto(painted.url("A", "/paint"), wait_until="load")
|
||||
frame = {"frame": wait_frame(page, painted.url("B"), "/paint"),
|
||||
"nested": wait_frame(page, painted.url("C"), "/paint")}[target]
|
||||
points = ((0, 0), (size[0] - 1, size[1] - 1), (size[0] // 2, size[1] // 2), (size[0] - 1, 0))
|
||||
width, height, pixel = painted_shot(page, lambda: frame.locator("#swatch").screenshot(scale="css"),
|
||||
[(point, color) for point in points])
|
||||
assert (width, height) == size
|
||||
for x, y in ((0, 0), (width - 1, height - 1), (width // 2, height // 2), (width - 1, 0)):
|
||||
assert near(pixel(x, y), color), ((x, y), pixel(x, y))
|
||||
|
||||
|
||||
def test_a_locator_screenshot_of_the_iframe_element_shows_the_frame(page, painted):
|
||||
page.goto(painted.url("A", "/paint"), wait_until="load")
|
||||
wait_frame(page, painted.url("C"), "/paint")
|
||||
width, height, pixel = painted_shot(page, lambda: page.locator("#b").screenshot(scale="css"),
|
||||
[((5, 5), PINK), ((60, 60), GREEN), ((125, 25), BLUE)])
|
||||
assert (width, height) == (300, 200)
|
||||
assert near(pixel(5, 5), PINK) and near(pixel(60, 60), GREEN) and near(pixel(125, 25), BLUE)
|
||||
@@ -0,0 +1,323 @@
|
||||
"""Workers made in frames of other sites, what a frame of another site keeps, and the frames that have no address.
|
||||
|
||||
Three sites (see `_fission_frames.py`): the top is A (`127.0.0.1`), the frame B (`localhost`), the frame C
|
||||
(`127.0.0.2`) nested in B. With Fission each site is a content process of its own.
|
||||
|
||||
* Identity inside workers. A dedicated Worker made in the top, in the frame of B and in the frame of C (blob and
|
||||
script-url workers) reports the same `navigator.userAgent`, `language`, `languages`, `hardwareConcurrency`,
|
||||
`platform` and time zone as the window of the top and as the window that made it: a worker lives in the process
|
||||
of the frame that made it, and its identity has to be declared there like the window's. The comparison reads an
|
||||
absence as a mismatch, never as an agreement. A SharedWorker and a ServiceWorker are made from the frame of B:
|
||||
the outcome asserted is what stock Firefox does there (see the docstrings).
|
||||
* Cookies and storage. A cookie set by site B inside a frame of A appears in `context.cookies()` with B's domain;
|
||||
what `document.cookie`, `localStorage` and `sessionStorage` show to B-in-A is what stock Firefox shows, and B
|
||||
opened as a top page does not see them: storage is partitioned by top-level site, as in retail Firefox (stock
|
||||
Playwright Firefox has that protection off; see the docstrings).
|
||||
* Frames with no address of their own, at the top level and inside the frame of B: `srcdoc`, `about:blank`, a
|
||||
`data:` url and a `sandbox`ed frame with and without `allow-scripts allow-same-origin`: they are in
|
||||
`page.frames`, `evaluate` works where scripts run, and `frame_locator` reaches into them (see the docstrings
|
||||
for what stock Firefox does with a sandbox that forbids scripts).
|
||||
|
||||
The first test proves the frames are in other processes, so the file cannot turn into a same-process suite.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from _fission_frames import Sites, assert_other_process, launch, new_page, wait_for, wait_frame
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: What a worker reads about the browser it runs in, as an object literal for its source.
|
||||
IDENTITY = ("{userAgent: navigator.userAgent, language: navigator.language, languages: navigator.languages.join('|'),"
|
||||
" hardwareConcurrency: navigator.hardwareConcurrency, platform: navigator.platform,"
|
||||
" timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone}")
|
||||
FIELDS = ("userAgent", "language", "languages", "hardwareConcurrency", "platform", "timeZone")
|
||||
|
||||
#: Run in a frame: make a dedicated worker (from a blob, or from the script of the frame's site) and return what it
|
||||
#: reports, or the error.
|
||||
WORKER_JS = """(kind) => new Promise(resolve => {
|
||||
const source = 'postMessage(' + %s + ')';
|
||||
let worker;
|
||||
try {
|
||||
worker = kind === 'blob' ? new Worker(URL.createObjectURL(new Blob([source], {type: 'text/javascript'})))
|
||||
: new Worker('/identity-worker.js');
|
||||
} catch (e) { resolve({error: String(e)}); return; }
|
||||
worker.onmessage = e => resolve(e.data);
|
||||
worker.onerror = e => resolve({error: 'worker error: ' + e.message});
|
||||
setTimeout(() => resolve({error: 'timeout'}), 30000);
|
||||
})""" % json.dumps(IDENTITY)
|
||||
|
||||
WINDOW_JS = "() => (%s)" % IDENTITY
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sites():
|
||||
with Sites() as s:
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser(firefox_binary):
|
||||
with launch(firefox_binary) as browser:
|
||||
yield browser
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser):
|
||||
context, page = new_page(browser)
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
def _absent(value):
|
||||
return value is None or value == "" or (isinstance(value, str) and value.startswith("error"))
|
||||
|
||||
|
||||
def mismatches(reference, other, fields=FIELDS):
|
||||
"""Every field in which ``other`` differs from ``reference``; an absence on either side is a mismatch."""
|
||||
problems = []
|
||||
for field in fields:
|
||||
if _absent(reference.get(field)):
|
||||
problems.append("reference has no %s: %r" % (field, reference.get(field)))
|
||||
elif _absent(other.get(field)):
|
||||
problems.append("%s is absent (%r), the reference reads %r" % (field, other.get(field), reference[field]))
|
||||
elif other[field] != reference[field]:
|
||||
problems.append("%s = %r, the reference reads %r" % (field, other[field], reference[field]))
|
||||
return problems
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# identity inside workers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def worker_pages(sites):
|
||||
sites.route("A", "/workers", "<!doctype html><title>top</title><iframe id='b' src='%s' width='600' height='300'>"
|
||||
"</iframe>" % sites.url("B", "/workers-b"))
|
||||
sites.route("B", "/workers-b", "<!doctype html><title>b</title><iframe id='c' src='%s' width='400' height='150'>"
|
||||
"</iframe>" % sites.url("C", "/workers-c"))
|
||||
sites.route("C", "/workers-c", "<!doctype html><title>c</title>")
|
||||
for site in ("A", "B", "C"):
|
||||
sites.route(site, "/identity-worker.js", "postMessage(%s)" % IDENTITY, ctype="text/javascript")
|
||||
return sites
|
||||
|
||||
|
||||
def test_the_frames_are_in_other_processes(page, worker_pages):
|
||||
page.goto(worker_pages.url("A", "/workers"), wait_until="load")
|
||||
b = wait_frame(page, worker_pages.url("B"), "/workers-b")
|
||||
assert_other_process(page.main_frame, b)
|
||||
assert_other_process(b, wait_frame(page, worker_pages.url("C"), "/workers-c"))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["blob", "url"])
|
||||
def test_a_dedicated_worker_reports_the_identity_of_the_window_in_every_frame(page, worker_pages, kind):
|
||||
page.goto(worker_pages.url("A", "/workers"), wait_until="load")
|
||||
frames = {"top": page.main_frame,
|
||||
"frame": wait_frame(page, worker_pages.url("B"), "/workers-b"),
|
||||
"nested": wait_frame(page, worker_pages.url("C"), "/workers-c")}
|
||||
reference = page.main_frame.evaluate(WINDOW_JS)
|
||||
assert not mismatches(reference, reference), reference
|
||||
problems = []
|
||||
for name, frame in frames.items():
|
||||
window = frame.evaluate(WINDOW_JS)
|
||||
worker = frame.evaluate(WORKER_JS, kind)
|
||||
problems += ["%s window: %s" % (name, p) for p in mismatches(reference, window)]
|
||||
problems += ["%s %s worker: %s" % (name, kind, p) for p in mismatches(reference, worker)]
|
||||
problems += ["%s worker against its own window: %s" % (name, p) for p in mismatches(window, worker)]
|
||||
assert not problems, "identity differs between the top window and the frames and workers:\n " + "\n ".join(problems)
|
||||
|
||||
|
||||
SHARED_WORKER_JS = """() => new Promise(resolve => {
|
||||
try {
|
||||
const worker = new SharedWorker('/shared-worker.js');
|
||||
worker.port.onmessage = e => resolve({outcome: 'ok', identity: e.data});
|
||||
worker.onerror = e => resolve({outcome: 'error', message: String(e.message || e)});
|
||||
} catch (e) { resolve({outcome: 'throw', message: e.name + ': ' + e.message}); }
|
||||
setTimeout(() => resolve({outcome: 'timeout'}), 30000);
|
||||
})"""
|
||||
|
||||
SERVICE_WORKER_JS = """() => new Promise(resolve => {
|
||||
try {
|
||||
navigator.serviceWorker.register('/service-worker.js').then(
|
||||
registration => navigator.serviceWorker.ready.then(ready => {
|
||||
navigator.serviceWorker.onmessage = e => resolve({outcome: 'registered', scope: registration.scope,
|
||||
identity: e.data});
|
||||
(ready.active || registration.active).postMessage('who');
|
||||
}),
|
||||
e => resolve({outcome: 'rejected', message: e.name + ': ' + e.message}));
|
||||
} catch (e) { resolve({outcome: 'throw', message: e.name + ': ' + e.message}); }
|
||||
setTimeout(() => resolve({outcome: 'timeout'}), 30000);
|
||||
})"""
|
||||
|
||||
|
||||
def test_a_shared_worker_made_in_a_frame_of_another_site_reports_the_identity_of_the_top(page, worker_pages):
|
||||
"""As stock Firefox does: a SharedWorker can be made from a frame of another site (its own site's worker
|
||||
script), starts, and answers. What it reports about the browser is what the top window reads."""
|
||||
worker_pages.route("B", "/shared-worker.js", "onconnect = e => { e.ports[0].postMessage(%s); };" % IDENTITY,
|
||||
ctype="text/javascript")
|
||||
page.goto(worker_pages.url("A", "/workers"), wait_until="load")
|
||||
frame = wait_frame(page, worker_pages.url("B"), "/workers-b")
|
||||
result = frame.evaluate(SHARED_WORKER_JS)
|
||||
assert result["outcome"] == "ok", result
|
||||
assert not mismatches(page.main_frame.evaluate(WINDOW_JS), result["identity"]), result
|
||||
|
||||
|
||||
def test_a_service_worker_registered_from_a_frame_of_another_site_reports_the_identity_of_the_top(page, worker_pages):
|
||||
"""As stock Firefox does: a frame of another site registers a ServiceWorker of its own site (scope the site's
|
||||
root), it becomes active, and answers a message; what it reports about the browser is what the top window
|
||||
reads."""
|
||||
worker_pages.route("B", "/service-worker.js",
|
||||
"self.addEventListener('install', e => self.skipWaiting());"
|
||||
"self.addEventListener('activate', e => e.waitUntil(clients.claim()));"
|
||||
"self.addEventListener('message', e => e.source.postMessage(%s));" % IDENTITY,
|
||||
ctype="text/javascript", headers=[("Service-Worker-Allowed", "/")])
|
||||
page.goto(worker_pages.url("A", "/workers"), wait_until="load")
|
||||
frame = wait_frame(page, worker_pages.url("B"), "/workers-b")
|
||||
result = frame.evaluate(SERVICE_WORKER_JS)
|
||||
assert result["outcome"] == "registered", result
|
||||
assert result["scope"] == worker_pages.url("B", "/"), result
|
||||
assert not mismatches(page.main_frame.evaluate(WINDOW_JS), result["identity"]), result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# cookies and storage
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def storage_pages(sites):
|
||||
read = "window.__r = {cookie: document.cookie, ls: localStorage.getItem('k'), ss: sessionStorage.getItem('k')};"
|
||||
sites.route("A", "/storage", "<!doctype html><title>top</title><iframe id='b' src='%s'></iframe>"
|
||||
% sites.url("B", "/storage-b"))
|
||||
sites.route("B", "/storage-b", "<!doctype html><title>b</title><script>"
|
||||
"document.cookie = 'jscookie=2; path=/'; localStorage.setItem('k', 'frame-ls');"
|
||||
"sessionStorage.setItem('k', 'frame-ss'); %s</script>" % read,
|
||||
headers=[("Set-Cookie", "hdrcookie=1; Path=/")])
|
||||
sites.route("B", "/storage-own", "<!doctype html><title>own</title><script>%s</script>" % read)
|
||||
# B as a top page writes a cookie and an item of its own; B in a frame of A reads them (they must not be there)
|
||||
sites.route("B", "/storage-top-writes", "<!doctype html><title>top writes</title><script>"
|
||||
"document.cookie = 'topcookie=3; path=/'; localStorage.setItem('top-only', 'top-ls');"
|
||||
"window.__r = {cookie: document.cookie, top: localStorage.getItem('top-only')};</script>")
|
||||
sites.route("B", "/storage-read-b", "<!doctype html><title>reads</title><script>"
|
||||
"window.__r = {cookie: document.cookie, top: localStorage.getItem('top-only')};</script>")
|
||||
sites.route("A", "/storage-read", "<!doctype html><title>top</title><iframe id='b' src='%s'></iframe>"
|
||||
% sites.url("B", "/storage-read-b"))
|
||||
return sites
|
||||
|
||||
|
||||
def test_what_a_frame_of_another_site_stores_is_seen_by_the_frame_and_by_the_context(page, storage_pages):
|
||||
"""As stock Firefox does: a cookie set by site B inside a frame of A (by a header and by script) is in
|
||||
`context.cookies()` with B's domain, `document.cookie` of the frame shows both, and so do `localStorage` and
|
||||
`sessionStorage` of the frame what the frame wrote; a second page of the context with the same frame sees
|
||||
the same cookies and local storage, and the session storage of its own tab (the frame wrote it there too)."""
|
||||
context = page.context
|
||||
page.goto(storage_pages.url("A", "/storage"), wait_until="load")
|
||||
frame = wait_frame(page, storage_pages.url("B"), "/storage-b")
|
||||
assert frame.evaluate("window.__r") == {"cookie": "hdrcookie=1; jscookie=2", "ls": "frame-ls", "ss": "frame-ss"}
|
||||
assert sorted((c["name"], c["domain"]) for c in context.cookies()) == [("hdrcookie", "localhost"),
|
||||
("jscookie", "localhost")]
|
||||
assert sorted(c["name"] for c in context.cookies(storage_pages.url("B"))) == ["hdrcookie", "jscookie"]
|
||||
assert context.cookies(storage_pages.url("A")) == []
|
||||
second = context.new_page()
|
||||
second.goto(storage_pages.url("A", "/storage"), wait_until="load")
|
||||
again = wait_frame(second, storage_pages.url("B"), "/storage-b")
|
||||
assert again.evaluate("window.__r") == {"cookie": "hdrcookie=1; jscookie=2", "ls": "frame-ls", "ss": "frame-ss"}
|
||||
|
||||
|
||||
def test_storage_of_site_b_is_partitioned_between_a_frame_of_a_and_b_as_a_top_page(page, storage_pages):
|
||||
"""The retail outcome, not stock Playwright's: cookies and web storage are partitioned by the top-level site.
|
||||
What site B wrote inside a frame of A is not visible to B opened as a top page: its `document.cookie` is empty
|
||||
and its `localStorage` item is null (`context.cookies()` still lists B's cookies, with B's domain, because it
|
||||
reads the whole jar). The reverse holds too: a cookie and a local-storage item that B wrote as a top page are
|
||||
not visible to B inside the frame of A. The session storage of the top page is empty in both cases.
|
||||
|
||||
Why the reference here is the retail Firefox and not stock Playwright Firefox: the reference of this project
|
||||
is what a page reads in a Firefox a user installed, and retail Firefox partitions third-party cookies and
|
||||
storage by top-level site (Total Cookie Protection). Playwright's own Firefox ships with that protection off
|
||||
and shows the stored values to B as a top page (observed with Playwright 1.62: `document.cookie` is
|
||||
`hdrcookie=1; jscookie=2` and the item is `frame-ls`), which is not what a page sees in a real browser, so
|
||||
its answer is not the one asserted."""
|
||||
context = page.context
|
||||
page.goto(storage_pages.url("A", "/storage"), wait_until="load")
|
||||
wait_frame(page, storage_pages.url("B"), "/storage-b")
|
||||
own = context.new_page()
|
||||
own.goto(storage_pages.url("B", "/storage-own"), wait_until="load")
|
||||
assert own.evaluate("window.__r") == {"cookie": "", "ls": None, "ss": None}
|
||||
assert sorted(c["name"] for c in context.cookies(storage_pages.url("B"))) == ["hdrcookie", "jscookie"]
|
||||
# the reverse: B writes as a top page, then is framed by A and reads
|
||||
own.goto(storage_pages.url("B", "/storage-top-writes"), wait_until="load")
|
||||
assert own.evaluate("window.__r") == {"cookie": "topcookie=3", "top": "top-ls"}
|
||||
reader = context.new_page()
|
||||
reader.goto(storage_pages.url("A", "/storage-read"), wait_until="load")
|
||||
frame = wait_frame(reader, storage_pages.url("B"), "/storage-read-b")
|
||||
# B inside A reads its own partition: the two cookies the frame wrote above are there, what B wrote as a top page
|
||||
# (`topcookie`, the `top-only` item) is not.
|
||||
assert frame.evaluate("window.__r") == {"cookie": "hdrcookie=1; jscookie=2", "top": None}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# frames with no address of their own
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
INNER = "<p id=x>%s</p><script>window.v=1</script>"
|
||||
SPECIAL = ('<iframe id="srcdoc" srcdoc="%s"></iframe>' % (INNER % "in srcdoc")
|
||||
+ '<iframe id="blank"></iframe>'
|
||||
+ '<iframe id="data" src="data:text/html,%s"></iframe>' % (INNER % "in data")
|
||||
+ '<iframe id="sb0" sandbox srcdoc="%s"></iframe>' % (INNER % "sb0")
|
||||
+ '<iframe id="sb1" sandbox="allow-scripts allow-same-origin" srcdoc="%s"></iframe>' % (INNER % "sb1")
|
||||
+ '<iframe id="sb2" sandbox="allow-scripts" srcdoc="%s"></iframe>' % (INNER % "sb2"))
|
||||
|
||||
#: id -> (url of the frame, `window.v` in it, text of #x). `window.v` is 1 where the document's script ran;
|
||||
#: a sandbox without `allow-scripts` runs none, but `evaluate` still works there and answers undefined.
|
||||
SPECIAL_FRAMES = {
|
||||
"srcdoc": ("about:srcdoc", 1, "in srcdoc"),
|
||||
"blank": ("about:blank", None, None),
|
||||
"data": (None, 1, "in data"),
|
||||
"sb0": ("about:srcdoc", None, "sb0"),
|
||||
"sb1": ("about:srcdoc", 1, "sb1"),
|
||||
"sb2": ("about:srcdoc", 1, "sb2"),
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def special_pages(sites):
|
||||
sites.route("A", "/special", "<!doctype html><title>special</title>" + SPECIAL)
|
||||
sites.route("B", "/special", "<!doctype html><title>special b</title>" + SPECIAL)
|
||||
sites.route("A", "/special-in-b", "<!doctype html><title>top</title><iframe id='b' src='%s'></iframe>"
|
||||
% sites.url("B", "/special"))
|
||||
return sites
|
||||
|
||||
|
||||
@pytest.mark.parametrize("where", ["top", "inside_b"])
|
||||
def test_special_frames_are_listed_evaluated_and_reached_by_frame_locator(page, special_pages, where):
|
||||
"""As stock Firefox does: `srcdoc` and every `sandbox`ed srcdoc frame is `about:srcdoc`, the empty one is
|
||||
`about:blank`, the `data:` one keeps its url; all are in `page.frames` under their parent, named by their id;
|
||||
`evaluate` works in all of them and finds `window.v` where the document's script could run (not in the
|
||||
sandbox without `allow-scripts`, not in the empty frame); `frame_locator` reaches the text inside each, in
|
||||
the empty frame once something is written there; the same at the top level and inside a frame of B."""
|
||||
path = "/special" if where == "top" else "/special-in-b"
|
||||
page.goto(special_pages.url("A", path), wait_until="load")
|
||||
owner_site = "A" if where == "top" else "B"
|
||||
owner = wait_frame(page, special_pages.url(owner_site), "/special")
|
||||
if where == "inside_b":
|
||||
assert_other_process(page.main_frame, owner)
|
||||
expected_count = 1 + (where == "inside_b") + len(SPECIAL_FRAMES)
|
||||
assert wait_for(page, lambda: len(page.frames) == expected_count), [(f.name, f.url) for f in page.frames]
|
||||
inner = {f.name: f for f in page.frames if f.parent_frame is owner}
|
||||
assert sorted(inner) == sorted(SPECIAL_FRAMES), [(f.name, f.url) for f in page.frames]
|
||||
scope = page.frame_locator("#b") if where == "inside_b" else page
|
||||
for frame_id, (url, value, text) in SPECIAL_FRAMES.items():
|
||||
frame = inner[frame_id]
|
||||
if url is None:
|
||||
assert frame.url.startswith("data:text/html,"), frame.url
|
||||
else:
|
||||
assert frame.url == url, (frame_id, frame.url)
|
||||
assert frame.evaluate("window.v") == value, frame_id
|
||||
if frame_id == "blank":
|
||||
frame.evaluate("document.body.innerHTML = '<p id=x>written</p>'")
|
||||
text = "written"
|
||||
assert scope.frame_locator("#" + frame_id).locator("#x").inner_text() == text, frame_id
|
||||
@@ -61,6 +61,7 @@ from urllib.parse import urlsplit
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from _fission_frames import PROOF_SECONDS, TRIALS, other_process_proved, ticks_inside # noqa: E402
|
||||
from _servers import LocalServer # noqa: E402
|
||||
|
||||
SEED = 4242
|
||||
@@ -86,12 +87,9 @@ GROUPS = {
|
||||
"fonts": ("fonts_check", "font_width_arial", "font_width_segoe_ui", "font_width_fallback"),
|
||||
}
|
||||
|
||||
#: How long the second iframe keeps its main thread busy, and the gaps the top then sees in a
|
||||
#: 10 ms timer: a process shared with the top delays the timer by about the whole spin, a process
|
||||
#: of its own does not delay it at all.
|
||||
#: How long the second iframe keeps its main thread busy; what the top's 10 ms timer does meanwhile
|
||||
#: says whether the process is shared (see `SPIN_PROBE_JS`).
|
||||
SPIN_MS = 400
|
||||
SHARED_PROCESS_GAP_MS = 300
|
||||
OWN_PROCESS_GAP_MS = 200
|
||||
|
||||
#: The strategy-0 prefs, passed explicitly so that the case keeps its meaning on the day the core
|
||||
#: writes strategy 1 by default.
|
||||
@@ -184,8 +182,11 @@ function measure(family) {
|
||||
// The process probe: a document asked to spin keeps its process's main thread busy.
|
||||
window.addEventListener('message', e => {
|
||||
if (e.data && e.data.fission_busy) {
|
||||
const start = Date.now();
|
||||
const end = performance.now() + e.data.fission_busy;
|
||||
while (performance.now() < end) { /* spin */ }
|
||||
// the wall-clock window of the spin, told to whoever asked: the observer's ticks are placed against it
|
||||
if (e.source) e.source.postMessage({fission_spun: [start, Date.now()]}, '*');
|
||||
}
|
||||
});
|
||||
async function collect(name) {
|
||||
@@ -533,23 +534,23 @@ def _serve():
|
||||
raise RuntimeError("no port free on all of %s, %s, %s: %s" % (HOST_TOP, HOST_OOP, HOST_OOP_2, last))
|
||||
|
||||
|
||||
#: Run in the top document: ask the iframe on the third site to spin, report the longest gap
|
||||
#: between two ticks of a 10 ms timer. What a site can measure about its own process, with no
|
||||
#: help from the driver.
|
||||
#: Run in the top document: ask the iframe on the third site to spin, tick a 10 ms timer meanwhile and report the
|
||||
#: time of every tick and the wall-clock window of the spin the iframe tells. What a site can measure about its own
|
||||
#: process, with no help from the driver. A tick INSIDE the window proves the iframe is in another process (one thread
|
||||
#: cannot tick while it spins); no tick proves nothing alone (a loaded machine starves a process for seconds).
|
||||
SPIN_PROBE_JS = """(spin) => new Promise(resolve => {
|
||||
let last = performance.now(), longest = 0;
|
||||
const id = setInterval(() => {
|
||||
const now = performance.now();
|
||||
longest = Math.max(longest, now - last);
|
||||
last = now;
|
||||
}, 10);
|
||||
const ticks = [];
|
||||
const id = setInterval(() => ticks.push(Date.now()), 10);
|
||||
const done = (spun) => { clearInterval(id); removeEventListener('message', on); resolve([ticks, spun]); };
|
||||
const on = e => { if (e.data && e.data.fission_spun) done(e.data.fission_spun); };
|
||||
addEventListener('message', on);
|
||||
document.getElementById('oop2').contentWindow.postMessage({fission_busy: spin}, '*');
|
||||
setTimeout(() => { clearInterval(id); resolve(longest); }, 1500);
|
||||
setTimeout(() => done(null), 30000);
|
||||
})"""
|
||||
|
||||
|
||||
def _run(binary: str, seed: int, strategy: int) -> dict:
|
||||
"""Open the page once; return what the four documents read and the longest timer gap the top saw."""
|
||||
"""Open the page once; return what the four documents read and the spin trials the top saw."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
prefs = dict(STRATEGY_1_PREFS if strategy == 1 else STRATEGY_0_PREFS)
|
||||
@@ -566,10 +567,20 @@ def _run(binary: str, seed: int, strategy: int) -> dict:
|
||||
break
|
||||
page.wait_for_timeout(200)
|
||||
results = page.evaluate("() => window.__parity")
|
||||
longest_gap = page.evaluate(SPIN_PROBE_JS, SPIN_MS)
|
||||
# strategy 1: until one spin shows ticks inside it (a healthy machine needs one). strategy 0: all of
|
||||
# them, and none may show a tick inside (the proof of one process is the absence, every time)
|
||||
trials = []
|
||||
if strategy == 1:
|
||||
# spins until one shows ticks inside it, for 30 s (a loaded machine starves the top for a whole spin now and then)
|
||||
end = time.monotonic() + PROOF_SECONDS
|
||||
while not other_process_proved(trials) and time.monotonic() < end:
|
||||
trials.append(tuple(page.evaluate(SPIN_PROBE_JS, SPIN_MS)))
|
||||
else:
|
||||
for _ in range(TRIALS):
|
||||
trials.append(tuple(page.evaluate(SPIN_PROBE_JS, SPIN_MS)))
|
||||
finally:
|
||||
server.shutdown()
|
||||
return {"results": results, "longest_gap_ms": longest_gap, "port": port}
|
||||
return {"results": results, "spin_trials": trials, "port": port}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=[
|
||||
@@ -599,18 +610,23 @@ def test_every_context_reported(run):
|
||||
def test_the_iframes_run_where_the_strategy_puts_them(run, strategy):
|
||||
"""The precondition of the strategy-1 case, read by the page itself.
|
||||
|
||||
The iframe on the third site spins for 400 ms. In a process shared with the top the top's
|
||||
10 ms timer stalls for about that long; in a process of its own it does not.
|
||||
The iframe on the third site spins for 400 ms while the top ticks a 10 ms timer, and the iframe tells the window
|
||||
of its spin. In a process shared with the top no tick can run inside the window; in a process of its own ticks
|
||||
run inside it (`_fission_frames.other_process_proved`, which says why that is the proof no load can fake).
|
||||
"""
|
||||
gap = run["longest_gap_ms"]
|
||||
trials = run["spin_trials"]
|
||||
seen = [(ticks_inside(ticks, spun), len(ticks), (spun[1] - spun[0]) if spun else None) for ticks, spun in trials]
|
||||
# a spin that did not happen proves nothing in either direction: at least one must have been seen
|
||||
assert any(spun and spun[1] - spun[0] >= SPIN_MS * 0.9 for _ticks, spun in trials), (
|
||||
"the iframe did not spin for %d ms (ticks inside, ticks in all, spin ms): %r" % (SPIN_MS, seen))
|
||||
if strategy == 0:
|
||||
assert gap >= SHARED_PROCESS_GAP_MS, (
|
||||
"strategy 0 keeps the iframes in the top's process, so a %d ms spin should stall "
|
||||
"the top's timer; the longest gap was %.0f ms" % (SPIN_MS, gap))
|
||||
assert not other_process_proved(trials), (
|
||||
"strategy 0 keeps the iframes in the top's process, so no tick of the top's timer can run inside a %d ms "
|
||||
"spin; (ticks inside, ticks in all, spin ms) per spin: %r" % (SPIN_MS, seen))
|
||||
else:
|
||||
assert gap < OWN_PROCESS_GAP_MS, (
|
||||
"strategy 1 gives the third site a process of its own, so a %d ms spin should not "
|
||||
"stall the top's timer; the longest gap was %.0f ms" % (SPIN_MS, gap))
|
||||
assert other_process_proved(trials), (
|
||||
"strategy 1 gives the third site a process of its own, so the top's timer should tick inside a %d ms "
|
||||
"spin; in %d spins it never did; (ticks inside, ticks in all, spin ms) per spin: %r" % (SPIN_MS, len(trials), seen))
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
|
||||
@@ -94,7 +94,8 @@ def test_the_crash_of_an_iframe_s_process_leaves_the_tab(firefox_binary, engine_
|
||||
port = server.server_address[1]
|
||||
marionette = None
|
||||
try:
|
||||
prefs = dict(FISSION, **{"marionette.port": webfont_probe.MARIONETTE_PORT})
|
||||
marionette_port = webfont_probe.marionette_port()
|
||||
prefs = dict(FISSION, **{"marionette.port": marionette_port})
|
||||
with InvisiblePlaywright(binary_path=firefox_binary, headless=True, humanize=False,
|
||||
extra_args=["-marionette"], extra_prefs=prefs) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
@@ -106,7 +107,7 @@ def test_the_crash_of_an_iframe_s_process_leaves_the_tab(firefox_binary, engine_
|
||||
# the iframe's document is not read, nor its address: what the client can see of a frame in another
|
||||
# process is what the rest of Fission builds
|
||||
|
||||
marionette = webfont_probe._Marionette(webfont_probe.MARIONETTE_PORT)
|
||||
marionette = webfont_probe._Marionette(marionette_port)
|
||||
marionette.call("WebDriver:NewSession", {"capabilities": {"alwaysMatch": {}}})
|
||||
marionette.call("Marionette:SetContext", {"value": "chrome"})
|
||||
pids = json.loads(marionette.call("WebDriver:ExecuteScript", {"script": PIDS, "args": []})["value"])
|
||||
|
||||
@@ -157,11 +157,12 @@ def page(browser):
|
||||
return page
|
||||
|
||||
|
||||
def wait_for(page, predicate, seconds=8.0):
|
||||
def wait_for(page, predicate, seconds=30.0):
|
||||
"""Until `predicate()`, with the client's events being read: the sync client takes the engine's events
|
||||
only inside its own calls, so a plain sleep would never see a frame arrive."""
|
||||
end = time.time() + seconds
|
||||
while time.time() < end:
|
||||
only inside its own calls, so a plain sleep would never see a frame arrive. Every use waits for something
|
||||
that must come, so the deadline is far beyond a healthy run: a loaded runner is slow, not wrong."""
|
||||
end = time.monotonic() + seconds
|
||||
while time.monotonic() < end:
|
||||
if predicate():
|
||||
return True
|
||||
page.wait_for_timeout(100)
|
||||
@@ -324,11 +325,16 @@ def test_named_world_declared_after_oop_iframe(page, cross_site_loop, events, en
|
||||
from invisible_core.juggler.injected import UTILITY_WORLD
|
||||
|
||||
page.goto(cross_site_loop["top"], wait_until="load")
|
||||
wait_for(page, lambda: len(page.frames) >= 3)
|
||||
page.wait_for_timeout(1000)
|
||||
created = [e["params"] for e in events if e["method"] == "Runtime.executionContextCreated"]
|
||||
default = {c["auxData"]["frameId"] for c in created if not c["auxData"].get("name")}
|
||||
utility = {c["auxData"]["frameId"] for c in created if c["auxData"].get("name") == UTILITY_WORLD}
|
||||
def contexts():
|
||||
created = [e["params"] for e in events if e["method"] == "Runtime.executionContextCreated"]
|
||||
default = {c["auxData"]["frameId"] for c in created if not c["auxData"].get("name")}
|
||||
utility = {c["auxData"]["frameId"] for c in created if c["auxData"].get("name") == UTILITY_WORLD}
|
||||
return default, utility
|
||||
|
||||
# until every frame has both contexts (a condition, not 1 s: the contexts of a loaded machine come later); if they
|
||||
# never do, the assertions below say which are missing
|
||||
wait_for(page, lambda: len(page.frames) >= 3 and len(contexts()[0]) >= 3 and contexts()[0] <= contexts()[1])
|
||||
default, utility = contexts()
|
||||
assert len(default) >= 3, "frames with a default context: %d" % len(default)
|
||||
assert default <= utility, "frames without a utility context: %d" % len(default - utility)
|
||||
# The contexts above can be those of the frame's first about:blank, which no one ever destroys: what
|
||||
@@ -414,9 +420,21 @@ def test_content_frame_of_an_iframe_nested_too_deep_is_none(page, cross_site_loo
|
||||
document. `contentWindow` is null there, and the client expects no content frame."""
|
||||
page.goto(cross_site_loop["deep"], wait_until="load")
|
||||
assert wait_for(page, lambda: len(page.frames) >= 10)
|
||||
page.wait_for_timeout(1500)
|
||||
last = page.frames[-1]
|
||||
owner = last.frame_element()
|
||||
|
||||
def last_owner_names_no_frame():
|
||||
try:
|
||||
owner = page.frames[-1].frame_element()
|
||||
except Exception: # the frame is not there yet (or no longer): look again; the assertion below is not wrapped
|
||||
return False
|
||||
try:
|
||||
return owner.content_frame() is None
|
||||
finally:
|
||||
owner.dispose()
|
||||
|
||||
# until the deepest frame the client lists is the one past the depth (a condition, not 1.5 s): while the chain is
|
||||
# still being announced the last frame is a shallower one, whose element does name a frame
|
||||
wait_for(page, last_owner_names_no_frame)
|
||||
owner = page.frames[-1].frame_element()
|
||||
try:
|
||||
assert owner.content_frame() is None
|
||||
finally:
|
||||
|
||||
Loaded 100 of 174 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user