Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c85220b54 | ||
|
|
e8d2be88d3 | ||
|
|
92ffcd9ca5 |
No files matched your search
@@ -24,7 +24,3 @@ tests/gates/wire_method_debt.json text eol=lf
|
||||
|
||||
# The lock of the gate is hashed byte for byte: its header names the sha256 of gate.in, so neither file may be rewritten with CRLF on a Windows checkout.
|
||||
ci/py-lock/** text eol=lf
|
||||
|
||||
# The vendored bundles are third-party bytes whose sha256 is pinned in tests/vendor/README.md: no checkout converts their line endings
|
||||
# (a Windows runner with core.autocrlf=true would hand them over with CRLF and the hash would no longer match).
|
||||
tests/vendor/*.js -text
|
||||
@@ -38,13 +38,3 @@ Describe what you ran:
|
||||
- [ ] `pytest` passes locally.
|
||||
- [ ] I updated `README.md` / `docs/` if user-visible behavior changed.
|
||||
- [ ] My change is in scope for this repo (Python wrapper / sampler / CLI / packaging - not the patched Firefox C++ source).
|
||||
|
||||
## Patch questions (filled by maintainers)
|
||||
|
||||
<!--
|
||||
Every applicable project rule question, answered with proof.
|
||||
"Not proven yet" blocks the merge; a question that does not apply says why in one line.
|
||||
-->
|
||||
|
||||
| Question | Answer | Proof (file:line, run id, test and its red-on-old run) |
|
||||
|---|---|---|
|
||||
@@ -28,28 +28,27 @@
|
||||
# version with content nobody compared, which is the exact failure mode the
|
||||
# `==` specifier was adopted to expose.
|
||||
#
|
||||
# So this workflow asks the index and reports a verdict, and the callers make
|
||||
# their real jobs depend on it. Three outcomes, all of them visible:
|
||||
# So this workflow asks the index and reports a verdict: the job is green only
|
||||
# when the pinned core is on the index, and RED in every other case. There is no
|
||||
# "skip" outcome and no output a caller can read to skip itself (rule ci-13:
|
||||
# nothing counts as passed that did not pass). Outcomes:
|
||||
#
|
||||
# the project is not on the index at all
|
||||
# -> the publish window. This job passes, emits a ::warning:: annotation
|
||||
# on the run page, writes the reason into the run summary, and returns
|
||||
# available=false. Every caller job is then SKIPPED - grey in the
|
||||
# checks list, not green - and the summary says in words that no tests
|
||||
# ran. Nobody can mistake it for a passing build.
|
||||
# -> red. During the publish window (the core is uploaded first, this
|
||||
# package after it) no install here can succeed, so the run says so and
|
||||
# fails; re-run it once the core's publish has finished. The callers
|
||||
# `need` this job, so they do not run, and the `gate` of tests.yml
|
||||
# refuses a skipped job.
|
||||
#
|
||||
# the project is on the index and carries the pinned version
|
||||
# -> available=true. Every caller job runs exactly as it did before this
|
||||
# file existed. Nothing is weakened, ever.
|
||||
# -> green. Every caller job runs exactly as it did before this file
|
||||
# existed. Nothing is weakened, ever.
|
||||
#
|
||||
# the project is on the index but NOT at the pinned version
|
||||
# -> this is not the window. The core has been published, so the pin
|
||||
# names a version that was never uploaded. Hard failure, red.
|
||||
# -> red: the pin names a version that was never uploaded.
|
||||
#
|
||||
# Anything ambiguous (index unreachable, malformed answer, no `==` pin in
|
||||
# pyproject.toml, two of them) is also a hard failure. A gate that answers
|
||||
# "skip" when it does not know would silently disable this repo's whole CI the
|
||||
# first time PyPI has a bad minute.
|
||||
# pyproject.toml, two of them) is also a hard failure.
|
||||
#
|
||||
# This does NOT stop being useful once the core is published: it is the check
|
||||
# that catches a pin pointing at a version that does not exist, about 20s
|
||||
@@ -60,12 +59,6 @@ name: core-on-index
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
available:
|
||||
description: >-
|
||||
"true" when the invisible-core version pinned in pyproject.toml can
|
||||
be resolved from the package index. Any other value means the caller
|
||||
must not attempt an install.
|
||||
value: ${{ jobs.probe.outputs.available }}
|
||||
pin:
|
||||
description: The invisible-core version this repo pins.
|
||||
value: ${{ jobs.probe.outputs.pin }}
|
||||
@@ -79,7 +72,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
outputs:
|
||||
available: ${{ steps.probe.outputs.available }}
|
||||
pin: ${{ steps.probe.outputs.pin }}
|
||||
steps:
|
||||
# SHA-pinned like e2e.yml: this job decides whether the rest of the repo's
|
||||
@@ -167,29 +159,20 @@ jobs:
|
||||
f"verdict, so this job fails instead of guessing. Re-run it.")
|
||||
|
||||
if unpublished:
|
||||
msg = (f"{DIST} has never been published to the index. This is the "
|
||||
f"expected publish window: the core is uploaded first, this "
|
||||
f"repo's package after it.")
|
||||
print(f"::warning title={DIST} is not on the index yet::{msg} "
|
||||
f"NOTHING WAS INSTALLED AND NO TEST RAN in this workflow run.")
|
||||
write("GITHUB_STEP_SUMMARY",
|
||||
f"### NO TESTS RAN\n\n{msg}\n\n"
|
||||
f"Every job in this workflow was **skipped**, not passed. "
|
||||
f"`pyproject.toml` pins `{DIST}=={pin}`; until that version is on "
|
||||
f"the index no `pip install` in this repository can resolve, so "
|
||||
f"there is nothing to run. Publish `{DIST}=={pin}`, then re-run "
|
||||
f"this workflow - the jobs come back on their own, with no edit "
|
||||
f"to any file here.\n")
|
||||
write("GITHUB_OUTPUT", "available=false")
|
||||
sys.exit(0)
|
||||
die(f"FAIL core-on-index: the pinned {DIST} {pin} is not on the index. "
|
||||
f"Fix: wait for its publish to finish, or pin a published core. "
|
||||
f"Rule: ci-13 nothing counts as passed that did not pass")
|
||||
|
||||
versions = data.get("versions")
|
||||
if not versions:
|
||||
die(f"{url} answered but listed no versions. The index API changed shape "
|
||||
f"or served something unexpected; refusing to turn that into a skip.")
|
||||
f"or served something unexpected; refusing to guess.")
|
||||
if pin not in versions:
|
||||
shown = sorted(versions)[-10:] # diagnostics only, so a plain sort
|
||||
die(f"pyproject.toml pins {DIST}=={pin}, but the index publishes "
|
||||
die(f"FAIL core-on-index: the pinned {DIST} {pin} is not on the index. "
|
||||
f"Fix: wait for its publish to finish, or pin a published core. "
|
||||
f"Rule: ci-13 nothing counts as passed that did not pass. "
|
||||
f"Detail: pyproject.toml pins {DIST}=={pin}, but the index publishes "
|
||||
f"{len(versions)} version(s) ({', '.join(shown)}) and not {pin}. "
|
||||
f"{DIST} exists, so this is NOT the "
|
||||
f"publish window - the pin names a version that was never uploaded. "
|
||||
@@ -197,11 +180,9 @@ jobs:
|
||||
f"the core first.")
|
||||
|
||||
print(f"{DIST}=={pin} is on the index - the workflow runs normally.")
|
||||
write("GITHUB_OUTPUT", "available=true")
|
||||
PY
|
||||
|
||||
- name: Say so in the run summary
|
||||
if: steps.probe.outputs.available == 'true'
|
||||
run: |
|
||||
echo "invisible-core==${{ steps.probe.outputs.pin }} is on the index; jobs run normally." \
|
||||
>> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -22,15 +22,6 @@
|
||||
# Windows runner separates the two without asking anyone to stay off it
|
||||
# for six hours.
|
||||
#
|
||||
# A second use, chosen by the input `ab_network_webrtc_seed` (empty = the loop
|
||||
# above, as always): the network oracle's WebRTC walk of that seed, alone,
|
||||
# `runs` times for each engine of its A/A (the published engine twice). It
|
||||
# exists to tell two readings apart when the A/A of that walk differs from
|
||||
# itself in the number of TURN Allocate datagrams (scripts/ci_ab_network.py:
|
||||
# AB_NETWORK_HUNT): each repetition keeps every datagram with its time and its
|
||||
# STUN transaction id and the page's own ICE times (network/hunt/<engine>-<i>.json,
|
||||
# summary in network/hunt/summary.json). It decides nothing: the step exits 0.
|
||||
#
|
||||
# Doesn't start on its own: `workflow_dispatch` only. It's not a gate, it's
|
||||
# an investigation tool, and it must not be added to the required contexts.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
@@ -43,10 +34,6 @@ on:
|
||||
description: "How many runs at most (at 12% it takes ~18 for a 90% chance)"
|
||||
required: false
|
||||
default: "18"
|
||||
ab_network_webrtc_seed:
|
||||
description: "A seed (e.g. 4) to repeat ONLY the network oracle's WebRTC walk of, `runs` times for each engine of its A/A, instead of the e2e loop. Empty: the e2e loop."
|
||||
required: false
|
||||
default: ""
|
||||
os:
|
||||
description: "Where to hunt. windows-latest answers a DIFFERENT question: are the interaction retries seen on the dev machine the product or contention?"
|
||||
required: false
|
||||
@@ -88,11 +75,6 @@ jobs:
|
||||
needs: linux-deps-hunt
|
||||
if: ${{ !cancelled() && (needs.linux-deps-hunt.result == 'success' || needs.linux-deps-hunt.result == 'skipped') }}
|
||||
runs-on: ${{ inputs.os }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(inputs.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(inputs.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
# 18 runs of ~6 minutes plus install time. Deliberately generous: the
|
||||
# ceiling here must NEVER be the thing that stops the hunt, or we're back
|
||||
# to a killed job that explains nothing, which is the original defect.
|
||||
@@ -139,29 +121,10 @@ jobs:
|
||||
sudo apt-get $APT update
|
||||
sudo cp /tmp/linux-deps/*.deb /var/cache/apt/archives/
|
||||
sudo apt-get $APT install -y --no-download --no-install-recommends $(cat /tmp/linux-deps/roots.txt)
|
||||
- name: The security state (a fixed directory of the repository)
|
||||
if: inputs.ab_network_webrtc_seed != ''
|
||||
run: python scripts/ci_lab_security_state.py set --pin ci/security-state.pin.json
|
||||
- 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)
|
||||
if: inputs.ab_network_webrtc_seed != ''
|
||||
run: python scripts/ci_lab_geoip.py build
|
||||
|
||||
# The hunt of the network oracle's WebRTC walk: instead of the loop below, never with it. `runs` is the number of repetitions per engine.
|
||||
- name: The network oracle's WebRTC walk of one seed, repeated (decides nothing)
|
||||
if: inputs.ab_network_webrtc_seed != ''
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
AB_NETWORK_HUNT: webrtc:${{ inputs.ab_network_webrtc_seed }}:${{ inputs.runs }}
|
||||
run: |
|
||||
set -u
|
||||
if [ "$RUNNER_OS" = "Linux" ]; then PRE="xvfb-run -a"; else PRE=""; fi
|
||||
mkdir -p network
|
||||
$PRE python -u scripts/ci_ab_network.py ab --a-a --out network --published-binary "$FF"
|
||||
|
||||
- name: Loop until it catches one
|
||||
if: inputs.ab_network_webrtc_seed == ''
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
INVPW_TEST_WATCHDOG_FILE: evidence/e2e-watchdog.log
|
||||
@@ -216,12 +179,3 @@ jobs:
|
||||
evidence/e2e-watchdog.log
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
- name: Upload the hunt of the network oracle's WebRTC walk
|
||||
if: always() && inputs.ab_network_webrtc_seed != ''
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: e2e-hunt-network-webrtc-${{ inputs.os }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: network/hunt
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
+135
-342
@@ -1,6 +1,9 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# e2e.yml - run the FULL browser-driving e2e suite (the 127 @pytest.mark.e2e)
|
||||
# on GitHub, on every push/PR to main.
|
||||
# on GitHub, in the merge queue run of every change to main and on every push to main.
|
||||
# A pull request runs the fast set (tests.yml); this workflow is too heavy for every push to a
|
||||
# pull request, so it runs when the change enters the merge queue (`merge_group`), and that run
|
||||
# decides: its ONE verdict is the job `e2e verdict`.
|
||||
#
|
||||
# Why this can run on CI when the drive-gate had to stay light: the drive-gate
|
||||
# launched Firefox in true HEADLESS mode, which is content-process unstable on
|
||||
@@ -22,16 +25,9 @@ on:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- 'LICENSE'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
# The same filter as `push` above, which had it and this one did not. A
|
||||
# docs-only PR (#54, deleting the Pages site) therefore spun up the full
|
||||
# browser bench, hung, and burned the whole 40-minute timeout on a change no
|
||||
# test can observe. The filter belongs on BOTH triggers or it is not a filter.
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- 'LICENSE'
|
||||
# The merge queue run. GitHub applies no `paths` or `paths-ignore` to it, so a docs-only change runs the whole set here too.
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
only:
|
||||
@@ -46,22 +42,20 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A newer push to a pull request cancels the older in-flight run of THIS
|
||||
# workflow on that pull request as a whole, cleanly, instead of leaving its
|
||||
# queued jobs to be cancelled one by one - which left the run marked failed even
|
||||
# though nothing had actually failed. Keyed by workflow + pull request number,
|
||||
# so tests and e2e never cancel each other.
|
||||
# Nothing cancels this workflow: a merge queue run is keyed by its own ref
|
||||
# (one per queue entry, `gh-readonly-queue/...`) and never cancelled in
|
||||
# progress, and the run of a push is unique to the run (`github.run_id`).
|
||||
#
|
||||
# NEVER on main. The release gate (scripts/e2e_is_green.py) asks for the e2e
|
||||
# check-run of the commit being tagged, and a cancelled one refuses the release:
|
||||
# with the group keyed by ref, the next push to main cancelled the run of the
|
||||
# commit before it. Outside a pull request the group is unique to the run
|
||||
# commit before it. Outside the merge queue the group is unique to the run
|
||||
# (`github.run_id`), so every commit of main keeps its own finished run, and a
|
||||
# pending run is not replaced by a newer one either (a group with a fixed name
|
||||
# drops the older pending run, cancel or not).
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'merge_group' && github.ref || github.run_id }}
|
||||
cancel-in-progress: false
|
||||
|
||||
# Engine and GeoIP downloads go through the release API with this token.
|
||||
# Anonymous requests share a 60-an-hour limit per runner address and are the
|
||||
@@ -72,12 +66,46 @@ env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
# THE FIRST JOB: does this change have anything for the workflow to test? GitHub applies no `paths` filter to a merge queue run, so a docs-only change would
|
||||
# run everything here. In a queue run scripts/ci_changes.py lists the files of the entry (base_sha..head_sha) and applies the path rules of the `push` trigger
|
||||
# above; on any other event it says run=true. `run=false` is an explicit "nothing to test", not a skip: every other job needs this one and runs only on
|
||||
# run == 'true', and `e2e verdict` (scripts/ci_gate.py, CHANGES_RUN) expects them all skipped then, and red otherwise. The script is read from main, never
|
||||
# from the branch it judges (a branch must not decide that it needs no test); while it is not on main yet the copy of this branch is used, and the log says so.
|
||||
changes:
|
||||
name: changes
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
outputs:
|
||||
run: ${{ steps.changes.outputs.run }}
|
||||
files: ${{ steps.changes.outputs.files }}
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- name: does the change touch anything this workflow tests
|
||||
id: changes
|
||||
shell: bash
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
HEAD_SHA: ${{ github.event.merge_group.head_sha }}
|
||||
run: |
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
if git cat-file -e origin/main:scripts/ci_changes.py 2>/dev/null; then
|
||||
git show origin/main:scripts/ci_changes.py > "$RUNNER_TEMP/ci_changes.py"
|
||||
else
|
||||
echo "ci_changes.py is not on origin/main yet: falling back to the copy of this branch"
|
||||
cp scripts/ci_changes.py "$RUNNER_TEMP/ci_changes.py"
|
||||
fi
|
||||
python3 "$RUNNER_TEMP/ci_changes.py" e2e "$EVENT_NAME" "$BASE_SHA" "$HEAD_SHA" | tee -a "$GITHUB_OUTPUT"
|
||||
|
||||
# The install below resolves `invisible-core==N.M.0` from the package index,
|
||||
# and the core is published BEFORE this package. This gate answers whether it
|
||||
# is on the index yet; during that window the e2e job is SKIPPED with the
|
||||
# reason in the run summary rather than faked green, and once the core is up
|
||||
# it runs unchanged. See .github/workflows/core-on-index.yml.
|
||||
# is on the index yet; during that window this job FAILS (rule ci-13: a core
|
||||
# that is not on the index is red, never a skip) and the e2e jobs, which
|
||||
# need it, do not run; once the core is up it runs unchanged. See .github/workflows/core-on-index.yml.
|
||||
core-on-index:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
|
||||
# THE UBUNTU PACKAGES OF THE LINUX JOBS, from Ubuntu's archive once per runner image and list (linux-deps.yml), never by a job: a run lost a green leg to its time
|
||||
@@ -86,8 +114,8 @@ jobs:
|
||||
# Playwright's install-deps names for Firefox. The jobs install its roots by name from that repository, with --no-download.
|
||||
linux-deps-e2e:
|
||||
name: linux-deps-e2e
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
uses: ./.github/workflows/linux-deps.yml
|
||||
with:
|
||||
name: e2e
|
||||
@@ -103,8 +131,8 @@ jobs:
|
||||
# branch protection read.
|
||||
e2e-linux:
|
||||
name: e2e (linux, part ${{ matrix.part }})
|
||||
needs: [core-on-index, linux-deps-e2e]
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index, linux-deps-e2e]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
@@ -116,14 +144,14 @@ jobs:
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The A/A of the three A/B oracles (page, network, host) runs on the first seeds of the candidate set on a pull request, and on ALL of them when the pull request
|
||||
# changes a file of that oracle (scripts/ci_ab_pr_seeds.py holds the lists). The checkout is shallow, so the script fetches the base commit and lists the files that
|
||||
# differ from it (`git diff --name-only <base> HEAD`: HEAD is the merge commit, so this is the pull request's own change); the tests read the variables it prints.
|
||||
# The A/A of the three A/B oracles (page, network, host) runs on the first seeds of the candidate set in the merge queue run, and on ALL of them when the change
|
||||
# touches a file of that oracle (scripts/ci_ab_pr_seeds.py holds the lists). The checkout is shallow, so the script fetches the base commit of the queue entry and lists the files that
|
||||
# differ from it (`git diff --name-only <base> HEAD`: HEAD is the merge group commit, so this is the change of the entry); the tests read the variables it prints.
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -368,13 +396,12 @@ jobs:
|
||||
# it is green only when every part is green. `needs.e2e-linux.result` is the result of the matrix as a whole (`success` only when every part succeeded;
|
||||
# one failed, cancelled or skipped part makes it something else), and anything but `success` is red here: a cancelled part measured nothing, a skipped
|
||||
# one ran nothing. `always()` so that a red or cancelled part still reaches this job and turns it red instead of skipping it, which reads as not red.
|
||||
# The gate of the core on the index stays the same as for the parts: while the pinned core is not on the index the parts are skipped with the reason in
|
||||
# the summary (core-on-index.yml), and so is this job, as the Linux job was before the split.
|
||||
# The gate of the core on the index stays the same as for the parts: while the pinned core is not on the index core-on-index is red and the parts are skipped, so this job (always()) sees their result `skipped` and fails (rule ci-13).
|
||||
# tests/test_ci_runs_once_per_commit.py (5.) holds this job.
|
||||
e2e:
|
||||
name: e2e (linux, xvfb)
|
||||
needs: [core-on-index, e2e-linux]
|
||||
if: always() && needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index, e2e-linux]
|
||||
if: always() && needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
@@ -391,12 +418,11 @@ jobs:
|
||||
# ``Control+A`` selects all in a field, on the PUBLISHED engine and the core this package pins, on Windows, where the keyboard of a real
|
||||
# user is: the shortcut letter used to reach the browser as Control+Shift+A (invisible-core 63.66.0 fixes it). The e2e is red on the
|
||||
# keyboard that held Shift for the capital A (tests/test_control_a_selects_all_in_a_field_e2e.py: 5 ways to press it x an <input> and a
|
||||
# <textarea>, in-process and served to the stock Playwright client). Same gate as the Linux job: it is SKIPPED, with the reason in the
|
||||
# summary, until the core is on the index, and it runs unchanged after; `workflow_dispatch` with `only: windows-control-a` runs it alone.
|
||||
# <textarea>, in-process and served to the stock Playwright client). Same gate as the Linux job: it needs core-on-index, which fails until the core is on the index, and it runs unchanged after; `workflow_dispatch` with `only: windows-control-a` runs it alone.
|
||||
e2e-windows-control-a:
|
||||
name: e2e (windows, Control+A)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 20
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
@@ -411,44 +437,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: Install wrapper + test deps (the stock client is in the dev extra)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
@@ -464,18 +454,6 @@ jobs:
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
run: INVPW_BINARY_PATH="$FF" python -u -m pytest -m e2e -p no:cacheprovider -v tests/test_control_a_selects_all_in_a_field_e2e.py
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the tests saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: invpw-evidence-windows-control-a-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: ${{ runner.temp }}/invpw-evidence
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
|
||||
# THE SAME e2e ON WINDOWS (Federico, 12/11: every test of the product runs on Linux AND Windows; where Windows behaves
|
||||
# differently the test adapts to the system). Before this, 562 of the 808 e2e had never run on Windows in any round. The census
|
||||
@@ -486,8 +464,8 @@ jobs:
|
||||
# partition whole and tests/test_every_suite_runs_on_linux_and_windows.py holds both systems together.
|
||||
e2e-windows:
|
||||
name: e2e (windows, part ${{ matrix.part }})
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 40
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
@@ -505,52 +483,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
# The A/A of the three A/B oracles (page, network, host) runs on the first seeds of the candidate set on a pull request, and on ALL of them when the pull request
|
||||
# changes a file of that oracle (scripts/ci_ab_pr_seeds.py holds the lists). The checkout is shallow, so the script fetches the base commit and lists the files that
|
||||
# differ from it (`git diff --name-only <base> HEAD`: HEAD is the merge commit, so this is the pull request's own change); the tests read the variables it prints.
|
||||
# The A/A of the three A/B oracles (page, network, host) runs on the first seeds of the candidate set in the merge queue run, and on ALL of them when the change
|
||||
# touches a file of that oracle (scripts/ci_ab_pr_seeds.py holds the lists). The checkout is shallow, so the script fetches the base commit of the queue entry and lists the files that
|
||||
# differ from it (`git diff --name-only <base> HEAD`: HEAD is the merge group commit, so this is the change of the entry); the tests read the variables it prints.
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -606,10 +548,6 @@ jobs:
|
||||
path: ${{ runner.temp }}/e2e-junit-*.xml
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the tests saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
@@ -626,8 +564,8 @@ jobs:
|
||||
# above, `own_job` in the Windows parts). The same setup as the shared jobs: the security state, the engine, the GeoIP database made by the repository.
|
||||
e2e-network:
|
||||
name: e2e (network, linux)
|
||||
needs: [core-on-index, linux-deps-e2e]
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index, linux-deps-e2e]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
# the network oracle's own guard (2197 s, two engine runs: the measured runs 45121964904 and 45153612447 plus 25%) and the job's own steps, with room for a slow runner
|
||||
timeout-minutes: 50
|
||||
@@ -637,10 +575,10 @@ jobs:
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -717,64 +655,24 @@ jobs:
|
||||
|
||||
e2e-network-windows:
|
||||
name: e2e (network, windows)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: windows-2022
|
||||
# the network oracle's own guard (2197 s, two engine runs: the measured runs 45121964904 and 45153612447 plus 25%) and the job's own steps, with room for a slow runner
|
||||
timeout-minutes: 50
|
||||
# TEMP and TMP on D:\a\_temp, as every Windows job that launches a browser (see e2e-windows): on C: the profiles saturate the disk.
|
||||
env:
|
||||
TEMP: 'D:\a\_temp'
|
||||
TMP: 'D:\a\_temp'
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -812,10 +710,6 @@ jobs:
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
@@ -834,8 +728,8 @@ jobs:
|
||||
# 35 for the test.
|
||||
e2e-host:
|
||||
name: e2e (host, linux)
|
||||
needs: [core-on-index, linux-deps-e2e]
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index, linux-deps-e2e]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 65
|
||||
steps:
|
||||
@@ -844,10 +738,10 @@ jobs:
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -944,63 +838,23 @@ jobs:
|
||||
|
||||
e2e-host-windows:
|
||||
name: e2e (host, windows)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 45
|
||||
# TEMP and TMP on D:\a\_temp, as every Windows job that launches a browser (see e2e-windows): on C: the profiles saturate the disk.
|
||||
env:
|
||||
TEMP: 'D:\a\_temp'
|
||||
TMP: 'D:\a\_temp'
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -1104,10 +958,6 @@ jobs:
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
@@ -1127,8 +977,8 @@ jobs:
|
||||
# `own_job` in the Windows parts). 45 minutes for the job, as the host oracle's: the setup of the job plus the guard of the test with the margin of Windows. The same setup as the shared jobs.
|
||||
e2e-page:
|
||||
name: e2e (page oracle, linux)
|
||||
needs: [core-on-index, linux-deps-e2e]
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index, linux-deps-e2e]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -1137,10 +987,10 @@ jobs:
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -1217,63 +1067,23 @@ jobs:
|
||||
|
||||
e2e-page-windows:
|
||||
name: e2e (page oracle, windows)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && inputs.only != 'windows-control-a'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 45
|
||||
# TEMP and TMP on D:\a\_temp, as every Windows job that launches a browser (see e2e-windows): on C: the profiles saturate the disk.
|
||||
env:
|
||||
TEMP: 'D:\a\_temp'
|
||||
TMP: 'D:\a\_temp'
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'merge_group'
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
@@ -1311,10 +1121,6 @@ jobs:
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
@@ -1340,8 +1146,8 @@ jobs:
|
||||
# Seed 0 is in shard 1, and its second launch on a reused profile is part of that shard's A/A.
|
||||
e2e-page-final-touched:
|
||||
name: e2e (page oracle, is it touched)
|
||||
needs: core-on-index
|
||||
if: github.event_name == 'pull_request' && needs.core-on-index.outputs.available == 'true' && inputs.only != 'windows-control-a'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true' && github.event_name == 'merge_group' && inputs.only != 'windows-control-a'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
outputs:
|
||||
@@ -1351,17 +1157,17 @@ jobs:
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: Does the pull request change a file of the page oracle
|
||||
- name: Does the change touch a file of the page oracle
|
||||
id: touched
|
||||
shell: bash
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
run: python scripts/ci_ab_oracle.py touched "$BASE_SHA" | tee -a "$GITHUB_OUTPUT"
|
||||
|
||||
e2e-page-final:
|
||||
name: e2e (page oracle, final seeds ${{ matrix.shard }}/4, linux)
|
||||
needs: [core-on-index, e2e-page-final-touched, linux-deps-e2e]
|
||||
if: needs.core-on-index.outputs.available == 'true' && needs.e2e-page-final-touched.outputs.touched == 'true'
|
||||
needs: [changes, core-on-index, e2e-page-final-touched, linux-deps-e2e]
|
||||
if: needs.changes.outputs.run == 'true' && needs.e2e-page-final-touched.outputs.touched == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
@@ -1450,14 +1256,10 @@ jobs:
|
||||
|
||||
e2e-page-final-windows:
|
||||
name: e2e (page oracle, final seeds ${{ matrix.shard }}/4, windows)
|
||||
needs: [core-on-index, e2e-page-final-touched]
|
||||
if: needs.core-on-index.outputs.available == 'true' && needs.e2e-page-final-touched.outputs.touched == 'true'
|
||||
needs: [changes, core-on-index, e2e-page-final-touched]
|
||||
if: needs.changes.outputs.run == 'true' && needs.e2e-page-final-touched.outputs.touched == 'true'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 40
|
||||
# TEMP and TMP on D:\a\_temp, as every Windows job that launches a browser (see e2e-windows): on C: the profiles saturate the disk.
|
||||
env:
|
||||
TEMP: 'D:\a\_temp'
|
||||
TMP: 'D:\a\_temp'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -1468,44 +1270,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
# The runner's screen (1024x768 by default) is smaller than the browser window the e2e open (1936x1048 for a 1920x1080 identity), so the
|
||||
# OS cursor cannot be parked outside it (tests/_os_cursor.py) and a native move for it reaches the page. 1920x1080 is the largest mode the
|
||||
# runner's video device accepts (run 45730213378 of oss-invisible/playwright): it leaves the strip below the window free. Declared here, read back.
|
||||
- name: The runner's screen is 1920x1080, larger than the browser window is tall (read back)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-DisplayResolution -Width 1920 -Height 1080 -Force
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$b = [System.Windows.Forms.SystemInformation]::VirtualScreen
|
||||
"the runner's screen: $($b.Width)x$($b.Height) at $($b.X),$($b.Y)"
|
||||
if ($b.Width -lt 1920 -or $b.Height -lt 1080) { Write-Error "the runner's screen is $($b.Width)x$($b.Height), not 1920x1080: the OS cursor could not be parked outside the browser window"; exit 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
# The native crash of the pytest worker ("node down: Not properly terminated", "Windows fatal exception: access violation" in a thread Python has no state for, jobs
|
||||
# 138402013609 and 138966622085): Windows Error Reporting writes a FULL dump of a python.exe that dies from an unhandled exception, into the evidence folder the job
|
||||
# uploads (dumps/python), so the faulting module and stack can be read. HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<image>, DumpType 2 = full,
|
||||
# DumpCount = how many are kept: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps . faulthandler (pytest enables it) is a vectored handler that
|
||||
# returns EXCEPTION_CONTINUE_SEARCH, so WER still sees the exception. BEFORE the first pytest step; the summary step before the upload reads what it left.
|
||||
- name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$dumps = Join-Path $env:RUNNER_TEMP 'invpw-evidence\dumps\python'
|
||||
New-Item -ItemType Directory -Force -Path $dumps | Out-Null
|
||||
$wer = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting'
|
||||
New-Item -Force -Path $wer | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name Disabled -PropertyType DWord -Value 0 | Out-Null
|
||||
New-ItemProperty -Force -Path $wer -Name DontShowUI -PropertyType DWord -Value 1 | Out-Null
|
||||
$key = "$wer\LocalDumps\python.exe"
|
||||
New-Item -Force -Path $key | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
@@ -1544,10 +1310,6 @@ jobs:
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)
|
||||
if: always()
|
||||
shell: bash
|
||||
run: python scripts/ci_wer_dumps.py "$RUNNER_TEMP/invpw-evidence/dumps/python"
|
||||
- name: Upload what the test saved
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
@@ -1558,3 +1320,34 @@ jobs:
|
||||
${{ runner.temp }}/page-final-e2e.xml
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
|
||||
# THE VERDICT of the workflow, the only one that decides (rule ci-13, nothing counts as passed that did not pass). It waits for EVERY job of this file, and
|
||||
# `if: always()` makes sure a failed, cancelled or skipped one still reaches it. Each must end in `success`; only the jobs scripts/ci_gate.py names as
|
||||
# conditional by design may be `skipped` (the final-seed shards when the page oracle is not touched, and what `only: windows-control-a` leaves out).
|
||||
# The judge is read from main, never from the branch it judges; while the file is not on main yet (the change that adds it) the copy of this branch is
|
||||
# used, and the log says so. `e2e (linux, xvfb)` above stays the Linux check the release reads (scripts/e2e_is_green.py).
|
||||
verdict:
|
||||
name: e2e verdict
|
||||
needs: [changes, core-on-index, linux-deps-e2e, e2e-linux, e2e, e2e-windows-control-a, e2e-windows, e2e-network, e2e-network-windows, e2e-host, e2e-host-windows, e2e-page, e2e-page-windows, e2e-page-final-touched, e2e-page-final, e2e-page-final-windows]
|
||||
if: always()
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- name: refuse unless every needed job succeeded
|
||||
env:
|
||||
NEEDS: ${{ toJSON(needs) }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
WORKFLOW: e2e
|
||||
CHANGES_RUN: ${{ needs.changes.outputs.run }}
|
||||
INPUT_ONLY: ${{ inputs.only }}
|
||||
run: |
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
if git cat-file -e origin/main:scripts/ci_gate.py 2>/dev/null; then
|
||||
git show origin/main:scripts/ci_gate.py > "$RUNNER_TEMP/ci_gate.py"
|
||||
else
|
||||
echo "ci_gate.py is not on origin/main yet: falling back to the copy of this branch"
|
||||
cp scripts/ci_gate.py "$RUNNER_TEMP/ci_gate.py"
|
||||
fi
|
||||
python3 "$RUNNER_TEMP/ci_gate.py"
|
||||
@@ -11,9 +11,10 @@
|
||||
# WHICH ENGINE. The published one (`python -m invisible_playwright fetch`), as e2e.yml. The candidate of the engine repository runs the same entry on its own
|
||||
# binary (scripts/run_fakeweb.py --binary), and judges the four e2e tests of this fake web as the suite `wrapper.e2e.fakeweb` of ci/required-suites.json.
|
||||
#
|
||||
# WHEN. A pull request or a push to main that touches the fake web or this file (the journey and the hard pages are not a round for every change); again by hand
|
||||
# with `workflow_dispatch`. Four legs, a profile on a system each (Linux under Xvfb, Windows); no leg is repeated or forgiven, and the ONE verdict of the workflow is the
|
||||
# job `fakeweb verdict`: red unless all four legs are green (a skipped leg, for a core that is not on the index yet, is not green: nothing was measured).
|
||||
# WHEN. The merge queue run of every change to main (`merge_group`: GitHub applies no `paths` filter to it, so every queue entry runs it, and that run decides), and a
|
||||
# push to main that touches the fake web or this file; again by hand with `workflow_dispatch`. A pull request does not run it: a pull request runs the fast set
|
||||
# (tests.yml). Four legs, a profile on a system each (Linux under Xvfb, Windows); no leg is repeated or forgiven, and the ONE verdict of the workflow is the
|
||||
# job `fakeweb verdict`: red unless every job of the workflow is green (a skipped leg, for a core that is not on the index yet, is not green: nothing was measured).
|
||||
|
||||
name: fakeweb
|
||||
|
||||
@@ -27,37 +28,66 @@ on:
|
||||
- 'scripts/fakeweb_p4_report.py'
|
||||
- 'scripts/playwright_pin.txt'
|
||||
- '.github/workflows/fakeweb.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'tests/fakeweb/**'
|
||||
- 'tests/test_fakeweb_*.py'
|
||||
- 'scripts/run_fakeweb.py'
|
||||
- 'scripts/fakeweb_p4_report.py'
|
||||
- 'scripts/playwright_pin.txt'
|
||||
- '.github/workflows/fakeweb.yml'
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A newer push to a pull request cancels the older run of THIS workflow on that pull request, and nothing else cancels (the same group as e2e.yml).
|
||||
# Nothing cancels this workflow (the same group as e2e.yml): a merge queue run is keyed by its own ref (one per queue entry) and never cancelled in progress,
|
||||
# and the run of a push is unique to the run.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'merge_group' && github.ref || github.run_id }}
|
||||
cancel-in-progress: false
|
||||
|
||||
# The engine download goes through the release API with the token of the job (anonymous requests are the ones GitHub drops first).
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
# THE FIRST JOB: does this change have anything for the workflow to test? GitHub applies no `paths` filter to a merge queue run, so a docs-only change would
|
||||
# run everything here. In a queue run scripts/ci_changes.py lists the files of the entry (base_sha..head_sha) and applies the path rules of the `push` trigger
|
||||
# above; on any other event it says run=true. `run=false` is an explicit "nothing to test", not a skip: every other job needs this one and runs only on
|
||||
# run == 'true', and `fakeweb verdict` (scripts/ci_gate.py, CHANGES_RUN) expects them all skipped then, and red otherwise. The script is read from main, never
|
||||
# from the branch it judges (a branch must not decide that it needs no test); while it is not on main yet the copy of this branch is used, and the log says so.
|
||||
changes:
|
||||
name: changes
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
outputs:
|
||||
run: ${{ steps.changes.outputs.run }}
|
||||
files: ${{ steps.changes.outputs.files }}
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- name: does the change touch anything this workflow tests
|
||||
id: changes
|
||||
shell: bash
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
||||
HEAD_SHA: ${{ github.event.merge_group.head_sha }}
|
||||
run: |
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
if git cat-file -e origin/main:scripts/ci_changes.py 2>/dev/null; then
|
||||
git show origin/main:scripts/ci_changes.py > "$RUNNER_TEMP/ci_changes.py"
|
||||
else
|
||||
echo "ci_changes.py is not on origin/main yet: falling back to the copy of this branch"
|
||||
cp scripts/ci_changes.py "$RUNNER_TEMP/ci_changes.py"
|
||||
fi
|
||||
python3 "$RUNNER_TEMP/ci_changes.py" fakeweb "$EVENT_NAME" "$BASE_SHA" "$HEAD_SHA" | tee -a "$GITHUB_OUTPUT"
|
||||
|
||||
core-on-index:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
|
||||
# The Ubuntu packages of the Linux legs, from Ubuntu's archive once per runner image and list (linux-deps.yml), never by a leg.
|
||||
linux-deps-fakeweb:
|
||||
name: linux-deps-fakeweb
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
needs: [changes, core-on-index]
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
uses: ./.github/workflows/linux-deps.yml
|
||||
with:
|
||||
name: fakeweb
|
||||
@@ -66,14 +96,9 @@ jobs:
|
||||
|
||||
walk:
|
||||
name: fakeweb ${{ matrix.profile }} (${{ matrix.os }})
|
||||
needs: [core-on-index, linux-deps-fakeweb]
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
needs: [changes, core-on-index, linux-deps-fakeweb]
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
runs-on: ${{ matrix.runner }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(matrix.runner, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(matrix.runner, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -180,19 +205,29 @@ jobs:
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
# THE VERDICT of the workflow, the only one: green only when all four legs ran and passed.
|
||||
# THE VERDICT of the workflow, the only one that decides (rule ci-13): it waits for EVERY job of this file, `if: always()` so that a failed, cancelled or skipped
|
||||
# one still reaches it, and each must end in `success` (a leg that did not run measured nothing). scripts/ci_gate.py judges it, read from main and never from
|
||||
# the branch it judges; while the file is not on main yet (the change that adds it) the copy of this branch is used, and the log says so.
|
||||
verdict:
|
||||
name: fakeweb verdict
|
||||
needs: [core-on-index, walk]
|
||||
needs: [changes, core-on-index, linux-deps-fakeweb, walk]
|
||||
if: always()
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: red unless every leg is green
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- name: refuse unless every needed job succeeded
|
||||
env:
|
||||
NEEDS: ${{ toJSON(needs) }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
WORKFLOW: fakeweb
|
||||
CHANGES_RUN: ${{ needs.changes.outputs.run }}
|
||||
run: |
|
||||
echo "core-on-index: ${{ needs.core-on-index.result }}"
|
||||
echo "walk (p2 and p4, linux and windows): ${{ needs.walk.result }}"
|
||||
if [ "${{ needs.walk.result }}" != "success" ]; then
|
||||
echo "RED: the four legs did not all pass (a leg that did not run measured nothing)"
|
||||
exit 1
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
if git cat-file -e origin/main:scripts/ci_gate.py 2>/dev/null; then
|
||||
git show origin/main:scripts/ci_gate.py > "$RUNNER_TEMP/ci_gate.py"
|
||||
else
|
||||
echo "ci_gate.py is not on origin/main yet: falling back to the copy of this branch"
|
||||
cp scripts/ci_gate.py "$RUNNER_TEMP/ci_gate.py"
|
||||
fi
|
||||
echo "green: ours equals stock on the fake web, on both systems"
|
||||
python3 "$RUNNER_TEMP/ci_gate.py"
|
||||
@@ -39,22 +39,16 @@ env:
|
||||
jobs:
|
||||
# `pip install .` below resolves `invisible-core==N.M.0` from the package
|
||||
# index, and the core is published BEFORE this package. This gate answers
|
||||
# whether it is there yet; during that window the smoke matrix is SKIPPED
|
||||
# with the reason in the run summary rather than faked green, and once the
|
||||
# core is up it runs unchanged. See .github/workflows/core-on-index.yml.
|
||||
# whether it is there yet; during that window this job FAILS (rule ci-13: a
|
||||
# core that is not on the index is red, never a skip) and the smoke matrix,
|
||||
# which needs it, does not run; once the core is up it runs unchanged. See .github/workflows/core-on-index.yml.
|
||||
core-on-index:
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
|
||||
smoke:
|
||||
name: launch (${{ matrix.os }}, py${{ matrix.python }})
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
runs-on: ${{ matrix.os }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: 'D:\a\_temp'
|
||||
TMP: 'D:\a\_temp'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# published-set.yml - the control side of the A/B oracles is the last PUBLISHED SET, and this keeps its lock equal to the index.
|
||||
#
|
||||
# An A/B oracle holds a candidate against the engine published before it, and that engine is launched by the core it was built for (it refuses a launch whose
|
||||
# declarations that core does not emit). So the control is a set: the last `invisible-playwright` on the index, the `invisible-core` it pins exactly, and the engine
|
||||
# that core's seal pins, in a venv of their own, installed by hash (ci-03): ci/py-lock/published.txt, made by scripts/ci_published_set.py. Nothing in it is chosen
|
||||
# by hand; a new release is the new baseline.
|
||||
#
|
||||
# The lock is a committed file so that a run installs it offline (the wheelhouse of the run holds the files it names). What can go stale is the lock, the day a
|
||||
# release is published: this reads the index (the JSON of the two packages, nothing is installed or run) and is RED when the committed lock is not the index's last
|
||||
# release. The fix is one command, `python scripts/ci_published_set.py resolve --write`, in the pull request that records the release.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
name: published-set
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "41 5 * * *"
|
||||
pull_request:
|
||||
paths:
|
||||
- ci/py-lock/published.txt
|
||||
- scripts/ci_published_set.py
|
||||
- .github/workflows/published-set.yml
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
lock-is-the-index:
|
||||
name: the committed published set is the index's last release
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Check out the lock and the script
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 (v4.4.0)
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 (v5.6.0)
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: The lock against the index (reads the index, installs nothing)
|
||||
run: python scripts/ci_published_set.py check
|
||||
@@ -164,11 +164,7 @@ jobs:
|
||||
fail-fast: false # one system failing must not hide the other's table
|
||||
matrix:
|
||||
os: [ubuntu-24.04, windows-latest]
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
VERSION: ${{ needs.plan.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
@@ -276,11 +272,6 @@ jobs:
|
||||
needs: [plan, linux-deps-real-sites]
|
||||
if: needs.plan.outputs.admission == 'true'
|
||||
runs-on: ${{ matrix.os }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
+48
-74
@@ -5,6 +5,9 @@ on:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
# The merge queue run: a pull request is judged by this fast set; e2e.yml and fakeweb.yml run in the queue run and that run decides.
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -17,9 +20,10 @@ permissions:
|
||||
# each other; only an older run of THIS workflow on the same branch is replaced.
|
||||
# A newer push to a pull request cancels the run it supersedes. Never on main:
|
||||
# outside a pull request the group is unique to the run (`github.run_id`), so
|
||||
# every commit of main keeps its own finished run (see e2e.yml for why).
|
||||
# every commit of main keeps its own finished run (see e2e.yml for why). A merge queue run is keyed by its own ref (one per queue entry) and is never
|
||||
# cancelled: `cancel-in-progress` is true on a pull request only.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'merge_group' && github.ref || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Engine and GeoIP downloads go through the release API with this token.
|
||||
@@ -152,11 +156,11 @@ jobs:
|
||||
# package index. The core is published BEFORE this package, so between the
|
||||
# first push of this repo and that upload there is a window in which no
|
||||
# install here can succeed. This gate answers "is it on the index?" and the
|
||||
# unit job depends on the answer: during the window that job is SKIPPED (grey
|
||||
# in the checks list, with the reason written into the run summary), never
|
||||
# faked green; once the core is published it runs exactly as before. Full
|
||||
# reasoning, including why `|| true`, `--no-deps` and a git fallback were all
|
||||
# rejected, is in .github/workflows/core-on-index.yml.
|
||||
# unit job depends on the answer: during the window this job FAILS with the
|
||||
# reason (rule ci-13: a core that is not on the index is red, never a skip),
|
||||
# and `gate` is red with it; once the core is published it runs exactly as
|
||||
# before. Full reasoning, including why `|| true`, `--no-deps` and a git
|
||||
# fallback were all rejected, is in .github/workflows/core-on-index.yml.
|
||||
core-on-index:
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
|
||||
@@ -169,13 +173,7 @@ jobs:
|
||||
unit:
|
||||
name: pytest (${{ matrix.os }}, py${{ matrix.python }})
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
runs-on: ${{ matrix.os }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -352,13 +350,12 @@ jobs:
|
||||
# exactly how it got here. This job depends on the whole matrix and its
|
||||
# name never changes.
|
||||
#
|
||||
# SKIPPED IS NOT FAILED, and that is the part specific to this repo. `unit`
|
||||
# is skipped on purpose when `core-on-index` says the pin is not yet on the
|
||||
# index: during that window no install can succeed, and the workflow chose
|
||||
# to SKIP instead of faking green. A gate that required `success` would
|
||||
# turn that choice into a red and push toward dropping the protection on
|
||||
# release day of all days. So it refuses on `failure` and `cancelled`,
|
||||
# never on `skipped`.
|
||||
# SKIPPED IS RED (rule ci-13: nothing counts as passed that did not pass).
|
||||
# A job that was skipped ran nothing. `unit` used to be skipped when
|
||||
# `core-on-index` said the pin was not on the index yet, and this gate
|
||||
# treated that skip as a pass: a pull request merged with no test run. Now
|
||||
# `core-on-index` fails in that case, and the gate refuses every needed job
|
||||
# whose result is not `success`.
|
||||
# The guides are the surface a stranger copies first, and until 2026-09-08
|
||||
# nothing read them: one page published `page.accessibility.snapshot()`, which
|
||||
# this fork does not have, so anybody who ran that block got an AttributeError.
|
||||
@@ -366,13 +363,11 @@ jobs:
|
||||
# by a reader who then leaves.
|
||||
#
|
||||
# It needs the package importable, because it asks the REAL classes what they
|
||||
# have rather than carrying a list that would drift from them - so it takes
|
||||
# core-on-index's answer exactly as `unit` does, and is SKIPPED during the
|
||||
# window rather than faked green.
|
||||
# have rather than carrying a list that would drift from them - so it needs
|
||||
# core-on-index exactly as `unit` does.
|
||||
docs-api:
|
||||
name: the guides name an API that exists
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 (v4.4.0)
|
||||
@@ -401,59 +396,37 @@ jobs:
|
||||
# the decorative protection this project has already met once, on the branch
|
||||
# rules that required job names no job produced any more.
|
||||
#
|
||||
# `skipped` is not a failure and must not be treated as one: `version` runs on
|
||||
# pull requests only and is skipped on every push to main, and `unit` and
|
||||
# `docs-api` are skipped during the window when the pinned core is not on the
|
||||
# index yet. The case arms name failure and cancelled, so a skip passes on
|
||||
# purpose. That is also why each arm carries its own sentence: a gate that
|
||||
# exits 1 without saying which of five inputs went red is a gate somebody has
|
||||
# to open five tabs to read.
|
||||
# Every needed job must end in `success`; `skipped`, `cancelled` and
|
||||
# `failure` are red, one FAIL line each (scripts/ci_gate.py). The single job
|
||||
# that is conditional by design is `version`: it runs on pull requests and in
|
||||
# the merge queue run, so a push to main skips it on purpose, and the script
|
||||
# expects `skipped` there and `success` on a pull request and in the queue.
|
||||
# Nothing else is forgiven. The
|
||||
# script is read from origin/main, not from the branch being judged. Its table and the `needs:` below are held together by
|
||||
# tests/test_the_gate_is_red_when_a_needed_job_is_skipped.py.
|
||||
gate:
|
||||
needs: [core-on-index, unit, docs-api, english, claims, version, way-in, install-job, noreply-identity]
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: refuse unless nothing failed
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 (v4.4.0)
|
||||
- name: refuse unless every needed job succeeded
|
||||
env:
|
||||
NEEDS: ${{ toJSON(needs) }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
WORKFLOW: tests
|
||||
# The judge is read from main, never from the branch it judges. Only
|
||||
# while the file is not on main yet (the change that adds it) the
|
||||
# copy of this branch is used, and the log says so.
|
||||
run: |
|
||||
echo "core-on-index: ${{ needs.core-on-index.result }}"
|
||||
echo "unit: ${{ needs.unit.result }}"
|
||||
echo "docs-api: ${{ needs.docs-api.result }}"
|
||||
echo "english: ${{ needs.english.result }}"
|
||||
echo "claims: ${{ needs.claims.result }}"
|
||||
echo "way-in: ${{ needs.way-in.result }}"
|
||||
echo "version: ${{ needs.version.result }}"
|
||||
echo "install-job: ${{ needs.install-job.result }}"
|
||||
echo "noreply-identity: ${{ needs.noreply-identity.result }}"
|
||||
case "${{ needs.unit.result }}" in
|
||||
failure|cancelled) echo "the suite did not pass"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.core-on-index.result }}" in
|
||||
failure|cancelled) echo "the index check did not run"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.docs-api.result }}" in
|
||||
failure|cancelled) echo "the guides name something that does not exist"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.english.result }}" in
|
||||
failure|cancelled) echo "the repository is not English"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.claims.result }}" in
|
||||
failure|cancelled) echo "the README promises what no measurement supports"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.way-in.result }}" in
|
||||
failure|cancelled) echo "an install instruction is not uv"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.version.result }}" in
|
||||
failure|cancelled) echo "the version this change proposes is already taken"; exit 1 ;;
|
||||
esac
|
||||
case "${{ needs.install-job.result }}" in
|
||||
failure|cancelled) echo "the user-install job would not run on a release, or leaks"; exit 1 ;;
|
||||
esac
|
||||
# Unlike the checks above this one must be `success`: it runs on every
|
||||
# event this workflow has, so a skip would mean the check never ran.
|
||||
if [ "${{ needs.noreply-identity.result }}" != "success" ]; then
|
||||
echo "a commit or tag of this change has an email that is not a GitHub noreply address"; exit 1
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
if git cat-file -e origin/main:scripts/ci_gate.py 2>/dev/null; then
|
||||
git show origin/main:scripts/ci_gate.py > "$RUNNER_TEMP/ci_gate.py"
|
||||
else
|
||||
echo "ci_gate.py is not on origin/main yet: falling back to the copy of this branch"
|
||||
cp scripts/ci_gate.py "$RUNNER_TEMP/ci_gate.py"
|
||||
fi
|
||||
echo "ok"
|
||||
python3 "$RUNNER_TEMP/ci_gate.py"
|
||||
|
||||
# Measured 2026-09-04: 0.10.0 was on the index while main sat on 0.10.0 with
|
||||
# FIFTEEN commits of different content on top of the tag - 39 files, 841
|
||||
@@ -463,13 +436,14 @@ jobs:
|
||||
# indistinguishable from somebody forgetting to bump. The fix could not have
|
||||
# reached anybody, and nothing would have said so.
|
||||
#
|
||||
# Pull requests only: on main straight after a release the version IS the
|
||||
# published one until somebody bumps, and a gate that is red at rest is one
|
||||
# people learn to skip. Bumping publishes nothing - publishing happens on a
|
||||
# Where a change is proposed (a pull request, and the merge queue run, which
|
||||
# compares the version the entry proposes with the published one): on main
|
||||
# straight after a release the version IS the published one until somebody
|
||||
# bumps, and a gate that is red at rest is one people learn to skip. Bumping publishes nothing - publishing happens on a
|
||||
# tag push - so main on an unreleased version is the normal state between
|
||||
# releases and the rule costs one line.
|
||||
version:
|
||||
if: github.event_name == 'pull_request'
|
||||
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 (v4.4.0)
|
||||
|
||||
@@ -91,11 +91,6 @@ jobs:
|
||||
needs: linux-deps-user-install
|
||||
name: ${{ matrix.os }} - install from ${{ github.event.inputs.source || 'index' }} and launch
|
||||
runs-on: ${{ matrix.os }}
|
||||
# TEMP and TMP on D:\a\_temp (the runner's temp folder): the Firefox profiles land in TEMP and on C: they saturate the disk (queue up to 144,
|
||||
# latencies up to 4 s, parent main thread still 40-60 s). On the job, not in a step: `runner.temp` is not readable in a job's `env`.
|
||||
env:
|
||||
TEMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
TMP: ${{ startsWith(matrix.os, 'windows') && 'D:\a\_temp' || '/tmp' }}
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false # one OS failing must not hide the other's result
|
||||
@@ -108,15 +103,12 @@ jobs:
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 (v5.6.0)
|
||||
with: { python-version: '3.11' }
|
||||
|
||||
# Only what the TEST needs, from the wrapper's hashed lock (ci/py-lock/gate.txt), the one the other test jobs read: never a hand list, which is how
|
||||
# `psutil` (imported by the OS-cursor helper of the tests since #609) was missing here and ledger #618 was red. The lock holds `uv` (the wait below asks it, and the
|
||||
# release test installs the package with it) and holds neither invisible-playwright nor invisible-core: the package under test is installed by the
|
||||
# Only what the TEST needs (and `uv`, for the wait below to ask uv, which the release test installs the package with). The package under test is installed by the
|
||||
# test itself, into a venv it creates, from the index - installing it
|
||||
# here as well would put a second copy on the path and the assertions
|
||||
# would be reading the wrong one. The runner's own pip, nothing unhashed.
|
||||
# A rule test of the unit suite (the install job has every module its tests import) holds every third-party module the tests import to that lock.
|
||||
# would be reading the wrong one.
|
||||
- name: Test harness only
|
||||
run: python -m pip install --require-hashes -r ci/py-lock/gate.txt
|
||||
run: python -m pip install --upgrade pip pytest packaging uv
|
||||
|
||||
# ⛔ THE VERSION OF A LEDGER PULL REQUEST IS THE ONE IT ADDS TO PUBLISHED.json, NOT THE ONE THE TREE DECLARES.
|
||||
# The ledger PR of a release is merged after this job is green, and the next release's tree can already be on main: ledger #534 recorded
|
||||
|
||||
+1
-33
@@ -4,42 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.61.0] - 2026-11-30
|
||||
## [0.59.1] - 2026-11-25
|
||||
|
||||
### Changed
|
||||
- Pins invisible-core 71.85.0 on the engine firefox-71 (Firefox 159.0).
|
||||
- The window origin is declared by the core, and the screen coordinates a page reads go through it, in the top document and in an
|
||||
out-of-process frame of another site: such a frame used to read the top document's origin without its own position.
|
||||
- The end point of a drag is mapped through the window of the drag source, and tooltips and autoscroll open at the real pointer.
|
||||
- A popup's position and outer size are set when it opens by Firefox's own rule, and a positioned popup is kept on the declared screen by
|
||||
Firefox's own clamp; the core no longer declares a popup position.
|
||||
- The height of the maximized browser chrome follows Firefox's toolbar density rule, and the window frame is computed from the system
|
||||
metrics at the declared scale: at 125% the bar above the page is 106 device pixels, as in retail Firefox 159, where 0.60.0 declared 107.
|
||||
- The core accepts exactly the display scales Windows offers (100% to 500%), and refuses a scale the declared screen does not offer.
|
||||
|
||||
### Fixed
|
||||
- The load of a frame waits for the processes below it, a navigation that does not create a new document no longer releases a frame, and
|
||||
the ready of a page is told once, after its document.
|
||||
- Drag and drop driven by the client reaches a frame of another site: the drag has one session, owned by the browser process, as a real
|
||||
drag does; `dragend` ends at the screen point of the declared window, the drag events carry the buttons held, and `drag` fires at the
|
||||
source.
|
||||
- A select dropdown opened by a click no longer closes on that click's own release: menus close on the next press or wheel, as with a
|
||||
real mouse, never on a release or a move.
|
||||
- `wait_for_selector(state="hidden")` returns at once when nothing matches and never returns a handle, as stock Playwright does.
|
||||
- A font face that our text code used after it could be released (a dangling HarfBuzz face pointer) is now held by its own type.
|
||||
- Through a UDP proxy, an IPv6 socket reaches its IPv4 relay after the association too.
|
||||
|
||||
## [0.60.0] - 2026-11-27
|
||||
|
||||
### Changed
|
||||
- Pins invisible-core 70.83.0 on the engine firefox-70 (Firefox 159.0).
|
||||
- The engine carries Firefox's fix for the race between the start and the shutdown of its telemetry (Glean): a browser closed while it was
|
||||
still starting no longer leaves that work half done.
|
||||
- ElementHandle pointer actions (`click`, `dblclick`, `hover`, `tap`, `check`, `uncheck`, `set_checked`) now use the same humanised pointer walk as selector actions (they used to jump to the exact centre of the element in one move).
|
||||
- Screenshot parameters that Playwright honours by modifying the page (`mask`/`maskColor`, `style`, `animations="disabled"`,
|
||||
`caret="initial"`) are now refused by name with a clear error instead of being silently ignored; `omitBackground` with PNG answers
|
||||
Firefox's own `Not implemented`, as stock Playwright does. A refused screenshot of an element or a locator is refused before the page is
|
||||
scrolled or measured.
|
||||
|
||||
## [0.59.0] - 2026-11-24
|
||||
|
||||
|
||||
-1630
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"format": "ab-host-expected/1",
|
||||
"differences": []
|
||||
"differences": [
|
||||
{
|
||||
"id": "gfxtest-69",
|
||||
"os": "linux",
|
||||
"category": "proc",
|
||||
"name": "gfxtest",
|
||||
"published": "present",
|
||||
"candidate": "absent",
|
||||
"reason": "the 69 no longer spawns the graphics probe gfxtest (GFX_PROBE_BINARY, widget/gtk/GfxInfo.cpp:55; commit 0e896e4ee1, the probe never reads the host); the paths only that process touched go with it"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,749 +0,0 @@
|
||||
{
|
||||
"format": "ab-oracle-expected/1",
|
||||
"differences": [
|
||||
{
|
||||
"id": "linux-seed6-state.after_fullscreen.events.mousemove",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
86
|
||||
],
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-state.after_fullscreen.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-state.after_fullscreen.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-state.normal.events.mousemove",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
86
|
||||
],
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-state.normal.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-state.normal.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-surface.visualViewport.height",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.visualViewport.height",
|
||||
"published": 730.4000244140625,
|
||||
"candidate": 731.2000122070312,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: visualViewport.height, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-surface.window.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.window.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed6-surface.window.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.window.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.events.click",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.click",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a click event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.events.mousedown",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mousedown",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousedown event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.events.mousemove",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
],
|
||||
[
|
||||
0,
|
||||
72
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.events.mouseup",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mouseup",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mouseup event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.after_fullscreen.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.events.click",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.click",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a click event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.events.mousedown",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mousedown",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousedown event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.events.mousemove",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
72
|
||||
],
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.events.mouseup",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mouseup",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mouseup event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-state.normal.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-surface.visualViewport.height",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.visualViewport.height",
|
||||
"published": 587.3333129882812,
|
||||
"candidate": 599.3333129882812,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: visualViewport.height, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-surface.window.innerHeight",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.window.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "linux-seed63-surface.window.mozInnerScreenY",
|
||||
"os": "linux",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.window.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.after_fullscreen.events.mousemove",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
86
|
||||
],
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.after_fullscreen.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.after_fullscreen.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.after_fullscreen.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.normal.events.mousemove",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
86
|
||||
],
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.normal.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-state.normal.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "state.normal.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-surface.visualViewport.height",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.visualViewport.height",
|
||||
"published": 730.4000244140625,
|
||||
"candidate": 731.2000122070312,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: visualViewport.height, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-surface.window.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.window.innerHeight",
|
||||
"published": 730,
|
||||
"candidate": 731,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed6-surface.window.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 6,
|
||||
"dpr": 1.25,
|
||||
"leaf": "surface.window.mozInnerScreenY",
|
||||
"published": 85.5999984741211,
|
||||
"candidate": 84.80000305175781,
|
||||
"reason": "Seed 6 is at 1.25. The bar of a main window, client top to content top, is 106 device px in retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406), not the 107 that the published engine's core declares; the candidate's core computes it with window_frame.chrome_height_device(1.25, 'normal'), which rounds the tab strip, the nav bar and the content border once, on the sum in app units (_offset_device), and the page gets 106 device px = 84.8 CSS px. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.events.click",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.click",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a click event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.events.mousedown",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mousedown",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousedown event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.events.mousemove",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
],
|
||||
[
|
||||
0,
|
||||
72
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.events.mouseup",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.events.mouseup",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mouseup event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.after_fullscreen.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.after_fullscreen.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.events.click",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.click",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a click event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.events.mousedown",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mousedown",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousedown event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.events.mousemove",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mousemove",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
],
|
||||
[
|
||||
0,
|
||||
84
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
72
|
||||
],
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mousemove event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.events.mouseup",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.events.mouseup",
|
||||
"published": [
|
||||
[
|
||||
0,
|
||||
85
|
||||
]
|
||||
],
|
||||
"candidate": [
|
||||
[
|
||||
0,
|
||||
73
|
||||
]
|
||||
],
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: the distinct (screenY - clientY) that a mouseup event of the page was seen with, in CSS px: the bar above the content as the page reads it from a pointer event."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-state.normal.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "state.normal.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-surface.visualViewport.height",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.visualViewport.height",
|
||||
"published": 587.3333129882812,
|
||||
"candidate": 599.3333129882812,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: visualViewport.height, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-surface.window.innerHeight",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.window.innerHeight",
|
||||
"published": 587,
|
||||
"candidate": 599,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.innerHeight, the viewport height in CSS px."
|
||||
},
|
||||
{
|
||||
"id": "windows-seed63-surface.window.mozInnerScreenY",
|
||||
"os": "windows",
|
||||
"seed": 63,
|
||||
"dpr": 1.5,
|
||||
"leaf": "surface.window.mozInnerScreenY",
|
||||
"published": 84.66666412353516,
|
||||
"candidate": 72.66666412353516,
|
||||
"reason": "Seed 63 is at 1.5, and the work area of its screen is under 720 CSS px high (about 693 on a 1920x1080 panel), so retail Firefox 159 chooses the compact density by itself (browser.js gUIDensity: compact while 36 CSS px over the reference height is more than browser.compactmode.auto.threshold 0.05, that is below 720 CSS px; RetailCaptures analysis/window-geometry/chrome-density; retail Firefox 159 on Windows, measured by the core's retail window-geometry capture workflow (rounds 2 and 3, runs 45672953042 and 45679625406)). The bar is the compact 109 device px = 73 CSS px, not the normal 127 device px = 85 CSS px that the published engine's core declares: the core's constants.ui_density and declared_maximized_ui pick the density, window_frame.chrome_height_device(1.5, 'compact') gives the bar. This leaf: window.mozInnerScreenY, the screen Y of the content's top in CSS px (the bar above the content)."
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+32
-32
@@ -6,7 +6,7 @@
|
||||
6,
|
||||
63
|
||||
],
|
||||
"core_version": "71.85.0",
|
||||
"core_version": "69.82.0",
|
||||
"counts": {
|
||||
"audio": {
|
||||
"audio.sample_rate=44100|audio.output_latency_ms=20|audio.max_channel_count=2": 4315,
|
||||
@@ -50,9 +50,9 @@
|
||||
"ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0": 40144
|
||||
},
|
||||
"dpr": {
|
||||
"layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31": 70210,
|
||||
"layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38": 18299,
|
||||
"layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.popup_ui=106|screen.popup_client_top=45": 11491
|
||||
"layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72": 70210,
|
||||
"layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90": 18299,
|
||||
"layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.maximized_ui=127|screen.popup_ui=106": 11491
|
||||
},
|
||||
"gfx_device": {
|
||||
"adliris_7085": 7197,
|
||||
@@ -156,9 +156,9 @@
|
||||
"ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0"
|
||||
],
|
||||
"dpr": [
|
||||
"layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38",
|
||||
"layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.popup_ui=106|screen.popup_client_top=45"
|
||||
"layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90",
|
||||
"layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.maximized_ui=127|screen.popup_ui=106"
|
||||
],
|
||||
"gfx_device": [
|
||||
"adliris_7085",
|
||||
@@ -254,7 +254,7 @@
|
||||
"codecs": "media.av1.enabled=false|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:9c24a8728f",
|
||||
"cores": "hw_concurrency=12",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx5070_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -266,7 +266,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=22",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "uhd630_2145",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:80c00ab015",
|
||||
"render_noise": "fpp.hw_seed=6",
|
||||
@@ -278,7 +278,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=32",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.popup_ui=106|screen.popup_client_top=45",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.maximized_ui=127|screen.popup_ui=106",
|
||||
"gfx_device": "rpl770_7092",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:05ce56d3c0",
|
||||
"render_noise": "fpp.hw_seed=16",
|
||||
@@ -290,7 +290,7 @@
|
||||
"codecs": "media.av1.enabled=false|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:9c24a8728f",
|
||||
"cores": "hw_concurrency=5",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "gtx980_58278",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=6",
|
||||
@@ -302,7 +302,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=24",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90",
|
||||
"gfx_device": "adliris_7085",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:05ce56d3c0",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -314,7 +314,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=false|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=6",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "gtx1650_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=20",
|
||||
@@ -326,7 +326,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=20",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "uhd620_2145",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:d1db3983c9",
|
||||
"render_noise": "fpp.hw_seed=28",
|
||||
@@ -338,7 +338,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=8",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "renoir_21925",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=16",
|
||||
@@ -350,7 +350,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=14",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx3060_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=19",
|
||||
@@ -362,7 +362,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=16",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90",
|
||||
"gfx_device": "rx580_21925",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=20",
|
||||
@@ -374,7 +374,7 @@
|
||||
"codecs": "media.av1.enabled=false|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:9c24a8728f",
|
||||
"cores": "hw_concurrency=28",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "irisxe_7085",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:05ce56d3c0",
|
||||
"render_noise": "fpp.hw_seed=6",
|
||||
@@ -386,7 +386,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=false|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=4",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "icl_2145",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:80c00ab015",
|
||||
"render_noise": "fpp.hw_seed=11",
|
||||
@@ -398,7 +398,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=12",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "uhd630_2145",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:80c00ab015",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -410,7 +410,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=8",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rx6600_32015",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -422,7 +422,7 @@
|
||||
"codecs": "media.av1.enabled=false|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:9c24a8728f",
|
||||
"cores": "hw_concurrency=4",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx5060_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=28",
|
||||
@@ -434,7 +434,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=8",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.popup_ui=106|screen.popup_client_top=45",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.maximized_ui=127|screen.popup_ui=106",
|
||||
"gfx_device": "arl_6629",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:098c0bf836",
|
||||
"render_noise": "fpp.hw_seed=19",
|
||||
@@ -446,7 +446,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=3",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx5080l_61742",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=28",
|
||||
@@ -458,7 +458,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=12",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90",
|
||||
"gfx_device": "adliris_7085",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:05ce56d3c0",
|
||||
"render_noise": "fpp.hw_seed=19",
|
||||
@@ -470,7 +470,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=false|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=7",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.popup_ui=89|screen.popup_client_top=38",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.25\"|screen.frame_border=9|screen.maximized_ui=107|screen.popup_ui=90",
|
||||
"gfx_device": "rx7600_32015",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=11",
|
||||
@@ -482,7 +482,7 @@
|
||||
"codecs": "media.av1.enabled=false|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:9c24a8728f",
|
||||
"cores": "hw_concurrency=32",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.popup_ui=106|screen.popup_client_top=45",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.5\"|screen.frame_border=11|screen.maximized_ui=127|screen.popup_ui=106",
|
||||
"gfx_device": "rx7600_32015",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -494,7 +494,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=4",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx5060ti_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=11",
|
||||
@@ -506,7 +506,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=10",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "uhd770_7092",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:05ce56d3c0",
|
||||
"render_noise": "fpp.hw_seed=5",
|
||||
@@ -518,7 +518,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=true|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=9",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=0|layout.css.prefers-color-scheme.content-override=1",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "rtx4060_62101",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:b153aef69f",
|
||||
"render_noise": "fpp.hw_seed=6",
|
||||
@@ -530,7 +530,7 @@
|
||||
"codecs": "media.av1.enabled=true|media.encoder.webm.enabled=true|media.mp4.enabled=true|media.webm.enabled=false|media.decode_support=sha:960968735a",
|
||||
"cores": "hw_concurrency=2",
|
||||
"dark_theme": "ui.systemUsesDarkTheme=1|layout.css.prefers-color-scheme.content-override=0",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.popup_ui=72|screen.popup_client_top=31",
|
||||
"dpr": "layout.css.devPixelsPerPx=\"1.0\"|screen.frame_border=8|screen.maximized_ui=85|screen.popup_ui=72",
|
||||
"gfx_device": "renoir_21925",
|
||||
"gfx_feature_status": "gfx.feature_status=sha:2f5fe3776b",
|
||||
"render_noise": "fpp.hw_seed=9",
|
||||
@@ -562,5 +562,5 @@
|
||||
],
|
||||
"format": "persona-seeds/1",
|
||||
"max_seed": 100000,
|
||||
"sha256": "82547e9f34ece0c17075d812dcc009c7e8e6f348eb33fb4cc5cdbff6253cc4f0"
|
||||
"sha256": "8de3d8a621389f707181b9c9569b4d3266931e26f4cb3ea6b64e8f40f3e9dc29"
|
||||
}
|
||||
+2
-4
@@ -1,12 +1,11 @@
|
||||
# Input of the gate lock; `python scripts/ci_py_lock.py` writes it and gate.txt from the sources below. Wrapper-owned (ci-03), read at the wrapper_ref.
|
||||
# python-version: 3.11
|
||||
# exclude-newer: 2026-11-25T00:00:00Z
|
||||
# wrapper: pyproject.toml sha256 93d8d0940284352ad53e189e17b9ad6e3109ce52e54ab138ecdfa01d8571b193 (at generation); its dependencies without invisible_core, and its `dev` extra
|
||||
# core: invisible_core==71.85.0, tag v71.85.0, pyproject.toml sha256 c0d14a4d26d3650005076ab72347eb24fba4b89e643f514e7f7334bd0a2ac174 (at generation); the core is a wheel of ours, only what it depends on is locked
|
||||
# wrapper: pyproject.toml sha256 3b2ba212158746aeb37a92a36d013b31327d4b5ecf1d2806f19810cccc2f1a37 (at generation); its dependencies without invisible_core, and its `dev` extra
|
||||
# core: invisible_core==69.82.0, tag v69.82.0, pyproject.toml sha256 c0d14a4d26d3650005076ab72347eb24fba4b89e643f514e7f7334bd0a2ac174 (at generation); the core is a wheel of ours, only what it depends on is locked
|
||||
# core-requires: platformdirs>=4 | psutil>=5.9 | requests[socks]>=2.31 | maxminddb>=2.2 | tzdata>=2024.1
|
||||
# playwright: 1.61.0 from scripts/playwright_pin.txt (the stock client the gate drives the engine with)
|
||||
# cryptography: 44.0.3 (the lab's PKI)
|
||||
# harness: uv>=0.5 (the installers of the install-from-index job)
|
||||
aioquic>=1.2
|
||||
build>=1
|
||||
cryptography==44.0.3
|
||||
@@ -24,5 +23,4 @@ pytest-xdist>=3
|
||||
requests[socks]>=2.31
|
||||
ruff>=0.6
|
||||
tzdata>=2024.1
|
||||
uv>=0.5
|
||||
websockets>=13
|
||||
+1
-21
@@ -1,5 +1,5 @@
|
||||
# Generated by `python scripts/ci_py_lock.py`: do not edit. Wrapper-owned (ci-03).
|
||||
# input: ci/py-lock/gate.in sha256 7de18cd95f842ff5df52b931d6fb2f318936f54b0ff1be1c8d66df1d6706d9df
|
||||
# input: ci/py-lock/gate.in sha256 31b110a3356c66a0cb6e9a56b5f27849541f9956ed813b73516e13965ae64081
|
||||
# resolver: uv pip compile --universal --generate-hashes --no-build --python-version 3.11 --exclude-newer 2026-11-25T00:00:00Z
|
||||
# Every file of each version is hashed (Linux and Windows wheels of every Python from 3.11, and the sdist): one lock for every OS.
|
||||
# A consumer installs it with: pip install --no-index --find-links <wheelhouse> --require-hashes -r <this file>
|
||||
@@ -668,26 +668,6 @@ tzdata==2026.6 \
|
||||
urllib3==2.8.0 \
|
||||
--hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \
|
||||
--hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63
|
||||
uv==0.13.10 \
|
||||
--hash=sha256:19a76fd50a6a2bba38ee088d8336566856569be08196865f98132a08806581fc \
|
||||
--hash=sha256:2a9ff188b442419c7aadebc445fcc1f287b25f99af50fa6d563b90cc0047b7cf \
|
||||
--hash=sha256:30e75714a9cff3aa56281c7bf533a4e93cb5bdfcc0325d3aae54b9106460bd63 \
|
||||
--hash=sha256:3bf1c1b13cac2533a342ca16b1c5f41347cd399404c9477a04ff79c5f7cb4dea \
|
||||
--hash=sha256:50bee2a59ea9422b493aabc0cde9288f58fbcf6e8d688c30c4ecd8309459cac1 \
|
||||
--hash=sha256:5bcf77c50760146ff7b41022ab7aeb1954d42dd47b89fad36b43a1a8a43da994 \
|
||||
--hash=sha256:771a749b34477501092c9fe6d5e52f45cef944d875b0f2e2c989047a2ee647ab \
|
||||
--hash=sha256:7cc9c41b43d583e34c781fd3446405b06e9c5fa2db468ce2a534d353db6429e5 \
|
||||
--hash=sha256:7fa025c4b0f33b9a5357252e1be058d94157e13bfb8ae45d7e27cfce3759c65d \
|
||||
--hash=sha256:8b0a15613aae9a3e1c134bb5ee706583af0addced7eb1add992f8b1b3e3a92a0 \
|
||||
--hash=sha256:a52ee170c00d4de1d42026c4dbb00c5d7f327edcf2b2bddeecd0cfb169868ac7 \
|
||||
--hash=sha256:a9636b4430a9b8a37ecc4d85111d1fd2560ef616edf5301b84f474073bf89e2f \
|
||||
--hash=sha256:bf7174b00c88879d4a1019b51256bbdb2dd61c55c7dc896031e16d090e380ce6 \
|
||||
--hash=sha256:c85a2ecb62d09d61904f5405b525fcc51f971d081f8508a881fa2f9bae7543a7 \
|
||||
--hash=sha256:d87b9cf8165f2b3cc596e856b5bf794da9cfad6d1b110ca9d87eed42a15b3684 \
|
||||
--hash=sha256:e52a1af7f97b717572f9e2bd69e54eb253b2c88a705500e35811c21106c439d4 \
|
||||
--hash=sha256:e89dd26ea831dde70639ba0a798fa04a4c7c0226fd2b241da86218bfa370e495 \
|
||||
--hash=sha256:ee3bca6523ed93c3ae0d1a90c2733be307f5f7cc5287c746214e93a3bae0da13 \
|
||||
--hash=sha256:ee403b6bbcfda1bc7db269be5c40c1624df27b3b838d3f8a416648e00e2de5d4
|
||||
websockets==17.4 \
|
||||
--hash=sha256:00ad98e4bb0df7a6711c645eec16d5a9fdf99f0692bd4f5b6cb85a68677ba8df \
|
||||
--hash=sha256:0132e3cbd3f5cfc1ec77588961b302d72a02e2603b82c2c23fd5fb59dc4fa206 \
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# The PUBLISHED SET, the control side of the A/B oracles (scripts/ci_published_set.py): the last published invisible-playwright and the invisible-core it pins (its seal pins the engine). Written by `python scripts/ci_published_set.py resolve --write`; .github/workflows/published-set.yml keeps it equal to the index.
|
||||
# wrapper-requires: greenlet<4.0.0,>=3.1.1 | psutil>=5.9 | pyee<14,>=13
|
||||
# core-requires: maxminddb>=2.2 | platformdirs>=4 | psutil>=5.9 | requests[socks]>=2.31 | tzdata>=2024.1
|
||||
invisible-core==70.83.0 \
|
||||
--hash=sha256:1dff040e41f5aba5aa07e086328ca436291fddbd31514d1bc9a9dbfc4ba7fb6a \
|
||||
--hash=sha256:f7144262686adf54a4a1c85a8d17f76b31dc4ddcfbd6636d777c5c39963d3293
|
||||
invisible-playwright==0.60.0 \
|
||||
--hash=sha256:00509578944ff0d742761d4d5f19fcde21b7657197fa24ab0718e076ebdf9aa6 \
|
||||
--hash=sha256:7285f5756ad2031087d12f339c2e89b76bdb953449c9151c0edc11a58d96d9c6
|
||||
+13
-17
@@ -6,31 +6,27 @@
|
||||
{"id": "wrapper.e2e.doh", "giro": "G2", "os": ["linux", "windows"], "min_tests": 19, "exact": true, "tests": ["tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_ice_names_by_the_context_proxy_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "Linux needs root: the resolver trap of the file (ResolverTrap) points /etc/resolv.conf at a counting resolver on port 53. Su Windows il resolver trap non gira: l'asserzione sul resolver di sistema è l'unica omessa. Run it without xdist (port 53 is one per host). On the Linux leg the gate exports INVPW_REQUIRE_TRAP=1: a trap that cannot run or bind port 53 is a failure, not a skipped assertion."},
|
||||
{"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": 36, "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). THE CLOSED CONTEXT CASE (1, gated firefox-65): a beacon sent on pagehide as a proxied context closes, to a name never looked up, is resolved over the DoH through the context's gateway after the close; on firefox-64 it went to the machine's resolver every time (hunt 43733181674)."},
|
||||
{"id": "wrapper.e2e.realness", "giro": "G2", "os": ["linux", "windows"], "min_tests": 31, "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.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": 273, "exact": true, "tests": ["tests/test_doh_session_prefs_unit.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_preload_newtab_is_written_only_when_asked.py", "tests/test_the_doh_e2e_launch_on_a_virtual_display.py", "tests/test_the_egress_sink_helpers.py", "tests/test_the_exit_of_a_context_is_discovered_through_its_own_gateway.py", "tests/test_the_fake_doh_answers.py", "tests/test_the_fake_doh_delays_and_refuses.py", "tests/test_the_h3_line_helpers.py", "tests/test_the_host_address_helper.py", "tests/test_the_http_proxy_helper_asks_for_credentials.py", "tests/test_the_lab_ca_and_its_ocsp_leaf.py", "tests/test_the_leak_watcher_sees_a_direct_connection.py", "tests/test_the_network_declaration_reaches_the_engine.py", "tests/test_the_realness_helpers.py", "tests/test_the_resolver_trap_counts_its_own_users.py", "tests/test_the_resolver_trap_is_required_by_the_gate.py", "tests/test_the_server_says_nothing_about_the_launch_counter.py", "tests/test_the_udp_bench_survives_what_a_loaded_machine_does_to_it.py", "tests/test_the_udp_chain_helper.py", "tests/test_the_witness_hears_a_direct_send.py", "tests/test_the_witness_picks_a_port_both_sockets_bind.py"], "marker": "unit", "needs_root": false, "note": "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": 130, "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", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py"], "marker": "e2e", "needs_root": false, "note": "130 = 126 + the 4 of test_a_drag_keeps_its_buttons_pressed_e2e.py (a drag reaches the page with the button it holds: event.buttons is 1 on every mousemove of a left drag, 2 on a right one, 0 after the release; with and without humanize). The 126 before it: 116 + the 9 of test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py (four browsers in one process, one closes: the loop is never seen inside a step of the close, the removal of the profile is held still and reached on a thread of the reaper while the close has returned, 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). 116 = 100 + the 16 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; 2 of them the strict networkidle cases, a document still arriving that moves). 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.", "moz_log": "DocumentChannel:5,ProcessIsolation:5,nsDocShell:4,DocLoader:4", "juggler_trace": true},
|
||||
{"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": 9, "exact": true, "tests": ["tests/test_software_compositing_is_declared_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_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. 9 = those 3 + the 6 families of tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py (from firefox-66, engine_at_least): a screenshot draws the text of Arial, Times New Roman, Consolas and Segoe UI, with accents, the typographic apostrophe, the euro sign, Chinese, Arabic and Russian, and of MS PGothic (face 2 of msgothic5_32.ttc: Japanese and Latin) and NSimSun (face 1 of simsun.ttc: Chinese), two faces that are not the first of their collection, with the same bytes as the content process drew them in a canvas (an SVG image with a foreignObject of the same markup), cut from the same page.screenshot, on both systems and with no threshold. EXPECTED RED on every engine that rebuilds the text in the parent with another font than the bundle (Linux: fontconfig answers DejaVu Sans), and skipped, hence red here, on an engine older than firefox-66. It saves the screenshot, the two boxes and a result.json under RUNNER_TEMP/invpw-evidence.", "runner_image": {"windows": "windows-2022"}},
|
||||
{"id": "wrapper.e2e.fakeweb", "giro": "G2", "os": ["linux", "windows"], "min_tests": 7, "exact": true, "tests": ["tests/test_fakeweb_p2_e2e.py", "tests/test_fakeweb_p4_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The fake web, offline: our browser on the hard pages (profile P2: a reused routed page reaches networkidle every time, also under a load of three other browsers; the other site is another process) and on the 17-step journey of a person (profile P4: every step as stock, and every page left only once its noise is done), each judged against what stock Firefox does, as tests/fakeweb/pages.json declares it. 7 = 3 + 4 (the last two: a `load` that takes 20 s is a step that succeeds, and a `load` that never comes ends in an error that names the wait and the page). Stock itself is held to that declaration, and compared with ours step by step, by scripts/run_fakeweb.py in .github/workflows/fakeweb.yml. Needs the candidate binary (STEALTHFOX_E2E_BINARY).", "stock_firefox": true, "extra_steps": ["fakeweb_profiles"]},
|
||||
{"id": "wrapper.e2e.stock_twin.dnd", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_drag_from_the_top_into_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the real drag from the top into a frame of another site (4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.select", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_select_dropdown_opens_at_its_element_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the select dropdown (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.tooltip", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_a_tooltip_opens_at_the_pointer_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of the tooltip (4 scales), measured from chrome scope against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe), the reference first and ours second; the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.stock_twin.intersection", "giro": "G2", "os": ["linux", "windows"], "min_tests": 8, "exact": true, "tests": ["tests/test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Split from the row wrapper.e2e.stock_twin, which ran past the 25-minute limit of a leg: one file, one leg. The twin of what the IntersectionObserver of a scrolled frame of another site reads (8 steps, 4 scales) and of when a lazy frame is requested (4 distances, 4 scales): the same steps first on Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client, and second on ours; the verdict is 'the same as the reference' (tests/_stock_twin.py). Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The file is in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
|
||||
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 30, "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, and the box cut out of a screenshot (its pixels, a box outside the picture refused, written as a PNG and read back, two boxes told apart by a pixel that is named, the pixels that are not grey)."},
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4375, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/tLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4387, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_marionette_session_is_asked_after_the_first_window.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_ab_oracle_declared_differences.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_published_set.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_a_twin_asks_for_is_routed.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_pytest_process_clears_the_gp_Line truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 3879, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_docs_only_change_runs_nothing_heavy_in_the_queue.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.py", "Line truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 3880, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_docs_only_change_runs_nothing_heavy_in_the_queue.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_report.py", "tests/test_fakeweb_stock_unsettled.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_glean_ready.py", "tests/test_goto_follows_the_base_url.pyLine truncated
|
||||
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode).", "core_dumps": "invpw-cores"},
|
||||
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 447, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_throuLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 420, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row,Line truncated
|
||||
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 333, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict).", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.1", "giro": "G2", "os": ["windows"], "min_tests": 332, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_detectors_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_ignore_https_errors_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_transport.py", "tests/test_keyboard_rhythm.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_workers_blocked.py", "tests/test_strict_and_force.py", "tests/test_the_engine_is_born_in_the_job_e2e.py", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_ua_widget_not_selectable.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 1 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 291, "exact": true, "tests": ["tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_select_dropdown_stays_open_after_the_release_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.3", "giro": "G2", "os": ["windows"], "min_tests": 277, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_drag_motion.py", "tests/test_element_screenshot_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_first_launch_from_a_new_path.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_post_data_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screencast.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_input_files_payloads.py", "tests/test_set_offline_e2e.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_external_texture_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 3 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.4", "giro": "G2", "os": ["windows"], "min_tests": 293, "exact": true, "tests": ["tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_frame_reads_only_declared_origins_while_it_loads_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_moves_and_resizes_as_declared_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_injected_node_surface.py", "tests/test_input_reaches_the_top_and_a_frame_of_another_site_at_every_scale_e2e.py", "tests/test_juggler_connection.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_oop_frame_element.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_scroll_into_view.py", "tests/test_shadow_trusted_input.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_maximized_window_frames_and_popups_read_retail_e2e.py", "tests/test_the_parent_methods_of_the_window_origin_are_not_exposed_to_a_page_e2e.py", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 4 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 415, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_Line truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 414, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.3", "giro": "G2", "os": ["linux"], "min_tests": 313, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_host_gl_probe_runs_only_on_an_undeclared_engine_linux_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py", "tests/test_webgpu_external_texture_e2e.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.3", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 565 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on linux (a skip is red in the verdict).", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.1", "giro": "G2", "os": ["windows"], "min_tests": 299, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_goto_to_a_refused_port_ends_with_its_reason_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_canvas_create_pattern_projection_e2e.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_detectors_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_reader_of_a_webgl_canvas_agrees_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_focus_survives_os_deactivation_e2e.py", "tests/test_geolocation_reads_nothing_of_the_host_windows_e2e.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_ignore_https_errors_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_transport.py", "tests/test_keyboard_rhythm.py", "tests/test_moz_element_paints_a_webgl_canvas_as_drawn_e2e.py", "tests/test_nested_frame_actions.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_workers_blocked.py", "tests/test_strict_and_force.py", "tests/test_the_engine_is_born_in_the_job_e2e.py", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_the_shutdown_ping_leaves_by_the_background_task_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_ua_widget_not_selectable.py", "tests/test_webgpu_canvas_readback_is_noised_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 1 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.2", "giro": "G2", "os": ["windows"], "min_tests": 286, "exact": true, "tests": ["tests/test_a_file_chooser_reaches_every_client_e2e.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_navigation_that_moved_is_told_by_the_engine_e2e.py", "tests/test_a_regional_indicator_pair_measures_the_same_first_and_after_other_families_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client_e2e.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_audio_context_values_are_declared_e2e.py", "tests/test_bundle_font_names_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_css_media_reads_the_declared_screen_and_pointer_e2e.py", "tests/test_declared_host_network_e2e.py", "tests/test_every_argument_reaches_the_page_e2e.py", "tests/test_expose_binding_e2e.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fullscreen_without_wm_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_desktop.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_native_line_endings_are_windows_e2e.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_nothing_leaves_but_the_proxy_e2e.py", "tests/test_nothing_of_a_context_leaves_but_through_its_proxy_e2e.py", "tests/test_oop_frame_geometry.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_e2e.py", "tests/test_screencast_stop_e2e.py", "tests/test_the_branding_a_page_loads_is_the_declared_archive_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_evaluated_code_has_no_debugger_name_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.3", "giro": "G2", "os": ["windows"], "min_tests": 276, "exact": true, "tests": ["tests/test_a_click_in_an_iframe_lands_at_the_frames_own_screen_origin_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_audio_noise_e2e.py", "tests/test_audio_sample_rate_is_declared_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_dom_iterables_from_evaluate_e2e.py", "tests/test_drag_motion.py", "tests/test_element_screenshot_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_first_launch_from_a_new_path.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_and_every_way_it_is_stopped_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_ipv6_literal_connect_e2e.py", "tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_post_data_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screencast.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_input_files_payloads.py", "tests/test_set_offline_e2e.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_launch_counter_is_one_plain_get_before_any_page_e2e.py", "tests/test_webgl_declared_parameters_e2e.py", "tests/test_webgl_shader_language_e2e.py", "tests/test_webgpu_adapter_is_declared_e2e.py", "tests/test_webgpu_external_texture_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "Part 3 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 610 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.4", "giro": "G2", "os": ["windows"], "min_tests": 274, "exact": true, "tests": ["tests/test_a_context_language_is_the_accept_language_of_every_request_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_handle_action_walks_like_a_selector_action_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_launch_and_a_context_timezone_reach_the_page_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_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_a_request_says_what_it_is_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_canvas_measure_text_metrics_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_exslt_date_time_through_an_imported_stylesheet_is_in_the_declared_zone_e2e.py", "tests/test_fakeweb_p2_e2e.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_frames_tree_input_and_pixels_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_hardware_values_are_declared_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_oop_frame_element.py", "tests/test_page_element_atoms_run_in_a_sandbox_e2e.py", "tests/test_popup_geometry_is_the_declared_frame_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_script_cache_written_is_adopted_e2e.py", "tests/test_scroll_into_view.py", "tests/test_shadow_trusted_input.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_window_occlusion_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.2", "note": "Part 4 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 4 rows of windows are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 609 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapper.e2e.udp.exit and wrapper.e2e.udp.sandbox (root and user namespaces, their own rows), the files of the round after the publication (tests/_post_publication.py), and the tests that skip on windows (a skip is red in the verdict).", "runner_image": {"windows": "windows-2022"}, "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.suite.windows.control_a", "giro": "G2", "os": ["windows"], "min_tests": 20, "exact": true, "tests": ["tests/test_control_a_selects_all_in_a_field_e2e.py"], "marker": "e2e", "needs_root": false, "linux_twin": "wrapper.e2e.suite.linux.1", "note": "The keyboard shortcut Control+A selects all in a field (5 ways to press it x an input and a textarea, in-process and served to the stock client), alone on its own Windows runner (windows-latest), as e2e.yml runs it on the published engine: the Windows keyboard of a real user is what it needs. The same file is in one of wrapper.e2e.suite.windows.1..4 and in wrapper.e2e.suite.linux.1.", "run": "suite_run"},
|
||||
{"id": "wrapper.e2e.ab_oracle", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_oracle_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Same seed, same bytes: the engine of the published set (the last published engine, with its own core and wrapper) against the candidate (with core_ref and wrapper_ref), on one machine, after the control: the published engine against ITSELF (the A/A; a difference is a broken control, exit 2, and the A/B is not run). On a pull request (no candidate: INVPW_BINARY_PATH is the published engine, no INVISIBLE_SEAL_FILE) the A/A is the whole test, on the first two seeds of the candidate set (all five when the pull request changes a file of this oracle: the step of e2e.yml that runs scripts/ci_ab_pr_seeds.py exports AB_ORACLE_PR_SEEDS), and saves both dumps and the diff under $AB_ORACLE_OUT or $RUNNER_TEMP/invpw-evidence/ab-oracle. scripts/ci_ab_oracle.py runs the host gate's dump (scripts/ci_host_gate.py dump: the persona seeds of ci/persona-seeds.json, each at its own DPR with nothing pinned, the whole page of scripts/host_gate; the `candidate` set of 5 seeds that reach every webgl renderer and every DPR, or with AB_ORACLE_SEED_SET=final and AB_ORACLE_SHARD=i/n the 20 seeds that reach every value of every dimension split over n jobs) twice, once with the published engine (fetched by the published set's own core under its own seal, which checks the archive's sha256, and dumped in that set's venv) and once with the candidate binary of the leg under its own seal, and compares every leaf of every visit: the only differences allowed are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys; anything else is red with the leaf, the two values and the seed; fewer leaves than the host gate's reference holds (16439 per visit; a DPR the reference does not record is held to the least of those it does) is red. The files (dump-<N>.json, dump-<N>-again.json for the tag of the published set, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) are the artifact ab-oracle-<os> of the leg. 1 = the one test; the comparator's own cases (51, the A/A's among them) are in tests/test_ab_oracle.py, the persona seeds' (15) in tests/test_persona_cover.py, in the rows of the whole unit suite. Needs the engine's binary (INVPW_BINARY_PATH) and, for the A/B, the candidate's seal (INVISIBLE_SEAL_FILE) and the network (the release assets of the published engine, and INVPW_PUBLISHED_PYTHON). Each engine runs with the core it was built for: a core that declares less than the published engine requires is no longer a red of this suite (it was: engine candidate 5, every A/B a broken control). THE CONTROL IS THE PUBLISHED SET, as a user installs it: the last invisible-playwright on the index, the invisible-core it pins exactly and the engine that core's seal pins, in a venv of their own (ci/py-lock/published.txt, installed by hash from the run's wheelhouse; scripts/ci_published_set.py; INVPW_PUBLISHED_PYTHON is its python). The candidate's side is the candidate engine with core_ref and wrapper_ref. No tag is written in a harness file.", "timeout_minutes": 50, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"], "artifact": "ab-oracle"},
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone, on the first seed (all five when the pull request changes a file of this oracle: AB_NETWORK_PR_SEEDS), in jobs of its own in e2e.yml on Linux and on Windows (the shared e2e jobs leave this file out). THE CONTROL IS THE PUBLISHED SET, as a user installs it: the last invisible-playwright on the index, the invisible-core it pins exactly and the engine that core's seal pins, in a venv of their own (ci/py-lock/published.txt, installed by hash from the run's wheelhouse; scripts/ci_published_set.py; INVPW_PUBLISHED_PYTHON is its python). The candidate's side is the candidate engine with core_ref and wrapper_ref. No tag is written in a harness file.", "timeout_minutes": 75, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"]},
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host A/B oracle: the whole TRACE of a closed run, from the launch to the exit of the browser, after the same journey. Compared: the processes by kind (the parent, -contentproc type, sandboxingKind, isForBrowser, the helpers by what they ran) with their count, except for the kinds of type tab whose count follows the idle time (only their presence counts), and the host paths the tree touched, judged by one rule (red if and only if a path is in all the measured launches of one engine and in no launch of the other, the long launches included; every other path that differs is listed in not-judged.json, not judged); what is ours (the package, the profile and temp dirs of the launch, the run cache, its own shared memory) leaves the comparison as a class. Linux: strace of the whole tree. Windows: the process-creation audit (event 4688, with the command line) and an ETW file trace of Kernel-File, which need an administrator. It has jobs of its own in e2e.yml on Linux and on Windows (a measurement shares the machine with no other browser), and its footprints keep the lifecycle of the tree (who started and ended when, how) and how the close ended. Each engine run starts with a discarded warm-up launch whose trace is kept and listed apart (what only the warm-up did, with the process that did it); only the tree of the launch is compared (a Windows service's paths are counted by process name and left out), and a path or a kind that differs names the processes to blame. A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, applied by kind, a list that may only shrink. There is no list of noise. Without a candidate (a PR e2e) the A/A alone, on the first two seeds (all five when the pull request changes a file of this oracle: AB_HOST_PR_SEEDS). THE CONTROL IS THE PUBLISHED SET, as a user installs it: the last invisible-playwright on the index, the invisible-core it pins exactly and the engine that core's seal pins, in a venv of their own (ci/py-lock/published.txt, installed by hash from the run's wheelhouse; scripts/ci_published_set.py; INVPW_PUBLISHED_PYTHON is its python). The candidate's side is the candidate engine with core_ref and wrapper_ref. No tag is written in a harness file.", "runner_image": {"windows": "windows-2022"}, "timeout_minutes": 50, "core_dumps": "cores", "stock_firefox": ["windows"], "location_service": ["windows"], "extra_steps": ["keep_oracle_files"]},
|
||||
{"id": "wrapper.e2e.ab_oracle", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_oracle_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Same seed, same bytes: the engine published as firefox-68 against the candidate, on one machine, with the same core and wrapper, after the control: the published engine against ITSELF (the A/A; a difference is a broken control, exit 2, and the A/B is not run). On a pull request (no candidate: INVPW_BINARY_PATH is the published engine, no INVISIBLE_SEAL_FILE) the A/A is the whole test, on the first two seeds of the candidate set (all five when the pull request changes a file of this oracle: the step of e2e.yml that runs scripts/ci_ab_pr_seeds.py exports AB_ORACLE_PR_SEEDS), and saves both dumps and the diff under $AB_ORACLE_OUT or $RUNNER_TEMP/invpw-evidence/ab-oracle. scripts/ci_ab_oracle.py runs the host gate's dump (scripts/ci_host_gate.py dump: the persona seeds of ci/persona-seeds.json, each at its own DPR with nothing pinned, the whole page of scripts/host_gate; the `candidate` set of 5 seeds that reach every webgl renderer and every DPR, or with AB_ORACLE_SEED_SET=final and AB_ORACLE_SHARD=i/n the 20 seeds that reach every value of every dimension split over n jobs) twice, once with the firefox-68 binary (the release's seal.json, then the core's own download.ensure_binary under that seal: the archive's sha256 is checked against the seal) and once with the candidate binary of the leg under its own seal, and compares every leaf of every visit: the only differences allowed are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys; anything else is red with the leaf, the two values and the seed; fewer leaves than the host gate's reference holds (16439 per visit; a DPR the reference does not record is held to the least of those it does) is red. The files (dump-68.json, dump-68-again.json, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) are the artifact ab-oracle-<os> of the leg. 1 = the one test; the comparator's own cases (51, the A/A's among them) are in tests/test_ab_oracle.py, the persona seeds' (15) in tests/test_persona_cover.py, in the rows of the whole unit suite. Needs the engine's binary (INVPW_BINARY_PATH) and, for the A/B, the candidate's seal (INVISIBLE_SEAL_FILE) and the network (the release assets of firefox-68). The engine of the candidate must accept the core of the leg and the 68 engine must accept it too: a core that declares something the published engine refuses is a red of this suite, not of the engine.", "timeout_minutes": 50, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"], "artifact": "ab-oracle"},
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone, on the first seed (all five when the pull request changes a file of this oracle: AB_NETWORK_PR_SEEDS), in jobs of its own in e2e.yml on Linux and on Windows (the shared e2e jobs leave this file out).", "timeout_minutes": 75, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"]},
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host A/B oracle: the whole TRACE of a closed run, from the launch to the exit of the browser, after the same journey. Compared: the processes by kind (the parent, -contentproc type, sandboxingKind, isForBrowser, the helpers by what they ran) with their count, except for the kinds of type tab whose count follows the idle time (only their presence counts), and the host paths the tree touched, judged by one rule (red if and only if a path is in all the measured launches of one engine and in no launch of the other, the long launches included; every other path that differs is listed in not-judged.json, not judged); what is ours (the package, the profile and temp dirs of the launch, the run cache, its own shared memory) leaves the comparison as a class. Linux: strace of the whole tree. Windows: the process-creation audit (event 4688, with the command line) and an ETW file trace of Kernel-File, which need an administrator. It has jobs of its own in e2e.yml on Linux and on Windows (a measurement shares the machine with no other browser), and its footprints keep the lifecycle of the tree (who started and ended when, how) and how the close ended. Each engine run starts with a discarded warm-up launch whose trace is kept and listed apart (what only the warm-up did, with the process that did it); only the tree of the launch is compared (a Windows service's paths are counted by process name and left out), and a path or a kind that differs names the processes to blame. A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, applied by kind, a list that may only shrink. There is no list of noise. Without a candidate (a PR e2e) the A/A alone, on the first two seeds (all five when the pull request changes a file of this oracle: AB_HOST_PR_SEEDS).", "runner_image": {"windows": "windows-2022"}, "timeout_minutes": 50, "core_dumps": "cores", "stock_firefox": ["windows"], "location_service": ["windows"], "extra_steps": ["keep_oracle_files"]},
|
||||
{"id": "wrapper.e2e.ab_host_crash", "giro": "G2", "os": ["linux"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_crash_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "A signal sent to the parent of the browser with os.kill, the core the kernel writes and gdb reads, and the signal line of strace exist on Linux only: Windows has no counterpart of this test. What a Windows launch that did not end with 0 leaves (the `.extra` files and the minidump names, read from the crash folders) is held by the unit tests of the recorder with fake launches, and by every Windows leg of the three oracles, which are red on any parent that does not end with 0.", "note": "The recorder of the host oracle, tested on a launch that dies on purpose: scripts/ci_ab_host.py crash-probe launches the engine once under the oracle's stand-in (strace of the tree, cores enabled, a crash watcher), sends SIGSEGV to the browser's parent with os.kill and closes it as the oracle closes its launches; the test passes when the oracle reports RED (exit 1, `FAIL the parent process exited with code ...: seed N, launch crash`) and the artifact (RUNNER_TEMP/invpw-evidence/ab-host-crash) holds the signal line of the strace log (strace-signals.txt, strace-tail.txt), the core run through gdb (gdb-core.*.txt: `thread apply all bt`, the MOZ_CRASH reason, `info sharedlibrary`), the build ids and what the collectors did not find (said.txt). It fails when the oracle says green for a launch that died, when the evidence is missing and when the probe did not run; the red of the probe does not make the job red. It runs in the job of the host oracle on Linux (e2e-host: strace, gdb and elfutils installed, kernel.core_pattern pointed at INVPW_CORE_DIR), after the A/A, and is left out of the shared e2e job (OWN_JOB_FILES).", "timeout_minutes": 35, "core_dumps": "cores", "extra_steps": ["keep_oracle_files"]}
|
||||
]
|
||||
@@ -8,10 +8,5 @@
|
||||
{"file": "tests/unit/test_canvas_text_refs.py", "reason": "feature cancelled with the 69 backlog (21/11)", "date": "2026-11-21", "tests": {"wrapper.unit.all.linux": 7, "wrapper.unit.all.windows": 7}},
|
||||
{"file": "tests/unit/test_compare_canvas_text_runs.py", "reason": "feature cancelled with the 69 backlog (21/11)", "date": "2026-11-21", "tests": {"wrapper.unit.all.linux": 3, "wrapper.unit.all.windows": 3}},
|
||||
{"file": "tests/unit/test_fontconfig_criterion.py", "reason": "feature cancelled with the 69 backlog (21/11)", "date": "2026-11-21", "tests": {"wrapper.unit.all.linux": 5, "wrapper.unit.all.windows": 5}},
|
||||
{"file": "tests/unit/test_theme_refusal_drop.py", "reason": "feature cancelled with the 69 backlog (21/11)", "date": "2026-11-21", "tests": {"wrapper.unit.all.linux": 3, "wrapper.unit.all.windows": 3}},
|
||||
{"nodeid": "tests/test_detectors_e2e.py::test_the_headless_detector_sees_no_headless_and_no_proxy_tell", "suite": "wrapper.e2e.suite.linux.1", "count": 1, "from_min_tests": 449, "reason": "removed with the vendored bundle whose licence notice cannot ship without a studied system's name (pm, 27/11)", "decided_by": "pm", "date": "2026-11-27"},
|
||||
{"nodeid": "tests/test_realness_behind_a_declared_exit_e2e.py::test_the_vendored_detection_page_finds_nothing_behind_the_gateway", "suite": "wrapper.e2e.suite.linux.1", "count": 1, "from_min_tests": 449, "reason": "removed with the vendored bundle whose licence notice cannot ship without a studied system's name (pm, 27/11)", "decided_by": "pm", "date": "2026-11-27"},
|
||||
{"nodeid": "tests/test_detectors_e2e.py::test_the_headless_detector_sees_no_headless_and_no_proxy_tell", "suite": "wrapper.e2e.suite.windows.1", "count": 1, "from_min_tests": 333, "reason": "removed with the vendored bundle whose licence notice cannot ship without a studied system's name (pm, 27/11)", "decided_by": "pm", "date": "2026-11-27"},
|
||||
{"nodeid": "tests/test_realness_behind_a_declared_exit_e2e.py::test_the_vendored_detection_page_finds_nothing_behind_the_gateway", "suite": "wrapper.e2e.suite.windows.4", "count": 1, "from_min_tests": 274, "reason": "removed with the vendored bundle whose licence notice cannot ship without a studied system's name (pm, 27/11)", "decided_by": "pm", "date": "2026-11-27"},
|
||||
{"nodeid": "tests/test_realness_behind_a_declared_exit_e2e.py::test_the_vendored_detection_page_finds_nothing_behind_the_gateway", "suite": "wrapper.e2e.realness", "count": 1, "from_min_tests": 32, "reason": "removed with the vendored bundle whose licence notice cannot ship without a studied system's name (pm, 27/11)", "decided_by": "pm", "date": "2026-11-27"}
|
||||
{"file": "tests/unit/test_theme_refusal_drop.py", "reason": "feature cancelled with the 69 backlog (21/11)", "date": "2026-11-21", "tests": {"wrapper.unit.all.linux": 3, "wrapper.unit.all.windows": 3}}
|
||||
]
|
||||
+2
-2
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "invisible_playwright"
|
||||
version = "0.61.0"
|
||||
version = "0.59.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==71.85.0",
|
||||
"invisible_core==69.82.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
|
||||
|
||||
+18
-30
@@ -116,7 +116,6 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import sysconfig
|
||||
import tempfile
|
||||
import time
|
||||
import threading
|
||||
@@ -1997,23 +1996,11 @@ def default_seeds() -> list:
|
||||
return list(gate.SEEDS)
|
||||
|
||||
|
||||
def install_folders() -> set:
|
||||
"""The folders the python of THIS process installs its packages in (sysconfig's purelib and platlib, the link and the real folder): the install prefix of the side that runs.
|
||||
|
||||
Each side's engine reads the branding of ITS OWN core, in the install folder of that core. The published side runs in the venv of the published set and the candidate in the
|
||||
python of the job (`run_subprocess`), so the two folders differ, and the same read of one file is a different path on each side. That folder is the side's own package, as the
|
||||
folder of its engine is; any other path under the install prefix (the python's own library, another folder of the machine, the other side's folder) stays the host's."""
|
||||
paths = sysconfig.get_paths()
|
||||
folders = {paths[name] for name in ("purelib", "platlib") if paths.get(name)}
|
||||
return folders | {os.path.realpath(folder) for folder in folders}
|
||||
|
||||
|
||||
def _context(binary: str, windows: bool, work: Path) -> Context:
|
||||
"""The run's own folders: the package (the link and the real folder) and the install folders of this process's python (`install_folders`: the core and the wrapper this
|
||||
engine is launched by), the temp root of this process (the oracle's subprocess runs with a TMPDIR / TEMP of its own, `run_subprocess`) and the folder of the work of the seed,
|
||||
and the cache folder of the run."""
|
||||
"""The run's own folders: the package (the link and the real folder), the temp root of this process (the oracle's subprocess runs with a
|
||||
TMPDIR / TEMP of its own, `run_subprocess`) and the folder of the work of the seed, and the cache folder of the run."""
|
||||
real = os.path.realpath(binary)
|
||||
app = {os.path.dirname(real), os.path.dirname(os.path.abspath(binary))} | install_folders()
|
||||
app = {os.path.dirname(real), os.path.dirname(os.path.abspath(binary))}
|
||||
temp = {tempfile.gettempdir(), str(work)}
|
||||
if windows:
|
||||
folders = [*app, *temp, os.path.expanduser("~"), *(os.environ.get(v, "") for v in ("USERPROFILE", "LOCALAPPDATA", "APPDATA", "TEMP", "TMP", "ProgramData", "SystemRoot"))]
|
||||
@@ -2719,14 +2706,17 @@ def staged_engine(binary: str, base=None):
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
|
||||
|
||||
def run_subprocess(binary: str, seal: Path | None, leg: str, out: Path, label: str, seeds: list, crash_with: str | None = None, python: str | None = None) -> int:
|
||||
def run_subprocess(binary: str, seal: Path | None, leg: str, out: Path, label: str, seeds: list, crash_with: str | None = None) -> int:
|
||||
"""`run` in a process of its own, with a cache folder and a temp root of its own: they are the run's, so what the engine does in them is `ours`
|
||||
(the cache of the bundle's fonts, the profile and the temp dirs of the launch) and the rest of the machine is the host's.
|
||||
|
||||
`crash_with` (a signal name) makes the run the recorder's own test: one launch, whose parent is sent that signal (`crash-probe`). `python` is the published set's
|
||||
(scripts/ci_published_set.py): the control side runs in the venv that holds the published core and wrapper, never in the candidate's."""
|
||||
env = oracle.process_env(seal, python)
|
||||
cmd = [python or sys.executable, "-u", str(Path(__file__).resolve()), "run", binary, "--leg", leg, "--out", str(out), "--label", label,
|
||||
`crash_with` (a signal name) makes the run the recorder's own test: one launch, whose parent is sent that signal (`crash-probe`)."""
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
if seal:
|
||||
env["INVISIBLE_SEAL_FILE"] = str(seal)
|
||||
for name in ("MOZ_LOG", "MOZ_LOG_FILE"):
|
||||
env.pop(name, None)
|
||||
cmd = [sys.executable, "-u", str(Path(__file__).resolve()), "run", binary, "--leg", leg, "--out", str(out), "--label", label,
|
||||
"--seeds", ",".join(str(s) for s in seeds)]
|
||||
if crash_with:
|
||||
cmd += ["--crash-with", crash_with]
|
||||
@@ -2854,18 +2844,18 @@ def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path,
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-host-fetch-"))
|
||||
try:
|
||||
binary, seal, python = oracle.split_published(published or oracle.fetch_published(engine_tag, work))
|
||||
runs = [(engine_tag, "footprint-%s.json" % engine_tag.rsplit("-", 1)[-1], binary, seal, python),
|
||||
(engine_tag + " again", "footprint-%s-again.json" % engine_tag.rsplit("-", 1)[-1], binary, seal, python)]
|
||||
binary, seal = published or oracle.fetch_published(engine_tag, work)
|
||||
runs = [(engine_tag, "footprint-%s.json" % engine_tag.rsplit("-", 1)[-1], binary, seal),
|
||||
(engine_tag + " again", "footprint-%s-again.json" % engine_tag.rsplit("-", 1)[-1], binary, seal)]
|
||||
if candidate:
|
||||
runs.append((oracle.CANDIDATE, "footprint-candidate.json", candidate, candidate_seal, None))
|
||||
runs.append((oracle.CANDIDATE, "footprint-candidate.json", candidate, candidate_seal))
|
||||
failed = []
|
||||
for label, name, exe, seal_file, side_python in runs:
|
||||
for label, name, exe, seal_file in runs:
|
||||
print("=== footprint with %s: %s (run from %s)" % (label, exe, stage_dir()))
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
with staged_engine(exe) as staged:
|
||||
rc = run_subprocess(staged, Path(seal_file) if seal_file else None, leg, out / name, label, seeds, **({"python": side_python} if side_python else {}))
|
||||
rc = run_subprocess(staged, Path(seal_file) if seal_file else None, leg, out / name, label, seeds)
|
||||
except OSError as e:
|
||||
print("the engine of %s could not be staged: %s" % (label, e))
|
||||
rc = 125
|
||||
@@ -2931,7 +2921,7 @@ def main(argv=None) -> int:
|
||||
x.add_argument("--candidate-seal", type=Path, default=os.environ.get("INVISIBLE_SEAL_FILE"))
|
||||
x.add_argument("--leg", required=True)
|
||||
x.add_argument("--out", type=Path, required=True)
|
||||
x.add_argument("--engine-tag", default=None, help="the label of the control side (default: the tag the published set's seal names)")
|
||||
x.add_argument("--engine-tag", default=oracle.ENGINE_TAG)
|
||||
x.add_argument("--seeds", default=None)
|
||||
x.add_argument("--published-binary", type=Path, help="use this binary for the published engine instead of fetching it")
|
||||
x.add_argument("--published-seal", type=Path, help="its seal (default: the environment's)")
|
||||
@@ -2957,8 +2947,6 @@ def main(argv=None) -> int:
|
||||
return 3
|
||||
return crash_probe(args.binary, args.leg, args.out, args.seed if args.seed is not None else default_seeds()[0])
|
||||
seeds = [int(s) for s in args.seeds.split(",")] if args.seeds else default_seeds()
|
||||
if args.cmd == "ab":
|
||||
args.engine_tag = args.engine_tag or oracle.default_tag()
|
||||
if args.cmd == "run":
|
||||
if sys.platform.startswith("linux") and not shutil.which("strace"):
|
||||
print("needs strace (apt install strace): without it the processes and the files of the run are not seen")
|
||||
|
||||
+39
-522
@@ -49,11 +49,6 @@ under ``exits``, outside the leaves that are compared, and a parent that did not
|
||||
the side, the seed, the launch and the code. What a launch that died left is kept beside the transcript (``transcript-68.json`` -> ``transcript-68.crash/``): the core through gdb with
|
||||
the build ids, the ``.extra`` and the minidump names, ``said.txt`` for what the collectors did not find. This oracle runs no strace (a trace would change the outcome it observes).
|
||||
|
||||
THE WEBRTC EVIDENCE AND THE HUNT. The WebRTC walk keeps, under ``transcript["evidence"]["seeds"][<seed>]["webrtc"]`` (never compared: the comparison reads ``seeds`` and nothing else), every datagram the gateway
|
||||
routed in it (when, target, message, STUN transaction id), the moments of its stages and of the page's call, and the page's own ``performance.now()`` at each step of the gather. With
|
||||
``AB_NETWORK_HUNT=webrtc:<seed>:<n>`` the command ``ab`` runs ONLY that walk of that seed, ``n`` times for each engine of the A/A, and writes ``<out>/hunt/<engine>-<i>.json`` and ``<out>/hunt/summary.json``;
|
||||
it decides nothing and exits 0 (e2e-hunt.yml: the input ``ab_network_webrtc_seed``).
|
||||
|
||||
Exit codes: 0 green, 1 red (a finding), 2 broken control (the A/A is red) or a run that could not run.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -84,24 +79,13 @@ import ci_crash_evidence as crash # noqa: E402 (how each launch's parent ended
|
||||
FORMAT = "ab-network/1"
|
||||
DIFF_FORMAT = "ab-network-diff/1"
|
||||
EVIDENCE_FORMAT = "ab-network-evidence/1"
|
||||
HUNT_FORMAT = "ab-network-hunt/1"
|
||||
HUNT_SUMMARY_FORMAT = "ab-network-hunt-summary/1"
|
||||
#: The environment variable that makes ``ab`` repeat one walk of one seed and nothing else (``cmd_hunt``): ``webrtc:<seed>:<n>``.
|
||||
HUNT_ENV = "AB_NETWORK_HUNT"
|
||||
#: The engine's own log in a hunt (the launch's environment, in hunt mode only): nICEr's reasons for accepting or rejecting an answer or ending a transaction, and the signaling.
|
||||
#: ``sync`` makes each line reach the file as it is written, so a process that ends (or is killed) loses none.
|
||||
HUNT_MOZ_LOG = "sync,timestamp,nicer:5,signaling:5"
|
||||
VOLATILE_FORMAT = "ab-network-volatile/1"
|
||||
VOLATILE_FILE = ROOT / "ci" / "ab-network-volatile.json"
|
||||
SEEDS_FILE = ROOT / "ci" / "persona-seeds.json"
|
||||
#: The seeds the A/B oracle of the page uses today (scripts/ci_host_gate.py: SEEDS), when ci/persona-seeds.json has no "candidate" key.
|
||||
FALLBACK_SEEDS = (11, 12, 13)
|
||||
ENGINE_TAG = "firefox-68"
|
||||
CANDIDATE = "candidate"
|
||||
#: The most times the engine sends one STUN request (a transmit and its retransmissions) before it gives the transaction up: the pref
|
||||
#: ``media.peerconnection.ice.stun_client_maximum_transmits`` (modules/libpref/init/all.js), 7. The first RTO is 100 ms and doubles, so how
|
||||
#: MANY transactions a walk has is the engine's and is compared, and how many datagrams each took is the network's timing and is not: a
|
||||
#: transaction over this number is a problem of the run (``udp_summary``'s ``over_limit``, ``_udp_overruns``), never a compared leaf.
|
||||
STUN_MAX_TRANSMITS = 7
|
||||
#: What a leaf that one side does not have reads as.
|
||||
MISSING = "<missing>"
|
||||
#: A value longer than this in diff.json is replaced by its length and its sha256.
|
||||
@@ -283,68 +267,6 @@ def _udp_attribution(la: Dict[str, Any], lb: Dict[str, Any]) -> Tuple[set, List[
|
||||
return paths, differences, unattributed
|
||||
|
||||
|
||||
_UDP_OVER_LIMIT = re.compile(r"^(?P<where>.*/udp)/over_limit/(?P<target>[^/]+)/\d+$")
|
||||
|
||||
|
||||
def _udp_overruns(la: Dict[str, Any], lb: Dict[str, Any], label_a: str, label_b: str) -> Tuple[set, List[str]]:
|
||||
"""The STUN transactions that were sent more times than the engine's maximum (``udp_summary``'s ``over_limit``: per destination, the number of transmits of each such
|
||||
transaction). They are not compared leaf by leaf: how many datagrams a transaction took is the network's timing, but more than the engine's own maximum is not
|
||||
timing, it is a client that does not stop. Returns the paths that take part and one problem line for each."""
|
||||
paths: set = set()
|
||||
problems: List[str] = []
|
||||
for label, leaves in ((label_a, la), (label_b, lb)):
|
||||
for path, value in sorted(leaves.items()):
|
||||
m = _UDP_OVER_LIMIT.match(path)
|
||||
if m:
|
||||
paths.add(path)
|
||||
problems.append("%s: a STUN transaction to %s was sent %s times, more than the engine's maximum of %d transmits (%s)"
|
||||
% (label, m.group("target"), value, STUN_MAX_TRANSMITS, m.group("where")))
|
||||
return paths, problems
|
||||
|
||||
|
||||
def turn_path_problems(transcript: Dict[str, Any], label: str) -> List[str]:
|
||||
"""Whether the TURN path of the lab WORKED in each WebRTC walk of a transcript: a relay candidate was made, no error names the lab's TURN server (701 is what a browser reports when
|
||||
every answer it got was thrown away as invalid, as with a wrong credential), and the server refused no request (``webrtc/turn/refused``, written by ``walk_webrtc``). An A/A that
|
||||
compared two runs in which the TURN path failed the same way would pass; this is the line that says it did not work. A transcript with no WebRTC walk says nothing."""
|
||||
out: List[str] = []
|
||||
for seed, body in sorted((transcript.get("seeds") or {}).items()):
|
||||
walk = body.get("webrtc")
|
||||
if not isinstance(walk, dict):
|
||||
continue
|
||||
errors = [e for e in walk.get("errors") or [] if TURN_TARGET in str(e)]
|
||||
refused = (walk.get("turn") or {}).get("refused") or 0
|
||||
if "relay" in (walk.get("candidate_types") or []) and not errors and not refused:
|
||||
continue
|
||||
seen = (errors + ["the lab TURN refused %d request(s)" % refused] * bool(refused)) or ["no error"]
|
||||
out.append("seeds/%s/webrtc: %s made no relay candidate through the lab TURN (%s). Fix: the probe's credential must be the lab TURN's (tests/_turn_chain.py PASSWORD) "
|
||||
"and the lab's answers must reach the browser. Rule: the A/A proves the TURN path it compares" % (seed, label, "; ".join(seen)))
|
||||
return out
|
||||
|
||||
|
||||
def turn_deallocation_problems(transcript: Dict[str, Any], label: str) -> List[str]:
|
||||
"""What the lab's TURN server heard of deallocations (``webrtc/turn/deallocation``, written by ``walk_webrtc`` with :func:`deallocation_facts`) that a walk must not have: an allocation ended
|
||||
by more than one deallocation, a deallocation from an address that has no allocation. One deallocation, or none, is the engine's best effort at teardown and is evidence, not a leaf; so is
|
||||
``early`` (see the comment below)."""
|
||||
out: List[str] = []
|
||||
for seed, body in sorted((transcript.get("seeds") or {}).items()):
|
||||
walk = body.get("webrtc")
|
||||
facts = ((walk or {}).get("turn") or {}).get("deallocation") if isinstance(walk, dict) else None
|
||||
if not isinstance(facts, dict):
|
||||
continue
|
||||
for key, what, fix in (("repeated", "%d allocation(s) of the lab TURN were ended by more than one deallocation (a Refresh with LIFETIME 0)",
|
||||
"find what sends the teardown twice; the engine sends it once"),
|
||||
("unallocated", "the lab TURN heard %d deallocation(s) (a Refresh with LIFETIME 0) from an address that has no allocation",
|
||||
"find what deallocates an allocation it never made; the lab's record is TurnServer.deallocations in tests/_turn_chain.py")):
|
||||
# ``early`` (a deallocation before the page began closing) is evidence, never a problem: the bound maps the page's performance.now() onto the recorder's clock,
|
||||
# and the page's clock is the engine's reduced-precision timer, not the recorder's. On Windows the published engine against itself was "early" on seeds 63 and 6
|
||||
# (wrapper #612's round, e2e (network, windows)), so the two events cannot be ordered on that mapping. Ordering them on one clock would take a marker the page
|
||||
# sends through the gateway before pc.close(), and that request would itself become a compared leaf of the walk.
|
||||
if facts.get(key):
|
||||
out.append("seeds/%s/webrtc: %s: %s. Fix: %s. Rule: the TURN deallocation is one best-effort send at teardown (nICEr nr_turn_client_deallocate)"
|
||||
% (seed, label, what % facts[key], fix))
|
||||
return out
|
||||
|
||||
|
||||
def exit_lines(transcript: Dict[str, Any], label: str, side: str) -> List[str]:
|
||||
"""The red lines of the launches of one side that did not end with 0 (``exits``, which ``run`` writes: scripts/ci_crash_evidence.py). A transcript that has no ``exits``
|
||||
was not made by ``run`` and says nothing about it; one that has it and no launch in it is a run whose probe saw no browser, which is red."""
|
||||
@@ -364,11 +286,7 @@ def compare_transcripts(a: Dict[str, Any], b: Dict[str, Any], volatile: List[Dic
|
||||
run the same seeds, when fewer than ``floor`` leaves were compared, or when an entry of the volatile list matches no leaf of either transcript (``stale``)."""
|
||||
la, lb = flatten(a.get("seeds") or {}), flatten(b.get("seeds") or {})
|
||||
attribution, attribution_differences, unattributed = _udp_attribution(la, lb)
|
||||
overrun_paths, overruns = _udp_overruns(la, lb, label_a, label_b)
|
||||
turn_problems = (turn_path_problems(a, label_a) + turn_path_problems(b, label_b) +
|
||||
turn_deallocation_problems(a, label_a) + turn_deallocation_problems(b, label_b))
|
||||
refused_paths = {p for p in set(la) | set(lb) if re.match(r"^seeds/[^/]+/webrtc/turn/(refused|deallocation/(repeated|unallocated|early))$", p)}
|
||||
paths = sorted((set(la) | set(lb)) - attribution - overrun_paths - refused_paths)
|
||||
paths = sorted((set(la) | set(lb)) - attribution)
|
||||
problems: List[str] = []
|
||||
if set(a.get("seeds") or {}) != set(b.get("seeds") or {}):
|
||||
problems.append("the sides ran different seeds: %s and %s" % (sorted(a.get("seeds") or {}), sorted(b.get("seeds") or {})))
|
||||
@@ -406,8 +324,6 @@ def compare_transcripts(a: Dict[str, Any], b: Dict[str, Any], volatile: List[Dic
|
||||
problems += ["a direct connection: " + d for d in direct]
|
||||
problems += exit_lines(a, label_a, "A") + exit_lines(b, label_b, "B")
|
||||
problems += invariants
|
||||
problems += overruns
|
||||
problems += turn_problems
|
||||
problems += ["the volatile entry %r matches no leaf of either transcript: it is stale, drop it" % p for p in stale]
|
||||
problems += ["%s: %s %s | %s %s" % (d["path"], label_a, json.dumps(d["a"], sort_keys=True)[:160], label_b, json.dumps(d["b"], sort_keys=True)[:160])
|
||||
for d in differences]
|
||||
@@ -552,31 +468,17 @@ def dns_summary(queries: List[Tuple[str, int, str]], openers: Optional[List[Opti
|
||||
|
||||
|
||||
def udp_summary(events: List[Dict[str, Any]], norm: Normalizer) -> Dict[str, Any]:
|
||||
"""The datagrams the relay carried in one phase: per destination, the kinds of message and how many.
|
||||
|
||||
``counts`` is the number of STUN TRANSACTIONS (distinct transaction ids) per destination, plus one for each datagram that is not STUN: a retransmission carries the
|
||||
transaction id of the request it repeats, and how many times a request is repeated is the timing of the network (the first RTO is 100 ms and doubles; a late answer
|
||||
on a loaded host adds one), so it is not what the engine decides. ``over_limit`` (only when there is one) lists, per destination, the transmits of each transaction
|
||||
that has more than ``STUN_MAX_TRANSMITS``: ``compare_transcripts`` reports it as a problem and never compares it."""
|
||||
"""The datagrams the relay carried in one phase: per destination, the kinds of message and how many."""
|
||||
kinds: Dict[str, set] = collections.defaultdict(set)
|
||||
transmits: Dict[str, collections.Counter] = collections.defaultdict(collections.Counter)
|
||||
plain: collections.Counter = collections.Counter()
|
||||
counts: collections.Counter = collections.Counter()
|
||||
order: List[str] = []
|
||||
for e in events:
|
||||
target = norm.text(e["target"])
|
||||
if target not in kinds:
|
||||
order.append(target)
|
||||
kinds[target].add(e["message"])
|
||||
if e.get("tid") is None:
|
||||
plain[target] += 1
|
||||
else:
|
||||
transmits[target][e["tid"]] += 1
|
||||
counts = {t: plain[t] + len(transmits[t]) for t in sorted(kinds)}
|
||||
out: Dict[str, Any] = {"order": order, "messages": {t: sorted(kinds[t]) for t in sorted(kinds)}, "counts": counts}
|
||||
over = {t: sorted((n for n in transmits[t].values() if n > STUN_MAX_TRANSMITS), reverse=True) for t in sorted(kinds)}
|
||||
over = {t: v for t, v in over.items() if v}
|
||||
if over:
|
||||
out["over_limit"] = over
|
||||
counts[target] += 1
|
||||
out: Dict[str, Any] = {"order": order, "messages": {t: sorted(kinds[t]) for t in sorted(kinds)}, "counts": dict(sorted(counts.items()))}
|
||||
who = _openers([norm.text(e["target"]) for e in events], [e.get("opener") for e in events])
|
||||
if who:
|
||||
out["openers"] = who
|
||||
@@ -642,93 +544,6 @@ def message_kind(payload: bytes) -> str:
|
||||
return "other"
|
||||
|
||||
|
||||
def stun_tid(payload: bytes) -> Optional[str]:
|
||||
"""The transaction id of a STUN message (bytes 8 to 20 of the datagram) in hex: what ties a retransmission to the request it repeats. None when the datagram is not STUN
|
||||
(the same test as :func:`message_kind`: the magic cookie at bytes 4 to 8). Written in the evidence of the WebRTC walk, never compared."""
|
||||
if len(payload) >= 20 and payload[4:8] == b"\x21\x12\xa4\x42":
|
||||
return payload[8:20].hex()
|
||||
return None
|
||||
|
||||
|
||||
def stun_attributes(data: bytes) -> Dict[int, bytes]:
|
||||
"""The attributes of a STUN message by type (RFC 8489: type, length, value padded to 4 bytes); what a truncated tail says is left out."""
|
||||
out: Dict[int, bytes] = {}
|
||||
i = 20
|
||||
while i + 4 <= len(data):
|
||||
kind, length = int.from_bytes(data[i:i + 2], "big"), int.from_bytes(data[i + 2:i + 4], "big")
|
||||
if i + 4 + length > len(data):
|
||||
break
|
||||
out[kind] = data[i + 4:i + 4 + length]
|
||||
i += 4 + ((length + 3) & ~3)
|
||||
return out
|
||||
|
||||
|
||||
def xor_address(value: Optional[bytes]) -> Optional[str]:
|
||||
"""An XOR-MAPPED-ADDRESS or XOR-RELAYED-ADDRESS value (IPv4) as ``ip:port``; None for a missing value or another family."""
|
||||
if value is None or len(value) < 8 or value[1] != 1:
|
||||
return None
|
||||
cookie = b"\x21\x12\xa4\x42"
|
||||
port = int.from_bytes(value[2:4], "big") ^ int.from_bytes(cookie[:2], "big")
|
||||
return "%s:%d" % (socket.inet_ntoa(bytes(a ^ b for a, b in zip(value[4:8], cookie))), port)
|
||||
|
||||
|
||||
def turn_request_record(data: bytes, source: Tuple[str, int], t: float) -> Optional[Dict[str, Any]]:
|
||||
"""What the lab's TURN server writes down of a datagram it receives (None when it is not STUN): when, from where, the transaction id, the message type, whether it carried
|
||||
USERNAME and MESSAGE-INTEGRITY, and (``responses``, filled by :func:`turn_response_record`) what the server answered."""
|
||||
if stun_tid(data) is None:
|
||||
return None
|
||||
attrs = stun_attributes(data)
|
||||
return {"t": t, "src": "%s:%d" % (source[0], source[1]), "tid": stun_tid(data), "type": "0x%04x" % int.from_bytes(data[:2], "big"),
|
||||
"username": 0x0006 in attrs, "integrity": 0x0008 in attrs, "responses": []}
|
||||
|
||||
|
||||
def turn_response_record(data: bytes, destination: Tuple[str, int], t: float) -> Optional[Dict[str, Any]]:
|
||||
"""What the lab's TURN server sends: when, the type (0x0113 an Allocate error, 0x0103 its success), the address it is sent to and, of a success, the XOR-RELAYED-ADDRESS and the
|
||||
XOR-MAPPED-ADDRESS it carries (of an error, its code)."""
|
||||
if stun_tid(data) is None:
|
||||
return None
|
||||
attrs = stun_attributes(data)
|
||||
error = attrs.get(0x0009)
|
||||
return {"t": t, "tid": stun_tid(data), "type": "0x%04x" % int.from_bytes(data[:2], "big"), "to": "%s:%d" % (destination[0], destination[1]),
|
||||
"relayed": xor_address(attrs.get(0x0016)), "mapped": xor_address(attrs.get(0x0020)),
|
||||
"error": (error[2] * 100 + error[3]) if error is not None and len(error) >= 4 else None}
|
||||
|
||||
|
||||
class ExchangeSocket:
|
||||
"""The UDP socket of the lab's TURN server with a record of what it receives and sends (``owner.exchanges``): the server's own code runs on it unchanged, and a failure of the record
|
||||
is never a failure of the server. ``owner.clock`` is the moment (the recorder's)."""
|
||||
|
||||
def __init__(self, sock: socket.socket, owner: Any) -> None:
|
||||
self._sock, self._owner = sock, owner
|
||||
|
||||
def recvfrom(self, size: int) -> Tuple[bytes, Any]:
|
||||
data, source = self._sock.recvfrom(size)
|
||||
try:
|
||||
record = turn_request_record(data, source, self._owner.clock())
|
||||
if record is not None:
|
||||
self._owner.exchanges.append(record)
|
||||
except Exception: # noqa: BLE001 - evidence, never the road
|
||||
pass
|
||||
return data, source
|
||||
|
||||
def sendto(self, data: bytes, address: Any) -> int:
|
||||
try:
|
||||
record = turn_response_record(data, address, self._owner.clock())
|
||||
if record is not None:
|
||||
for exchange in reversed(self._owner.exchanges):
|
||||
if exchange.get("tid") == record["tid"]:
|
||||
exchange["responses"].append(record)
|
||||
break
|
||||
else:
|
||||
self._owner.exchanges.append({"t": record["t"], "src": None, "tid": record["tid"], "type": None, "username": None, "integrity": None, "responses": [record]})
|
||||
except Exception: # noqa: BLE001 - evidence, never the road
|
||||
pass
|
||||
return self._sock.sendto(data, address)
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
return getattr(self._sock, name)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------
|
||||
# The seeds, the transcript and its files
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -776,12 +591,6 @@ class Recorder:
|
||||
self._t0 = time.monotonic()
|
||||
self._sources: Dict[str, list] = {}
|
||||
self._marks: List[Tuple[str, Dict[str, int]]] = []
|
||||
#: The moment (``t``, as an event's) at which each stage began: the evidence of the WebRTC walk says where its stages sit among the datagrams.
|
||||
self.phase_t: Dict[str, float] = {}
|
||||
|
||||
def now(self) -> float:
|
||||
"""The recorder's clock, the ``t`` of an event: seconds since the recorder started."""
|
||||
return round(time.monotonic() - self._t0, 3)
|
||||
|
||||
def attach(self, name: str, items: list) -> None:
|
||||
self._sources[name] = items
|
||||
@@ -791,7 +600,6 @@ class Recorder:
|
||||
with self._lock:
|
||||
self._marks.append((name, {k: len(v) for k, v in self._sources.items()}))
|
||||
self.phase = name
|
||||
self.phase_t[name] = self.now()
|
||||
|
||||
def event(self, kind: str, **fields: Any) -> None:
|
||||
with self._lock:
|
||||
@@ -899,7 +707,7 @@ def make_lab_classes() -> Tuple[type, type, type]:
|
||||
|
||||
import _doh_servers as ds
|
||||
from _socks_servers import MEASURE_NUMBER, STUN_NAME, STUN_NUMBER, STUN_PORT, WHOAMI4, WHOAMI6, WEB_NAME
|
||||
from _turn_chain import TURN_IP, TURN_PORT, TurnServer, is_deallocation
|
||||
from _turn_chain import TURN_IP, TURN_PORT, TurnServer
|
||||
|
||||
class LabGateway(ds.DohGateway):
|
||||
"""A coherent SOCKS5 gateway with the DoH road. Past loopback it carries only what the lab names: the CONNECTs to the servers of the lab that stand at the
|
||||
@@ -919,17 +727,6 @@ def make_lab_classes() -> Tuple[type, type, type]:
|
||||
self.opener_lookup: Callable[..., str] = self._look_up_opener
|
||||
super().__init__("lab", doh, udp="relay", tcp_exit=exit_ip, udp_exit=exit_ip, relay_host=host, exit_host=host)
|
||||
|
||||
def _deliver(self, relay: socket.socket, to: Any, host: str, port: int, payload: bytes) -> None:
|
||||
"""Every datagram the relay sends BACK to the browser is written down (``udp_back``: the address it claims in the SOCKS UDP header, where it is sent, from which relay
|
||||
socket, the STUN type and transaction id), then sent as it always was."""
|
||||
try:
|
||||
local = relay.getsockname()
|
||||
self.rec.event("udp_back", claimed="%s:%d" % (host, port), to="%s:%d" % (to[0], to[1]), relay="%s:%d" % (local[0], local[1]),
|
||||
message=message_kind(payload), tid=stun_tid(payload))
|
||||
except Exception: # noqa: BLE001 - evidence, never the road
|
||||
pass
|
||||
super()._deliver(relay, to, host, port, payload)
|
||||
|
||||
def _attributing(self) -> bool:
|
||||
phase = self.rec.phase
|
||||
return any(phase == p or phase.startswith(p + ".") for p in self.attribute_in)
|
||||
@@ -985,9 +782,7 @@ def make_lab_classes() -> Tuple[type, type, type]:
|
||||
|
||||
def _route(self, host: str, dport: int, atyp: int, payload: bytes, out_port: int, answer: Any) -> Any:
|
||||
association = getattr(self._dgram, "index", None)
|
||||
# ``deallocation``: the datagram is a TURN deallocation by what it means (``_turn_chain.is_deallocation``, the reading the lab's TURN server uses): marked here, where the payload is.
|
||||
self.rec.event("udp", target="%s:%d" % (host, dport), message=message_kind(payload), tid=stun_tid(payload), deallocation=is_deallocation(payload),
|
||||
opener=self._association_openers.get(association) if association is not None else None)
|
||||
self.rec.event("udp", target="%s:%d" % (host, dport), message=message_kind(payload), opener=self._association_openers.get(association) if association is not None else None)
|
||||
if atyp == 1 and (host, dport) == (TURN_IP, TURN_PORT):
|
||||
return self.turn.address, (host, dport)
|
||||
if (host, dport) in ((STUN_NAME, STUN_PORT), (STUN_NUMBER, STUN_PORT), (MEASURE_NUMBER, STUN_PORT)):
|
||||
@@ -1001,18 +796,12 @@ def make_lab_classes() -> Tuple[type, type, type]:
|
||||
from an address of the host to loopback."""
|
||||
|
||||
def __init__(self, address: str) -> None:
|
||||
raw = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
raw.bind((address, 0))
|
||||
self.address = raw.getsockname()
|
||||
#: Every STUN datagram it received with the answers it sent (``turn_request_record``), by the clock the lab sets (``Lab``): evidence of the WebRTC walk, never compared.
|
||||
self.exchanges: list = []
|
||||
self.clock: Callable[[], float] = time.monotonic
|
||||
self.sock = ExchangeSocket(raw, self)
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock.bind((address, 0))
|
||||
self.address = self.sock.getsockname()
|
||||
self.seen: list = []
|
||||
self.allocations: list = []
|
||||
self.requests: list = []
|
||||
self.deallocations: list = []
|
||||
self.refused: list = []
|
||||
self._closed = False
|
||||
threading.Thread(target=self._serve, daemon=True).start()
|
||||
|
||||
@@ -1063,42 +852,25 @@ JOURNEY_A, JOURNEY_O = "journey-a.test", "journey-o.test"
|
||||
PAGE_NAME, H1_NAME, H2_NAME, H3_NAME = "page.lab.test", "h1.lab.test", "h2.lab.test", "h3.lab.test"
|
||||
STUN_URL = "stun:198.51.100.5:19302"
|
||||
TURN_URL = "turn:198.51.100.7:3478?transport=udp"
|
||||
#: The TURN server of ``TURN_URL`` as the gateway names the target of a datagram (a test holds it equal to ``tests/_turn_chain.py``).
|
||||
TURN_TARGET = "198.51.100.7:3478"
|
||||
#: The user name the probe gives the TURN server (the lab's server takes any: the key is made from it and the password of ``tests/_turn_chain.py``, which the walk passes as the credential).
|
||||
TURN_USERNAME = "lab"
|
||||
#: The probe of the WebRTC page: one STUN and one TURN server by address (the relay answers both; the TURN's user name and credential are its arguments, never written here), a data channel, and the page waits for the end of the gather (the
|
||||
#: The probe of the WebRTC page: one STUN and one TURN server by address (the relay answers both), a data channel, and the page waits for the end of the gather (the
|
||||
#: timer is the safety net of a gather that never ends, not a measure of it).
|
||||
RTC_JS = r"""async (args) => {
|
||||
const [stunUrl, turnUrl, username, credential] = args;
|
||||
const T = {start: performance.now(), offer: null, local: null, candidates: [], errors: [], gathered: null, closing: null, closed: null};
|
||||
const pc = new RTCPeerConnection({iceServers: [{urls: [stunUrl]}, {urls: [turnUrl], username, credential}]});
|
||||
RTC_JS = r"""async (urls) => {
|
||||
const pc = new RTCPeerConnection({iceServers: [{urls: [urls[0]]}, {urls: [urls[1]], username: 'lab', credential: 'lab'}]});
|
||||
pc.createDataChannel('');
|
||||
const cands = [], errors = [];
|
||||
pc.addEventListener('icecandidate', e => {
|
||||
if (e.candidate && e.candidate.candidate) cands.push(e.candidate.candidate);
|
||||
T.candidates.push({t: performance.now(), type: e.candidate ? (e.candidate.type || null) : 'end'});
|
||||
});
|
||||
pc.addEventListener('icecandidateerror', e => {
|
||||
errors.push({code: e.errorCode, url: e.url});
|
||||
T.errors.push({t: performance.now(), code: e.errorCode, url: e.url});
|
||||
});
|
||||
const offer = await pc.createOffer();
|
||||
T.offer = performance.now();
|
||||
await pc.setLocalDescription(offer);
|
||||
T.local = performance.now();
|
||||
pc.addEventListener('icecandidate', e => { if (e.candidate && e.candidate.candidate) cands.push(e.candidate.candidate); });
|
||||
pc.addEventListener('icecandidateerror', e => { errors.push({code: e.errorCode, url: e.url}); });
|
||||
await pc.setLocalDescription(await pc.createOffer());
|
||||
await new Promise(resolve => {
|
||||
const timer = setTimeout(resolve, 30000);
|
||||
const done = () => { clearTimeout(timer); if (T.gathered === null) T.gathered = performance.now(); resolve(); };
|
||||
const done = () => { clearTimeout(timer); resolve(); };
|
||||
if (pc.iceGatheringState === 'complete') done();
|
||||
pc.addEventListener('icegatheringstatechange', () => { if (pc.iceGatheringState === 'complete') done(); });
|
||||
});
|
||||
const sdp = (pc.localDescription && pc.localDescription.sdp) || '';
|
||||
const gathering = pc.iceGatheringState;
|
||||
T.closing = performance.now();
|
||||
try { pc.close(); } catch (e) {}
|
||||
T.closed = performance.now();
|
||||
return {candidates: cands, errors, sdp, gathering, times: T};
|
||||
return {candidates: cands, errors, sdp, gathering};
|
||||
}"""
|
||||
FETCH_JS = r"""async () => {
|
||||
await (await fetch('/api?x=1', {cache: 'no-store'})).text();
|
||||
@@ -1203,8 +975,6 @@ class Lab:
|
||||
self.roles: Dict[int, str] = {}
|
||||
self.collisions: List[Tuple[int, str, str]] = []
|
||||
self.norm = Normalizer(self.roles)
|
||||
#: What the WebRTC walk measured about itself (``walk_webrtc``), for ``webrtc_evidence``: never a leaf.
|
||||
self.webrtc: Dict[str, Any] = {}
|
||||
self._closers: List[Callable[[], None]] = []
|
||||
self.h1 = self.h2 = self.h3 = None
|
||||
self.origin_a = self.origin_o = ""
|
||||
@@ -1221,7 +991,6 @@ class Lab:
|
||||
self._closers.append(self.witness.close)
|
||||
self._claim(self.witness.port, "witness")
|
||||
self.turn = turn_class(self.host)
|
||||
self.turn.clock = self.rec.now
|
||||
self._closers.append(self.turn.close)
|
||||
self.gateway = gateway_class(self.rec, self.doh, self.turn, self.host, self.exit_ip)
|
||||
self.gateway.attribute_in = attribute_in
|
||||
@@ -1309,10 +1078,9 @@ def guarded(fn: Callable[[], Any]) -> Any:
|
||||
return {"error": _first_line(exc)}
|
||||
|
||||
|
||||
def phase_data(lab: Lab, phase: str, skip_connects: Callable[[str], bool] = lambda target: False,
|
||||
skip_udp: Callable[[Dict[str, Any]], bool] = lambda event: False) -> Dict[str, Any]:
|
||||
def phase_data(lab: Lab, phase: str, skip_connects: Callable[[str], bool] = lambda target: False) -> Dict[str, Any]:
|
||||
"""What the lab saw in a stage and the stages under it: the CONNECTs, the DoH questions, the datagrams, the HTTP requests of the tees. Where the lab looked who opened an entry
|
||||
(``Lab(attribute_in=...)``), each summary says so: ``openers``. ``skip_connects`` leaves out the CONNECTs it is true of, ``skip_udp`` the datagrams (events) it is true of."""
|
||||
(``Lab(attribute_in=...)``), each summary says so: ``openers``. ``skip_connects`` leaves out the CONNECTs it is true of."""
|
||||
queries = [(q.name, q.qtype, q.via) for q in lab.rec.slice("doh", phase)]
|
||||
gateway = getattr(lab, "gateway", None)
|
||||
attributing = bool(gateway is not None and gateway.attribute_in)
|
||||
@@ -1320,7 +1088,7 @@ def phase_data(lab: Lab, phase: str, skip_connects: Callable[[str], bool] = lamb
|
||||
connects = [e for e in lab.rec.of(phase, "connect") if not skip_connects(e["target"])]
|
||||
return {"connects": connect_summary([e["target"] for e in connects], lab.norm, [e.get("opener") for e in connects]),
|
||||
"dns": dns_summary(queries, [gateway.opener_of_connection(i) for i in asked_on] if attributing else None),
|
||||
"udp": udp_summary([e for e in lab.rec.of(phase, "udp") if not skip_udp(e)], lab.norm), "requests": request_summary(lab.rec.of(phase, "http"), lab.norm)}
|
||||
"udp": udp_summary(lab.rec.of(phase, "udp"), lab.norm), "requests": request_summary(lab.rec.of(phase, "http"), lab.norm)}
|
||||
|
||||
|
||||
def launch_data(lab: Lab) -> Dict[str, Any]:
|
||||
@@ -1635,89 +1403,22 @@ def walk_h3(browser: Any, lab: Lab, guard_ms: int = LEAVE_GUARD_MS) -> Dict[str,
|
||||
|
||||
|
||||
def walk_webrtc(browser: Any, lab: Lab) -> Dict[str, Any]:
|
||||
from _turn_chain import PASSWORD as TURN_PASSWORD # the one the lab's TURN server signs its answers with: a browser with another finds every success invalid and makes no relay
|
||||
|
||||
lab.rec.set_phase("webrtc")
|
||||
context = browser.new_context(ignore_https_errors=True)
|
||||
try:
|
||||
page = context.new_page()
|
||||
page.goto("http://%s:%d/rtc" % (PAGE_NAME, lab.site.port), wait_until="load", timeout=60000)
|
||||
lab.webrtc["evaluate"] = {"called": lab.rec.now()}
|
||||
result = page.evaluate(RTC_JS, [STUN_URL, TURN_URL, TURN_USERNAME, TURN_PASSWORD])
|
||||
lab.webrtc["evaluate"]["returned"] = lab.rec.now()
|
||||
result = page.evaluate(RTC_JS, [STUN_URL, TURN_URL])
|
||||
finally:
|
||||
context.close()
|
||||
lab.rec.set_phase("webrtc.end")
|
||||
# What the page measured of itself goes to the evidence and to nothing that is compared: ``webrtc_summary`` reads the fields it always read.
|
||||
lab.webrtc["page"] = result.pop("times", None)
|
||||
# The TURN deallocation (a Refresh with LIFETIME 0) is one best-effort send at teardown, so it is evidence (``webrtc_evidence``) and no leaf. Source: dom/media/webrtc/transport/third_party/
|
||||
# nICEr/src/stun/turn_client_ctx.cpp:693-730, ``nr_turn_client_deallocate``: ONE request, no retransmission, sent while the TURN context is destroyed. It reaches the lab in some walks and
|
||||
# not in others for the same engine, so it is out of the datagrams counted for the TURN address (told by the mark the gateway wrote on it from its payload, not by when it came) and out
|
||||
# of the messages (told by the transaction id the lab's TURN server wrote for it, recorded before the request itself).
|
||||
ended = {tid.hex() for tid in lab.turn.deallocation_tids()}
|
||||
data = phase_data(lab, "webrtc", skip_udp=lambda event: event["target"] == TURN_TARGET and bool(event.get("deallocation")))
|
||||
lab.webrtc["counted"] = len(lab.rec.of("webrtc", "udp"))
|
||||
data = phase_data(lab, "webrtc")
|
||||
out = webrtc_summary(result, lab.exit_ip)
|
||||
marked = [e for e in lab.rec.of("webrtc", "udp") if e["target"] == TURN_TARGET and e.get("deallocation")]
|
||||
out.update(connects=data["connects"], dns=data["dns"], udp=data["udp"],
|
||||
turn={"messages": sorted({"0x%04x" % t for _when, tid, t, _credentials in lab.turn.requests if tid.hex() not in ended}), "allocated": bool(lab.turn.allocations),
|
||||
"refused": len(lab.turn.refused), "deallocation": deallocation_facts(lab.turn, marked, closing_began(lab.webrtc["evaluate"]["called"], lab.webrtc["page"]))})
|
||||
turn={"messages": sorted({"0x%04x" % t for _ip, _port, t in lab.turn.seen}), "allocated": bool(lab.turn.allocations)})
|
||||
return lab.norm.walk(out)
|
||||
|
||||
|
||||
def closing_began(called: float, page: Optional[Dict[str, Any]]) -> Optional[float]:
|
||||
"""The moment, on the recorder's clock, from which the page was closing its connection: the recorder's time at which the walk called the page (``evaluate.called``) plus the time the page
|
||||
measured from its start to its ``closing`` (``performance.now()`` in milliseconds, of the page's own clock: ``start`` and ``closing`` are both read there, so their difference is a length
|
||||
of time and needs no common origin). The script starts at or after the call, so this is never later than the real moment: a deallocation before it was surely sent before the close.
|
||||
None when the page did not return its times."""
|
||||
if not isinstance(page, dict) or page.get("start") is None or page.get("closing") is None:
|
||||
return None
|
||||
return called + (page["closing"] - page["start"]) / 1000.0
|
||||
|
||||
|
||||
def deallocation_facts(turn: Any, marked: List[Dict[str, Any]], began_closing: Optional[float]) -> Dict[str, int]:
|
||||
"""What the lab heard of deallocations that a walk must not have: ``repeated`` allocations that were ended by more than one transaction, ``unallocated`` deallocations from an address
|
||||
that has no allocation (both from the lab's TURN server), and ``early`` deallocation transactions that the gateway carried (``marked``, its events of them) before the page began closing
|
||||
(``began_closing``, :func:`closing_began`; unknown: none is early). ``repeated`` and ``unallocated`` are 0 in a healthy walk and ``turn_deallocation_problems`` says it when they are not;
|
||||
``early`` is evidence only (the page's clock cannot order it, see ``turn_deallocation_problems``). None of them is compared."""
|
||||
ends: collections.Counter = collections.Counter()
|
||||
unallocated = 0
|
||||
for _ip, _port, _tid, _t, allocation in turn.deallocation_transactions():
|
||||
if allocation is None:
|
||||
unallocated += 1
|
||||
else:
|
||||
ends[allocation] += 1
|
||||
first: Dict[Any, float] = {}
|
||||
for event in marked:
|
||||
first.setdefault(event.get("tid"), event["t"])
|
||||
early = sum(1 for t in first.values() if began_closing is not None and t < began_closing)
|
||||
return {"repeated": sum(1 for n in ends.values() if n > 1), "unallocated": unallocated, "early": early}
|
||||
|
||||
|
||||
def webrtc_evidence(lab: Lab) -> Dict[str, Any]:
|
||||
"""The WebRTC walk of a seed as it happened, outside the leaves that are compared: every datagram the gateway routed in its stages (when, to whom, the message, the STUN transaction id,
|
||||
its stage, and whether it was already there when the summary of the walk was taken: ``counted``), the moments of the stages and of the page's call on the recorder's clock, and the
|
||||
page's own ``performance.now()`` at each step of the gather (``page``: the offer, each candidate with its type, each error with its code and url, the end of the gather, the close).
|
||||
It exists to tell two readings of a run that differs from itself apart: a close that cuts the retransmissions of the TURN server short at a variable point, and a retransmission of the
|
||||
first request whose answer came late."""
|
||||
info = getattr(lab, "webrtc", None) or {}
|
||||
began = lab.rec.phase_t.get("webrtc")
|
||||
counted = info.get("counted")
|
||||
datagrams = [{"t": e["t"], "phase": e["phase"], "target": e["target"], "message": e["message"], "tid": e.get("tid"), "counted": counted is None or i < counted}
|
||||
for i, e in enumerate(lab.rec.of("webrtc", "udp"))]
|
||||
# The lab's TURN server: each request with what it carried and what it answered; the relay's datagrams back to the browser: the address each claims and the 5-tuple it goes to.
|
||||
exchanges = [e for e in getattr(getattr(lab, "turn", None), "exchanges", None) or [] if began is None or e["t"] >= began]
|
||||
returned = [{"t": e["t"], "phase": e["phase"], "claimed": e["claimed"], "to": e["to"], "relay": e["relay"], "message": e["message"], "tid": e.get("tid")} for e in lab.rec.of("webrtc", "udp_back")]
|
||||
# The deallocation (a Refresh with LIFETIME 0, sent once at teardown): whether the lab's TURN server heard it, and for each transaction when (the recorder's clock, from the exchange of
|
||||
# the same transaction id) and which. It is no leaf: the walk leaves it out of what it compares.
|
||||
heard = getattr(getattr(lab, "turn", None), "deallocation_transactions", None)
|
||||
when = {e["tid"]: e["t"] for e in reversed(exchanges)}
|
||||
records = [{"t": when.get(tid.hex()), "tid": tid.hex(), "src": "%s:%d" % (ip, port), "allocation": allocation} for ip, port, tid, _t, allocation in (heard() if heard else [])]
|
||||
return {"phase_t": {name: lab.rec.phase_t.get(name) for name in ("webrtc", "webrtc.end")}, "evaluate": info.get("evaluate"), "page": info.get("page"), "datagrams": datagrams,
|
||||
"turn": exchanges, "returned": returned, "send_errors": list(getattr(getattr(lab, "gateway", None), "send_errors", None) or []),
|
||||
"deallocation": {"seen": bool(records), "records": records}}
|
||||
|
||||
|
||||
def direct_report(lab: Lab, watcher: Any, trap: Any) -> Dict[str, Any]:
|
||||
"""Everything that reached the lab or the network around the proxy. Each list is empty on a browser that keeps its word; a watcher that never saw the
|
||||
browser is a list with that fact in it (a sink that sees nothing proves nothing)."""
|
||||
@@ -1814,7 +1515,7 @@ def wire_evidence(lab: Lab) -> Dict[str, Any]:
|
||||
for q in lab.h3.snapshot()["quic"]:
|
||||
h3.append({"phase": q["phase"], "requests": [{"t": r.get("t"), "written": r.get("written_t"),
|
||||
"request": "%s %s" % (dict(r["headers"]).get(":method"), lab.norm.text(dict(r["headers"]).get(":path", "")))} for r in q["requests"]]})
|
||||
return {"journey": journey, "https": https, "h3": h3, "webrtc": webrtc_evidence(lab)}
|
||||
return {"journey": journey, "https": https, "h3": h3}
|
||||
|
||||
|
||||
def sentinel_signature(lab: Lab) -> Dict[str, Any]:
|
||||
@@ -2025,28 +1726,15 @@ def judge(report: Dict[str, Any], control: bool) -> int:
|
||||
return 2 if control else 1
|
||||
|
||||
|
||||
def engine_env(seal: Optional[str], python: Optional[str] = None) -> Dict[str, str]:
|
||||
"""The environment of a process that runs one engine: its seal, no autofix, no pin check, no browser logging. With `python` (the published set's venv,
|
||||
scripts/ci_published_set.py) it is the set's: nothing of the candidate's job that makes it import another core or run another seal, and the pin check stays on."""
|
||||
if python:
|
||||
from ci_published_set import clean_env
|
||||
|
||||
env = clean_env({"INVISIBLE_CORE_AUTOFIX": "off"})
|
||||
else:
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
def run_engine(binary: str, seal: Optional[str], label: str, seeds: Tuple[int, ...], out: Path) -> int:
|
||||
"""``run`` in a process of its own: the seal a process runs under is read at import, so each engine gets its own."""
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
if seal:
|
||||
env["INVISIBLE_SEAL_FILE"] = str(seal)
|
||||
for name in ("MOZ_LOG", "MOZ_LOG_FILE"):
|
||||
env.pop(name, None)
|
||||
return env
|
||||
|
||||
|
||||
def run_engine(binary: str, seal: Optional[str], label: str, seeds: Tuple[int, ...], out: Path, python: Optional[str] = None) -> int:
|
||||
"""``run`` in a process of its own: the seal a process runs under is read at import, so each engine gets its own. `python` is the published set's: the control
|
||||
side runs in the venv that holds the published core and wrapper, never in the candidate's."""
|
||||
env = engine_env(seal, python)
|
||||
env[crash.CRASH_DIR_ENV] = str(Path(out).parent / (Path(out).stem + ".crash")) # footprint-68.json -> transcript-68.crash/: what a launch that did not end with 0 left
|
||||
command = [python or sys.executable, "-u", str(Path(__file__).resolve()), "run", "--binary", binary, "--label", label, "--seeds", ",".join(map(str, seeds)), "--out", str(out)]
|
||||
command = [sys.executable, "-u", str(Path(__file__).resolve()), "run", "--binary", binary, "--label", label, "--seeds", ",".join(map(str, seeds)), "--out", str(out)]
|
||||
print("=== run %s: %s (seal %s)" % (label, binary, seal or "the one this process has"))
|
||||
sys.stdout.flush()
|
||||
from ci_ab_oracle import own_cache_env
|
||||
@@ -2058,168 +1746,6 @@ def run_engine(binary: str, seal: Optional[str], label: str, seeds: Tuple[int, .
|
||||
return 124
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------
|
||||
# The hunt: one walk of one seed, repeated, and the evidence of each repetition (never a verdict)
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------
|
||||
def parse_hunt(text: str) -> Tuple[str, int, int]:
|
||||
"""``webrtc:<seed>:<n>`` -> ``("webrtc", seed, n)``. Anything else is a usage error: the walk is named, the seed and the count are whole numbers, and n is at least 1."""
|
||||
parts = (text or "").strip().split(":")
|
||||
if len(parts) != 3 or parts[0] != "webrtc":
|
||||
raise ValueError("%s is %r: expected webrtc:<seed>:<n>" % (HUNT_ENV, text))
|
||||
try:
|
||||
seed, n = int(parts[1]), int(parts[2])
|
||||
except ValueError:
|
||||
raise ValueError("%s is %r: the seed and n are whole numbers" % (HUNT_ENV, text)) from None
|
||||
if n < 1:
|
||||
raise ValueError("%s is %r: n is at least 1" % (HUNT_ENV, text))
|
||||
return parts[0], seed, n
|
||||
|
||||
|
||||
def hunt_counts(evidence: Optional[Dict[str, Any]]) -> Dict[str, int]:
|
||||
"""Datagrams to the TURN server in a repetition: ``counted`` as the summary of the walk (what the A/A compares) took them, ``all`` with the ones that came after."""
|
||||
turn = [d for d in (evidence or {}).get("datagrams") or [] if d.get("target") == TURN_TARGET]
|
||||
return {"counted": sum(1 for d in turn if d.get("counted")), "all": len(turn)}
|
||||
|
||||
|
||||
def hunt_repetition(binary: str, label: str, i: int, seed: int, patch: Any, out_dir: Optional[Path] = None) -> Dict[str, Any]:
|
||||
"""One repetition: a launch behind a lab as the main launch has it, the WebRTC walk only, the close, and what the lab saw of it. A failure is the ``error`` of the record."""
|
||||
record: Dict[str, Any] = {"format": HUNT_FORMAT, "engine": label, "i": i, "seed": seed, "error": None, "evidence": None}
|
||||
if out_dir is not None:
|
||||
# The engine logs to ``<out_dir>/<engine>-<i>-mozlog`` (its child processes to the same name with ``.child-N``): the launch inherits this process's environment.
|
||||
record["mozlog"] = "%s-%d-mozlog" % (label, i)
|
||||
patch.setenv("MOZ_LOG", HUNT_MOZ_LOG)
|
||||
patch.setenv("MOZ_LOG_FILE", str(Path(out_dir) / record["mozlog"]))
|
||||
try:
|
||||
with open_lab(journey=True, wire=True) as lab:
|
||||
begin_launch(seed, "hunt")
|
||||
session = launch(binary, seed, lab, patch)
|
||||
with session as browser:
|
||||
browser.new_context(ignore_https_errors=True).new_page() # Glean is born when a window opens (``glean_ready``); the walk opens its own context
|
||||
record.update(glean_ready(session, seed, "hunt"))
|
||||
record["walk"] = guarded(lambda: walk_webrtc(browser, lab))
|
||||
record["evidence"] = webrtc_evidence(lab) # after the close: the datagrams the close leaves in flight are in it
|
||||
except Exception as exc: # noqa: BLE001 - evidence, never a verdict
|
||||
record["error"] = _first_line(exc)
|
||||
finally:
|
||||
if out_dir is not None:
|
||||
patch.delenv("MOZ_LOG", raising=False)
|
||||
patch.delenv("MOZ_LOG_FILE", raising=False)
|
||||
record["counts"] = hunt_counts(record["evidence"])
|
||||
return record
|
||||
|
||||
|
||||
def hunt_run(binary: str, label: str, seed: int, n: int, out_dir: Path) -> int:
|
||||
"""``n`` repetitions of the WebRTC walk of ``seed`` with one engine, each written to ``<out_dir>/<label>-<i>.json``. Exits 0: it decides nothing."""
|
||||
import pytest
|
||||
|
||||
patch = pytest.MonkeyPatch()
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-network-hunt-"))
|
||||
try:
|
||||
import _lab_egress
|
||||
|
||||
_lab_egress.install(patch, work)
|
||||
global RUN_LABEL
|
||||
RUN_LABEL = label
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
for i in range(1, n + 1):
|
||||
record = hunt_repetition(binary, label, i, seed, patch, out_dir)
|
||||
write_json(out_dir / ("%s-%d.json" % (label, i)), record)
|
||||
print("hunt %s %d/%d: %d datagrams to the TURN server (%d with the late ones)%s" % (
|
||||
label, i, n, record["counts"]["counted"], record["counts"]["all"], "" if record["error"] is None else ", ERROR " + record["error"]))
|
||||
sys.stdout.flush()
|
||||
return 0
|
||||
finally:
|
||||
patch.undo()
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
|
||||
|
||||
def hunt_summary(records: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""The summary of the repetition files: per repetition the count of datagrams to the TURN server (``count_3478``: as the A/A counts them; ``count_3478_all``: with the late ones) and, per
|
||||
target, the transaction ids in the order they first appeared with the number of datagrams each carried (``[tid, n]``: a retransmission repeats its request's id); per engine, how often
|
||||
each count came."""
|
||||
repetitions = []
|
||||
distribution: Dict[str, collections.Counter] = {}
|
||||
for record in records:
|
||||
counts = hunt_counts(record.get("evidence"))
|
||||
groups: Dict[str, Dict[Any, int]] = {}
|
||||
for d in (record.get("evidence") or {}).get("datagrams") or []:
|
||||
tids = groups.setdefault(d["target"], {})
|
||||
tids[d.get("tid")] = tids.get(d.get("tid"), 0) + 1
|
||||
repetitions.append({"engine": record["engine"], "i": record["i"], "count_3478": counts["counted"], "count_3478_all": counts["all"],
|
||||
"targets": {t: [[tid, n] for tid, n in groups[t].items()] for t in sorted(groups)}, "error": record.get("error")})
|
||||
distribution.setdefault(record["engine"], collections.Counter())[counts["counted"]] += 1
|
||||
return {"format": HUNT_SUMMARY_FORMAT, "target": TURN_TARGET, "repetitions": repetitions,
|
||||
"count_3478_by_engine": {engine: {str(k): v for k, v in sorted(c.items())} for engine, c in sorted(distribution.items())}}
|
||||
|
||||
|
||||
def read_hunt_records(folder: Path) -> List[Dict[str, Any]]:
|
||||
"""The repetition files of a folder, by engine and repetition."""
|
||||
records = []
|
||||
for path in sorted(Path(folder).glob("*.json")):
|
||||
document = json.loads(path.read_text(encoding="utf-8"))
|
||||
if document.get("format") == HUNT_FORMAT:
|
||||
records.append(document)
|
||||
return sorted(records, key=lambda r: (r["engine"], r["i"]))
|
||||
|
||||
|
||||
#: The safety net of a hunt's engine run, in seconds: a base and a share per repetition (a launch, Glean, the gather's own 30 s). Never a verdict.
|
||||
HUNT_BASE_S = 600
|
||||
HUNT_PER_REPETITION_S = 120
|
||||
|
||||
|
||||
def hunt_engine(binary: str, seal: Optional[str], label: str, seed: int, n: int, out_dir: Path, python: Optional[str] = None) -> int:
|
||||
"""``hunt_run`` in a process of its own, as ``run_engine`` runs ``run``: each engine its own seal and its own cache."""
|
||||
env = engine_env(seal, python)
|
||||
command = [python or sys.executable, "-u", str(Path(__file__).resolve()), "hunt-run", "--binary", binary, "--label", label, "--seed", str(seed), "--n", str(n), "--out", str(out_dir)]
|
||||
print("=== hunt %s: %s (seal %s), %d repetitions of the WebRTC walk of seed %d" % (label, binary, seal or "the one this process has", n, seed))
|
||||
sys.stdout.flush()
|
||||
from ci_ab_oracle import own_cache_env
|
||||
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="ab-network-cache-") as cache:
|
||||
return subprocess.run(command, env=own_cache_env(env, cache), timeout=HUNT_BASE_S + n * HUNT_PER_REPETITION_S).returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
return 124
|
||||
|
||||
|
||||
def published_engine(args: argparse.Namespace, work: Path) -> Tuple[str, Optional[str], Optional[str]]:
|
||||
"""The published engine of an ``ab``: the binary the caller gave (run as this process is), or the one the published set fetches with its own core (its seal and its
|
||||
python: the control side runs in that venv)."""
|
||||
if args.published_binary:
|
||||
return str(args.published_binary), (str(args.published_seal) if args.published_seal else None), None
|
||||
import ci_ab_oracle as oracle
|
||||
|
||||
binary, seal, python = oracle.split_published(oracle.fetch_published(args.engine_tag, work))
|
||||
return binary, (str(seal) if seal else None), python
|
||||
|
||||
|
||||
def cmd_hunt(args: argparse.Namespace, spec: str) -> int:
|
||||
"""``ab`` with ``AB_NETWORK_HUNT=webrtc:<seed>:<n>``: the WebRTC walk of that seed, ``n`` times, for each engine of the A/A (the published engine twice), written to ``<out>/hunt``:
|
||||
``<engine>-<i>.json`` per repetition and ``summary.json``. It decides nothing and exits 0 (2 only for a spec that does not read)."""
|
||||
try:
|
||||
_walk, seed, n = parse_hunt(spec)
|
||||
except ValueError as exc:
|
||||
print("FAIL " + str(exc))
|
||||
return 2
|
||||
out = Path(args.out) / "hunt"
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-network-"))
|
||||
try:
|
||||
binary, seal, python = published_engine(args, work)
|
||||
for label in (args.engine_tag, args.engine_tag + "-again"):
|
||||
code = hunt_engine(binary, seal, label, seed, n, out, **({"python": python} if python else {}))
|
||||
if code != 0:
|
||||
print("hunt %s ended with %s" % (label, code))
|
||||
summary = hunt_summary(read_hunt_records(out))
|
||||
write_json(out / "summary.json", summary)
|
||||
for r in summary["repetitions"]:
|
||||
print("hunt %s %d: %d to the TURN server (%d with the late ones); %s" % (r["engine"], r["i"], r["count_3478"], r["count_3478_all"], r["targets"].get(TURN_TARGET)))
|
||||
print("hunt summary written: %s" % (out / "summary.json"))
|
||||
return 0
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
|
||||
|
||||
def compare_files(a: Path, b: Path, out: Optional[Path], floor: int, volatile_path: Path, control: bool) -> Dict[str, Any]:
|
||||
ta, tb = read_transcript(a), read_transcript(b)
|
||||
report = compare_transcripts(ta, tb, load_volatile(volatile_path), floor, ta.get("label", "A"), tb.get("label", "B"))
|
||||
@@ -2231,13 +1757,6 @@ def compare_files(a: Path, b: Path, out: Optional[Path], floor: int, volatile_pa
|
||||
|
||||
|
||||
def cmd_ab(args: argparse.Namespace) -> int:
|
||||
if args.engine_tag is None:
|
||||
from ci_ab_oracle import default_tag
|
||||
|
||||
args.engine_tag = default_tag()
|
||||
spec = os.environ.get(HUNT_ENV)
|
||||
if spec:
|
||||
return cmd_hunt(args, spec)
|
||||
out = Path(args.out)
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
seeds = parse_seeds(args.seeds)
|
||||
@@ -2249,12 +1768,18 @@ def cmd_ab(args: argparse.Namespace) -> int:
|
||||
return 2
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-network-"))
|
||||
try:
|
||||
binary, seal, python = published_engine(args, work)
|
||||
if args.published_binary:
|
||||
binary, seal = str(args.published_binary), (str(args.published_seal) if args.published_seal else None)
|
||||
else:
|
||||
import ci_ab_oracle as oracle
|
||||
|
||||
binary, seal = oracle.fetch_published(args.engine_tag, work)
|
||||
seal = str(seal)
|
||||
tag = args.engine_tag.rsplit("-", 1)[-1]
|
||||
first, again = out / ("transcript-%s.json" % tag), out / ("transcript-%s-again.json" % tag)
|
||||
problems = []
|
||||
for path, label in ((first, args.engine_tag), (again, args.engine_tag + "-again")):
|
||||
if run_engine(binary, seal, label, seeds, path, **({"python": python} if python else {})) != 0 or not path.is_file():
|
||||
if run_engine(binary, seal, label, seeds, path) != 0 or not path.is_file():
|
||||
problems.append("the run %s did not produce a transcript" % label)
|
||||
if problems:
|
||||
print("\n".join("FAIL " + p for p in problems))
|
||||
@@ -2285,12 +1810,6 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
r.add_argument("--label", default="engine")
|
||||
r.add_argument("--seeds", default=None)
|
||||
r.add_argument("--out", type=Path, required=True)
|
||||
h = sub.add_parser("hunt-run", help="one engine: the WebRTC walk of one seed, n times (what AB_NETWORK_HUNT makes `ab` run)")
|
||||
h.add_argument("--binary", required=True)
|
||||
h.add_argument("--label", required=True)
|
||||
h.add_argument("--seed", type=int, required=True)
|
||||
h.add_argument("--n", type=int, required=True)
|
||||
h.add_argument("--out", type=Path, required=True)
|
||||
c = sub.add_parser("compare", help="two transcripts: the diff and the leaf count")
|
||||
c.add_argument("a", type=Path)
|
||||
c.add_argument("b", type=Path)
|
||||
@@ -2307,7 +1826,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
a.add_argument("--candidate-seal", default=os.environ.get("INVISIBLE_SEAL_FILE"))
|
||||
a.add_argument("--published-binary", type=Path, default=None, help="use this binary as the published engine instead of fetching it")
|
||||
a.add_argument("--published-seal", type=Path, default=None)
|
||||
a.add_argument("--engine-tag", default=None, help="the label of the control side (default: the tag the published set's seal names)")
|
||||
a.add_argument("--engine-tag", default=ENGINE_TAG)
|
||||
a.add_argument("--seeds", default=None)
|
||||
a.add_argument("--floor", type=int, default=0)
|
||||
a.add_argument("--volatile", type=Path, default=VOLATILE_FILE)
|
||||
@@ -2316,8 +1835,6 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
args = ap.parse_args(argv)
|
||||
if args.cmd == "run":
|
||||
return run(args.binary, args.label, parse_seeds(args.seeds), args.out)
|
||||
if args.cmd == "hunt-run":
|
||||
return hunt_run(args.binary, args.label, args.seed, args.n, args.out)
|
||||
if args.cmd == "compare":
|
||||
return judge(compare_files(args.a, args.b, args.out, args.floor, args.volatile, args.a_a), args.a_a)
|
||||
if args.cmd == "judge":
|
||||
|
||||
+71
-200
@@ -3,19 +3,17 @@
|
||||
|
||||
A page reads the same values from two engines that differ only by the work of one
|
||||
release. This runs the host gate's dump (scripts/ci_host_gate.py dump: the page in
|
||||
scripts/host_gate, whole APIs) twice on the SAME machine, each engine with ITS OWN core and wrapper
|
||||
(the published engine with the published set, the candidate with core_ref and wrapper_ref), over the persona seeds (ci/persona-seeds.json, computed by scripts/persona_cover.py
|
||||
scripts/host_gate, whole APIs) twice on the SAME machine, with the same core and the same
|
||||
wrapper, over the persona seeds (ci/persona-seeds.json, computed by scripts/persona_cover.py
|
||||
from the prefs the core emits: the `candidate` set, 5 seeds that reach every webgl renderer
|
||||
and every DPR, or the `final` set, 20 seeds that reach every value of every dimension). Each
|
||||
seed runs at its OWN DPR (nothing is pinned):
|
||||
|
||||
1. with the published engine: the one the PUBLISHED SET carries (scripts/ci_published_set.py:
|
||||
the last wrapper on the index, the core it pins, the engine that core's seal pins). The
|
||||
set's venv fetches its own engine the way a user's core does (ensure_binary under its
|
||||
own seal, which checks the sha256 of the archive and the engine against the seal) and
|
||||
the dump runs in that venv: the engine is launched by the core it was built for;
|
||||
2. with the candidate binary the gate already holds, under its own seal, in the venv of
|
||||
the job (core_ref, wrapper_ref).
|
||||
1. with the published engine (firefox-68 by default): its seal and its archive are
|
||||
downloaded the way the core downloads an engine (the release's seal.json, then
|
||||
invisible_core.download.ensure_binary under that seal, which checks the sha256 of
|
||||
the archive against the seal and the engine against the seal);
|
||||
2. with the candidate binary the gate already holds, under its own seal.
|
||||
|
||||
The dump also reads what the host gate's retail comparison leaves alone, the ab. leaves (ci_host_gate.is_ab): ab.poison on every seed (zone, language, colour scheme, a
|
||||
canary font and the audio context, which scripts/ci_poison_host.py holds to the declared identity on a poisoned host) and, on seeds 0 and 63, the extra visit of every realm and
|
||||
@@ -29,15 +27,8 @@ the two values and the seed. It is also red when a visit is missing on one side,
|
||||
visit compares fewer leaves than MIN_LEAVES says: a page that dumped less than the host gate's
|
||||
own reference would pass anything.
|
||||
|
||||
DECLARED DIFFERENCES. ci/ab-oracle-expected.json (format ab-oracle-expected/1) lists, one row per os x seed x dpr x leaf, the differences between the published engine and the candidate that a
|
||||
release is known to make, each with the two values and the reason. They are applied to the A/B only, never to the A/A (the engine against itself has none). A difference is allowed only
|
||||
when a row matches it exactly: the same os (the leg's), seed, dpr and leaf, and both values. Any other difference is red, and so is a row that does not show in the run (its os, a visit the
|
||||
run made, and no matching difference): it is STALE and the verdict says "remove it". The rows say what the published engine reads and what the candidate reads, never a tag: when the published set
|
||||
moves to the release that holds the candidate's work, the two sides agree on those leaves, every row is stale, and the stale check forces them out. A row for a visit this run did not make (another
|
||||
shard, another seed set) is not judged here.
|
||||
|
||||
python ci_ab_oracle.py run <candidate-firefox> --candidate-seal gate.seal.json \\
|
||||
--leg linux-x86_64 --out ab-oracle [--engine-tag <the set's tag>] [--seed-set candidate|final] [--shard i/n]
|
||||
--leg linux-x86_64 --out ab-oracle [--engine-tag firefox-68] [--seed-set candidate|final] [--shard i/n]
|
||||
python ci_ab_oracle.py run --published-binary <firefox> --leg linux-x86_64 --out ab-oracle --limit 2 (the A/A alone)
|
||||
python ci_ab_oracle.py compare ab-oracle [--a-a] [--seed-set ...] [--shard i/n] (again, from the dumps)
|
||||
|
||||
@@ -92,21 +83,11 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import ci_crash_evidence as crash # noqa: E402
|
||||
import ci_host_gate as gate # noqa: E402
|
||||
import ci_published_set as published_set # noqa: E402
|
||||
import persona_cover as personas # noqa: E402
|
||||
|
||||
FORMAT = "ab-oracle/1"
|
||||
EXPECTED_FORMAT = "ab-oracle-expected/1"
|
||||
EXPECTED_FILE = Path(__file__).resolve().parents[1] / "ci" / "ab-oracle-expected.json"
|
||||
#: What a row of the file has, and nothing else.
|
||||
EXPECTED_KEYS = ("id", "os", "seed", "dpr", "leaf", "published", "candidate", "reason")
|
||||
#: The legs the gate runs, and the os a row names for each.
|
||||
LEG_OS = {"linux-x86_64": "linux", "win-x86_64": "windows"}
|
||||
#: The control side is the PUBLISHED SET (scripts/ci_published_set.py): the wrapper the index published last, the core that wrapper pins, and the engine that core's seal pins, in a venv
|
||||
#: of their own. The variable names that venv's python; the job sets it (or the oracle's test makes the venv from the run's wheelhouse). No tag is written in this file: the engine the
|
||||
#: candidate is held to is the one the set carries, so a new release is the new baseline.
|
||||
PUBLISHED_PYTHON_ENV = "INVPW_PUBLISHED_PYTHON"
|
||||
SET_SCRIPT = Path(__file__).resolve().parent / "ci_published_set.py"
|
||||
#: The engine the candidate is held to: the last one published.
|
||||
ENGINE_TAG = "firefox-68"
|
||||
CANDIDATE = "candidate"
|
||||
#: What the host gate's own reference holds per visit (non-diag leaves at each DPR, today).
|
||||
#: A visit that compares fewer leaves than this is red. Moves by hand with the reference
|
||||
@@ -211,68 +192,8 @@ def tab_crashes(leaves: dict) -> list:
|
||||
return [(launch, f.get("error"), f.get("step")) for (_second, launch), f in sorted(found.items())]
|
||||
|
||||
|
||||
def os_of_leg(leg: str) -> str:
|
||||
"""The os a row of the declared differences names for this leg ("linux-x86_64" is linux, "win-x86_64" is windows); any other leg is refused."""
|
||||
if leg not in LEG_OS:
|
||||
raise SystemExit("--leg is one of %s, not %r: the declared differences are per os" % ("/".join(sorted(LEG_OS)), leg))
|
||||
return LEG_OS[leg]
|
||||
|
||||
|
||||
def load_expected(path: Path | None = None) -> list:
|
||||
"""The rows of ci/ab-oracle-expected.json (EXPECTED_FILE when no path is given). Refused: another format, a row that does not have exactly EXPECTED_KEYS, an os that is not
|
||||
linux or windows, an empty reason, two rows with one id or with one (os, seed, dpr, leaf)."""
|
||||
path = Path(path or EXPECTED_FILE)
|
||||
document = json.loads(path.read_text(encoding="utf-8"))
|
||||
if document.get("format") != EXPECTED_FORMAT:
|
||||
raise SystemExit("%s is not an %s file" % (path, EXPECTED_FORMAT))
|
||||
rows, ids, places = document["differences"], set(), set()
|
||||
for row in rows:
|
||||
if sorted(row) != sorted(EXPECTED_KEYS):
|
||||
raise SystemExit("%s: the row %r has the keys %s, it must have exactly %s" % (path, row.get("id"), sorted(row), sorted(EXPECTED_KEYS)))
|
||||
if row["os"] not in LEG_OS.values():
|
||||
raise SystemExit("%s: the row %r names the os %r, it is linux or windows" % (path, row["id"], row["os"]))
|
||||
if not str(row["reason"]).strip():
|
||||
raise SystemExit("%s: the row %r has no reason" % (path, row["id"]))
|
||||
place = (row["os"], row["seed"], row["dpr"], row["leaf"])
|
||||
if row["id"] in ids or place in places:
|
||||
raise SystemExit("%s: the row %r is declared twice (by id, or by os, seed, dpr and leaf)" % (path, row["id"]))
|
||||
ids.add(row["id"])
|
||||
places.add(place)
|
||||
return rows
|
||||
|
||||
|
||||
def _same_value(a, b) -> bool:
|
||||
"""Equal as JSON says it (1 is not true, a list is its elements in order)."""
|
||||
return json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True)
|
||||
|
||||
|
||||
def declared_covers(entry: dict, os_name: str, diff: dict) -> bool:
|
||||
"""A row covers a difference only when os, seed, dpr, leaf and BOTH values are the row's."""
|
||||
return (entry["os"] == os_name and entry["seed"] == diff["seed"] and entry["dpr"] == diff["dpr"] and entry["leaf"] == diff["leaf"]
|
||||
and _same_value(entry["published"], diff["a"]) and _same_value(entry["candidate"], diff["b"]))
|
||||
|
||||
|
||||
def apply_declared(differences: list, declared: list, os_name: str, seen: set, expected) -> tuple:
|
||||
"""(the differences no row covers, the differences the rows cover with the id of the row, the stale rows).
|
||||
|
||||
A row is judged only when it names this os and a visit this run asked for and both sides have (`seen`); it is stale when no difference of the run is exactly its own."""
|
||||
left, covered, stale = list(differences), [], []
|
||||
for entry in declared:
|
||||
visit = (entry["dpr"], entry["seed"])
|
||||
if entry["os"] != os_name or visit not in expected or visit not in seen:
|
||||
continue
|
||||
hit = [d for d in left if declared_covers(entry, os_name, d)]
|
||||
if not hit:
|
||||
stale.append(entry)
|
||||
for d in hit:
|
||||
left.remove(d)
|
||||
covered.append(dict(d, id=entry["id"]))
|
||||
return left, covered, stale
|
||||
|
||||
|
||||
def compare_visits(a: dict, b: dict, noise: list, min_leaves: dict | None = None,
|
||||
expected: tuple | None = None, relaunch: tuple | None = None,
|
||||
declared: list | None = None, os_name: str | None = None) -> dict:
|
||||
expected: tuple | None = None, relaunch: tuple | None = None) -> dict:
|
||||
"""a and b map (dpr, seed) to the items of that visit (as the dump returns them).
|
||||
|
||||
Returns the report: {"verdict": "green"|"red", "problems": [str], "differences":
|
||||
@@ -281,12 +202,7 @@ def compare_visits(a: dict, b: dict, noise: list, min_leaves: dict | None = None
|
||||
fewest leaves a visit of that dpr may compare; `expected` is the visits both sides must have
|
||||
(default: every seed at every DPR of the host gate). `relaunch` is the visits that were launched twice on one profile (default: those of RELAUNCH_SEED among the expected ones): each side must have the
|
||||
second launch's leaves (prefix `relaunch.`) in them, as many as the floor, counted apart (report["relaunch"]), and a side must not have them in a visit that
|
||||
was not asked to.
|
||||
|
||||
`declared` is the rows of ci/ab-oracle-expected.json, applied only with the `os_name` of the leg: the A/B passes them, the A/A never does. A difference that a row covers exactly
|
||||
is not a problem and is listed in report["declared"] with the row's id; a row that this run does not show is a problem (stale) and its id is in report["stale"]."""
|
||||
if declared and os_name is None:
|
||||
raise ValueError("declared differences are per os: say which (os_name)")
|
||||
was not asked to."""
|
||||
min_leaves = MIN_LEAVES if min_leaves is None else min_leaves
|
||||
if expected is None:
|
||||
expected = tuple((dpr, seed) for dpr in gate.DPRS for seed in gate.SEEDS)
|
||||
@@ -346,14 +262,10 @@ def compare_visits(a: dict, b: dict, noise: list, min_leaves: dict | None = None
|
||||
" (the %d leaves of this visit that the tab could not read, or that only the other side has, are not compared)" % cascade[visit_name(c["dpr"], c["seed"])]
|
||||
if visit_name(c["dpr"], c["seed"]) in cascade else "") for c in crashes]
|
||||
problems = tab_lines + problems # the tab crash is the first line of the verdict, before anything it caused
|
||||
covered, stale = [], []
|
||||
if declared:
|
||||
differences, covered, stale = apply_declared(differences, declared, os_name, {k for k in a if k in b}, expected)
|
||||
problems += ["the declared difference %r (%s) does not show in this run: it is stale, remove it" % (e["id"], e["reason"]) for e in stale]
|
||||
for d in differences:
|
||||
problems.append("seed %d dpr %s %s: %s" % (d["seed"], d["dpr"], d["leaf"], d["what"]))
|
||||
return {"verdict": "red" if problems else "green", "problems": problems, "differences": differences, "tab_crashes": crashes,
|
||||
"compared": compared, "relaunch": relaunched, "excused": excused, "declared": covered, "stale": [e["id"] for e in stale]}
|
||||
"compared": compared, "relaunch": relaunched, "excused": excused}
|
||||
|
||||
|
||||
# -
|
||||
@@ -380,9 +292,8 @@ def unpack(document: dict) -> dict:
|
||||
|
||||
|
||||
def judge(published: dict, candidate: dict, noise: list, extra_problems=(), expected: tuple | None = None,
|
||||
relaunch: tuple | None = None, declared: list | None = None, os_name: str | None = None) -> dict:
|
||||
"""The verdict on two sets of visits. `declared` and `os_name` are the A/B's: the rows of ci/ab-oracle-expected.json and the os of the leg; the A/A is judged without them."""
|
||||
report = compare_visits(published, candidate, noise, expected=expected, relaunch=relaunch, declared=declared, os_name=os_name)
|
||||
relaunch: tuple | None = None) -> dict:
|
||||
report = compare_visits(published, candidate, noise, expected=expected, relaunch=relaunch)
|
||||
if extra_problems:
|
||||
crashed = [x for x in report["problems"] if x.startswith(TAB_CRASH)] # a tab that died is named before the exit code of the dump it left
|
||||
report["problems"] = crashed + list(extra_problems) + report["problems"][len(crashed):]
|
||||
@@ -401,11 +312,6 @@ def print_report(report: dict, published: str, other: str = CANDIDATE, title: st
|
||||
report["excused"]))
|
||||
if report.get("relaunch"):
|
||||
print("second launch on a reused profile, leaves per visit: %s" % ", ".join("%s %d" % kv for kv in sorted(report["relaunch"].items())))
|
||||
if report.get("declared"):
|
||||
print("%d differences declared in ci/ab-oracle-expected.json (the A/B only), each one exactly as its row says:" % len(report["declared"]))
|
||||
for d in report["declared"]:
|
||||
print("DECLARED %s seed %d dpr %s leaf %s: %s | %s" % (d["id"], d["seed"], d["dpr"], d["leaf"],
|
||||
json.dumps(d["a"], sort_keys=True)[:80], json.dumps(d["b"], sort_keys=True)[:80]))
|
||||
for d in report["differences"][:PRINT_LIMIT]:
|
||||
print("DIFF seed %d dpr %s leaf %s: %s %s | %s %s" % (d["seed"], d["dpr"], d["leaf"], published,
|
||||
json.dumps(d["a"], sort_keys=True)[:160],
|
||||
@@ -421,68 +327,35 @@ def print_report(report: dict, published: str, other: str = CANDIDATE, title: st
|
||||
# -
|
||||
# The run: two dumps, one per engine, as subprocesses (the seal a process runs under is read at import).
|
||||
|
||||
def published_python() -> str:
|
||||
"""The python of the published set's venv (INVPW_PUBLISHED_PYTHON). RuntimeError when there is none: a candidate held to a control that is not the published set is
|
||||
the broken control this file used to run (the candidate's core with the published engine, which refuses a launch whose declarations that core does not emit)."""
|
||||
python = os.environ.get(PUBLISHED_PYTHON_ENV)
|
||||
if not python or not Path(python).is_file():
|
||||
raise RuntimeError("%s names no python (%r): the control side of an A/B is the PUBLISHED SET in a venv of its own (scripts/ci_published_set.py install --house <the "
|
||||
"run's wheelhouse> --venv <dir>, then export the python it prints), never the core and the wrapper of the candidate" % (PUBLISHED_PYTHON_ENV, python))
|
||||
return python
|
||||
def fetch_published(tag: str, work: Path) -> tuple:
|
||||
"""(binary, seal path) of the published engine `tag`, fetched the way the core fetches an engine."""
|
||||
os.environ.setdefault("INVISIBLE_CORE_AUTOFIX", "off")
|
||||
os.environ.setdefault("INVISIBLE_CORE_PIN", "allow")
|
||||
from invisible_core import download
|
||||
from invisible_core.constants import RELEASE_URL_TEMPLATE
|
||||
from invisible_core.seal import load_seal
|
||||
|
||||
|
||||
def set_command(python: str, *argv: str) -> list:
|
||||
"""`python scripts/ci_published_set.py <argv>`, run BY the set's python: stdlib and its own invisible_core."""
|
||||
return [python, str(SET_SCRIPT)] + list(argv)
|
||||
|
||||
|
||||
def default_tag() -> str:
|
||||
"""The tag of the engine the control side runs: the one the seal of the published set's core names; without a set (a pull request, whose engine IS the published one and
|
||||
runs under the core the wrapper pins) the seal of the core of this process."""
|
||||
python = os.environ.get(PUBLISHED_PYTHON_ENV)
|
||||
if python and Path(python).is_file():
|
||||
done = subprocess.run(set_command(python, "tag"), capture_output=True, text=True, env=published_set.clean_env(), timeout=120)
|
||||
if done.returncode != 0:
|
||||
raise RuntimeError("the published set's core names no seal tag: %s" % (done.stderr or done.stdout)[-600:])
|
||||
return done.stdout.strip().splitlines()[-1]
|
||||
from invisible_core.seal import active_seal
|
||||
|
||||
return active_seal().tag
|
||||
|
||||
|
||||
def fetch_published(tag: str | None, work: Path) -> tuple:
|
||||
"""(binary, None, python) of the published set: the engine its own core fetches under its own seal, and the python that is its venv's. `tag`, when given, is held
|
||||
to the seal of the set (a label that names another engine than the one the set carries is a wrong control, said here)."""
|
||||
python = published_python()
|
||||
done = subprocess.run(set_command(python, "fetch", "--work", str(work)), capture_output=True, text=True, env=published_set.clean_env(), timeout=DUMP_TIMEOUT_S)
|
||||
if done.returncode != 0:
|
||||
raise RuntimeError("the published set could not fetch its engine (exit %s): %s" % (done.returncode, (done.stderr or done.stdout)[-800:]))
|
||||
fetched = json.loads(done.stdout.strip().splitlines()[-1])
|
||||
if tag and fetched["tag"] != tag:
|
||||
raise RuntimeError("the control is labelled %s but the published set carries %s" % (tag, fetched["tag"]))
|
||||
print("published engine %s: %s (core and wrapper of the published set, %s)" % (fetched["tag"], fetched["describe"], python))
|
||||
owner, repo = download._parse_owner_repo(RELEASE_URL_TEMPLATE)
|
||||
seal_path = work / ("seal-%s.json" % tag)
|
||||
sources = download.release_asset_urls(owner, repo, tag, "seal.json",
|
||||
RELEASE_URL_TEMPLATE.format(tag=tag, asset="seal.json"))
|
||||
download._download_file(sources, seal_path)
|
||||
seal = load_seal(seal_path)
|
||||
if seal.tag != tag or seal.is_local:
|
||||
raise SystemExit("the seal of the release %s says tag %r (local: %s)" % (tag, seal.tag, seal.is_local))
|
||||
print("published engine %s: %s" % (tag, seal.describe()))
|
||||
sys.stdout.flush()
|
||||
return fetched["binary"], None, python
|
||||
|
||||
|
||||
def process_env(seal, python: str | None = None) -> dict:
|
||||
"""The environment of a process that runs ONE engine: no autofix, no browser logging, and the seal of that engine. With `python` (the published set's venv) the process is the
|
||||
set's: nothing of the candidate's job that could make it import another core or run another seal reaches it, and the core's pin check stays ON (a set whose wrapper and
|
||||
core do not agree is refused, as it is on a user's machine). Without it (the candidate, or a pull request's published engine) it is as it always was."""
|
||||
if python:
|
||||
env = published_set.clean_env({"INVISIBLE_CORE_AUTOFIX": "off"})
|
||||
else:
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
if seal: # None: the engine runs under the seal of the core it is launched with (the published set's, a pull request's published engine)
|
||||
env["INVISIBLE_SEAL_FILE"] = str(seal)
|
||||
for name in ("MOZ_LOG", "MOZ_LOG_FILE"): # the e2e legs log the engine; a run is as the host gate's
|
||||
env.pop(name, None)
|
||||
return env
|
||||
|
||||
|
||||
def split_published(published: tuple) -> tuple:
|
||||
"""(binary, seal, python or None) of a `published` tuple: two items (a binary given, run in this process's environment) or three (the published set)."""
|
||||
return (published[0], published[1], published[2] if len(published) > 2 else None)
|
||||
# the engine store of this fetch only: the dumps that follow run under the environment they were given
|
||||
before = os.environ.get(download.ENGINE_DIR_ENV)
|
||||
os.environ[download.ENGINE_DIR_ENV] = str(work / "engines")
|
||||
try:
|
||||
binary = download.ensure_binary(seal=seal)
|
||||
finally:
|
||||
if before is None:
|
||||
os.environ.pop(download.ENGINE_DIR_ENV, None)
|
||||
else:
|
||||
os.environ[download.ENGINE_DIR_ENV] = before
|
||||
return str(binary), seal_path
|
||||
|
||||
|
||||
def own_cache_env(env: dict, folder: str, platform: str | None = None) -> dict:
|
||||
@@ -508,24 +381,27 @@ def own_cache_env(env: dict, folder: str, platform: str | None = None) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def dump_with_exits(name: str, exe: str, seal_file, leg: str, visits, target: Path, out: Path, python: str | None = None) -> tuple:
|
||||
def dump_with_exits(name: str, exe: str, seal_file, leg: str, visits, target: Path, out: Path) -> tuple:
|
||||
"""The dump of one engine run as `run_dump` makes it, with the folder where its probe writes how each browser ended (`<out>/crash/<name>`, named to the dump process by
|
||||
AB_CRASH_DIR): `(rc or "timeout", the red lines of the launches that did not end with 0, or that nobody saw)`. A dump process whose probe wrote nothing is red: an oracle
|
||||
that does not see how its browsers end does not see them."""
|
||||
crash_dir = out / "crash" / name
|
||||
try:
|
||||
with crash.environment(**{crash.CRASH_DIR_ENV: crash_dir}):
|
||||
rc = run_dump(exe, Path(seal_file) if seal_file else None, leg, target, visits, **({"python": python} if python else {}))
|
||||
rc = run_dump(exe, Path(seal_file) if seal_file else None, leg, target, visits)
|
||||
except subprocess.TimeoutExpired:
|
||||
rc = "timeout"
|
||||
return rc, crash.exits_of_run(crash_dir, name, windows=leg.startswith("win"), needed=(rc == 0))
|
||||
|
||||
|
||||
def run_dump(binary: str, seal: Path | None, leg: str, out: Path, visits: list | None = None, python: str | None = None) -> int:
|
||||
"""The host gate's dump of `visits` ([(dpr, seed)], each seed at its own DPR) as a subprocess; None is the host gate's own grid. `python` is the published set's: the
|
||||
dump of the control side runs in the venv that holds the published core and wrapper, never in the candidate's."""
|
||||
env = process_env(seal, python)
|
||||
cmd = [python or sys.executable, str(Path(gate.__file__)), "dump", binary, "--leg", leg, "--out", str(out)]
|
||||
def run_dump(binary: str, seal: Path | None, leg: str, out: Path, visits: list | None = None) -> int:
|
||||
"""The host gate's dump of `visits` ([(dpr, seed)], each seed at its own DPR) as a subprocess; None is the host gate's own grid."""
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
if seal is not None: # None: the engine runs under the seal of the core it is launched with (a pull request's published engine)
|
||||
env["INVISIBLE_SEAL_FILE"] = str(seal)
|
||||
for name in ("MOZ_LOG", "MOZ_LOG_FILE"): # the e2e legs log the engine; a dump runs as the host gate's does
|
||||
env.pop(name, None)
|
||||
cmd = [sys.executable, str(Path(gate.__file__)), "dump", binary, "--leg", leg, "--out", str(out)]
|
||||
if visits is not None:
|
||||
if relaunch_visits(visits):
|
||||
cmd += ["--relaunch-seed", str(RELAUNCH_SEED)]
|
||||
@@ -543,13 +419,13 @@ def run(candidate: str, candidate_seal: Path, leg: str, out: Path, engine_tag: s
|
||||
started = time.time()
|
||||
problems, dumps = [], {}
|
||||
try:
|
||||
binary, seal, python = split_published(published or fetch_published(engine_tag, work))
|
||||
for name, exe, seal_file, side_python in ((engine_tag, binary, seal, python), (CANDIDATE, candidate, candidate_seal, None)):
|
||||
binary, seal = published or fetch_published(engine_tag, work)
|
||||
for name, exe, seal_file in ((engine_tag, binary, seal), (CANDIDATE, candidate, candidate_seal)):
|
||||
target = work / name
|
||||
print("=== dump with %s: %s (seal %s), seeds %s"
|
||||
% (name, exe, seal_file, " ".join("%d@%s" % (seed, dpr) for dpr, seed in visits)))
|
||||
sys.stdout.flush()
|
||||
rc, exits = dump_with_exits(name, exe, seal_file, leg, visits, target, out, side_python)
|
||||
rc, exits = dump_with_exits(name, exe, seal_file, leg, visits, target, out)
|
||||
if rc != 0:
|
||||
problems.append("the dump with %s ended with %s" % (name, rc))
|
||||
problems += exits
|
||||
@@ -565,7 +441,7 @@ def run(candidate: str, candidate_seal: Path, leg: str, out: Path, engine_tag: s
|
||||
finally:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
noise = gate.load_exceptions().get("noise", [])
|
||||
report = judge(dumps[engine_tag], dumps[CANDIDATE], noise, problems, expected=tuple(visits), declared=load_expected(), os_name=os_of_leg(leg))
|
||||
report = judge(dumps[engine_tag], dumps[CANDIDATE], noise, problems, expected=tuple(visits))
|
||||
report.update(format=FORMAT, engine=engine_tag, leg=leg, seconds=round(time.time() - started),
|
||||
visits=["%d@%s" % (seed, dpr) for dpr, seed in visits])
|
||||
write_json(out / "diff.json", report)
|
||||
@@ -578,13 +454,13 @@ def again_name(engine_tag: str) -> str:
|
||||
return dump_name(engine_tag)[:-len(".json")] + "-again.json"
|
||||
|
||||
|
||||
def _dump_visits(name: str, exe: str, seal_file, leg: str, visits: list, work: Path, out: Path, file_name: str, python: str | None = None) -> tuple:
|
||||
def _dump_visits(name: str, exe: str, seal_file, leg: str, visits: list, work: Path, out: Path, file_name: str) -> tuple:
|
||||
"""One engine's dump of `visits`: ({(dpr, seed): items}, problems); the packed dump is written to out/file_name."""
|
||||
target = work / name
|
||||
print("=== dump with %s: %s (seal %s), seeds %s"
|
||||
% (name, exe, seal_file or "of the core", " ".join("%d@%s" % (seed, dpr) for dpr, seed in visits)))
|
||||
sys.stdout.flush()
|
||||
rc, exits = dump_with_exits(name, exe, seal_file, leg, visits, target, out, python)
|
||||
rc, exits = dump_with_exits(name, exe, seal_file, leg, visits, target, out)
|
||||
problems = ([] if rc == 0 else ["the dump with %s ended with %s" % (name, rc)]) + exits
|
||||
dumped = read_visits(target) if target.is_dir() else {}
|
||||
write_json(out / file_name, pack(name, dumped))
|
||||
@@ -596,8 +472,7 @@ def run_ab(leg: str, out: Path, engine_tag: str, published: tuple | None = None,
|
||||
"""The A/A (the published engine twice), then, with a candidate, the A/B against the first dump. 0 green, 1 a finding,
|
||||
2 a broken control (the A/A differs, or a dump of it did not run: the A/B is not run) .
|
||||
|
||||
`published` is (binary, seal or None) of a binary the caller gave, run in this process's environment, or (binary, None, python) of the published set; without it the
|
||||
set the job made (INVPW_PUBLISHED_PYTHON) fetches its own engine."""
|
||||
`published` is (binary, seal or None); without it the engine is fetched the way the core fetches one."""
|
||||
visits = select_visits() if visits is None else visits
|
||||
expected = tuple(visits)
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
@@ -607,9 +482,9 @@ def run_ab(leg: str, out: Path, engine_tag: str, published: tuple | None = None,
|
||||
asked = ["%d@%s" % (seed, dpr) for dpr, seed in visits]
|
||||
try:
|
||||
try:
|
||||
binary, seal, python = split_published(published or fetch_published(engine_tag, work))
|
||||
first, p1 = _dump_visits(engine_tag, binary, seal, leg, visits, work, out, dump_name(engine_tag), **({"python": python} if python else {}))
|
||||
again, p2 = _dump_visits(engine_tag + "-again", binary, seal, leg, visits, work, out, again_name(engine_tag), **({"python": python} if python else {}))
|
||||
binary, seal = published or fetch_published(engine_tag, work)
|
||||
first, p1 = _dump_visits(engine_tag, binary, seal, leg, visits, work, out, dump_name(engine_tag))
|
||||
again, p2 = _dump_visits(engine_tag + "-again", binary, seal, leg, visits, work, out, again_name(engine_tag))
|
||||
problems = p1 + p2
|
||||
except SystemExit:
|
||||
raise
|
||||
@@ -626,7 +501,7 @@ def run_ab(leg: str, out: Path, engine_tag: str, published: tuple | None = None,
|
||||
if candidate is None:
|
||||
return 0
|
||||
cand, pc = _dump_visits(CANDIDATE, candidate, candidate_seal, leg, visits, work, out, "dump-%s.json" % CANDIDATE)
|
||||
report = judge(first, cand, noise, pc, expected=expected, declared=load_expected(), os_name=os_of_leg(leg))
|
||||
report = judge(first, cand, noise, pc, expected=expected)
|
||||
report.update(format=FORMAT, engine=engine_tag, leg=leg, seconds=round(time.time() - started), visits=asked)
|
||||
write_json(out / "diff.json", report)
|
||||
print_report(report, engine_tag)
|
||||
@@ -646,8 +521,8 @@ def run_clean(leg: str, out: Path, engine_tag: str, visits: list, published: tup
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
work = Path(tempfile.mkdtemp(prefix="ab-oracle-clean-"))
|
||||
try:
|
||||
binary, seal, python = split_published(published or fetch_published(engine_tag, work))
|
||||
_, problems = _dump_visits(engine_tag + "-clean", binary, seal, leg, visits, work, out, clean_name(engine_tag), **({"python": python} if python else {}))
|
||||
binary, seal = published or fetch_published(engine_tag, work)
|
||||
_, problems = _dump_visits(engine_tag + "-clean", binary, seal, leg, visits, work, out, clean_name(engine_tag))
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception as e: # noqa: BLE001 - said, not raised: this is a by-product
|
||||
@@ -659,8 +534,7 @@ def run_clean(leg: str, out: Path, engine_tag: str, visits: list, published: tup
|
||||
return 1 if problems else 0
|
||||
|
||||
|
||||
def recompare(directory: Path, engine_tag: str, visits: list | None = None, a_a: bool = False, leg: str | None = None) -> int:
|
||||
"""`leg` (default: the os this runs on) says which rows of the declared differences apply to the A/B; the A/A takes none."""
|
||||
def recompare(directory: Path, engine_tag: str, visits: list | None = None, a_a: bool = False) -> int:
|
||||
visits = select_visits() if visits is None else visits
|
||||
published = unpack(json.loads((directory / dump_name(engine_tag)).read_text(encoding="utf-8")))
|
||||
if a_a:
|
||||
@@ -671,8 +545,7 @@ def recompare(directory: Path, engine_tag: str, visits: list | None = None, a_a:
|
||||
print_report(report, engine_tag, engine_tag + "-again", "AB ORACLE A/A")
|
||||
return 0 if report["verdict"] == "green" else 2
|
||||
candidate = unpack(json.loads((directory / ("dump-%s.json" % CANDIDATE)).read_text(encoding="utf-8")))
|
||||
leg = leg or ("win-x86_64" if sys.platform == "win32" else "linux-x86_64")
|
||||
report = judge(published, candidate, gate.load_exceptions().get("noise", []), expected=tuple(visits), declared=load_expected(), os_name=os_of_leg(leg))
|
||||
report = judge(published, candidate, gate.load_exceptions().get("noise", []), expected=tuple(visits))
|
||||
report.update(format=FORMAT, engine=engine_tag, visits=["%d@%s" % (seed, dpr) for dpr, seed in visits])
|
||||
write_json(directory / "diff.json", report)
|
||||
print_report(report, engine_tag)
|
||||
@@ -695,7 +568,7 @@ def main(argv=None) -> int:
|
||||
help="the candidate's seal (default: INVISIBLE_SEAL_FILE)")
|
||||
r.add_argument("--leg", required=True)
|
||||
r.add_argument("--out", type=Path, required=True)
|
||||
r.add_argument("--engine-tag", default=None, help="the label of the control side (default: the tag the published set's seal names)")
|
||||
r.add_argument("--engine-tag", default=ENGINE_TAG)
|
||||
r.add_argument("--seed-set", choices=SEED_SETS, default=SEED_SET,
|
||||
help="the persona seeds to visit (ci/persona-seeds.json), each at its own DPR")
|
||||
r.add_argument("--shard", help="i/n: every n-th seed of the set from the i-th (the final set over n jobs)")
|
||||
@@ -707,18 +580,17 @@ def main(argv=None) -> int:
|
||||
k = sub.add_parser("clean", help="the published engine's dump on this (clean) machine, for the poisoned run's by-product")
|
||||
k.add_argument("--leg", required=True)
|
||||
k.add_argument("--out", type=Path, required=True)
|
||||
k.add_argument("--engine-tag", default=None, help="the label of the control side (default: the tag the published set's seal names)")
|
||||
k.add_argument("--engine-tag", default=ENGINE_TAG)
|
||||
k.add_argument("--seed-set", choices=SEED_SETS, default=SEED_SET)
|
||||
k.add_argument("--shard")
|
||||
k.add_argument("--limit", type=int)
|
||||
c = sub.add_parser("compare")
|
||||
c.add_argument("directory", type=Path)
|
||||
c.add_argument("--engine-tag", default=None, help="the label of the control side (default: the tag the published set's seal names)")
|
||||
c.add_argument("--engine-tag", default=ENGINE_TAG)
|
||||
c.add_argument("--seed-set", choices=SEED_SETS, default=SEED_SET)
|
||||
c.add_argument("--shard")
|
||||
c.add_argument("--limit", type=int)
|
||||
c.add_argument("--a-a", action="store_true", help="compare the two dumps of the published engine (the control)")
|
||||
c.add_argument("--leg", help="the leg the dumps are of, which says the os of the declared differences (default: this machine's)")
|
||||
args = ap.parse_args(argv)
|
||||
if args.cmd == "touched":
|
||||
import ci_ab_pr_seeds as pr
|
||||
@@ -726,11 +598,10 @@ def main(argv=None) -> int:
|
||||
sys.stdout.reconfigure(newline="\n") # the line goes to $GITHUB_OUTPUT: a carriage return would be part of the value
|
||||
print("touched=%s" % ("true" if touched(pr.changed_files(args.base)) else "false"))
|
||||
return 0
|
||||
args.engine_tag = args.engine_tag or default_tag()
|
||||
if args.cmd == "clean":
|
||||
return run_clean(args.leg, args.out, args.engine_tag, select_visits(args.seed_set, args.shard, limit=args.limit))
|
||||
if args.cmd == "compare":
|
||||
return recompare(args.directory, args.engine_tag, select_visits(args.seed_set, args.shard, limit=args.limit), args.a_a, args.leg)
|
||||
return recompare(args.directory, args.engine_tag, select_visits(args.seed_set, args.shard, limit=args.limit), args.a_a)
|
||||
if args.published_seal and not args.published_binary:
|
||||
ap.error("--published-seal goes with --published-binary")
|
||||
if args.candidate:
|
||||
|
||||
@@ -28,10 +28,10 @@ ROOT = Path(__file__).resolve().parent.parent
|
||||
SHARED = ("scripts/ci_ab_oracle.py", "scripts/ci_crash_evidence.py", "scripts/ci_ab_pr_seeds.py", "scripts/persona_cover.py", "ci/persona-seeds.json")
|
||||
#: variable -> (oracle, seeds by default on a pull request that does not touch it, the files of the oracle: exact paths or fnmatch patterns).
|
||||
ORACLES = {
|
||||
"AB_ORACLE_PR_SEEDS": ("page", 2, SHARED + ("scripts/ci_host_gate.py", "scripts/ci_poison_host.py", "scripts/host_gate/*", "ci/ab-oracle-expected.json", "tests/test_ab_oracle*", "tests/test_ci_host_gate*",
|
||||
"AB_ORACLE_PR_SEEDS": ("page", 2, SHARED + ("scripts/ci_host_gate.py", "scripts/ci_poison_host.py", "scripts/host_gate/*", "tests/test_ab_oracle*", "tests/test_ci_host_gate*",
|
||||
"tests/test_ci_poison_host.py")),
|
||||
"AB_NETWORK_PR_SEEDS": ("network", 1, SHARED + ("scripts/ci_ab_network.py", "ci/ab-network-volatile.json", "tests/test_ab_network*")),
|
||||
"AB_HOST_PR_SEEDS": ("host", 2, SHARED + ("scripts/ci_ab_host.py", "tests/_strace_stand_in.py", "tests/_ab_host_declared.py", "ci/ab-host-expected.json", "tests/test_ab_host*")),
|
||||
"AB_HOST_PR_SEEDS": ("host", 2, SHARED + ("scripts/ci_ab_host.py", "tests/_strace_stand_in.py", "ci/ab-host-expected.json", "tests/test_ab_host*")),
|
||||
}
|
||||
FALLBACK_SEEDS = 5
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
"""Does a change have anything for a heavy workflow to test? The job `changes` of e2e.yml and of fakeweb.yml.
|
||||
|
||||
python scripts/ci_changes.py <e2e|fakeweb> <github.event_name> [BASE_SHA HEAD_SHA]
|
||||
|
||||
GitHub applies no `paths` filter to a merge queue run (`merge_group`), so without this a docs-only change would run the whole e2e and the whole fake web in
|
||||
the queue. In a queue run this lists the files that differ between the base and the head of the entry (`github.event.merge_group.base_sha` and
|
||||
`head_sha`) and applies the path rules the `push` trigger of the same workflow has, so the queue and main agree on what is worth a run:
|
||||
|
||||
e2e `paths-ignore`: a change runs it unless EVERY file matches IGNORE (`**.md`, `docs/**`, `LICENSE`);
|
||||
fakeweb `paths`: a change runs it only if SOME file matches ONLY (the fake web, its report, the pin, its workflow).
|
||||
|
||||
On any other event (push and workflow_dispatch: a push was already filtered by GitHub, a dispatch is a person asking) the answer is always `run=true`.
|
||||
|
||||
Prints `run=true|false` and `files=<n>` (the lines go to $GITHUB_OUTPUT). `run=false` is an explicit answer, "nothing to test": the verdict job of the workflow
|
||||
(scripts/ci_gate.py) then expects every other job `skipped` and says so in its last line; it is never a skip the verdict waves through. A change that cannot be
|
||||
listed (a commit that cannot be fetched) is an error: the job is red, and so is the verdict. A change that lists no file at all cannot be told from a broken
|
||||
diff, so it runs.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# e2e.yml `on.push.paths-ignore`: a change of only these files is not a change the browsers can observe (tests/test_the_workflows_are_ready_for_the_merge_queue.py
|
||||
# holds this table equal to the filter of the workflow).
|
||||
IGNORE = {
|
||||
"e2e": ("**.md", "docs/**", "LICENSE"),
|
||||
}
|
||||
# fakeweb.yml `on.push.paths`.
|
||||
ONLY = {
|
||||
"fakeweb": (
|
||||
"tests/fakeweb/**",
|
||||
"tests/test_fakeweb_*.py",
|
||||
"scripts/run_fakeweb.py",
|
||||
"scripts/fakeweb_p4_report.py",
|
||||
"scripts/playwright_pin.txt",
|
||||
".github/workflows/fakeweb.yml",
|
||||
),
|
||||
}
|
||||
WORKFLOWS = tuple(sorted(set(IGNORE) | set(ONLY)))
|
||||
|
||||
|
||||
def glob_regex(pattern: str) -> "re.Pattern[str]":
|
||||
"""A path filter of a workflow as a regular expression: `**` is any characters, `*` any characters but `/`, `?` one character but `/`."""
|
||||
out = []
|
||||
i = 0
|
||||
while i < len(pattern):
|
||||
if pattern.startswith("**", i):
|
||||
out.append(".*")
|
||||
i += 2
|
||||
continue
|
||||
char = pattern[i]
|
||||
out.append("[^/]*" if char == "*" else "[^/]" if char == "?" else re.escape(char))
|
||||
i += 1
|
||||
return re.compile("".join(out) + r"\Z")
|
||||
|
||||
|
||||
def matches(path: str, patterns) -> bool:
|
||||
return any(glob_regex(p).match(path) for p in patterns)
|
||||
|
||||
|
||||
def should_run(workflow: str, files: list) -> bool:
|
||||
"""Is there something in `files` (the paths a change touches) for `workflow` to test?"""
|
||||
if workflow not in WORKFLOWS:
|
||||
raise ValueError("unknown workflow %r (one of %s)" % (workflow, ", ".join(WORKFLOWS)))
|
||||
if not files:
|
||||
return True
|
||||
if workflow in IGNORE:
|
||||
return any(not matches(f, IGNORE[workflow]) for f in files)
|
||||
return any(matches(f, ONLY[workflow]) for f in files)
|
||||
|
||||
|
||||
def changed_files(base: str, head: str, run=subprocess.run) -> list:
|
||||
"""The files that differ between the base and the head of a queue entry (fetched when the shallow checkout does not have them)."""
|
||||
for sha in (base, head):
|
||||
if run(["git", "cat-file", "-e", sha + "^{commit}"], capture_output=True, text=True).returncode != 0:
|
||||
run(["git", "fetch", "--no-tags", "--depth=1", "origin", sha], check=True, capture_output=True, text=True)
|
||||
done = run(["git", "diff", "--name-only", base, head], check=True, capture_output=True, text=True)
|
||||
return [line.strip() for line in done.stdout.splitlines() if line.strip()]
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
args = sys.argv[1:] if argv is None else argv
|
||||
if len(args) not in (2, 4) or args[0] not in WORKFLOWS:
|
||||
print("usage: ci_changes.py <%s> EVENT_NAME [BASE_SHA HEAD_SHA]" % "|".join(WORKFLOWS), file=sys.stderr)
|
||||
return 2
|
||||
workflow, event = args[0], args[1]
|
||||
sys.stdout.reconfigure(newline="\n") # the lines go to $GITHUB_OUTPUT: a carriage return would be part of the value
|
||||
if event != "merge_group":
|
||||
print("%s: %s is not a merge queue run, it always runs" % (workflow, event or "no event"), file=sys.stderr)
|
||||
print("run=true")
|
||||
print("files=0")
|
||||
return 0
|
||||
if len(args) != 4 or not args[2] or not args[3]:
|
||||
print("FAIL changes: a merge queue run without the base and the head of its entry. Fix: pass github.event.merge_group.base_sha and head_sha", file=sys.stderr)
|
||||
return 2
|
||||
files = changed_files(args[2], args[3])
|
||||
run = should_run(workflow, files)
|
||||
print("%s: %d files changed, %s" % (workflow, len(files), "something to test" if run else "none under its paths: nothing to test"), file=sys.stderr)
|
||||
for name in files[:20]:
|
||||
print(" " + name, file=sys.stderr)
|
||||
print("run=%s" % ("true" if run else "false"))
|
||||
print("files=%d" % len(files))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,193 @@
|
||||
"""The verdict job of a workflow that gates a merge: every job it waits for must have ended in `success`.
|
||||
|
||||
NEEDS='<toJSON(needs)>' EVENT_NAME=<github.event_name> WORKFLOW=<tests|e2e|fakeweb> [CHANGES_RUN=<needs.changes.outputs.run>] python scripts/ci_gate.py
|
||||
|
||||
Three workflows have one: the job `gate` of tests.yml, `e2e verdict` of e2e.yml and `fakeweb verdict` of fakeweb.yml. WORKFLOW (default `tests`) picks
|
||||
the tables that belong to the workflow. A pull request runs the fast set (tests.yml); e2e.yml and fakeweb.yml run in the merge queue run
|
||||
(`merge_group`), and that run decides. `gate` is the one context main requires on a pull request.
|
||||
|
||||
Rule ci-13: nothing counts as passed that did not pass, so `skipped`, `cancelled` and `failure` are all red. A job that was skipped ran nothing: when
|
||||
`unit` was skipped for a core that was not on the index, the old gate said "ok".
|
||||
|
||||
The only jobs that may end in something else than `success` are the ones that are conditional BY DESIGN, and each says when:
|
||||
|
||||
* CONDITIONAL: the events on which the job runs; on any other event it is expected to be `skipped`, and on those events it must be `success`;
|
||||
* E2E_BY_OUTPUT: a job that runs only when another job of the workflow says so by an output (the final-seed shards, when the page oracle is touched);
|
||||
* E2E_NARROWED: what `workflow_dispatch` with `only: windows-control-a` leaves out on purpose (that run is the Windows job of one shortcut alone).
|
||||
|
||||
* NOTHING TO TEST: e2e.yml and fakeweb.yml start with the job `changes` (scripts/ci_changes.py: in a merge queue run, do the files of the entry fall under the
|
||||
paths of the workflow?). Its output `run` comes in as CHANGES_RUN. `run=false` is an explicit answer: `changes` must be `success` and every other job
|
||||
`skipped` (a job that ran anyway is red, so is one that is `success` here), and the verdict ends with `ok: nothing to test (<n> files changed, none under the
|
||||
paths of <workflow>)`. `run=true`: every job as above. A `run` that is missing or is not `true` or `false` is red: nothing is judged on a guess.
|
||||
|
||||
Nothing else is forgiven, and a job the workflow waits for that the table does not know is red as well (the table and the `needs:` of the verdict job
|
||||
cannot drift apart without tests/test_the_gate_is_red_when_a_needed_job_is_skipped.py and tests/test_the_workflows_are_ready_for_the_merge_queue.py
|
||||
saying so).
|
||||
|
||||
Prints one line per job that is not as expected, `FAIL <verdict job>: job <name> is <result>. Fix: <how>. Rule: ci-13 ...`, and exits 1; prints `ok` and
|
||||
exits 0 when every job is.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
RULE = "ci-13 nothing counts as passed that did not pass"
|
||||
|
||||
_CHANGES = "open the job `changes` and fix scripts/ci_changes.py (or the diff it lists): it must succeed and print run=true|false"
|
||||
_CORE = "wait for the publish of the pinned invisible-core to finish, or pin a published core, then re-run"
|
||||
|
||||
# tests.yml: the jobs `gate` waits for, each with what to do when it is not green.
|
||||
FIX = {
|
||||
"core-on-index": _CORE,
|
||||
"unit": "open the job pytest of the failing system and fix its test; when it is skipped, fix the job it needs (core-on-index) first",
|
||||
"docs-api": "open the job and fix the guide that names an API that does not exist; when it is skipped, fix core-on-index first",
|
||||
"english": "open the job and translate the lines it names; when it is skipped, fix core-on-index first",
|
||||
"claims": "open the job and fix the README sentence no measurement supports; when it is skipped, fix core-on-index first",
|
||||
"way-in": "open the job and make the install instruction uv; when it is skipped, fix core-on-index first",
|
||||
"install-job": "open the job and fix the user-install workflow; when it is skipped, fix core-on-index first",
|
||||
"noreply-identity": "open the job and rewrite the commit or tag whose email is not a GitHub noreply address",
|
||||
"version": "bump the version in pyproject.toml: the one this change proposes is already published",
|
||||
}
|
||||
|
||||
# Conditional by design: job -> the events on which it runs. On any other event it must be `skipped`.
|
||||
CONDITIONAL = {
|
||||
# `version` runs where a change is proposed: on a pull request and in the merge queue run (it compares the version the change proposes with the
|
||||
# published one, so it must run in the queue too). On main straight after a release the version IS the published one until somebody bumps, and a
|
||||
# check that is red at rest is one people learn to skip. So a push to main skips it on purpose.
|
||||
"version": ("pull_request", "merge_group"),
|
||||
}
|
||||
|
||||
# e2e.yml: the jobs `e2e verdict` waits for.
|
||||
E2E_FIX = {
|
||||
"changes": _CHANGES,
|
||||
"core-on-index": _CORE,
|
||||
"linux-deps-e2e": "open the job linux-deps-e2e and fix the package list of the Linux jobs; when it is skipped, fix core-on-index first",
|
||||
"e2e-linux": "open the failing part of `e2e (linux, part N)` and fix its test; when it is skipped, fix core-on-index or linux-deps-e2e first",
|
||||
"e2e": "open the job `e2e (linux, xvfb)`: one of the three Linux parts did not pass",
|
||||
"e2e-windows-control-a": "open the job `e2e (windows, Control+A)` and fix the shortcut test",
|
||||
"e2e-windows": "open the failing part of `e2e (windows, part N)` and fix its test; when it is skipped, fix core-on-index first",
|
||||
"e2e-network": "open the job of the network oracle on Linux and fix its test; when it is skipped, fix core-on-index or linux-deps-e2e first",
|
||||
"e2e-network-windows": "open the job of the network oracle on Windows and fix its test; when it is skipped, fix core-on-index first",
|
||||
"e2e-host": "open the job of the host oracle on Linux and fix its test; when it is skipped, fix core-on-index or linux-deps-e2e first",
|
||||
"e2e-host-windows": "open the job of the host oracle on Windows and fix its test; when it is skipped, fix core-on-index first",
|
||||
"e2e-page": "open the job of the page oracle on Linux and fix its test; when it is skipped, fix core-on-index or linux-deps-e2e first",
|
||||
"e2e-page-windows": "open the job of the page oracle on Windows and fix its test; when it is skipped, fix core-on-index first",
|
||||
"e2e-page-final-touched": "open the job and fix scripts/ci_ab_oracle.py touched: in the merge queue run it must print touched=true|false",
|
||||
"e2e-page-final": "open the failing shard of the page oracle on the final seeds (linux) and fix its test; when it is skipped, fix the job that decides it",
|
||||
"e2e-page-final-windows": "open the failing shard of the page oracle on the final seeds (windows) and fix its test; when it is skipped, fix the job that decides it",
|
||||
}
|
||||
E2E_CONDITIONAL = {
|
||||
# The base of the change is the one of the merge queue entry (`github.event.merge_group.base_sha`): the job runs there and nowhere else.
|
||||
"e2e-page-final-touched": ("merge_group",),
|
||||
}
|
||||
# A job that runs only when another job says so: job -> (the job that decides, its output, the value that makes it run). Otherwise it is `skipped`.
|
||||
E2E_BY_OUTPUT = {
|
||||
"e2e-page-final": ("e2e-page-final-touched", "touched", "true"),
|
||||
"e2e-page-final-windows": ("e2e-page-final-touched", "touched", "true"),
|
||||
}
|
||||
# What `workflow_dispatch` with `only: windows-control-a` skips on purpose: every job but the two that run it.
|
||||
E2E_NARROWED = tuple(sorted(set(E2E_FIX) - {"changes", "core-on-index", "e2e-windows-control-a"}))
|
||||
|
||||
# fakeweb.yml: every job runs on every event the workflow listens to.
|
||||
FAKEWEB_FIX = {
|
||||
"changes": _CHANGES,
|
||||
"core-on-index": _CORE,
|
||||
"linux-deps-fakeweb": "open the job linux-deps-fakeweb and fix the package list; when it is skipped, fix core-on-index first",
|
||||
"walk": "open the failing leg (`fakeweb p2` or `p4`, on linux or windows) and fix what differs from stock; when it is skipped, fix core-on-index first",
|
||||
}
|
||||
|
||||
# The workflows that start with the job `changes`, and the name of that job.
|
||||
CHANGES_JOB = "changes"
|
||||
HAS_CHANGES = ("e2e", "fakeweb")
|
||||
|
||||
# WORKFLOW -> (the name of the verdict job, its FIX table, its CONDITIONAL table).
|
||||
TABLES = {
|
||||
"tests": ("gate", FIX, CONDITIONAL),
|
||||
"e2e": ("e2e verdict", E2E_FIX, E2E_CONDITIONAL),
|
||||
"fakeweb": ("fakeweb verdict", FAKEWEB_FIX, {}),
|
||||
}
|
||||
|
||||
|
||||
def expected_result(name: str, needs: dict, event: str, workflow: str = "tests", only: str = "", changes_run: str = "true") -> str:
|
||||
"""`success`, or `skipped` for a job that is conditional by design on this event (or on this input, or on the output of another job, or because
|
||||
`changes` said there is nothing to test)."""
|
||||
conditional = TABLES[workflow][2]
|
||||
if workflow in HAS_CHANGES and name != CHANGES_JOB and changes_run == "false":
|
||||
return "skipped"
|
||||
if workflow == "e2e":
|
||||
if only == "windows-control-a" and name in E2E_NARROWED:
|
||||
return "skipped"
|
||||
if name in E2E_BY_OUTPUT:
|
||||
decider, output, value = E2E_BY_OUTPUT[name]
|
||||
entry = needs.get(decider)
|
||||
outputs = entry.get("outputs") if isinstance(entry, dict) else None
|
||||
ran = isinstance(outputs, dict) and outputs.get(output) == value
|
||||
return "success" if ran else "skipped"
|
||||
if name in conditional and event not in conditional[name]:
|
||||
return "skipped"
|
||||
return "success"
|
||||
|
||||
|
||||
def nothing_to_test(needs: dict, workflow: str) -> str:
|
||||
"""The last line of a verdict whose `changes` job said there is nothing to test."""
|
||||
entry = needs.get(CHANGES_JOB)
|
||||
outputs = entry.get("outputs") if isinstance(entry, dict) else None
|
||||
files = outputs.get("files") if isinstance(outputs, dict) else None
|
||||
count = files if isinstance(files, str) and files.isdigit() else "?"
|
||||
return "ok: nothing to test (%s files changed, none under the paths of %s)" % (count, workflow)
|
||||
|
||||
|
||||
def verdict(needs: dict, event: str, workflow: str = "tests", only: str = "", changes_run: "str | None" = None) -> list[str]:
|
||||
"""The FAIL lines for the results of `needs` (the object `toJSON(needs)` gives) of `workflow` on `event`; empty when every job is as expected.
|
||||
`changes_run` is the output `run` of the job `changes` (workflows that have one): `true` or `false`, anything else is red."""
|
||||
label, fix, _conditional = TABLES[workflow]
|
||||
out = []
|
||||
if workflow in HAS_CHANGES:
|
||||
if changes_run not in ("true", "false"):
|
||||
return ["FAIL %s: the output run of the job changes is %r, not true or false. Fix: pass CHANGES_RUN=${{ needs.changes.outputs.run }} and make the job changes print "
|
||||
"run=true|false. Rule: %s" % (label, "missing" if changes_run in (None, "") else changes_run, RULE)]
|
||||
else:
|
||||
changes_run = "true"
|
||||
for name in sorted(set(fix) | set(needs)):
|
||||
entry = needs.get(name)
|
||||
result = entry.get("result") if isinstance(entry, dict) else None
|
||||
if name not in fix:
|
||||
out.append(
|
||||
"FAIL %s: job %s is %s. Fix: add it to the table of %s in scripts/ci_gate.py, or take it out of `needs:` of the job %s. Rule: %s"
|
||||
% (label, name, result, workflow, label, RULE))
|
||||
elif result != expected_result(name, needs, event, workflow, only, changes_run):
|
||||
out.append("FAIL %s: job %s is %s. Fix: %s. Rule: %s" % (label, name, result or "missing", fix[name], RULE))
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
workflow = os.environ.get("WORKFLOW", "") or "tests"
|
||||
if workflow not in TABLES:
|
||||
print("FAIL gate: WORKFLOW is %r, not one of %s. Fix: pass WORKFLOW=tests, e2e or fakeweb. Rule: %s" % (workflow, "|".join(sorted(TABLES)), RULE))
|
||||
return 1
|
||||
label = TABLES[workflow][0]
|
||||
try:
|
||||
needs = json.loads(os.environ.get("NEEDS", ""))
|
||||
if not isinstance(needs, dict):
|
||||
raise ValueError("not an object")
|
||||
except ValueError as exc:
|
||||
print("FAIL %s: the results of the needed jobs cannot be read (%s). Fix: pass NEEDS=${{ toJSON(needs) }}. Rule: %s" % (label, exc, RULE))
|
||||
return 1
|
||||
event = os.environ.get("EVENT_NAME", "")
|
||||
for name in sorted(needs):
|
||||
entry = needs[name]
|
||||
print("%-24s %s" % (name + ":", entry.get("result") if isinstance(entry, dict) else entry))
|
||||
changes_run = os.environ.get("CHANGES_RUN")
|
||||
lines = verdict(needs, event, workflow, os.environ.get("INPUT_ONLY", ""), changes_run)
|
||||
for line in lines:
|
||||
print(line)
|
||||
if lines:
|
||||
return 1
|
||||
print(nothing_to_test(needs, workflow) if workflow in HAS_CHANGES and changes_run == "false" else "ok")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -248,15 +248,8 @@ def dump_findings(dump: dict, wants: Callable = declared) -> list:
|
||||
# the same seeds. Every leaf that differs is a host dependency the published engine ALREADY has: not a failure of the candidate and never red,
|
||||
# a finding, kept in a file of its own and summarised in the job's summary.
|
||||
|
||||
def clean_file(engine_tag: str) -> str:
|
||||
"""poison-clean-70.json for firefox-70: the published engine's dump on the clean runner (ci_ab_oracle.clean_name). The tag is the one the published set carries."""
|
||||
return "poison-clean-%s.json" % engine_tag.rsplit("-", 1)[-1]
|
||||
|
||||
|
||||
def dependence_file(engine_tag: str) -> str:
|
||||
return "poison-host-dependence-%s.json" % engine_tag.rsplit("-", 1)[-1]
|
||||
|
||||
|
||||
CLEAN_FILE = "poison-clean-68.json"
|
||||
DEPENDENCE_FILE = "poison-host-dependence-68.json"
|
||||
DEPENDENCE_FORMAT = "poison-host-dependence/1"
|
||||
CLIP = 300
|
||||
|
||||
@@ -312,17 +305,14 @@ def dependence_markdown(report: dict | None) -> str:
|
||||
return "\n".join(lines + [""])
|
||||
|
||||
|
||||
def write_dependence(out: Path, summary: Path | None = None, engine_tag: str | None = None) -> dict | None:
|
||||
"""Write the dependence file in `out` from the clean dump and the published engine's dump there (named for `engine_tag`, by default the tag the published set carries),
|
||||
and the markdown to `summary` (the job's $GITHUB_STEP_SUMMARY). Returns the report, or None when there is no clean dump. Never a verdict."""
|
||||
import ci_ab_oracle as oracle
|
||||
|
||||
engine_tag = engine_tag or oracle.default_tag()
|
||||
clean, poisoned = out / clean_file(engine_tag), out / oracle.dump_name(engine_tag)
|
||||
def write_dependence(out: Path, summary: Path | None = None) -> dict | None:
|
||||
"""Write DEPENDENCE_FILE in `out` from CLEAN_FILE and dump-68.json there, and the markdown to `summary` (the job's $GITHUB_STEP_SUMMARY).
|
||||
Returns the report, or None when there is no clean dump. Never a verdict."""
|
||||
clean, poisoned = out / CLEAN_FILE, out / "dump-68.json"
|
||||
report = None
|
||||
if clean.is_file() and poisoned.is_file():
|
||||
report = host_dependence(json.loads(clean.read_text(encoding="utf-8")), json.loads(poisoned.read_text(encoding="utf-8")))
|
||||
(out / dependence_file(engine_tag)).write_text(json.dumps(report, sort_keys=True, ensure_ascii=False), encoding="utf-8")
|
||||
(out / DEPENDENCE_FILE).write_text(json.dumps(report, sort_keys=True, ensure_ascii=False), encoding="utf-8")
|
||||
text = dependence_markdown(report)
|
||||
if summary:
|
||||
with open(summary, "a", encoding="utf-8", newline="\n") as f:
|
||||
|
||||
@@ -1,442 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The PUBLISHED SET: the control side of every A/B oracle, exactly as a user installs it.
|
||||
|
||||
An A/B oracle holds a candidate against the engine published before it. That engine is not a binary alone: it is launched by the core that declares the prefs it
|
||||
requires (the engine refuses a launch whose declarations are not the ones it was built for), and that core is the one the published wrapper pins. So the control
|
||||
side is a SET, and nothing in it is chosen by hand: the last published `invisible-playwright` on PyPI pins its core exactly, and that core's seal pins its engine.
|
||||
|
||||
ci/py-lock/published.txt the set as a lock (ci-03): the wrapper and the core it pins, each at an exact version with the sha256 of EVERY file of that
|
||||
version on the index, and the requirements each declares (the headers), which the gate's own lock must satisfy.
|
||||
python scripts/ci_published_set.py resolve [--write] reads PyPI (the only command that does), prints the lock, or writes it
|
||||
python scripts/ci_published_set.py check PyPI's last release against the committed lock: red when they differ (.github/workflows/published-set.yml)
|
||||
python scripts/ci_published_set.py install --house DIR --venv DIR [--lock FILE]
|
||||
OFFLINE and hash-checked: a venv of its own with the gate's third-party lock (DIR/lock.txt), then the two wheels of the set by their hashes
|
||||
(`--no-deps`, from DIR/published: the wheelhouse of the run, whose job downloaded the files this lock names there). Prints the venv's python.
|
||||
DIR itself holds the candidate's wheels of the same two packages (built from core_ref and wrapper_ref, and at an equal version with the SAME
|
||||
file names): the set never takes a file of invisible-core or invisible-playwright from DIR, only from DIR/published.
|
||||
python scripts/ci_published_set.py verify --python PY what that python imports is the lock's set, from its own venv and from nowhere else
|
||||
python scripts/ci_published_set.py fetch --work DIR (run BY the set's python) fetches the engine the way a user's core does: its own seal
|
||||
python scripts/ci_published_set.py tag (run BY the set's python) the tag its seal names
|
||||
|
||||
Exit codes: 0 green, 1 red (a finding), 2 the command could not run.
|
||||
|
||||
The candidate's side is untouched: its core is core_ref's, its wrapper is wrapper_ref's, its engine is the candidate.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
LOCK_PATH = ROOT / "ci" / "py-lock" / "published.txt"
|
||||
GATE_LOCK_PATH = ROOT / "ci" / "py-lock" / "gate.txt"
|
||||
#: Where the wheelhouse of the run keeps the two wheels of the published set (the wheelhouse's own folder holds the candidate's wheels of the same names).
|
||||
PUBLISHED_DIR = "published"
|
||||
#: What install writes in the venv: which wheel of each package it installed (file name, sha256) and the digest of every file of the package as that wheel holds it. verify reads it
|
||||
#: and holds it to the lock and to the disk: the lock and the candidate's lock can name the same package at the same version, so a version says nothing of WHICH file is installed.
|
||||
RECORD_FILE = "published-set.json"
|
||||
RECORD_FORMAT = "published-set-installed/1"
|
||||
|
||||
WRAPPER = "invisible-playwright"
|
||||
CORE = "invisible-core"
|
||||
INDEX = "https://pypi.org/pypi"
|
||||
|
||||
HASH_RE = re.compile(r"^--hash=sha256:([0-9a-f]{64})$")
|
||||
PIN_RE = re.compile(r"^([A-Za-z0-9][A-Za-z0-9._-]*)==([0-9][A-Za-z0-9.!+_-]*)$")
|
||||
HEADER = ("The PUBLISHED SET, the control side of the A/B oracles (scripts/ci_published_set.py): the last published invisible-playwright and the invisible-core it pins "
|
||||
"(its seal pins the engine). Written by `python scripts/ci_published_set.py resolve --write`; .github/workflows/published-set.yml keeps it equal to the index.")
|
||||
|
||||
#: What a process of the published set must not inherit from the candidate's job: anything that makes its python import another wrapper or another core, or run
|
||||
#: another engine's seal. The set is what its venv holds, as it is on a user's machine.
|
||||
SET_LEAKS = ("PYTHONPATH", "PYTHONHOME", "PYTHONSTARTUP", "PYTHONUSERBASE", "VIRTUAL_ENV", "INVISIBLE_SEAL_FILE", "INVISIBLE_CORE_PIN", "INVISIBLE_CORE_AUTOFIX",
|
||||
"INVISIBLE_PLAYWRIGHT_ENGINE_DIR")
|
||||
|
||||
|
||||
def norm(name: str) -> str:
|
||||
return re.sub(r"[-_.]+", "-", name).lower()
|
||||
|
||||
|
||||
# -
|
||||
# The lock: text <-> parts (pure, no network)
|
||||
|
||||
def _release_parts(release: dict, name: str) -> tuple:
|
||||
"""(version, [sha256 of every file], [requirements without extras]) of a PyPI release document (`/pypi/<name>/<version>/json`)."""
|
||||
info = release.get("info") or {}
|
||||
if norm(info.get("name") or "") != norm(name):
|
||||
raise ValueError("the document is of %r, not %s" % (info.get("name"), name))
|
||||
files = [f for f in release.get("urls") or [] if not f.get("yanked")]
|
||||
hashes = sorted({(f.get("digests") or {}).get("sha256", "") for f in files})
|
||||
if not files or not all(re.fullmatch(r"[0-9a-f]{64}", h) for h in hashes):
|
||||
raise ValueError("%s %s has no file with a sha256 on the index" % (name, info.get("version")))
|
||||
if not any(f.get("packagetype") == "bdist_wheel" for f in files):
|
||||
raise ValueError("%s %s has no wheel on the index" % (name, info.get("version")))
|
||||
requires = [r for r in (info.get("requires_dist") or []) if "extra ==" not in r]
|
||||
return info["version"], hashes, requires
|
||||
|
||||
|
||||
def core_pin_of(requires: list) -> str:
|
||||
"""The version of `invisible-core==X` among the requirements of the wrapper; ValueError when there is not exactly one exact pin."""
|
||||
pins = []
|
||||
for r in requires:
|
||||
m = re.fullmatch(r"\s*invisible[-_.]core\s*==\s*([0-9][A-Za-z0-9.!+_-]*)\s*(?:;.*)?", r)
|
||||
if m:
|
||||
pins.append(m.group(1))
|
||||
if len(pins) != 1:
|
||||
raise ValueError("the published wrapper does not pin invisible-core exactly once with `==` (it declares %s)" % (requires or "nothing"))
|
||||
return pins[0]
|
||||
|
||||
|
||||
def lock_text(wrapper_release: dict, core_release: dict) -> str:
|
||||
version, hashes, requires = _release_parts(wrapper_release, WRAPPER)
|
||||
core_version, core_hashes, core_requires = _release_parts(core_release, CORE)
|
||||
pin = core_pin_of(requires)
|
||||
if pin != core_version:
|
||||
raise ValueError("%s %s pins invisible-core==%s but the core document is of %s" % (WRAPPER, version, pin, core_version))
|
||||
others = [r for r in requires if not re.match(r"\s*invisible[-_.]core\b", r, re.I)]
|
||||
out = ["# " + HEADER,
|
||||
"# wrapper-requires: " + " | ".join(sorted(others)),
|
||||
"# core-requires: " + " | ".join(sorted(core_requires))]
|
||||
for name, v, hs in ((CORE, core_version, core_hashes), (WRAPPER, version, hashes)):
|
||||
out.append("%s==%s \\" % (name, v))
|
||||
out.append(" \\\n".join(" --hash=sha256:" + h for h in hs))
|
||||
return "\n".join(out) + "\n"
|
||||
|
||||
|
||||
def parse_lock(text: str) -> dict:
|
||||
"""{"wrapper": (version, hashes), "core": (version, hashes), "wrapper_requires": [...], "core_requires": [...]}; ValueError names what is wrong.
|
||||
Every entry is `name==version` with at least one sha256: no range, no URL, no entry without a hash."""
|
||||
meta, entries, current = {}, {}, None
|
||||
joined = text.replace("\\\n", " ")
|
||||
for raw in joined.splitlines():
|
||||
line = raw.strip()
|
||||
if not line:
|
||||
continue
|
||||
m = re.match(r"^#\s*(wrapper-requires|core-requires):\s*(.*)$", line)
|
||||
if m:
|
||||
meta[m.group(1)] = [r.strip() for r in m.group(2).split(" | ") if r.strip()]
|
||||
continue
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
parts = line.split()
|
||||
pin = PIN_RE.match(parts[0])
|
||||
if not pin:
|
||||
raise ValueError("a line that is not `name==version --hash=sha256:...`: %r" % line[:80])
|
||||
hashes = []
|
||||
for p in parts[1:]:
|
||||
h = HASH_RE.match(p)
|
||||
if not h:
|
||||
raise ValueError("%s: %r is not a --hash=sha256:<64 hex>" % (parts[0], p[:40]))
|
||||
hashes.append(h.group(1))
|
||||
if not hashes:
|
||||
raise ValueError("%s has no hash: an entry without a hash is an unchecked install" % parts[0])
|
||||
current = norm(pin.group(1))
|
||||
if current in entries:
|
||||
raise ValueError("%s is listed twice" % current)
|
||||
entries[current] = (pin.group(2), sorted(hashes))
|
||||
if sorted(entries) != sorted([CORE, WRAPPER]):
|
||||
raise ValueError("the lock holds %s, it must hold exactly %s and %s" % (sorted(entries), CORE, WRAPPER))
|
||||
for key in ("wrapper-requires", "core-requires"):
|
||||
if key not in meta:
|
||||
raise ValueError("the header line `# %s:` is missing" % key)
|
||||
return {"wrapper": entries[WRAPPER], "core": entries[CORE], "wrapper_requires": meta["wrapper-requires"], "core_requires": meta["core-requires"]}
|
||||
|
||||
|
||||
def locked_versions(gate_text: str) -> dict:
|
||||
"""{normalized name: version} of the pinned entries of a lock (ci/py-lock/gate.txt)."""
|
||||
out = {}
|
||||
for line in gate_text.replace("\\\n", " ").splitlines():
|
||||
m = PIN_RE.match(line.split()[0]) if line.strip() and not line.lstrip().startswith("#") else None
|
||||
if m:
|
||||
out[norm(re.sub(r"\[.*\]", "", m.group(1)))] = m.group(2)
|
||||
return out
|
||||
|
||||
|
||||
def problems_of_lock(parsed: dict, gate_text: str) -> list:
|
||||
"""What makes the set not installable, offline, over the gate's lock: the wrapper's pin of the core is not the core in the lock, or a requirement of either is
|
||||
not met by the third-party package the gate's lock holds (the venv of the set is the gate's lock plus these two wheels, `--no-deps`)."""
|
||||
from packaging.requirements import Requirement # the gate lock installs it (pytest needs it); resolve/check do not come here
|
||||
|
||||
problems = []
|
||||
try:
|
||||
pin = core_pin_of(parsed["wrapper_requires"] + ["%s==%s" % (CORE, parsed["core"][0])])
|
||||
if pin != parsed["core"][0]:
|
||||
problems.append("the lock names core %s" % parsed["core"][0])
|
||||
except ValueError as e:
|
||||
problems.append(str(e))
|
||||
held = locked_versions(gate_text)
|
||||
for owner, requires in (("the published wrapper", parsed["wrapper_requires"]), ("the published core", parsed["core_requires"])):
|
||||
for text in requires:
|
||||
req = Requirement(text)
|
||||
if req.marker is not None and not req.marker.evaluate({"extra": ""}):
|
||||
continue
|
||||
version = held.get(norm(req.name))
|
||||
if version is None:
|
||||
problems.append("%s requires %s: the gate's lock (ci/py-lock/gate.txt) does not hold it, so the set cannot be installed offline" % (owner, text))
|
||||
elif not req.specifier.contains(version, prereleases=True):
|
||||
problems.append("%s requires %s: the gate's lock holds %s==%s" % (owner, text, req.name, version))
|
||||
return problems
|
||||
|
||||
|
||||
# -
|
||||
# The index (the only network here)
|
||||
|
||||
def fetch_json(url: str) -> dict:
|
||||
request = urllib.request.Request(url, headers={"User-Agent": "ci-published-set"})
|
||||
with urllib.request.urlopen(request, timeout=60) as response: # noqa: S310 - the index of the package, https
|
||||
return json.loads(response.read().decode("utf-8"))
|
||||
|
||||
|
||||
def resolve(get=fetch_json) -> str:
|
||||
"""The lock of the last published set: PyPI's latest release of the wrapper, and the core that wrapper pins."""
|
||||
latest = get("%s/%s/json" % (INDEX, WRAPPER))
|
||||
version = (latest.get("info") or {}).get("version")
|
||||
if not version:
|
||||
raise ValueError("the index names no latest version of %s" % WRAPPER)
|
||||
wrapper = get("%s/%s/%s/json" % (INDEX, WRAPPER, version))
|
||||
pin = core_pin_of(_release_parts(wrapper, WRAPPER)[2])
|
||||
return lock_text(wrapper, get("%s/%s/%s/json" % (INDEX, CORE, pin)))
|
||||
|
||||
|
||||
def check(get=fetch_json, path: Path = LOCK_PATH) -> list:
|
||||
"""[] when the committed lock is the index's last release; else the lines that say how it differs (and how to fix it)."""
|
||||
committed = path.read_text(encoding="utf-8") if path.is_file() else ""
|
||||
try:
|
||||
wanted = resolve(get)
|
||||
except (ValueError, OSError) as e:
|
||||
return ["the index could not be read or is not what a release is: %s" % e]
|
||||
if committed == wanted:
|
||||
return []
|
||||
old = parse_lock(committed) if committed else None
|
||||
new = parse_lock(wanted)
|
||||
now = "%s %s + %s %s" % (WRAPPER, new["wrapper"][0], CORE, new["core"][0])
|
||||
was = "%s %s + %s %s" % (WRAPPER, old["wrapper"][0], CORE, old["core"][0]) if old else "nothing"
|
||||
return ["%s holds %s but the index's last release is %s. Fix: python scripts/ci_published_set.py resolve --write, and commit it. "
|
||||
"Rule: the control side of an A/B is the last published set" % (path.name, was, now)]
|
||||
|
||||
|
||||
# -
|
||||
# The venv of the set (offline) and what it must be
|
||||
|
||||
def venv_python(venv: Path) -> Path:
|
||||
return venv / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
|
||||
|
||||
|
||||
def clean_env(extra: dict | None = None) -> dict:
|
||||
env = {k: v for k, v in os.environ.items() if k not in SET_LEAKS}
|
||||
env.update(extra or {})
|
||||
return env
|
||||
|
||||
|
||||
def install(house: Path, venv: Path, lock: Path = LOCK_PATH, run=subprocess.run) -> Path:
|
||||
"""A venv of its own: the gate's third-party lock from the wheelhouse (`house/lock.txt`, the lock of the run), then the two wheels of the set by their hashes, from
|
||||
`house/published` ONLY. Offline: `--no-index` and `--require-hashes` on both; the two are installed `--no-deps` because the first step holds everything they need.
|
||||
|
||||
The wheelhouse's own folder holds the candidate's wheels of invisible-core and invisible-playwright, built from core_ref and wrapper_ref; at an equal version they have
|
||||
the file names of the published ones, so the published ones live in their own folder and are the only place the second step looks: a wheel of ours taken from the wheelhouse
|
||||
would be the candidate's core in the control's venv, or a hash refused. pip never sees the wheelhouse's folder and `published/` in one call: with two `--find-links` it takes
|
||||
the first local file of a name and fails on a hash mismatch, it does not choose by hash. Then `pip check` over the venv: red, with what pip reports, when a requirement of
|
||||
the two wheels is not met."""
|
||||
parse_lock(lock.read_text(encoding="utf-8")) # a lock that does not read is no install
|
||||
house_lock = house / "lock.txt"
|
||||
if not house_lock.is_file():
|
||||
raise FileNotFoundError("the wheelhouse %s has no lock.txt (the gate's lock): it is not a py-deps wheelhouse" % house)
|
||||
published = house / PUBLISHED_DIR
|
||||
if not published.is_dir():
|
||||
raise FileNotFoundError("the wheelhouse %s has no %s/ folder: the two wheels of the published set (the files ci/py-lock/published.txt names) are kept there, "
|
||||
"apart from the candidate's wheels of the same names" % (house, PUBLISHED_DIR))
|
||||
parsed = parse_lock(lock.read_text(encoding="utf-8"))
|
||||
chosen = {name: published_wheel(published, name, *parsed[key]) for key, name in (("core", CORE), ("wrapper", WRAPPER))}
|
||||
run([sys.executable, "-m", "venv", str(venv)], check=True)
|
||||
python = str(venv_python(venv))
|
||||
base = [python, "-m", "pip", "install", "--quiet", "--no-index", "--require-hashes"]
|
||||
run(base + ["--find-links", str(house), "-r", str(house_lock)], check=True, env=clean_env())
|
||||
run(base + ["--find-links", str(published), "--no-deps", "-r", str(lock)], check=True, env=clean_env())
|
||||
# `--no-deps` installs the two wheels without looking at what they declare: pip check does, over the whole venv (the third-party lock and the two wheels).
|
||||
checked = run([python, "-m", "pip", "check"], capture_output=True, text=True, env=clean_env())
|
||||
if checked.returncode != 0:
|
||||
raise RuntimeError("pip check of the published set's venv %s is red (the requirements of the published wheels are not met by the wheelhouse's dependencies): %s"
|
||||
% (venv, (checked.stdout + checked.stderr).strip()[-1500:]))
|
||||
write_record(venv, chosen)
|
||||
return venv_python(venv)
|
||||
|
||||
|
||||
def file_digest(data: bytes) -> str:
|
||||
"""The digest of a file as a wheel's RECORD writes it: `sha256=<urlsafe base64, no padding>`."""
|
||||
return "sha256=" + base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b"=").decode()
|
||||
|
||||
|
||||
def published_wheel(published: Path, name: str, version: str, hashes: list) -> tuple:
|
||||
"""(path, sha256) of the wheel of `name` `version` in `published` whose sha256 is one the lock holds. FileNotFoundError names what was there and what the lock holds."""
|
||||
stem = name.replace("-", "_").lower() + "-" + version + "-"
|
||||
seen = []
|
||||
for path in sorted(published.glob("*.whl")):
|
||||
if path.name.lower().startswith(stem):
|
||||
sha = hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
if sha in hashes:
|
||||
return path, sha
|
||||
seen.append("%s sha256 %s" % (path.name, sha))
|
||||
raise FileNotFoundError("%s %s: no wheel in %s has a sha256 the lock (ci/py-lock/published.txt) holds (%s); there %s"
|
||||
% (name, version, published, ", ".join(hashes), "is " + "; ".join(seen) if seen else "is none of that name"))
|
||||
|
||||
|
||||
def package_digests(wheel: Path, package: str) -> dict:
|
||||
"""{path: digest} of every file of the package `package` in the wheel, taken from the bytes of the wheel (its RECORD is not believed)."""
|
||||
with zipfile.ZipFile(wheel) as z:
|
||||
return {n: file_digest(z.read(n)) for n in sorted(z.namelist()) if n.startswith(package + "/") and not n.endswith("/")}
|
||||
|
||||
|
||||
def write_record(venv: Path, chosen: dict) -> Path:
|
||||
"""`chosen` is {distribution: (wheel path, sha256)}: what was installed into `venv`, written where verify reads it."""
|
||||
packages = {name: {"wheel": path.name, "sha256": sha, "files": package_digests(path, name.replace("-", "_"))} for name, (path, sha) in chosen.items()}
|
||||
target = Path(venv) / RECORD_FILE
|
||||
Path(venv).mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(json.dumps({"format": RECORD_FORMAT, "packages": packages}, sort_keys=True, indent=1) + "\n", encoding="utf-8", newline="\n")
|
||||
return target
|
||||
|
||||
|
||||
def installed_problems(prefix: str, parsed: dict, site_files: dict) -> list:
|
||||
"""What the record of the venv `prefix` says was installed, against the lock and against the disk. `site_files` is {distribution: the folder that holds its package}.
|
||||
A package the record names with a sha256 the lock does not hold is red, naming the file and both hashes; so is a file of the package that is not, byte for byte, the wheel's."""
|
||||
path = Path(prefix) / RECORD_FILE
|
||||
if not path.is_file():
|
||||
return ["%s has no %s: nothing says which wheel of invisible-core and invisible-playwright was installed (install writes it); the same version can be a "
|
||||
"different file (the candidate's wheels have the names of the published ones)" % (prefix, RECORD_FILE)]
|
||||
record = json.loads(path.read_text(encoding="utf-8"))
|
||||
problems = []
|
||||
for key, name in (("core", CORE), ("wrapper", WRAPPER)):
|
||||
entry = (record.get("packages") or {}).get(name)
|
||||
if not entry:
|
||||
problems.append("%s: the record of the venv does not name the wheel it installed" % name)
|
||||
continue
|
||||
lock_hashes = parsed[key][1]
|
||||
if entry["sha256"] not in lock_hashes:
|
||||
problems.append("%s: the file installed is %s with sha256 %s, and ci/py-lock/published.txt holds %s (the published set is %s %s)"
|
||||
% (name, entry["wheel"], entry["sha256"], ", ".join(lock_hashes), name, parsed[key][0]))
|
||||
for rel, digest in sorted(entry["files"].items()):
|
||||
target = Path(site_files[name]) / rel
|
||||
actual = file_digest(target.read_bytes()) if target.is_file() else "missing"
|
||||
if actual != digest:
|
||||
problems.append("%s: %s on disk is %s, the wheel %s (sha256 %s) holds %s" % (name, rel, actual, entry["wheel"], entry["sha256"], digest))
|
||||
break
|
||||
return problems
|
||||
|
||||
|
||||
IDENTITY_CODE = """
|
||||
import importlib.metadata as md, json, sys
|
||||
import invisible_core, invisible_playwright
|
||||
from invisible_core.seal import active_seal
|
||||
seal = active_seal()
|
||||
print(json.dumps({"prefix": sys.prefix, "core": md.version("invisible-core"), "core_version": invisible_core.__version__, "core_file": invisible_core.__file__,
|
||||
"wrapper": md.version("invisible-playwright"), "wrapper_file": invisible_playwright.__file__, "seal_tag": seal.tag, "seal_local": seal.is_local}))
|
||||
"""
|
||||
|
||||
|
||||
def identity(python: str, run=subprocess.run) -> dict:
|
||||
"""What `python` is when it imports the set: versions, files and the tag of the seal its core carries (read in isolated mode, with no variable of the job)."""
|
||||
done = run([python, "-I", "-c", IDENTITY_CODE], capture_output=True, text=True, env=clean_env(), timeout=120)
|
||||
if done.returncode != 0:
|
||||
raise RuntimeError("%s could not import the published set (exit %s): %s" % (python, done.returncode, (done.stderr or done.stdout)[-800:]))
|
||||
return json.loads(done.stdout.strip().splitlines()[-1])
|
||||
|
||||
|
||||
def verify(python: str, lock: Path = LOCK_PATH, run=subprocess.run) -> list:
|
||||
"""[] when `python` runs the lock's wrapper and the lock's core, both from its own prefix, under the seal its core was published with, and the files they are made of
|
||||
are the wheels the lock's sha256 name (read from the record install wrote and from the disk, never assumed from the version)."""
|
||||
parsed = parse_lock(lock.read_text(encoding="utf-8"))
|
||||
ident = identity(python, run)
|
||||
problems = []
|
||||
if ident["wrapper"] != parsed["wrapper"][0] or not ident["wrapper_file"].startswith(ident["prefix"]):
|
||||
problems.append("the wrapper it runs is %s from %s, the set says %s from its own venv" % (ident["wrapper"], ident["wrapper_file"], parsed["wrapper"][0]))
|
||||
if ident["core"] != parsed["core"][0] or ident["core_version"] != parsed["core"][0] or not ident["core_file"].startswith(ident["prefix"]):
|
||||
problems.append("the core it runs is %s (reports %s) from %s, the set says %s from its own venv"
|
||||
% (ident["core"], ident["core_version"], ident["core_file"], parsed["core"][0]))
|
||||
if ident["seal_local"]:
|
||||
problems.append("its core runs under a local seal: a published core carries a release seal")
|
||||
problems += installed_problems(ident["prefix"], parsed, {CORE: str(Path(ident["core_file"]).parent.parent), WRAPPER: str(Path(ident["wrapper_file"]).parent.parent)})
|
||||
return problems
|
||||
|
||||
|
||||
# -
|
||||
# What the set's own python does (the commands below are run BY it: they import the published core)
|
||||
|
||||
def fetch(work: Path) -> dict:
|
||||
"""The engine of the core this python has, fetched the way a user's core fetches it: its own seal, its own download, its own verification."""
|
||||
from invisible_core import download
|
||||
from invisible_core.seal import active_seal
|
||||
|
||||
work = Path(work)
|
||||
os.environ[download.ENGINE_DIR_ENV] = str(work / "engines")
|
||||
seal = active_seal()
|
||||
binary = download.ensure_binary()
|
||||
return {"binary": str(binary), "tag": seal.tag, "describe": seal.describe()}
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
||||
sub = ap.add_subparsers(dest="cmd", required=True)
|
||||
r = sub.add_parser("resolve")
|
||||
r.add_argument("--write", action="store_true")
|
||||
sub.add_parser("check")
|
||||
i = sub.add_parser("install")
|
||||
i.add_argument("--house", type=Path, required=True)
|
||||
i.add_argument("--venv", type=Path, required=True)
|
||||
i.add_argument("--lock", type=Path, default=LOCK_PATH)
|
||||
v = sub.add_parser("verify")
|
||||
v.add_argument("--python", required=True)
|
||||
v.add_argument("--lock", type=Path, default=LOCK_PATH)
|
||||
f = sub.add_parser("fetch")
|
||||
f.add_argument("--work", type=Path, required=True)
|
||||
sub.add_parser("tag")
|
||||
args = ap.parse_args(argv)
|
||||
try:
|
||||
if args.cmd == "resolve":
|
||||
text = resolve()
|
||||
if args.write:
|
||||
LOCK_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % LOCK_PATH)
|
||||
else:
|
||||
sys.stdout.write(text)
|
||||
return 0
|
||||
if args.cmd == "check":
|
||||
problems = check()
|
||||
print("\n".join("FAIL " + p for p in problems) if problems else "OK the committed published set is the index's last release")
|
||||
return 1 if problems else 0
|
||||
if args.cmd == "install":
|
||||
python = install(args.house, args.venv, args.lock)
|
||||
problems = verify(str(python), args.lock)
|
||||
for name, entry in sorted(json.loads((args.venv / RECORD_FILE).read_text(encoding="utf-8"))["packages"].items()):
|
||||
print("installed %s: %s sha256 %s" % (name, entry["wheel"], entry["sha256"]), file=sys.stderr)
|
||||
if problems:
|
||||
print("\n".join("FAIL " + p for p in problems))
|
||||
return 1
|
||||
print(python)
|
||||
return 0
|
||||
if args.cmd == "verify":
|
||||
problems = verify(args.python, args.lock)
|
||||
print("\n".join("FAIL " + p for p in problems) if problems else "OK")
|
||||
return 1 if problems else 0
|
||||
if args.cmd == "fetch":
|
||||
print(json.dumps(fetch(args.work)))
|
||||
return 0
|
||||
if args.cmd == "tag":
|
||||
from invisible_core.seal import active_seal
|
||||
|
||||
print(active_seal().tag)
|
||||
return 0
|
||||
except (ValueError, OSError, RuntimeError, subprocess.CalledProcessError) as e:
|
||||
print("ERROR %s: %s" % (type(e).__name__, e))
|
||||
return 2
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -7,9 +7,7 @@ THIRD-PARTY distribution the gate installs from the wrapper:
|
||||
|
||||
* the wrapper's dependencies (`[project].dependencies` of pyproject.toml, without `invisible_core`, which is built as a wheel of ours) and its `dev` extra;
|
||||
* the dependencies of the core the wrapper pins (`invisible_core==X`: the `[project].dependencies` of the core's pyproject.toml at the tag vX);
|
||||
* playwright at scripts/playwright_pin.txt (the stock client the gate drives the engine with) and cryptography at CRYPTOGRAPHY (the lab's PKI);
|
||||
* the installer the install-from-index job needs beside pytest (HARNESS: `uv`, which the release test installs the package with and the wait asks), so that
|
||||
job installs its test harness from this lock and from nothing else (tests/test_the_install_job_has_every_module_its_tests_import.py).
|
||||
* playwright at scripts/playwright_pin.txt (the stock client the gate drives the engine with) and cryptography at CRYPTOGRAPHY (the lab's PKI).
|
||||
|
||||
One command regenerates both files after a dependency change or a bump of the core pin:
|
||||
|
||||
@@ -38,8 +36,6 @@ PLAYWRIGHT_PIN = ROOT / "scripts" / "playwright_pin.txt"
|
||||
|
||||
#: What the lab's PKI needs, as the series' gate installs it today.
|
||||
CRYPTOGRAPHY = "cryptography==44.0.3"
|
||||
#: Installers the install-from-index job (user-install.yml) needs and no dependency of the wrapper brings: the README's way in (`uv`) and the wait on the index.
|
||||
HARNESS = ["uv>=0.5"]
|
||||
#: The floor of the lock: the Python the unit job judges; `--universal` covers every Linux and Windows wheel of every Python from it.
|
||||
PYTHON_VERSION = "3.11"
|
||||
DEFAULT_EXCLUDE_NEWER = "2026-11-25T00:00:00Z"
|
||||
@@ -128,7 +124,7 @@ def core_dependencies(core_pyproject_text: str) -> list:
|
||||
def expected_requirements(pyproject_text: str, core_requires: list, playwright_pin: str) -> list:
|
||||
"""The requirements the lock must cover, in the order the input prints them."""
|
||||
src = wrapper_sources(pyproject_text)
|
||||
reqs = set(src["dependencies"]) | set(src["dev"]) | set(core_requires) | set(HARNESS) | {"playwright==%s" % playwright_pin.strip(), CRYPTOGRAPHY}
|
||||
reqs = set(src["dependencies"]) | set(src["dev"]) | set(core_requires) | {"playwright==%s" % playwright_pin.strip(), CRYPTOGRAPHY}
|
||||
return sorted(reqs, key=lambda r: (base_name(r), r))
|
||||
|
||||
|
||||
@@ -145,7 +141,6 @@ def make_in(pyproject_text: str, core_pyproject_text: str, playwright_pin: str,
|
||||
"# core-requires: %s" % SEP.join(core_requires),
|
||||
"# playwright: %s from scripts/playwright_pin.txt (the stock client the gate drives the engine with)" % playwright_pin.strip(),
|
||||
"# cryptography: %s (the lab's PKI)" % CRYPTOGRAPHY.split("==")[1],
|
||||
"# harness: %s (the installers of the install-from-index job)" % SEP.join(HARNESS),
|
||||
]
|
||||
return "\n".join(head + expected_requirements(pyproject_text, core_requires, playwright_pin)) + "\n"
|
||||
|
||||
|
||||
+11
-93
@@ -24,11 +24,6 @@ pytest wrote and fails on every one of them.
|
||||
The one exception is `retired-tests.json` NEXT TO main's list (read from main, never from the judged branch): a file it names that
|
||||
no longer exists in the checkout may leave the rows, and the minimum of a row may go down by the tests main counted for it in that
|
||||
row (`tests: {row id: n}`), and by no more. A retired file still on disk, or any other lost test, stays red.
|
||||
The same file may also retire single tests whose file stays: {"nodeid": "<file>::<test>", "suite": <row id>, "count": n, "reason",
|
||||
"decided_by", "date", "from_min_tests"}. The minimum of that row may go down by the sum of the `count` of its entries and by no more, and
|
||||
only for a nodeid whose file the row of main lists, and only while main's minimum of that row still equals `from_min_tests` (once the removal
|
||||
is on main and its floor is lower, the entry is inert); a declared nodeid that the judged leg still collects is red, and so is any test that
|
||||
goes without an entry.
|
||||
What the file of main is can be said only by the gate, which checks main out (a failed download is not
|
||||
"main has no list"): the file exists -> it is compared; it does not exist and the gate passed
|
||||
--main-has-no-list (main was checked out and has no such file) -> passed, declared; it does not exist
|
||||
@@ -338,25 +333,17 @@ def _int(value):
|
||||
RETIRED_NAME = "retired-tests.json"
|
||||
|
||||
|
||||
def validate_retired(data, suite_ids=None):
|
||||
"""-> the reasons why `data` is not a well-formed list of retired tests (empty if it is). Two kinds of entry, in one list:
|
||||
a FILE that is gone ({file, reason, date, tests: {row id: number of tests the file had in that row on main, counted with the row's marker}}), and
|
||||
a single TEST whose file stays ({nodeid: "<file>::<test>", suite: row id, count > 0, reason, decided_by, date, from_min_tests: the minimum of
|
||||
the row on main when the entry was written, an integer >= count, the same for every entry of a suite}). `suite_ids`, when given, are the row
|
||||
ids of main's list: the suite of a nodeid entry must be one of them."""
|
||||
def validate_retired(data):
|
||||
"""-> the reasons why `data` is not a well-formed list of retired files (empty if it is). An entry: the file, why it went, the date, and
|
||||
for each row id the number of tests the file had in that row on main (counted with the row's marker)."""
|
||||
if not isinstance(data, list):
|
||||
return ["the retired list must be a JSON list"]
|
||||
problems, seen, seen_nodes, froms = [], set(), set(), {}
|
||||
problems, seen = [], set()
|
||||
for i, e in enumerate(data):
|
||||
where = "retired entry %d" % i
|
||||
if not isinstance(e, dict):
|
||||
problems.append("%s is not an object" % where)
|
||||
continue
|
||||
if "nodeid" in e or "suite" in e:
|
||||
problems += _validate_retired_node(e, where, suite_ids, seen_nodes)
|
||||
if isinstance(e.get("suite"), str) and _is_int(e.get("from_min_tests")):
|
||||
froms.setdefault(e["suite"], set()).add(e["from_min_tests"])
|
||||
continue
|
||||
f = e.get("file")
|
||||
if not isinstance(f, str) or not f.strip():
|
||||
problems.append("%s has no file" % where)
|
||||
@@ -371,44 +358,12 @@ def validate_retired(data, suite_ids=None):
|
||||
counts = e.get("tests")
|
||||
if not (isinstance(counts, dict) and counts and all(isinstance(k, str) and _is_int(v) and v > 0 for k, v in counts.items())):
|
||||
problems.append("%s: tests must be {row id: number of tests of the file in that row (> 0)}" % where)
|
||||
for suite, values in sorted(froms.items()):
|
||||
if len(values) > 1:
|
||||
problems.append("the retired tests of %s disagree on from_min_tests (%s): one suite, one floor of main" % (suite, sorted(values)))
|
||||
return problems
|
||||
|
||||
|
||||
def _validate_retired_node(e, where, suite_ids, seen):
|
||||
problems = []
|
||||
nid, suite = e.get("nodeid"), e.get("suite")
|
||||
if "file" in e or "tests" in e:
|
||||
problems.append("%s: an entry is a retired file (file, tests) or a retired test (nodeid, suite, count), not both" % where)
|
||||
parts = nid.split("::", 1) if isinstance(nid, str) else []
|
||||
if len(parts) != 2 or not parts[0].strip() or not parts[1].strip():
|
||||
problems.append("%s: nodeid must be \"<file>::<test>\"" % where)
|
||||
else:
|
||||
where = "retired test %s" % nid
|
||||
if not isinstance(suite, str) or not suite.strip():
|
||||
problems.append("%s: suite must be a non-empty string (the id of a row)" % where)
|
||||
elif suite_ids is not None and suite not in suite_ids:
|
||||
problems.append("%s: the suite %s is not a row of main's required list" % (where, suite))
|
||||
if isinstance(nid, str) and isinstance(suite, str):
|
||||
if (nid, suite) in seen:
|
||||
problems.append("%s: appears more than once for the suite %s" % (where, suite))
|
||||
seen.add((nid, suite))
|
||||
if not _is_int(e.get("count")) or e.get("count") < 1:
|
||||
problems.append("%s: count must be an integer >= 1 (the tests the suite loses)" % where)
|
||||
for key in ("reason", "decided_by", "date"):
|
||||
if not isinstance(e.get(key), str) or not e.get(key).strip():
|
||||
problems.append("%s: %s must be a non-empty string" % (where, key))
|
||||
frm = e.get("from_min_tests")
|
||||
if not _is_int(frm) or frm < 1 or (_is_int(e.get("count")) and frm < e["count"]):
|
||||
problems.append("%s: from_min_tests must be an integer >= count (the minimum of the suite on main when the entry was written)" % where)
|
||||
return problems
|
||||
|
||||
|
||||
def retired_of_main(main_required):
|
||||
"""The retired files and tests of main: ``ci/retired-tests.json`` next to main's list, read from main and never from the judged branch. It may
|
||||
not exist (main older than the format): nothing is retired. A malformed one is a problem, never an empty list. -> (entries, problems)."""
|
||||
"""The retired files of main: ``ci/retired-tests.json`` next to main's list, read from main and never from the judged branch. It may not
|
||||
exist (main older than the format): nothing is retired. A malformed one is a problem, never an empty list. -> (entries, problems)."""
|
||||
path = Path(main_required).with_name(RETIRED_NAME)
|
||||
if not path.is_file():
|
||||
return [], []
|
||||
@@ -416,55 +371,22 @@ def retired_of_main(main_required):
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError) as exc:
|
||||
return [], ["the retired list of main %s cannot be read: %s" % (path, exc)]
|
||||
try:
|
||||
rows = json.loads(Path(main_required).read_text(encoding="utf-8"))
|
||||
suite_ids = {r.get("id") for r in rows if isinstance(r, dict)} if isinstance(rows, list) else None
|
||||
except (OSError, ValueError):
|
||||
suite_ids = None # the list of main itself is read (and refused) by the caller
|
||||
bad = validate_retired(data, suite_ids)
|
||||
bad = validate_retired(data)
|
||||
if bad:
|
||||
return [], ["the retired list of main %s is malformed: %s" % (path, "; ".join(bad))]
|
||||
return data, []
|
||||
|
||||
|
||||
def _retired_tests_of(row, retired, collected, judged):
|
||||
"""-> (the number of tests the row may lose because main retired them one by one, problems). An entry counts only if the file of its nodeid is
|
||||
in the row of main (a nodeid that the row does not run is not a test the row loses). The judge has the junit of the leg it judges and only
|
||||
counts of main, so a declared nodeid that the judged leg still collects is red (and counts for nothing), and the nodeid of another row is taken
|
||||
on its count, the leg of that row checking it. An entry counts only while the minimum of the row on main is still its `from_min_tests`: once
|
||||
the removal is on main the floor is lower and the entry is inert (it allows nothing and asks nothing)."""
|
||||
allowed, problems = 0, []
|
||||
listed = row.get("tests", [])
|
||||
for e in retired:
|
||||
if not (isinstance(e, dict) and isinstance(e.get("nodeid"), str) and e.get("suite") == row.get("id")):
|
||||
continue
|
||||
nid = e["nodeid"]
|
||||
if _int(row.get("min_tests")) != e.get("from_min_tests"):
|
||||
continue
|
||||
if nid not in listed and nid.split("::", 1)[0] not in listed:
|
||||
continue
|
||||
if collected is not None and judged == row.get("id") and any(n == nid or _base(n) == nid for n in collected):
|
||||
problems.append("the test %s is declared retired for %s, but the suite still collects it: it did not leave" % (nid, row.get("id")))
|
||||
continue
|
||||
allowed += _int(e.get("count"))
|
||||
return allowed, problems
|
||||
|
||||
|
||||
def against_main(current, main, retired=(), exists=os.path.exists, collected=None, judged=None):
|
||||
def against_main(current, main, retired=(), exists=os.path.exists):
|
||||
"""The list only grows: every suite of main is still here, with no lower minimum, no exact turned off, no lost
|
||||
test or OS and the same marker. `main` is read leniently (it may be older than the current format).
|
||||
|
||||
The one way a test leaves a row is `retired` (the list of MAIN, never of the branch): a file that main retired and that no longer exists
|
||||
(`exists`, in the checkout judged) is not a lost test, and the minimum of the row may go down by exactly the tests main counted for that file
|
||||
in that row (``tests[row id]``), and by no more. A retired file that is still on disk is not excused: it must stay in its rows.
|
||||
|
||||
The other way is a single retired test (``nodeid``, ``suite``, ``count``) whose file stays in the row: the minimum of the suite may go down by
|
||||
the ``count`` of its entries, and by no more. ``collected`` (the node ids of the junit of the judged leg) and ``judged`` (that leg's suite) let
|
||||
the judge see that a declared nodeid is gone from the leg; of the collection of main it has only the count."""
|
||||
in that row (``tests[row id]``), and by no more. A retired file that is still on disk is not excused: it must stay in its rows."""
|
||||
problems = []
|
||||
if not isinstance(main, list):
|
||||
return ["the list of main is not a JSON list: it cannot be compared"]
|
||||
retired = list(retired)
|
||||
gone = {e["file"]: e["tests"] for e in retired if isinstance(e, dict) and isinstance(e.get("file"), str)
|
||||
and isinstance(e.get("tests"), dict) and not exists(e["file"])}
|
||||
by_id = {s.get("id"): s for s in current if isinstance(s, dict)}
|
||||
@@ -480,13 +402,10 @@ def against_main(current, main, retired=(), exists=os.path.exists, collected=Non
|
||||
excused = [t for t in lost if t in gone]
|
||||
lost = [t for t in lost if t not in gone]
|
||||
allowed = sum(_int(gone[t].get(sid)) for t in excused)
|
||||
by_test, why = _retired_tests_of(old, retired, collected, judged)
|
||||
allowed += by_test
|
||||
problems += why
|
||||
if _int(new.get("min_tests")) < _int(old.get("min_tests")) - allowed:
|
||||
problems.append("the minimum of %s went down: %s on main, %s here%s"
|
||||
% (sid, old.get("min_tests"), new.get("min_tests"),
|
||||
" (retired files and tests account for %d of it)" % allowed if allowed else ""))
|
||||
" (retired files account for %d of it)" % allowed if allowed else ""))
|
||||
if old.get("exact") is True and new.get("exact") is not True:
|
||||
problems.append("the suite %s is no longer exact, as it is on main" % sid)
|
||||
if lost:
|
||||
@@ -628,8 +547,7 @@ def cmd_judge(ns):
|
||||
try:
|
||||
retired, retired_problems = retired_of_main(ns.main_required)
|
||||
problems += retired_problems
|
||||
problems += against_main(suites, _read_json_list(ns.main_required), retired,
|
||||
collected={n for n, _o in cases}, judged=ns.suite)
|
||||
problems += against_main(suites, _read_json_list(ns.main_required), retired)
|
||||
except Usage as exc:
|
||||
problems.append(str(exc))
|
||||
elif ns.main_has_no_list:
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
r"""Read the full user-mode dumps Windows Error Reporting left for a python.exe that died, and say what each one holds (CI evidence, no debugger needed).
|
||||
|
||||
The Windows e2e jobs set ``HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\python.exe`` (full dump, folder ``<evidence>/dumps/python``)
|
||||
before their tests; when a pytest-xdist worker dies from an unhandled exception ("node down: Not properly terminated", "Windows fatal exception: access violation")
|
||||
WER writes ``python.exe.<pid>.dmp`` there and the evidence artifact carries it. This script runs after the tests (``if: always()``): it lists every dump with its size
|
||||
and reads the header of the MINIDUMP file, with ``struct`` only, to name what a debugger would name first: the thread that raised, the exception code, the faulting
|
||||
address and the module that holds it (with the offset in it), plus the access that failed for an access violation. The summary goes to stdout and to
|
||||
``summary.txt`` beside the dumps. It never fails the job: no dump is the normal case.
|
||||
|
||||
Format of the file: https://learn.microsoft.com/windows/win32/api/minidumpapiset/ (MINIDUMP_HEADER, MINIDUMP_DIRECTORY, MINIDUMP_EXCEPTION_STREAM,
|
||||
MINIDUMP_MODULE). Dump types and the LocalDumps key: https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
SIGNATURE = b"MDMP"
|
||||
MODULE_LIST_STREAM = 4
|
||||
EXCEPTION_STREAM = 6
|
||||
MODULE_SIZE = 108 # sizeof(MINIDUMP_MODULE)
|
||||
|
||||
EXCEPTION_NAMES = {
|
||||
0xC0000005: "EXCEPTION_ACCESS_VIOLATION",
|
||||
0xC0000374: "STATUS_HEAP_CORRUPTION",
|
||||
0xC0000409: "STATUS_STACK_BUFFER_OVERRUN (fail fast)",
|
||||
0xC00000FD: "EXCEPTION_STACK_OVERFLOW",
|
||||
0xC000001D: "EXCEPTION_ILLEGAL_INSTRUCTION",
|
||||
0xC0000094: "EXCEPTION_INT_DIVIDE_BY_ZERO",
|
||||
0xC0000026: "STATUS_INVALID_DISPOSITION",
|
||||
0xC0000096: "EXCEPTION_PRIV_INSTRUCTION",
|
||||
0xC0000006: "EXCEPTION_IN_PAGE_ERROR",
|
||||
0x80000003: "EXCEPTION_BREAKPOINT",
|
||||
0xE06D7363: "C++ exception",
|
||||
}
|
||||
ACCESS = {0: "read", 1: "write", 8: "execute (DEP)"}
|
||||
|
||||
|
||||
def read_dump(path: Path) -> dict:
|
||||
"""The facts of one minidump: thread id, exception code and address, the module holding the address. Raises ValueError on a file that is not a minidump."""
|
||||
with open(path, "rb") as f:
|
||||
head = f.read(32)
|
||||
if len(head) < 32 or head[:4] != SIGNATURE:
|
||||
raise ValueError("not a minidump (no MDMP signature)")
|
||||
_sig, _version, n_streams, dir_rva = struct.unpack_from("<4sIII", head, 0)
|
||||
f.seek(dir_rva)
|
||||
directory = [struct.unpack("<III", f.read(12)) for _ in range(n_streams)]
|
||||
out: dict = {"streams": n_streams}
|
||||
modules: list[tuple[int, int, str]] = []
|
||||
for kind, size, rva in directory:
|
||||
if kind == MODULE_LIST_STREAM:
|
||||
f.seek(rva)
|
||||
(count,) = struct.unpack("<I", f.read(4))
|
||||
records = f.read(count * MODULE_SIZE)
|
||||
for i in range(count):
|
||||
base, image_size, _cs, _ts, name_rva = struct.unpack_from("<QIIII", records, i * MODULE_SIZE)
|
||||
here = f.tell()
|
||||
f.seek(name_rva)
|
||||
(nbytes,) = struct.unpack("<I", f.read(4))
|
||||
name = f.read(nbytes).decode("utf-16-le", "replace")
|
||||
f.seek(here)
|
||||
modules.append((base, image_size, name))
|
||||
elif kind == EXCEPTION_STREAM:
|
||||
f.seek(rva)
|
||||
raw = f.read(8 + 8 + 8 + 8 + 8 + 15 * 8)
|
||||
tid, _pad, code, flags, _chain, address, n_params, _pad2 = struct.unpack_from("<IIIIQQII", raw, 0)
|
||||
params = struct.unpack_from("<15Q", raw, 8 + 32)
|
||||
out.update(thread_id=tid, code=code, flags=flags, address=address, params=list(params[:n_params]))
|
||||
out["module_count"] = len(modules)
|
||||
if "address" in out:
|
||||
for base, image_size, name in modules:
|
||||
if base <= out["address"] < base + image_size:
|
||||
out["module"] = name
|
||||
out["offset"] = out["address"] - base
|
||||
break
|
||||
return out
|
||||
|
||||
|
||||
def describe(path: Path) -> str:
|
||||
size = path.stat().st_size
|
||||
head = "%s: %.1f MB" % (path.name, size / 1e6)
|
||||
try:
|
||||
d = read_dump(path)
|
||||
except (ValueError, OSError, struct.error) as e:
|
||||
return "%s, unreadable header: %s" % (head, e)
|
||||
if "code" not in d:
|
||||
return "%s, %d modules, no exception stream (a dump taken on request, not on a fault)" % (head, d["module_count"])
|
||||
name = EXCEPTION_NAMES.get(d["code"], "unknown")
|
||||
lines = [
|
||||
head,
|
||||
" exception 0x%08X %s on thread %d" % (d["code"], name, d["thread_id"]),
|
||||
" at 0x%016X in %s" % (d["address"], ("%s+0x%X" % (d["module"], d["offset"])) if "module" in d else "no module of the dump (JIT or freed code)"),
|
||||
]
|
||||
p = d["params"]
|
||||
if d["code"] in (0xC0000005, 0xC0000006) and len(p) >= 2:
|
||||
lines.append(" failed access: %s of 0x%016X" % (ACCESS.get(p[0], str(p[0])), p[1]))
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def summarize(folder: Path) -> str:
|
||||
dumps = sorted(folder.glob("*.dmp")) if folder.is_dir() else []
|
||||
cdb = shutil.which("cdb") or shutil.which("windbg")
|
||||
lines = ["WER dumps of python.exe in %s: %d" % (folder, len(dumps)), "debugger on the runner: %s" % (cdb or "none (the header reader above is all there is)")]
|
||||
for p in dumps:
|
||||
lines.append(describe(p) + "\n written %s" % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(p.stat().st_mtime)))
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
folder = Path(argv[1]) if len(argv) > 1 else Path(".")
|
||||
text = summarize(folder)
|
||||
sys.stdout.write(text)
|
||||
if folder.is_dir():
|
||||
(folder / "summary.txt").write_text(text, encoding="utf-8", newline="\n")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv))
|
||||
@@ -1,227 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extracts, from Mozilla's own sources at a release tag, the names a chrome-scope script of a test may call, into ci/mozilla-chrome-api.json.
|
||||
|
||||
A twin of the retail Firefox runs chrome JS (through Marionette) on a Firefox that is NOT ours. A call to a name that this Firefox does not have fails there only, at the run:
|
||||
``win.windowUtils.sendMouseEvent`` is not in Firefox 159 (its chrome input is ``Window.synthesizeMouseEvent``), and nothing red said so before the twins ran. The names are therefore read
|
||||
from the source of the release the twins use, never typed:
|
||||
|
||||
* ``dom/interfaces/base/nsIDOMWindowUtils.idl``: the methods, attributes and constants of ``nsIDOMWindowUtils`` (what ``win.windowUtils.<name>`` reaches);
|
||||
* ``dom/webidl/Window.webidl``: the members of ``interface Window`` and ``partial interface Window`` (with the parameter types and whether the member is ``ChromeOnly``), and every
|
||||
dictionary with its fields, parents included (what the options of ``win.synthesizeMouseEvent`` may carry).
|
||||
|
||||
The same two files of OUR engine tree are read the same way, and what they carry that Mozilla's do not is written apart, under ``ours``: ``jugglerSendMouseEvent``, the fields of the
|
||||
latency line. A call to one of those from code that runs on retail Firefox is red (tests/test_the_chrome_calls_of_the_tests_exist_in_firefox.py).
|
||||
|
||||
The file records, for every source, its path, the tag or commit and the sha256 of the bytes read. The wrapper's CI has no Firefox source, so the test reads the committed file and this
|
||||
module's functions are tested on a small sample (tests/test_the_extractor_of_the_chrome_names_reads_idl_and_webidl.py). One command regenerates the file:
|
||||
|
||||
python scripts/extract_mozilla_chrome_api.py --mozilla-repo <git repository with the Mozilla tag> --tag FIREFOX_159_0_RELEASE --ours-repo <our engine tree> --ours-ref <commit> --write
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DATA_PATH = ROOT / "ci" / "mozilla-chrome-api.json"
|
||||
|
||||
WINDOW_UTILS_IDL = "dom/interfaces/base/nsIDOMWindowUtils.idl"
|
||||
WINDOW_WEBIDL = "dom/webidl/Window.webidl"
|
||||
SOURCES = (WINDOW_UTILS_IDL, WINDOW_WEBIDL)
|
||||
|
||||
_BLOCK_COMMENT = re.compile(r"/\*.*?\*/", re.S)
|
||||
_LINE_COMMENT = re.compile(r"//[^\n]*")
|
||||
_LEADING_ATTRS = re.compile(r"^\s*(?:\[[^\]]*\]\s*)*")
|
||||
_WORD = re.compile(r"[A-Za-z_]\w*")
|
||||
|
||||
|
||||
def strip_comments(text: str) -> str:
|
||||
"""The text without comments and without preprocessor lines."""
|
||||
text = _BLOCK_COMMENT.sub(" ", text)
|
||||
text = _LINE_COMMENT.sub("", text)
|
||||
return "\n".join(line for line in text.splitlines() if not line.lstrip().startswith("#"))
|
||||
|
||||
|
||||
def _bodies(text: str, header: "re.Pattern[str]") -> List[Tuple[re.Match, str]]:
|
||||
"""Every ``header { body }`` of ``text`` (braces matched), with the header's match."""
|
||||
out: List[Tuple[re.Match, str]] = []
|
||||
for m in header.finditer(text):
|
||||
depth, i = 1, m.end()
|
||||
while i < len(text) and depth:
|
||||
depth += {"{": 1, "}": -1}.get(text[i], 0)
|
||||
i += 1
|
||||
out.append((m, text[m.end():i - 1]))
|
||||
return out
|
||||
|
||||
|
||||
def _statements(body: str) -> List[str]:
|
||||
"""The ``;``-terminated statements at the top level of ``body`` (a nested ``{}`` or ``()`` does not end one)."""
|
||||
out, depth, cur = [], 0, []
|
||||
for ch in body:
|
||||
if ch in "{(":
|
||||
depth += 1
|
||||
elif ch in "})":
|
||||
depth -= 1
|
||||
if ch == ";" and depth == 0:
|
||||
out.append("".join(cur).strip())
|
||||
cur = []
|
||||
else:
|
||||
cur.append(ch)
|
||||
return [s for s in out if s]
|
||||
|
||||
|
||||
def _split_params(text: str) -> List[str]:
|
||||
out, depth, cur = [], 0, []
|
||||
for ch in text:
|
||||
if ch in "<([":
|
||||
depth += 1
|
||||
elif ch in ">)]":
|
||||
depth -= 1
|
||||
if ch == "," and depth == 0:
|
||||
out.append("".join(cur).strip())
|
||||
cur = []
|
||||
else:
|
||||
cur.append(ch)
|
||||
tail = "".join(cur).strip()
|
||||
return out + [tail] if tail else out
|
||||
|
||||
|
||||
def _params(signature: str) -> List[List[str]]:
|
||||
"""``[[name, type], ...]`` of the parameters of the call in ``signature`` (``optional`` and defaults dropped, ``in`` of the IDL dropped)."""
|
||||
start = signature.index("(")
|
||||
depth, i = 0, start
|
||||
while i < len(signature):
|
||||
depth += {"(": 1, ")": -1}.get(signature[i], 0)
|
||||
if depth == 0:
|
||||
break
|
||||
i += 1
|
||||
out = []
|
||||
for raw in _split_params(signature[start + 1:i]):
|
||||
raw = re.sub(r"\[[^\]]*\]", " ", raw.split("=")[0])
|
||||
words = [w for w in raw.replace("<", " < ").replace(">", " > ").split() if w not in ("optional", "in", "out", "inout", "required")]
|
||||
text = " ".join(words).replace(" < ", "<").replace(" > ", ">").replace(" ,", ",")
|
||||
if not text:
|
||||
continue
|
||||
m = re.search(r"(\w+)$", text)
|
||||
out.append([m.group(1), text[:m.start()].strip()])
|
||||
return out
|
||||
|
||||
|
||||
def window_utils(idl_text: str) -> Dict[str, List[str]]:
|
||||
"""The methods, attributes and constants of ``nsIDOMWindowUtils`` in the text of its IDL file."""
|
||||
text = strip_comments(idl_text)
|
||||
methods, attributes, constants = set(), set(), set()
|
||||
for _m, body in _bodies(text, re.compile(r"interface\s+nsIDOMWindowUtils\b[^{;]*\{")):
|
||||
for statement in _statements(body):
|
||||
rest = _LEADING_ATTRS.sub("", statement).strip()
|
||||
if rest.startswith("const "):
|
||||
constants.add(_WORD.findall(rest.split("=")[0])[-1])
|
||||
elif re.search(r"\battribute\b", rest):
|
||||
attributes.add(_WORD.findall(rest.split("=")[0])[-1])
|
||||
elif "(" in rest:
|
||||
methods.add(_WORD.findall(rest.split("(")[0])[-1])
|
||||
return {"methods": sorted(methods), "attributes": sorted(attributes), "constants": sorted(constants)}
|
||||
|
||||
|
||||
def window(webidl_text: str) -> Dict[str, Any]:
|
||||
"""The members of ``Window`` (``interface`` and ``partial interface``) and every dictionary, parents folded in, from the text of a WebIDL file."""
|
||||
text = strip_comments(webidl_text)
|
||||
methods: Dict[str, Dict[str, Any]] = {}
|
||||
attributes: Dict[str, Dict[str, Any]] = {}
|
||||
for _m, body in _bodies(text, re.compile(r"(?:partial\s+)?interface\s+Window\b[^{;]*\{")):
|
||||
for statement in _statements(body):
|
||||
attrs = re.match(r"^\s*((?:\[[^\]]*\]\s*)*)", statement).group(1)
|
||||
rest = _LEADING_ATTRS.sub("", statement).strip()
|
||||
chrome_only = bool(re.search(r"\bChromeOnly\b", attrs))
|
||||
if re.search(r"\battribute\b", rest):
|
||||
attributes[_WORD.findall(rest.split("=")[0])[-1]] = {"chrome_only": chrome_only}
|
||||
elif "(" in rest and not rest.startswith("constructor"):
|
||||
name = _WORD.findall(rest.split("(")[0])[-1]
|
||||
methods[name] = {"chrome_only": chrome_only, "params": _params(rest)}
|
||||
own: Dict[str, Tuple[Optional[str], List[str]]] = {}
|
||||
for m, body in _bodies(text, re.compile(r"dictionary\s+(\w+)\s*(?::\s*(\w+))?\s*\{")):
|
||||
fields = []
|
||||
for statement in _statements(body):
|
||||
rest = _LEADING_ATTRS.sub("", statement.split("=")[0]).strip()
|
||||
if rest:
|
||||
fields.append(_WORD.findall(rest)[-1])
|
||||
own[m.group(1)] = (m.group(2), fields)
|
||||
|
||||
def flat(name: str) -> List[str]:
|
||||
parent, fields = own[name]
|
||||
return sorted(set(fields) | (set(flat(parent)) if parent in own else set()))
|
||||
|
||||
return {
|
||||
"methods": {k: methods[k] for k in sorted(methods)},
|
||||
"attributes": {k: attributes[k] for k in sorted(attributes)},
|
||||
"dictionaries": {k: flat(k) for k in sorted(own)},
|
||||
}
|
||||
|
||||
|
||||
def extract(idl_text: str, webidl_text: str) -> Dict[str, Any]:
|
||||
return {"window_utils": window_utils(idl_text), "window": window(webidl_text)}
|
||||
|
||||
|
||||
def only_in_ours(mozilla: Dict[str, Any], ours: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""What the extraction of our tree carries and Mozilla's does not."""
|
||||
out: Dict[str, Any] = {"window_utils": {}, "window": {"methods": [], "attributes": [], "dictionaries": {}}}
|
||||
for kind in ("methods", "attributes", "constants"):
|
||||
out["window_utils"][kind] = sorted(set(ours["window_utils"][kind]) - set(mozilla["window_utils"][kind]))
|
||||
for kind in ("methods", "attributes"):
|
||||
out["window"][kind] = sorted(set(ours["window"][kind]) - set(mozilla["window"][kind]))
|
||||
for name, fields in ours["window"]["dictionaries"].items():
|
||||
extra = sorted(set(fields) - set(mozilla["window"]["dictionaries"].get(name, [])))
|
||||
if extra:
|
||||
out["window"]["dictionaries"][name] = extra
|
||||
return out
|
||||
|
||||
|
||||
def _git_show(repo: Path, ref: str, path: str) -> bytes:
|
||||
return subprocess.run(["git", "-C", str(repo), "show", "%s:%s" % (ref, path)], check=True, capture_output=True).stdout
|
||||
|
||||
|
||||
def _read_source(repo: Path, ref: str) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||
blobs = {path: _git_show(repo, ref, path) for path in SOURCES}
|
||||
parsed = extract(blobs[WINDOW_UTILS_IDL].decode("utf-8"), blobs[WINDOW_WEBIDL].decode("utf-8"))
|
||||
sources = [{"path": path, "sha256": hashlib.sha256(blobs[path]).hexdigest()} for path in SOURCES]
|
||||
commit = subprocess.run(["git", "-C", str(repo), "rev-parse", "%s^{commit}" % ref], check=True, capture_output=True, text=True).stdout.strip()
|
||||
return parsed, {"ref": ref, "commit": commit, "files": sources}
|
||||
|
||||
|
||||
def build(mozilla_repo: Path, tag: str, ours_repo: Path, ours_ref: str) -> Dict[str, Any]:
|
||||
mozilla, mozilla_source = _read_source(mozilla_repo, tag)
|
||||
ours, ours_source = _read_source(ours_repo, ours_ref)
|
||||
return {
|
||||
"about": "Names a chrome-scope script of a test may call on the retail Firefox of the twins, extracted by scripts/extract_mozilla_chrome_api.py. Never edited by hand.",
|
||||
"mozilla": dict(mozilla_source, **mozilla),
|
||||
"ours": dict(ours_source, **only_in_ours(mozilla, ours)),
|
||||
}
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
||||
ap.add_argument("--mozilla-repo", type=Path, required=True)
|
||||
ap.add_argument("--tag", required=True)
|
||||
ap.add_argument("--ours-repo", type=Path, required=True)
|
||||
ap.add_argument("--ours-ref", required=True)
|
||||
ap.add_argument("--write", action="store_true", help="write ci/mozilla-chrome-api.json; without it the file is compared and the exit is 1 when it differs")
|
||||
args = ap.parse_args(argv)
|
||||
data = build(args.mozilla_repo, args.tag, args.ours_repo, args.ours_ref)
|
||||
text = json.dumps(data, indent=2, sort_keys=True) + "\n"
|
||||
if args.write:
|
||||
DATA_PATH.write_text(text, encoding="utf-8", newline="\n")
|
||||
print("wrote %s" % DATA_PATH)
|
||||
return 0
|
||||
same = DATA_PATH.read_text(encoding="utf-8") == text
|
||||
print("%s %s" % (DATA_PATH, "is what the sources give" if same else "DIFFERS from what the sources give: regenerate it with --write"))
|
||||
return 0 if same else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -10,9 +10,7 @@ seeds. This computes them from the prefs themselves, never from a list of the ta
|
||||
is a seed dimension);
|
||||
* every pref whose value differs between two seeds must belong to a DIMENSION below (a group of prefs read
|
||||
together: the renderer, the screen panel, the audio chain...) or be named in EXCLUDED with its reason. A pref
|
||||
that varies and is in neither is an error, so a new pref of a later core cannot go uncovered unnoticed. A pref that
|
||||
is a function of a dimension (the bar of a maximized window is of the panel) is in DERIVED instead: it is checked to
|
||||
take one value per value of its dimension, and it is no part of the stored features;
|
||||
that varies and is in neither is an error, so a new pref of a later core cannot go uncovered unnoticed;
|
||||
* a dimension's value for a seed is the joint value of its prefs; the reachable values of a dimension are the
|
||||
ones some seed in range produces.
|
||||
|
||||
@@ -58,7 +56,7 @@ DIMENSIONS = {
|
||||
"gfx_feature_status": (P + "gfx.feature_status",),
|
||||
"screen_panel": (P + "screen.width", P + "screen.height", P + "screen.avail_device_width",
|
||||
P + "screen.avail_device_height", "layout.css.devPixelsPerPx"),
|
||||
"dpr": ("layout.css.devPixelsPerPx", P + "screen.frame_border", P + "screen.popup_ui", P + "screen.popup_client_top"),
|
||||
"dpr": ("layout.css.devPixelsPerPx", P + "screen.frame_border", P + "screen.maximized_ui", P + "screen.popup_ui"),
|
||||
"cores": (P + "hw_concurrency",),
|
||||
"audio": (P + "audio.sample_rate", P + "audio.output_latency_ms", P + "audio.max_channel_count"),
|
||||
"codecs": ("media.av1.enabled", "media.encoder.webm.enabled", "media.mp4.enabled", "media.webm.enabled",
|
||||
@@ -75,15 +73,6 @@ EXCLUDED = {
|
||||
P + "media.enumeration_ms": "the time of the first enumerateDevices(): a draw from its own stream, hundreds of values, "
|
||||
"no class of seeds to cover",
|
||||
}
|
||||
#: Prefs that are a function of a dimension: {pref: the dimension}. They are not part of the dimension's value (so the
|
||||
#: stored features do not depend on which core emits them) and compute() CHECKS that, across the seeds, each takes exactly
|
||||
#: one value per value of its dimension, like the webgl prefs per renderer. A derived pref the core does not emit at all is
|
||||
#: fine: it is the pref of a core that comes later than the one in use (or earlier than the one that added it), and the pair
|
||||
#: of cores must give the same file. maximized_ui is of the panel because the core declares the bar from the work area's
|
||||
#: height as well as from the scale (declared_maximized_ui: compact when the work area is short in CSS px).
|
||||
DERIVED = {
|
||||
P + "screen.maximized_ui": "screen_panel",
|
||||
}
|
||||
#: What the candidate run visits: the smallest set that reaches every one of these dimensions' values.
|
||||
CANDIDATE_DIMENSIONS = ("webgl_renderer", "dpr")
|
||||
WEBGL = P + "webgl."
|
||||
@@ -117,7 +106,6 @@ def seed_features(seed: int) -> tuple:
|
||||
features["gfx_device"] = profile.gpu.device or "<none>"
|
||||
webgl = {k: json.dumps(v, sort_keys=True) for k, v in prefs.items() if k.startswith(WEBGL)}
|
||||
features["_webgl"] = hashlib.sha256(json.dumps(webgl, sort_keys=True).encode()).hexdigest()[:12]
|
||||
features["_derived"] = {k: json.dumps(prefs.get(k, "<absent>"), sort_keys=True) for k in DERIVED}
|
||||
return features, {k: json.dumps(v, sort_keys=True) for k, v in prefs.items()}
|
||||
|
||||
|
||||
@@ -137,25 +125,11 @@ def _range(bounds: tuple) -> tuple:
|
||||
return features, seen
|
||||
|
||||
|
||||
def check_derived(features: dict) -> None:
|
||||
"""Raises when a DERIVED pref takes two values within one value of its dimension. features: {seed: {dimension: value,
|
||||
"_derived": {pref: value}}}. A pref no seed has is skipped (a core that does not emit it)."""
|
||||
for pref, dim in DERIVED.items():
|
||||
seen = {}
|
||||
for seed in sorted(features):
|
||||
value = features[seed]["_derived"][pref]
|
||||
if seen.setdefault(features[seed][dim], (value, seed))[0] != value:
|
||||
first = seen[features[seed][dim]]
|
||||
raise SystemExit("the derived pref %s is not a function of the dimension %s (seed %d: %s, seed %d: %s, "
|
||||
"both with %s): it belongs to a wider dimension" % (
|
||||
pref, dim, first[1], first[0], seed, value, features[seed][dim]))
|
||||
|
||||
|
||||
def compute(max_seed: int = MAX_SEED, workers: int | None = None) -> dict:
|
||||
"""The features of every seed 0..max_seed-1: {seed: {dimension: value}} (the dimensions of ALL_DIMENSIONS).
|
||||
|
||||
Raises when a pref varies across the seeds and is in no dimension and not in EXCLUDED or DERIVED, when a DERIVED
|
||||
pref is not a function of its dimension, or when the webgl prefs are not a function of the renderer."""
|
||||
Raises when a pref varies across the seeds and is in no dimension and not in EXCLUDED, or when the webgl prefs are
|
||||
not a function of the renderer."""
|
||||
workers = workers or max(1, min(os.cpu_count() or 1, 8))
|
||||
step = max(1, -(-max_seed // (workers * 4)))
|
||||
bounds = [(lo, min(lo + step, max_seed)) for lo in range(0, max_seed, step)]
|
||||
@@ -171,12 +145,10 @@ def compute(max_seed: int = MAX_SEED, workers: int | None = None) -> dict:
|
||||
seen.setdefault(k, set()).update(vs)
|
||||
covered = {k for keys in DIMENSIONS.values() for k in keys}
|
||||
varying = sorted(k for k, vs in seen.items() if len(vs) > 1)
|
||||
loose = [k for k in varying if k not in covered and k not in EXCLUDED and k not in DERIVED and not k.startswith(WEBGL)]
|
||||
loose = [k for k in varying if k not in covered and k not in EXCLUDED and not k.startswith(WEBGL)]
|
||||
if loose:
|
||||
raise SystemExit("prefs that vary across seeds and belong to no dimension and are not excluded: %s\n"
|
||||
"add each to a DIMENSION, to DERIVED (a function of one) or to EXCLUDED (with the reason) in "
|
||||
"scripts/persona_cover.py" % loose)
|
||||
check_derived(features)
|
||||
"add each to a DIMENSION or to EXCLUDED (with the reason) in scripts/persona_cover.py" % loose)
|
||||
byrenderer = {}
|
||||
for seed in sorted(features):
|
||||
f = features[seed]
|
||||
@@ -184,8 +156,6 @@ def compute(max_seed: int = MAX_SEED, workers: int | None = None) -> dict:
|
||||
raise SystemExit("the webgl prefs are not a function of the renderer (seed %d, %s): split the dimension"
|
||||
% (seed, f["webgl_renderer"]))
|
||||
del f["_webgl"]
|
||||
for f in features.values():
|
||||
del f["_derived"]
|
||||
stale = [k for k in EXCLUDED if k not in seen or len(seen[k]) < 2]
|
||||
if stale:
|
||||
raise SystemExit("excluded prefs that no longer vary: %s: remove them from EXCLUDED" % stale)
|
||||
|
||||
@@ -215,45 +215,3 @@ def refusal(operation):
|
||||
"invisible_playwright does not implement: the package covers the "
|
||||
"automation core, and " + feature + " is outside it by decision, "
|
||||
"not by omission. See 32-stacco-da-playwright.md section 5.4.")
|
||||
|
||||
|
||||
#: ⛔ A PARAMETER OF A SERVED OPERATION THAT IS REFUSED, keyed by (operation, parameter), and the sentence a caller reads.
|
||||
#: The operations above are refused whole; these are refused one parameter (or one value of it) at a time, and the call
|
||||
#: without them is served. They are raised in `server.py` by `_refuse_parameter(operation, parameter)`, the one function
|
||||
#: that reads this table, and `tests/test_every_refusal_is_declared.py` holds the two sides to each other.
|
||||
#:
|
||||
#: ⛔ WHY THESE FIVE. Stock Playwright honours `mask`, `style` and `animations="disabled"` by MODIFYING THE PAGE (an overlay,
|
||||
#: an injected `<style>`, animations finished or cancelled) before the picture and putting it back after. This package does
|
||||
#: not touch a page to photograph it, and until now it did not read them either: the call succeeded and the picture was as
|
||||
#: if they had not been written, which a caller cannot see. `caret="initial"` asks for the text caret to be drawn, and the
|
||||
#: engine never draws it (the capture does not set the flag that draws it), so the picture it takes is the one `"hide"`
|
||||
#: asks for, which is also Playwright's default: `"hide"` and an absent `caret` are served. `omitBackground` with png is
|
||||
#: Firefox's own `Not implemented` in stock (`FFPage.setBackgroundColor`), word for word; with jpeg stock does nothing and
|
||||
#: neither do we.
|
||||
REFUSED_PARAMETERS = {
|
||||
("screenshot", "mask"):
|
||||
"screenshot(mask=...) is not served: Playwright covers the masked elements by modifying the page (an overlay is "
|
||||
"put on it before the picture), and this package does not touch a page to take a picture. maskColor goes with "
|
||||
"mask and is refused with it. Hide the elements yourself before the screenshot (for example set their "
|
||||
"visibility to hidden in your own script) and restore them after.",
|
||||
("screenshot", "style"):
|
||||
"screenshot(style=...) is not served: Playwright applies it by modifying the page (a <style> element is "
|
||||
"injected before the picture and removed after), and this package does not touch a page to take a picture. Add "
|
||||
"the style yourself with page.add_style_tag() before the screenshot and remove the element it returns after.",
|
||||
("screenshot", "animations"):
|
||||
'screenshot(animations="disabled") is not served: Playwright does it by modifying the page (the finite '
|
||||
"animations are finished and the infinite ones cancelled), and this package does not touch a page to take a "
|
||||
"picture. Wait for the animations to end, or pause them in your own script (document.getAnimations()), before "
|
||||
'the screenshot. animations="allow" is what is served.',
|
||||
("screenshot", "caret"):
|
||||
'screenshot(caret="initial") is not served: it asks for the text caret to be drawn in the picture, and the '
|
||||
'engine never draws it (the picture is the one caret="hide" asks for, which is the default of Playwright). Leave '
|
||||
'caret out or pass "hide".',
|
||||
("screenshot", "omitBackground"):
|
||||
"Not implemented",
|
||||
}
|
||||
|
||||
|
||||
def parameter_refusal(operation, parameter):
|
||||
"""The sentence for a refused (operation, parameter): `KeyError` for one that is not declared."""
|
||||
return REFUSED_PARAMETERS[(operation, parameter)]
|
||||
@@ -47,7 +47,7 @@ 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 _bindings, dialogs, perimeter
|
||||
from . import _bindings, dialogs
|
||||
from ._reaped import SessionRemoval
|
||||
from ._threads import ThreadStarterLease
|
||||
from .pointer import Pointer
|
||||
@@ -676,37 +676,6 @@ def _run_callers_code(injected: InjectedScript, frame_id: str, params: Dict,
|
||||
argument.release()
|
||||
|
||||
|
||||
def _refuse_parameter(operation: str, parameter: str):
|
||||
"""Refuse one parameter of a served operation with the sentence `perimeter.REFUSED_PARAMETERS` holds for it.
|
||||
|
||||
⛔ THE ONLY WAY A PARAMETER IS REFUSED, so that the inventory and the code cannot drift: the test of the refusals reads
|
||||
every call of this function in the file and holds it to that table, both ways."""
|
||||
raise ProtocolException(perimeter.parameter_refusal(operation, parameter))
|
||||
|
||||
|
||||
def _refuse_unserved_screenshot_parameters(params: Dict) -> None:
|
||||
"""⛔ WHAT STOCK DOES BY MODIFYING THE PAGE IS REFUSED, NOT IGNORED, AND BEFORE THE PAGE IS TOUCHED. `mask`, `style` and
|
||||
`animations="disabled"` change the page before the picture in Playwright; this server took them without reading them, and the
|
||||
picture came back as if they had not been written. `caret="initial"` asks for the text caret to be drawn, which the engine never
|
||||
does. `omitBackground` with png is Firefox's own `Not implemented` (stock reaches it only for png). The sentences are
|
||||
`perimeter.REFUSED_PARAMETERS`'.
|
||||
|
||||
⛔ THE ONE CHECK, CALLED FIRST BY THE PAGE'S SCREENSHOT AND BY THE ELEMENT'S (a locator's is the element's): the element's call
|
||||
scrolls the element into view and measures it, and a call that is going to be refused must not have done either. It reads
|
||||
`params` and nothing else, so calling it again with the same parameters, as the element's call does through the page's, answers
|
||||
the same."""
|
||||
if params.get("mask"):
|
||||
_refuse_parameter("screenshot", "mask")
|
||||
if params.get("style"):
|
||||
_refuse_parameter("screenshot", "style")
|
||||
if params.get("animations") == "disabled":
|
||||
_refuse_parameter("screenshot", "animations")
|
||||
if params.get("caret") == "initial":
|
||||
_refuse_parameter("screenshot", "caret")
|
||||
if params.get("omitBackground") and params.get("type") != "jpeg":
|
||||
_refuse_parameter("screenshot", "omitBackground")
|
||||
|
||||
|
||||
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
|
||||
@@ -1102,8 +1071,6 @@ class ElementHandleDispatcher(Dispatcher):
|
||||
Playwright's screenshotter does: the left and top edges to the nearest
|
||||
pixel, the size from the rounded right and bottom edges.
|
||||
"""
|
||||
# ⛔ THE REFUSAL COMES BEFORE THE SCROLL AND THE MEASURE: a call that is refused must not have moved the page.
|
||||
_refuse_unserved_screenshot_parameters(params)
|
||||
# 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:
|
||||
@@ -4510,10 +4477,6 @@ class PageDispatcher(Dispatcher):
|
||||
# A clip the CALLER supplied is passed through untouched. Playwright
|
||||
# documents it in page coordinates, which is what the engine wants, so
|
||||
# there is nothing to translate.
|
||||
# ⛔ THE REFUSALS ARE `_refuse_unserved_screenshot_parameters`, THE FIRST THING HERE AND THE FIRST THING IN THE ELEMENT'S SCREENSHOT.
|
||||
# It is idempotent, so the element's call, which hands its rectangle and the caller's parameters to this one, passes it twice
|
||||
# and the second pass is the same answer.
|
||||
_refuse_unserved_screenshot_parameters(params)
|
||||
clip = params.get("clip")
|
||||
if not clip:
|
||||
box = self.injected.evaluate(
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
"""The row the host oracle's declared list carried while the published engine was the 68 or the 69 and the candidate no longer spawned the graphics probe.
|
||||
|
||||
ci/ab-host-expected.json declares what the published engine of today and the candidate differ by, which is nothing now (the published engine is the 70, which does not spawn
|
||||
gfxtest either, so the row would be stale in every run). The mechanism of a declared `proc` difference (the kind and the paths only that process touched, the A/B only, the stale
|
||||
check) is tested with this row, as a row of the tests' own.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
|
||||
GFXTEST_ROW = {
|
||||
"id": "gfxtest-69",
|
||||
"os": "linux",
|
||||
"category": "proc",
|
||||
"name": "gfxtest",
|
||||
"published": "present",
|
||||
"candidate": "absent",
|
||||
"reason": "the 69 no longer spawns the graphics probe gfxtest (GFX_PROBE_BINARY, widget/gtk/GfxInfo.cpp:55; commit 0e896e4ee1, the probe never reads the host); the paths only that process touched go with it",
|
||||
}
|
||||
|
||||
|
||||
def gfxtest_rows() -> list:
|
||||
return [copy.deepcopy(GFXTEST_ROW)]
|
||||
@@ -1,187 +0,0 @@
|
||||
"""What the drag twin records of a drag, and how two records are compared: every drag event the page hears, in the top document and in the frame, never a number of ours.
|
||||
|
||||
``RECORDER_JS`` is the script both pages run: for each of ``dragstart``, ``drag``, ``dragenter``, ``dragover``, ``dragleave``, ``drop`` and ``dragend`` (heard at the document, after the
|
||||
page's own handlers, so ``dataTransfer.types`` is what the page has set by then) it keeps, in ``window.__events``, the fields of ``FIELDS``:
|
||||
|
||||
type, at (the id of the event's target), under (the id of ``document.elementFromPoint`` at the event's client point), cx/cy (clientX/Y), sx/sy (screenX/Y), buttons, input (mozInputSource),
|
||||
types (dataTransfer.types), allowed (effectAllowed), effect (dropEffect), cancelled (mozUserCancelled), source_null (whether mozSourceNode is null), trusted (isTrusted).
|
||||
|
||||
``record(top_events, frame_events)`` is what one browser leaves: for each document (the top one, where the drag starts and ends and a drop can land, and the frame) the events that happen once
|
||||
or a few times (``once``: dragstart, dragenter, dragleave, drop, dragend, in the order the page heard them) whole, and for ``drag`` and ``dragover``, which repeat as often as the mouse moves
|
||||
and as a timer fires, their count, their first and last event and the ids they were dispatched at. ``end_minus_last`` is ``dragend``'s client point less the last ``drag``'s, in the top
|
||||
document.
|
||||
|
||||
HOW TWO RECORDS ARE COMPARED (``compare``): with stock, only what stock decides the same way on every machine and in either process model: the routing and the targets (the event sequence, the
|
||||
type, the target, what is under the point), the client points, ``rel``, the data transfer's types, trusted, the input source, and, in the top document, the effects (the same process on both
|
||||
sides) of every event but the one the frame's process decides (see the twin rule). In a CSS pixel for the client points (``TOLERANCES``: the point of a drag is a device pixel that crosses a process and is rounded to CSS, the tolerance the twin has always had for the
|
||||
drop point); and through the relation for the screen points. ``screenX/Y`` is where the window stands on the screen: stock's is the real place of its window and ours is the declared one, so the
|
||||
two are not the same number and no number of ours is the expected one. What the page reads is the same in both: where a point is on the screen relative to where the top document's first event is
|
||||
(``rel``: ``screen - client`` of the event, less that of the first event of the top document). It is 0 for every event of the top document and the frame's place in it for a frame's event, in a
|
||||
browser whose window stands anywhere. The absolute screen points and the origin are in the record, printed when the two differ, and not in the comparison. The count of ``dragover`` events is in
|
||||
the record and not in the comparison: it is timer-driven.
|
||||
|
||||
THE TWIN RULE (``DECLARED``): a field that depends on stock's frame being in the top's process, or on stock's drag being Juggler's synthetic one, is in the record and NOT compared with stock; the
|
||||
list says which and why, and ``recorded`` returns what differs there, for the report. Retail decides those fields, through the capture of the round ``drag`` of the core's window-geometry workflow.
|
||||
They are ``buttons`` (stock's synthetic drag has no OLE loop: 0), ``drag`` at the source (count and presence: no OLE loop, no timer-driven ``drag``), the ``dragend`` point less the last ``drag``
|
||||
(no ``drag`` to be less of), and in the frame ``effectAllowed``, ``dropEffect`` and ``mozSourceNode`` (stock's frame is in-process and reads the source's own DataTransfer; ours is in another
|
||||
process, where Mozilla's cross-process DataTransfer starts with effectAllowed ``uninitialized`` and the dropEffect is the action, nsContentUtils FilterDropEffect).
|
||||
For the drop in the frame (``kind`` ``frame``), two more fields of the TOP document depend on the frame's process, and ``comparable`` moves them out of ``top.once`` before the comparison: every top
|
||||
``dragleave`` whose ``under`` is the frame (``top.into_frame``: stock's frame is in its own process model, so the top's event manager fires a leave at the body when the cursor enters the
|
||||
subdocument; retail with the frame out of process has none, and ours has none) and the ``dropEffect`` of the top ``dragend`` (``top.dragend_effect``: it is the frame's drop result, which crosses
|
||||
processes). In the drop in the top document (``kind`` ``top``) the record is compared whole, ``dragend``'s effect included.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from _stock_twin import IN_PROCESS_FRAME, SYNTHETIC_DRAG, both, split_differences
|
||||
|
||||
#: The events of a drag, in the order a drag starts, goes over and ends.
|
||||
TYPES = ("dragstart", "drag", "dragenter", "dragover", "dragleave", "drop", "dragend")
|
||||
#: Events that repeat (every mouse move, every timer tick): the record keeps their count, their first and last event.
|
||||
REPEATED = ("drag", "dragover")
|
||||
#: What the page keeps of each event, and so what the record has of it.
|
||||
FIELDS = ("type", "at", "under", "cx", "cy", "sx", "sy", "buttons", "input", "types", "allowed", "effect", "cancelled", "source_null", "trusted")
|
||||
#: A CSS pixel for a client point and for the relation of the screen point to the client one; every other number exactly.
|
||||
TOLERANCES: Dict[str, float] = {"cx": 1.0, "cy": 1.0, "rel": 1.0}
|
||||
#: Keys of the record that are in it and not in the comparison, and why (the count of ``drag`` and of ``dragover`` is left out in ``_comparable``: a timer fires them, so it depends on the speed of the machine).
|
||||
NOT_COMPARED = {
|
||||
"sx": "the real place of stock's window and the declared one of ours: compared through rel",
|
||||
"sy": "the real place of stock's window and the declared one of ours: compared through rel",
|
||||
"screen_origin": "screen minus client of the first event of the top document: where the window stands",
|
||||
}
|
||||
|
||||
#: THE TWIN RULE. Stock Playwright's Firefox sets ``fission.webContentIsolationStrategy=0``: its cross-site frame is in the top's process, ours is in another process, and stock's drag is Juggler's
|
||||
#: synthetic one (no OLE drag loop). A field that depends on either is RECORDED, not compared with stock: the retail capture decides it (round ``drag`` of the core's window-geometry workflow, which
|
||||
#: drives a real drag on retail). Each key is a pattern of canonical paths of the record (``top.once[].buttons``; ``*`` is any run of characters), each value is the reason.
|
||||
#: What is compared with stock is the routing and the targets (the event sequence, ``type``, ``at``, ``under``), the client points and ``rel``, ``types``, ``trusted`` and ``input`` (mozInputSource),
|
||||
#: in both documents, and ``effectAllowed`` and ``dropEffect`` of the top document, except, in the drop in the frame, the top's leave into the frame and the top ``dragend``'s ``dropEffect``.
|
||||
DECLARED: Dict[str, str] = {
|
||||
# stock's synthetic Juggler drag: no OLE loop, so the mouse buttons are 0 in its events and ``drag`` never fires at the source (and the dragend point less the last drag has no drag to be less of)
|
||||
"*.buttons": SYNTHETIC_DRAG,
|
||||
"top.repeated.drag.*": SYNTHETIC_DRAG,
|
||||
"end_minus_last*": SYNTHETIC_DRAG,
|
||||
# stock's frame is in-process: it reads the source's own DataTransfer; ours is in another process, where Mozilla's cross-process DataTransfer starts with effectAllowed 'uninitialized' and
|
||||
# dropEffect is the action (nsContentUtils FilterDropEffect), and mozSourceNode is not reachable
|
||||
"frame.*.allowed": IN_PROCESS_FRAME,
|
||||
"frame.*.effect": IN_PROCESS_FRAME,
|
||||
"frame.*.source_null": IN_PROCESS_FRAME,
|
||||
# the frame drop only (``comparable`` makes these keys): stock's top hears a leave at the body when the cursor enters its in-process-model subdocument, and the top dragend's dropEffect is the
|
||||
# frame's drop result, which crosses processes
|
||||
"top.into_frame*": IN_PROCESS_FRAME,
|
||||
"top.dragend_effect*": IN_PROCESS_FRAME,
|
||||
}
|
||||
|
||||
RECORDER_JS = """
|
||||
window.__events = [];
|
||||
(function () {
|
||||
const name = n => n ? (n.id || n.nodeName.toLowerCase()) : null;
|
||||
for (const type of %s) {
|
||||
document.addEventListener(type, e => {
|
||||
const dt = e.dataTransfer;
|
||||
window.__events.push({
|
||||
type: e.type, at: name(e.target), under: name(document.elementFromPoint(e.clientX, e.clientY)),
|
||||
cx: e.clientX, cy: e.clientY, sx: e.screenX, sy: e.screenY, buttons: e.buttons, input: e.mozInputSource,
|
||||
types: dt ? Array.from(dt.types) : null, allowed: dt ? dt.effectAllowed : null, effect: dt ? dt.dropEffect : null,
|
||||
cancelled: dt ? dt.mozUserCancelled : null, source_null: dt ? dt.mozSourceNode === null : null, trusted: e.isTrusted,
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
""" % json.dumps(list(TYPES))
|
||||
|
||||
READ_JS = "() => window.__events"
|
||||
|
||||
|
||||
def read_events(document) -> List[Dict[str, Any]]:
|
||||
"""The raw events a page or frame heard (``document`` is a Playwright page or frame)."""
|
||||
return document.evaluate(READ_JS)
|
||||
|
||||
|
||||
def _event(raw: Dict[str, Any], origin: Optional[List[float]]) -> Dict[str, Any]:
|
||||
missing = [f for f in FIELDS if f not in raw]
|
||||
if missing:
|
||||
raise ValueError("a drag event the page recorded has no %s (an absent field is a difference, never an agreement): %r" % (", ".join(missing), raw))
|
||||
out = {f: raw[f] for f in FIELDS}
|
||||
out["rel"] = None if origin is None else [raw["sx"] - raw["cx"] - origin[0], raw["sy"] - raw["cy"] - origin[1]]
|
||||
return out
|
||||
|
||||
|
||||
def _document(events: List[Dict[str, Any]], origin: Optional[List[float]]) -> Dict[str, Any]:
|
||||
once = [_event(e, origin) for e in events if e.get("type") not in REPEATED]
|
||||
repeated: Dict[str, Any] = {}
|
||||
for kind in REPEATED:
|
||||
of_kind = [_event(e, origin) for e in events if e.get("type") == kind]
|
||||
repeated[kind] = ({"count": len(of_kind), "first": of_kind[0], "last": of_kind[-1], "at": sorted({str(e["at"]) for e in of_kind})}
|
||||
if of_kind else {"count": 0})
|
||||
return {"once": once, "repeated": repeated}
|
||||
|
||||
|
||||
def record(top_events: List[Dict[str, Any]], frame_events: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""What one browser leaves of one drag: both documents' events, the end point less the last drag point, and the origin of the screen points."""
|
||||
origin = [top_events[0]["sx"] - top_events[0]["cx"], top_events[0]["sy"] - top_events[0]["cy"]] if top_events else None
|
||||
top = _document(top_events, origin)
|
||||
drags = [e for e in top_events if e.get("type") == "drag"]
|
||||
ends = [e for e in top_events if e.get("type") == "dragend"]
|
||||
last, end = (drags[-1] if drags else None), (ends[-1] if ends else None)
|
||||
return {"top": top, "frame": _document(frame_events, origin),
|
||||
"end_minus_last": [end["cx"] - last["cx"], end["cy"] - last["cy"]] if (end and last) else None,
|
||||
"screen_origin": origin}
|
||||
|
||||
|
||||
def read_record(page, frame) -> Dict[str, Any]:
|
||||
"""The record of a drag, read from the top page and from the frame."""
|
||||
return record(read_events(page), read_events(frame))
|
||||
|
||||
|
||||
def _comparable(node: Any, key: str = "") -> Any:
|
||||
if isinstance(node, dict):
|
||||
return {k: _comparable(v, k) for k, v in node.items() if k not in NOT_COMPARED and not (key in REPEATED and k == "count")}
|
||||
if isinstance(node, list):
|
||||
return [_comparable(v, key) for v in node]
|
||||
return copy.deepcopy(node)
|
||||
|
||||
|
||||
#: The id of the frame in the top page (``f``): the ``under`` of the top's leave into it.
|
||||
FRAME_ID = "f"
|
||||
|
||||
|
||||
def comparable(record: Dict[str, Any], kind: str) -> Dict[str, Any]:
|
||||
"""The record as it is compared: for the drop in the frame (``kind`` ``frame``) the top's ``dragleave`` events under the frame leave ``top.once`` for ``top.into_frame`` and the top ``dragend``'s
|
||||
``effect`` leaves its event for ``top.dragend_effect``; both keys are in ``DECLARED``. For the drop in the top document (``top``) the record is unchanged."""
|
||||
if kind not in ("top", "frame"):
|
||||
raise ValueError("the drop is in the 'top' document or in the 'frame', not %r" % (kind,))
|
||||
out = _comparable(record)
|
||||
if kind == "frame":
|
||||
top = out["top"]
|
||||
into_frame = [e for e in top["once"] if e["type"] == "dragleave" and e["under"] == FRAME_ID]
|
||||
top["once"] = [e for e in top["once"] if not (e["type"] == "dragleave" and e["under"] == FRAME_ID)]
|
||||
top["into_frame"] = into_frame
|
||||
top["dragend_effect"] = [e.pop("effect") for e in top["once"] if e["type"] == "dragend"]
|
||||
return out
|
||||
|
||||
|
||||
def split(stock: Dict[str, Any], ours: Dict[str, Any], kind: str, path: str = "drag") -> Tuple[List[str], List[str]]:
|
||||
"""``(red, recorded)``: the differences that decide, and those of the declared fields (``DECLARED``), kept for the report. ``kind`` is where the drop ended: ``top`` or ``frame``."""
|
||||
return split_differences(comparable(stock, kind), comparable(ours, kind), DECLARED, TOLERANCES, path)
|
||||
|
||||
|
||||
def compare(stock: Dict[str, Any], ours: Dict[str, Any], kind: str, path: str = "drag") -> List[str]:
|
||||
"""Every place where ours is not what stock is in a field that is compared, as ``path: stock X, ours Y``; empty when the page reads the same there."""
|
||||
return split(stock, ours, kind, path)[0]
|
||||
|
||||
|
||||
def recorded(stock: Dict[str, Any], ours: Dict[str, Any], kind: str, path: str = "drag") -> List[str]:
|
||||
"""The differences in the fields of ``DECLARED``: in the report, never in the verdict."""
|
||||
return split(stock, ours, kind, path)[1]
|
||||
|
||||
|
||||
def verdict(case: str, kind: str, stock: Dict[str, Any], ours: Dict[str, Any]) -> str:
|
||||
"""The message of a red drag twin, with both records whole; empty when ours is what stock is."""
|
||||
differing = compare(stock, ours, kind, "%s drop" % kind)
|
||||
if not differing:
|
||||
return ""
|
||||
return ("%s: the drag that ends in the %s of ours does not read what stock's does (every event, that drag fired at the source, dragend less the last drag):\n %s%s"
|
||||
% (case, "frame of another site" if kind == "frame" else "top document", "\n ".join(differing), both(case, stock, ours)))
|
||||
@@ -1,58 +0,0 @@
|
||||
"""A stock Playwright client that launches nothing and records what ``p.firefox.launch`` was called with, for the unit tests of the stock twins (no browser, no display)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import _stock_twin
|
||||
|
||||
|
||||
class _Page:
|
||||
pass
|
||||
|
||||
|
||||
class _Context:
|
||||
def new_page(self) -> _Page:
|
||||
return _Page()
|
||||
|
||||
|
||||
class _Browser:
|
||||
def __init__(self, events: List[str]) -> None:
|
||||
self._events = events
|
||||
|
||||
def new_context(self, **kwargs: Any) -> _Context:
|
||||
return _Context()
|
||||
|
||||
def close(self) -> None:
|
||||
self._events.append("browser closed")
|
||||
|
||||
|
||||
class _Firefox:
|
||||
def __init__(self, launches: List[Dict[str, Any]], events: List[str], fail: bool) -> None:
|
||||
self._launches, self._events, self._fail = launches, events, fail
|
||||
|
||||
def launch(self, **kwargs: Any) -> _Browser:
|
||||
self._events.append("launch")
|
||||
self._launches.append(kwargs)
|
||||
if self._fail:
|
||||
raise RuntimeError("the launch fails")
|
||||
return _Browser(self._events)
|
||||
|
||||
|
||||
class _Playwright:
|
||||
def __init__(self, launches: List[Dict[str, Any]], events: List[str], fail: bool) -> None:
|
||||
self.firefox = _Firefox(launches, events, fail)
|
||||
|
||||
def __enter__(self) -> "_Playwright":
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc: Any) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def install(monkeypatch, events: List[str] = None, fail: bool = False) -> List[Dict[str, Any]]:
|
||||
"""``_stock_twin._on_stock`` on a client that records its launches (the keywords of each) in the list returned, and its steps in ``events``."""
|
||||
launches: List[Dict[str, Any]] = []
|
||||
events = [] if events is None else events
|
||||
monkeypatch.setattr(_stock_twin, "stock_client", lambda: (lambda: _Playwright(launches, events, fail)))
|
||||
monkeypatch.setattr(_stock_twin, "Chrome", type("FakeChrome", (), {"__init__": lambda self, page: None, "close": lambda self: None}))
|
||||
return launches
|
||||
@@ -1,228 +0,0 @@
|
||||
"""A test that is not e2e never leaves the machine: every connection, datagram and name lookup it makes goes to this host or is refused.
|
||||
|
||||
The markers say it already (pyproject.toml: ``unit`` is "no network", ``integration`` is "no network"), and nothing enforced it:
|
||||
``tests/unit/test_config_public.py`` composed the default prefs with no declared exit, the core asked api.ipify.org and icanhazip.com
|
||||
where it leaves from, and the test failed on a machine whose network refused them. A test cannot fail for the reasons of a third party.
|
||||
|
||||
:func:`install` patches the four doors of the standard library that every client in the process goes through (``socket.socket.connect``,
|
||||
``connect_ex`` and ``sendto``, and ``socket.getaddrinfo``): a destination on this host passes, anything else is refused with
|
||||
:class:`LeftTheMachine` (a ``ConnectionRefusedError``, so the code under test sees what an offline machine shows it) AND recorded, so the test
|
||||
fails at its teardown even when the code under test swallowed the refusal. The record names the test, the door and the destination.
|
||||
|
||||
asyncio has doors of its own, and on Windows they skip the four above: the Proactor loop connects with ``ConnectEx`` and sends datagrams with
|
||||
``WSASendTo`` (``_overlapped``), never through ``socket.socket``. So the guard also patches the loop methods every asyncio client goes through, for
|
||||
both loop kinds: ``BaseEventLoop.create_connection`` and ``create_datagram_endpoint`` (``remote_addr``), ``sock_connect`` and ``sock_sendto`` of the
|
||||
selector and of the Proactor loop, and the Proactor datagram transport's ``sendto``.
|
||||
|
||||
What it cannot see, on any system: a socket made from ``_socket`` directly or used through ``_overlapped`` by hand (no library of this project
|
||||
does), native code in the same process, and a child process (a subprocess has its own interpreter: the e2e are where a browser runs).
|
||||
|
||||
On this host: a loopback address (127/8, ::1), the unspecified address (0.0.0.0, ::, which a connect reaches on this host), a name that is
|
||||
``localhost`` or ends in ``.localhost``, and an AF_UNIX path. The documentation ranges (192.0.2/24, 198.51.100/24, 203.0.113/24, 2001:db8::/32)
|
||||
pass too: they are never routed, and the lab gives one of them to an interface of this host (the exit of the lab, tests/_lab_egress.py).
|
||||
And the address this host sends from (its default route's, tests/_host_address.py): a relay of the tests that leaves from the address of the
|
||||
host is on this host, and a datagram to it never leaves the machine.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ipaddress
|
||||
import socket
|
||||
import threading
|
||||
from typing import Any, List, Optional, Sequence, Tuple
|
||||
|
||||
_DOCUMENTATION = tuple(ipaddress.ip_network(n) for n in ("192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24", "2001:db8::/32"))
|
||||
|
||||
RULE = ("a test that is not e2e never leaves the machine (pyproject.toml markers: unit and integration are 'no network'): "
|
||||
"a test cannot fail for the reasons of a third party")
|
||||
FIX = ("declare the value the code would ask the network for (timezone=, locale=, proxy= with a local gateway), use a server of the tests "
|
||||
"on loopback (tests/_servers.py, the local_egress_echo fixture), or mark the test e2e if it is one")
|
||||
|
||||
|
||||
#: The ONE file whose job is to ask a third party, and the hosts it may ask. Nothing else is declared, and a new entry is a decision, not a fix.
|
||||
#: ``tests/test_version_is_not_taken.py`` is the version gate of a pull request: it asks the index whether the version the change proposes
|
||||
#: is already published, which only the index can answer. It is skipped unless ``IPW_CHECK_VERSION`` is set, which only the ``version`` job
|
||||
#: of tests.yml does. Its host is allowed for its name lookup and for the addresses that lookup answered, nothing else.
|
||||
DECLARED_THIRD_PARTIES = {
|
||||
"tests/test_version_is_not_taken.py": ("pypi.org",),
|
||||
}
|
||||
|
||||
|
||||
class LeftTheMachine(ConnectionRefusedError):
|
||||
"""A destination outside this host, refused by the guard of the tests."""
|
||||
|
||||
|
||||
def own_addresses() -> Tuple[str, ...]:
|
||||
"""The addresses this host sends from, IPv4 and IPv6 (the source its default route picks). A UDP connect sends no packet; a family with
|
||||
no route has none. Read BEFORE the doors are patched."""
|
||||
found = []
|
||||
for family, probe in ((socket.AF_INET, ("192.0.2.1", 9)), (socket.AF_INET6, ("2001:db8::1", 9))):
|
||||
try:
|
||||
with socket.socket(family, socket.SOCK_DGRAM) as s:
|
||||
s.connect(probe)
|
||||
found.append(s.getsockname()[0].split("%", 1)[0])
|
||||
except OSError:
|
||||
pass
|
||||
return tuple(found)
|
||||
|
||||
|
||||
def is_on_this_host(host: Any, own: Sequence[str] = ()) -> bool:
|
||||
"""Whether ``host`` (an address, a name, or None) is on this host, the way the guard decides it; ``own`` are the addresses of this host
|
||||
(:func:`own_addresses`)."""
|
||||
if host is None:
|
||||
return True
|
||||
if isinstance(host, bytes):
|
||||
host = host.decode("ascii", "replace")
|
||||
host = str(host).strip("[]").split("%", 1)[0]
|
||||
if host == "" or host.lower() == "localhost" or host.lower().endswith(".localhost"):
|
||||
return True
|
||||
try:
|
||||
address = ipaddress.ip_address(host)
|
||||
except ValueError:
|
||||
return False # a name: resolving it is already a question to the network
|
||||
if getattr(address, "ipv4_mapped", None) is not None:
|
||||
address = address.ipv4_mapped
|
||||
return (address.is_loopback or address.is_unspecified or any(address in net for net in _DOCUMENTATION)
|
||||
or any(address == ipaddress.ip_address(mine) for mine in own))
|
||||
|
||||
|
||||
def _destination(address: Any, own: Sequence[str] = ()) -> Optional[str]:
|
||||
"""``host:port`` of a socket address that leaves the machine, or None when it does not (AF_UNIX paths and this host)."""
|
||||
if not isinstance(address, tuple) or not address:
|
||||
return None # an AF_UNIX path or an abstract name: this host
|
||||
host = address[0]
|
||||
if is_on_this_host(host, own):
|
||||
return None
|
||||
return "%s:%s" % (host, address[1] if len(address) > 1 else "?")
|
||||
|
||||
|
||||
class Guard:
|
||||
"""The record of one test: what it tried outside the machine. Thread-safe: a client thread of the test is recorded too."""
|
||||
|
||||
def __init__(self, test: str) -> None:
|
||||
self.test = test
|
||||
self.attempts: List[str] = []
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def refuse(self, door: str, destination: str) -> LeftTheMachine:
|
||||
sentence = "%s %s" % (door, destination)
|
||||
with self._lock:
|
||||
if sentence not in self.attempts:
|
||||
self.attempts.append(sentence)
|
||||
return LeftTheMachine("WHERE: %s. WHAT: %s, outside this host, refused. FIX: %s. RULE: %s." % (self.test, sentence, FIX, RULE))
|
||||
|
||||
def verdict(self) -> Optional[str]:
|
||||
"""The failure of the test, or None when it stayed on this host."""
|
||||
if not self.attempts:
|
||||
return None
|
||||
return ("WHERE: %s. WHAT: the test tried to leave the machine: %s (each was refused). FIX: %s. RULE: %s."
|
||||
% (self.test, "; ".join(self.attempts), FIX, RULE))
|
||||
|
||||
|
||||
def install(monkeypatch: Any, test: str) -> Guard:
|
||||
"""Patch the four doors for the duration of ``monkeypatch``; return the record of ``test``."""
|
||||
guard = Guard(test)
|
||||
declared_hosts = DECLARED_THIRD_PARTIES.get(test.split("::", 1)[0].replace("\\", "/"), ())
|
||||
answered = set() # the addresses a lookup of a declared host answered: a connection to them is that host
|
||||
own = tuple(own_addresses())
|
||||
|
||||
def mine():
|
||||
return own + tuple(answered)
|
||||
connect, connect_ex, sendto, getaddrinfo = (socket.socket.connect, socket.socket.connect_ex, socket.socket.sendto,
|
||||
socket.getaddrinfo)
|
||||
|
||||
def guarded_connect(self, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("connect to", where)
|
||||
return connect(self, address)
|
||||
|
||||
def guarded_connect_ex(self, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("connect to", where)
|
||||
return connect_ex(self, address)
|
||||
|
||||
def guarded_sendto(self, data, *rest):
|
||||
where = _destination(rest[-1] if rest else None, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("datagram to", where)
|
||||
return sendto(self, data, *rest)
|
||||
|
||||
def guarded_getaddrinfo(host, *args, **kwargs):
|
||||
if isinstance(host, str) and host.lower() in declared_hosts:
|
||||
found = getaddrinfo(host, *args, **kwargs)
|
||||
answered.update(info[4][0] for info in found)
|
||||
return found
|
||||
if not is_on_this_host(host, mine()):
|
||||
raise guard.refuse("name lookup of", str(host))
|
||||
return getaddrinfo(host, *args, **kwargs)
|
||||
|
||||
_install_asyncio(monkeypatch, guard, mine)
|
||||
monkeypatch.setattr(socket.socket, "connect", guarded_connect)
|
||||
monkeypatch.setattr(socket.socket, "connect_ex", guarded_connect_ex)
|
||||
monkeypatch.setattr(socket.socket, "sendto", guarded_sendto)
|
||||
monkeypatch.setattr(socket, "getaddrinfo", guarded_getaddrinfo)
|
||||
return guard
|
||||
|
||||
|
||||
def _install_asyncio(monkeypatch: Any, guard: Guard, mine: Any) -> None:
|
||||
"""The asyncio doors (module docstring), for the selector loop and, where it exists, the Proactor loop."""
|
||||
import asyncio.base_events as base_events
|
||||
import asyncio.selector_events as selector_events
|
||||
|
||||
loops = [selector_events.BaseSelectorEventLoop]
|
||||
datagram_transports = []
|
||||
try:
|
||||
import asyncio.proactor_events as proactor_events
|
||||
loops.append(proactor_events.BaseProactorEventLoop)
|
||||
datagram_transports.append(proactor_events._ProactorDatagramTransport)
|
||||
except ImportError: # pragma: no cover - the module exists on every system; its loop runs only on Windows
|
||||
pass
|
||||
|
||||
create_connection = base_events.BaseEventLoop.create_connection
|
||||
create_datagram_endpoint = base_events.BaseEventLoop.create_datagram_endpoint
|
||||
|
||||
async def guarded_create_connection(self, protocol_factory, host=None, port=None, *args, **kwargs):
|
||||
if host is not None and kwargs.get("sock") is None and not is_on_this_host(host, mine()):
|
||||
raise guard.refuse("asyncio connect to", "%s:%s" % (host, port))
|
||||
return await create_connection(self, protocol_factory, host, port, *args, **kwargs)
|
||||
|
||||
async def guarded_create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, **kwargs):
|
||||
where = _destination(remote_addr, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram endpoint to", where)
|
||||
return await create_datagram_endpoint(self, protocol_factory, local_addr=local_addr, remote_addr=remote_addr, **kwargs)
|
||||
|
||||
monkeypatch.setattr(base_events.BaseEventLoop, "create_connection", guarded_create_connection)
|
||||
monkeypatch.setattr(base_events.BaseEventLoop, "create_datagram_endpoint", guarded_create_datagram_endpoint)
|
||||
|
||||
for loop in loops:
|
||||
sock_connect, sock_sendto = loop.sock_connect, loop.sock_sendto
|
||||
|
||||
def make(sock_connect=sock_connect, sock_sendto=sock_sendto):
|
||||
async def guarded_sock_connect(self, sock, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio connect to", where)
|
||||
return await sock_connect(self, sock, address)
|
||||
|
||||
async def guarded_sock_sendto(self, sock, data, address):
|
||||
where = _destination(address, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram to", where)
|
||||
return await sock_sendto(self, sock, data, address)
|
||||
return guarded_sock_connect, guarded_sock_sendto
|
||||
|
||||
guarded_sock_connect, guarded_sock_sendto = make()
|
||||
monkeypatch.setattr(loop, "sock_connect", guarded_sock_connect)
|
||||
monkeypatch.setattr(loop, "sock_sendto", guarded_sock_sendto)
|
||||
|
||||
for transport in datagram_transports:
|
||||
def make_sendto(sendto=transport.sendto):
|
||||
def guarded_sendto(self, data, addr=None):
|
||||
where = _destination(addr, mine())
|
||||
if where is not None:
|
||||
raise guard.refuse("asyncio datagram to", where)
|
||||
return sendto(self, data, addr)
|
||||
return guarded_sendto
|
||||
monkeypatch.setattr(transport, "sendto", make_sendto())
|
||||
@@ -1,200 +0,0 @@
|
||||
"""Where the operating system's own cursor is while a headed browser window is on the desktop the test runs on.
|
||||
|
||||
A real window that appears under the OS cursor receives a native ``WM_MOUSEMOVE`` for it, and the first native move of a process always passes Gecko's
|
||||
``LastMouseMoveData`` filter, so the page sees ``mousemove`` at the cursor's place with ``buttons=0``, at a moment the test does not choose. On a GitHub
|
||||
Windows runner the cursor sits at (512, 384) and the headed window covers (-8, -8) to (1928, 1040): the move reached the page once in the middle of a drag
|
||||
(``test_drag_motion.py::test_a_real_page_sees_a_drag_that_travelled`` saw ``mousemove 512,299 buttons=0`` after the press). The engine keeps delivering native
|
||||
input to content, so the arrangement is the test's: the cursor is parked on a point of the desktop that no window of the browser covers, before the browser
|
||||
starts, and a test that records pointer events checks it still is when its gesture begins.
|
||||
|
||||
* Windows: ``user32`` through ctypes. The windows are the visible top-level ones of the processes below the test process (the browsers it launched), seen from
|
||||
the desktop the test runs on: a ``headless=True`` browser runs on a Win32 desktop of its own (``make_virtual_display``), is not enumerated here and cannot
|
||||
receive the interactive cursor.
|
||||
* Linux and macOS: nothing to do. The Linux e2e run under ``xvfb-run``: an X server with virtual pointer and keyboard devices (XTEST) and no physical one,
|
||||
so nothing moves a pointer there; every function answers "outside" and ``park`` does nothing.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
from typing import List, Optional, Sequence, Tuple
|
||||
|
||||
#: ``(left, top, right, bottom)`` as ``GetWindowRect`` gives it: ``right`` and ``bottom`` are the first pixel outside.
|
||||
Rect = Tuple[int, int, int, int]
|
||||
Point = Tuple[int, int]
|
||||
|
||||
#: How far from every window the parked cursor is, in pixels: a window is moved or grown by a border or a shadow, and the cursor must stay outside of it.
|
||||
MARGIN = 8
|
||||
|
||||
|
||||
class TheCursorIsInside(AssertionError):
|
||||
"""The OS cursor is over a window of the browser while a gesture is about to start."""
|
||||
|
||||
|
||||
class TheCursorCannotBeParked(RuntimeError):
|
||||
"""No point of the desktop is free of the browser's windows, or the system did not move the cursor."""
|
||||
|
||||
|
||||
def _inflate(rect: Rect, margin: int) -> Rect:
|
||||
return (rect[0] - margin, rect[1] - margin, rect[2] + margin, rect[3] + margin)
|
||||
|
||||
|
||||
def _contains(rect: Rect, point: Point) -> bool:
|
||||
return rect[0] <= point[0] < rect[2] and rect[1] <= point[1] < rect[3]
|
||||
|
||||
|
||||
def cursor_is_outside(window_rects: Sequence[Rect], cursor: Optional[Point] = None, margin: int = 0, *,
|
||||
api: Optional["_Win32"] = None) -> bool:
|
||||
"""True when ``cursor`` (read from the system when None) is outside every rectangle, ``margin`` pixels beyond its edge included.
|
||||
|
||||
Not Windows: True, there is no OS cursor that reaches a window."""
|
||||
if cursor is None:
|
||||
api = api or _api()
|
||||
if api is None:
|
||||
return True
|
||||
cursor = api.cursor_position()
|
||||
return not any(_contains(_inflate(r, margin), cursor) for r in window_rects)
|
||||
|
||||
|
||||
def park_outside(window_rects: Sequence[Rect], screen_rect: Rect, margin: int = MARGIN) -> Point:
|
||||
"""A pixel of the virtual screen that is at least ``margin`` pixels from every window rectangle: the bottom-right corner when it is free.
|
||||
|
||||
``screen_rect`` is ``(left, top, right, bottom)`` of the virtual screen, ``right`` and ``bottom`` exclusive (its origin is negative when a monitor lies left of or
|
||||
above the primary one). The candidates are the screen's edges and the places just beyond each window's inflated edges; a free pixel exists only if one
|
||||
of them is free (the free pixel can be slid left and up until it touches an edge, and it stays free), so a ``TheCursorCannotBeParked`` is exact."""
|
||||
left, top, right, bottom = screen_rect
|
||||
if right <= left or bottom <= top:
|
||||
raise TheCursorCannotBeParked(
|
||||
"park_outside: the virtual screen %r is empty. Where: the screen rectangle read from the system. What: no pixel to put the cursor on. "
|
||||
"Fix: run the e2e on an interactive desktop session." % (screen_rect,))
|
||||
inflated = [_inflate(r, margin) for r in window_rects]
|
||||
xs = sorted({right - 1, left, *(min(max(r[2], left), right - 1) for r in inflated), *(min(max(r[0] - 1, left), right - 1) for r in inflated)},
|
||||
reverse=True)
|
||||
ys = sorted({bottom - 1, top, *(min(max(r[3], top), bottom - 1) for r in inflated), *(min(max(r[1] - 1, top), bottom - 1) for r in inflated)},
|
||||
reverse=True)
|
||||
for y in ys:
|
||||
for x in xs:
|
||||
if not any(_contains(r, (x, y)) for r in inflated):
|
||||
return (x, y)
|
||||
raise TheCursorCannotBeParked(
|
||||
"park_outside: the windows %r cover every pixel of the screen %r with a margin of %d. Where: the headed browser window the test launched. What: the "
|
||||
"OS cursor would be over the page whatever the point, and a native mouse move would reach it. Fix: shrink the window below the screen (the test's own "
|
||||
"geometry; it is not this helper's to change) or run the test on a bigger desktop." % (list(window_rects), screen_rect, margin))
|
||||
|
||||
|
||||
class _Win32:
|
||||
"""What the desktop answers, by ``user32``. One object so a test can stand a fake in for it."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
from ctypes import wintypes
|
||||
|
||||
self.wintypes = wintypes
|
||||
self.user32 = ctypes.WinDLL("user32", use_last_error=True)
|
||||
u = self.user32
|
||||
u.GetCursorPos.argtypes = (ctypes.POINTER(wintypes.POINT),)
|
||||
u.GetCursorPos.restype = wintypes.BOOL
|
||||
u.SetCursorPos.argtypes = (ctypes.c_int, ctypes.c_int)
|
||||
u.SetCursorPos.restype = wintypes.BOOL
|
||||
u.GetSystemMetrics.argtypes = (ctypes.c_int,)
|
||||
u.GetSystemMetrics.restype = ctypes.c_int
|
||||
u.GetWindowRect.argtypes = (wintypes.HWND, ctypes.POINTER(wintypes.RECT))
|
||||
u.GetWindowRect.restype = wintypes.BOOL
|
||||
u.IsWindowVisible.argtypes = (wintypes.HWND,)
|
||||
u.IsWindowVisible.restype = wintypes.BOOL
|
||||
u.IsIconic.argtypes = (wintypes.HWND,)
|
||||
u.IsIconic.restype = wintypes.BOOL
|
||||
u.GetWindowThreadProcessId.argtypes = (wintypes.HWND, ctypes.POINTER(wintypes.DWORD))
|
||||
u.GetWindowThreadProcessId.restype = wintypes.DWORD
|
||||
self.enum_proc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
|
||||
u.EnumWindows.argtypes = (self.enum_proc, wintypes.LPARAM)
|
||||
u.EnumWindows.restype = wintypes.BOOL
|
||||
|
||||
def cursor_position(self) -> Point:
|
||||
point = self.wintypes.POINT()
|
||||
if not self.user32.GetCursorPos(ctypes.byref(point)):
|
||||
raise TheCursorCannotBeParked(
|
||||
"GetCursorPos failed (error %d). Where: user32, on the desktop the test runs on. What: the OS cursor cannot be read. Fix: run the e2e on an "
|
||||
"interactive desktop session (not a locked screen or a service)." % ctypes.get_last_error())
|
||||
return (point.x, point.y)
|
||||
|
||||
def set_cursor_position(self, x: int, y: int) -> None:
|
||||
self.user32.SetCursorPos(x, y)
|
||||
|
||||
def screen(self) -> Rect:
|
||||
"""The virtual screen: ``SM_XVIRTUALSCREEN``, ``SM_YVIRTUALSCREEN``, ``SM_CXVIRTUALSCREEN``, ``SM_CYVIRTUALSCREEN``."""
|
||||
x, y, w, h = (self.user32.GetSystemMetrics(n) for n in (76, 77, 78, 79))
|
||||
return (x, y, x + w, y + h)
|
||||
|
||||
def windows_below(self, root_pid: int) -> List[Rect]:
|
||||
"""The rectangles of the visible, not minimised, top-level windows of the processes below ``root_pid``."""
|
||||
import psutil
|
||||
|
||||
try:
|
||||
pids = {p.pid for p in psutil.Process(root_pid).children(recursive=True)}
|
||||
except psutil.Error:
|
||||
return []
|
||||
found: List[Rect] = []
|
||||
|
||||
def each(hwnd, _):
|
||||
owner = self.wintypes.DWORD()
|
||||
self.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(owner))
|
||||
if owner.value in pids and self.user32.IsWindowVisible(hwnd) and not self.user32.IsIconic(hwnd):
|
||||
rect = self.wintypes.RECT()
|
||||
if self.user32.GetWindowRect(hwnd, ctypes.byref(rect)) and rect.right > rect.left and rect.bottom > rect.top:
|
||||
found.append((rect.left, rect.top, rect.right, rect.bottom))
|
||||
return True
|
||||
|
||||
self.user32.EnumWindows(self.enum_proc(each), 0)
|
||||
return found
|
||||
|
||||
|
||||
def _is_windows() -> bool:
|
||||
return sys.platform == "win32"
|
||||
|
||||
|
||||
def _api() -> Optional[_Win32]:
|
||||
return _Win32() if _is_windows() else None
|
||||
|
||||
|
||||
def browser_windows(root_pid: Optional[int] = None, *, api: Optional[_Win32] = None) -> List[Rect]:
|
||||
"""The rectangles of the windows of the browsers below ``root_pid`` (the test process by default) on this desktop; empty when not Windows."""
|
||||
api = api or _api()
|
||||
if api is None:
|
||||
return []
|
||||
return api.windows_below(os.getpid() if root_pid is None else root_pid)
|
||||
|
||||
|
||||
def park(root_pid: Optional[int] = None, *, api: Optional[_Win32] = None) -> Optional[Point]:
|
||||
"""Windows: put the OS cursor on a point no window of the browsers below ``root_pid`` covers and read it back. Returns the point; None when not Windows.
|
||||
|
||||
Called before the browser starts there is no window yet and the point is the bottom-right corner of the virtual screen, where the engine places no window."""
|
||||
api = api or _api()
|
||||
if api is None:
|
||||
return None
|
||||
target = park_outside(api.windows_below(os.getpid() if root_pid is None else root_pid), api.screen())
|
||||
api.set_cursor_position(*target)
|
||||
read_back = api.cursor_position()
|
||||
if read_back != target:
|
||||
raise TheCursorCannotBeParked(
|
||||
"SetCursorPos(%d, %d) left the cursor at %r. Where: user32, on the desktop the test runs on. What: the OS cursor cannot be moved, so a native "
|
||||
"mouse move for it can reach a window of the browser mid-gesture. Fix: run the e2e on an interactive desktop session (not a locked screen "
|
||||
"or a service), with no other program holding the cursor." % (target[0], target[1], read_back))
|
||||
return target
|
||||
|
||||
|
||||
def require_outside(root_pid: Optional[int] = None, *, api: Optional[_Win32] = None, margin: int = 0) -> None:
|
||||
"""The precondition of a gesture a test judges by the pointer events the page records: the OS cursor is outside every window of the browsers.
|
||||
|
||||
Raises ``TheCursorIsInside`` otherwise, with the cursor and the windows. Not Windows: nothing."""
|
||||
api = api or _api()
|
||||
if api is None:
|
||||
return
|
||||
windows = api.windows_below(os.getpid() if root_pid is None else root_pid)
|
||||
cursor = api.cursor_position()
|
||||
if not cursor_is_outside(windows, cursor, margin):
|
||||
raise TheCursorIsInside(
|
||||
"the OS cursor is at %r, inside the browser window(s) %r, when a pointer gesture is about to start. Where: the desktop the test runs on. What: "
|
||||
"a native WM_MOUSEMOVE for it passes Gecko's first-move filter and reaches the page as a mousemove with buttons=0 at a moment of the "
|
||||
"system's choosing, in the middle of the gesture the test records. Fix: park the cursor outside the window before the browser starts "
|
||||
"(the autouse fixture `_the_os_cursor_is_outside_the_browser_window` of tests/conftest.py does it for every e2e test on Windows)." % (cursor, windows))
|
||||
@@ -1,151 +0,0 @@
|
||||
"""What a popup twin records about each element it clicks, so that a red run says what the click and the geometry were, and a green run leaves the numbers to compare.
|
||||
|
||||
A twin that clicks an element and waits for a popup (the select dropdown) used to say "the dropdown did not open" and nothing about the click: where it was sent, at which scale, what the
|
||||
element's box was in its document and in the window, and what the popup was doing. This module is what the twin keeps for each element, and writes:
|
||||
|
||||
* ``click``: the point in CSS pixels, and the point the driver sent (the unit it is in and the device point it makes: CSS times the scale the driver knows);
|
||||
* ``scales``: the record of ``Driver.scales()`` (the page's and the chrome's ``devicePixelRatio`` and the real scale of the screen), once per browser;
|
||||
* ``select_rect``: ``getBoundingClientRect`` of the element inside its own document, and, for an element of a frame, ``iframe_rect``: the frame element's box in the top document;
|
||||
* ``mozInnerScreen``: ``window.mozInnerScreenX/Y`` of the top document and, for a frame, of the frame's document;
|
||||
* ``activation_at_click`` and ``activation_after_click``: whether the window was the active one, and had the focus, when the click was sent and right after (``look_at_activation``): chrome
|
||||
``Services.focus.activeWindow === win``, ``win.document.hasFocus()``, the browsing context's ``isActive`` (``win.gBrowser.selectedBrowser.browsingContext.isActive``), the top content document's
|
||||
``hasFocus()`` and ``visibilityState``, and the driver's ack of the click when it has one (``last_click_ack``); a popup that does not open for a window that was not active is not a popup that is at the wrong place;
|
||||
* ``popup``: the state after the click (the first look), the last look of the wait (at the deadline) and, when the popup did not reach the state, a second look (the select test: a short wait on the same condition, so that a popup that comes late is seen to come late).
|
||||
|
||||
A read that fails is recorded in ``errors`` and never raised: the diagnosis must not replace the finding. The record is in the message of the failure and, on a runner (``RUNNER_TEMP`` set), in
|
||||
``$RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json``, the folder every e2e job uploads (see ``_watchdog_log``), whatever the result.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Mapping, Optional, Sequence
|
||||
|
||||
from _watchdog_log import EVIDENCE_FOLDER
|
||||
|
||||
#: The folder of this evidence inside ``$RUNNER_TEMP/invpw-evidence``.
|
||||
SUBFOLDER = "popup-diagnostics"
|
||||
|
||||
#: The top document: the element's box, the frame element's box, the window's place on the screen. Both ids are given by the page of the twin.
|
||||
TOP_GEOMETRY_JS = """(() => {
|
||||
const box = id => { const e = document.getElementById(id); if (!e) { return null; } const b = e.getBoundingClientRect(); return {x: b.x, y: b.y, w: b.width, h: b.height}; };
|
||||
return {select: box(%(select)s), iframe: box(%(iframe)s), mozInnerScreen: [window.mozInnerScreenX, window.mozInnerScreenY], scroll: [window.scrollX, window.scrollY]};
|
||||
})()"""
|
||||
|
||||
#: The document of a frame: the element's box inside it and its own place on the screen.
|
||||
FRAME_GEOMETRY_JS = """(() => {
|
||||
const e = document.getElementById(%(select)s); const b = e ? e.getBoundingClientRect() : null;
|
||||
return {select: b && {x: b.x, y: b.y, w: b.width, h: b.height}, mozInnerScreen: [window.mozInnerScreenX, window.mozInnerScreenY], scroll: [window.scrollX, window.scrollY]};
|
||||
})()"""
|
||||
|
||||
|
||||
#: Chrome scope: the window's activation and focus, and the browsing context of the selected tab. ``win`` is the most recent browser window, as every chrome script of the twins reads it.
|
||||
ACTIVATION_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
return JSON.stringify({
|
||||
active_window: Services.focus.activeWindow === win,
|
||||
window_has_focus: win.document.hasFocus(),
|
||||
browsing_context_is_active: win.gBrowser.selectedBrowser.browsingContext.isActive,
|
||||
});
|
||||
"""
|
||||
|
||||
#: The top content document, read through the driver (``driver.eval``): the same expression on every driver.
|
||||
CONTENT_ACTIVATION_JS = """(() => ({hasFocus: document.hasFocus(), visibilityState: document.visibilityState}))()"""
|
||||
|
||||
|
||||
def _failed(exc: BaseException) -> str:
|
||||
return "%s: %s" % (type(exc).__name__, str(exc)[:300])
|
||||
|
||||
|
||||
def look_at_geometry(driver: Any, in_frame: bool, select_id: str = "s", frame_id: str = "f") -> Dict[str, Any]:
|
||||
"""The boxes and the window's place for one element, read before the click. ``driver.eval`` reads the top document, ``driver.eval_in_frame`` the frame's.
|
||||
A read that fails leaves its field out and says why in ``errors``."""
|
||||
ids = {"select": json.dumps(select_id), "iframe": json.dumps(frame_id)}
|
||||
out: Dict[str, Any] = {"errors": {}}
|
||||
top: Optional[Dict[str, Any]] = None
|
||||
try:
|
||||
top = driver.eval(TOP_GEOMETRY_JS % ids)
|
||||
except Exception as exc: # noqa: BLE001 the diagnosis never replaces the finding
|
||||
out["errors"]["top_document"] = _failed(exc)
|
||||
top = top or {}
|
||||
out["mozInnerScreen"] = {"top": top.get("mozInnerScreen")}
|
||||
if not in_frame:
|
||||
out["select_rect"] = top.get("select")
|
||||
out["iframe_rect"] = None
|
||||
else:
|
||||
out["iframe_rect"] = top.get("iframe")
|
||||
try:
|
||||
inner = driver.eval_in_frame(FRAME_GEOMETRY_JS % ids)
|
||||
out["select_rect"] = inner.get("select")
|
||||
out["mozInnerScreen"]["frame"] = inner.get("mozInnerScreen")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
out["errors"]["frame_document"] = _failed(exc)
|
||||
out["select_rect"] = None
|
||||
out["mozInnerScreen"]["frame"] = None
|
||||
if not out["errors"]:
|
||||
del out["errors"]
|
||||
return out
|
||||
|
||||
|
||||
def look_at_activation(driver: Any) -> Dict[str, Any]:
|
||||
"""The window's activation and focus now: the chrome's (``ACTIVATION_JS``), the top content document's (``CONTENT_ACTIVATION_JS``) and the driver's ack of the click, when it keeps one
|
||||
(``last_click_ack``, None otherwise). A read that fails leaves its part out and says why in ``errors``; the diagnosis never replaces the finding."""
|
||||
out: Dict[str, Any] = {"errors": {}}
|
||||
try:
|
||||
out["chrome"] = driver.chrome.script(ACTIVATION_JS)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
out["errors"]["chrome"] = _failed(exc)
|
||||
try:
|
||||
out["content"] = driver.eval(CONTENT_ACTIVATION_JS)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
out["errors"]["content"] = _failed(exc)
|
||||
out["click_ack"] = getattr(driver, "last_click_ack", None)
|
||||
if not out["errors"]:
|
||||
del out["errors"]
|
||||
return out
|
||||
|
||||
|
||||
def click_record(driver: Any, css: Sequence[float]) -> Dict[str, Any]:
|
||||
"""The click as asked (CSS pixels) and as the driver sent it (``driver.last_click``: the point, its unit, the device point), as the driver wrote it."""
|
||||
return {"css": list(css), "sent": getattr(driver, "last_click", None)}
|
||||
|
||||
|
||||
class Diagnostics:
|
||||
"""The record of one browser on one case: its scales and one entry per element."""
|
||||
|
||||
def __init__(self, case: str, browser: str) -> None:
|
||||
self.case, self.browser = case, browser
|
||||
self.scales: Optional[Dict[str, Any]] = None
|
||||
self.entries: Dict[str, Dict[str, Any]] = {}
|
||||
self.save_error: Optional[str] = None
|
||||
|
||||
def entry(self, name: str) -> Dict[str, Any]:
|
||||
return self.entries.setdefault(name, {})
|
||||
|
||||
def record(self) -> Dict[str, Any]:
|
||||
return {"case": self.case, "browser": self.browser, "scales": self.scales, "elements": self.entries}
|
||||
|
||||
def message(self, headline: str, name: str) -> str:
|
||||
"""``headline``, then everything known about the element ``name`` and the scales, as one JSON line a reader can paste."""
|
||||
body = {"case": self.case, "browser": self.browser, "element": name, "scales": self.scales, **self.entries.get(name, {})}
|
||||
return "%s\n diagnostics: %s" % (headline, json.dumps(body, sort_keys=True))
|
||||
|
||||
def path(self, environ: Mapping[str, str]) -> Optional[Path]:
|
||||
runner = environ.get("RUNNER_TEMP")
|
||||
if not runner:
|
||||
return None
|
||||
return Path(runner) / EVIDENCE_FOLDER / SUBFOLDER / ("%s-%s.json" % (self.case, self.browser))
|
||||
|
||||
def save(self, environ: Optional[Mapping[str, str]] = None) -> Optional[Path]:
|
||||
"""Writes the record where the jobs upload it; None off a runner. A failed write is kept in ``save_error`` and never raised: this runs while a finding may be on its way up."""
|
||||
path = self.path(os.environ if environ is None else environ)
|
||||
if path is None:
|
||||
return None
|
||||
try:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(self.record(), indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
except OSError as exc:
|
||||
self.save_error = _failed(exc)
|
||||
return None
|
||||
return path
|
||||
@@ -20,12 +20,11 @@ from _waits import wait_until
|
||||
#: position 4 (device pixels, and CSS pixels at 1.0). The screen is the one the other surface tests pin.
|
||||
PIN = {"screen.width": 1920, "screen.height": 1080, "screen.dpr": 1.0}
|
||||
|
||||
#: A second declared window frame that no runner has: a border of 6 and a popup UI of 53 above the content. The declared frame at scale 1.0 (8, 72) is the frame
|
||||
#: of a retail Windows window, so a Windows runner's own popup has it too (outer - inner = 16 x 80) and a launch with the engine off cannot tell the declaration from
|
||||
#: the host there; a launch declared with ANOTHER frame can (the prefs are applied last, over the core's declaration). The position of an unpositioned popup is not
|
||||
#: declared: it is Firefox's own rule (browser.xhtml screenX/screenY = 4, the stagger, the clamp), the same under every frame.
|
||||
OTHER_FRAME = {"zoom.stealth.screen.frame_border": 6, "zoom.stealth.screen.popup_ui": 53}
|
||||
OTHER_BORDER, OTHER_POPUP_UI = 6, 53
|
||||
#: A second declared window frame that no runner has: a border of 6, a popup UI of 53 above the content, a default position of 9. The declared frame at scale 1.0
|
||||
#: (8, 72, 4) is the frame of a retail Windows window, so a Windows runner's own popup has it too (outer - inner = 16 x 80) and a launch with the engine off
|
||||
#: cannot tell the declaration from the host there; a launch declared with ANOTHER frame can (the prefs are applied last, over the core's declaration).
|
||||
OTHER_FRAME = {"zoom.stealth.screen.frame_border": 6, "zoom.stealth.screen.popup_ui": 53, "zoom.stealth.screen.popup_position": 9}
|
||||
OTHER_BORDER, OTHER_POPUP_UI, OTHER_POSITION = 6, 53, 9
|
||||
|
||||
READ = """() => ({iw: innerWidth, ih: innerHeight, ow: outerWidth, oh: outerHeight,
|
||||
sx: screenX, sy: screenY, mx: mozInnerScreenX, my: mozInnerScreenY})"""
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
"""The retail reference of the chrome-scope twins: RETAIL Firefox 159, driven by Marionette alone (no Playwright), headed on a display of its own (the wrapper's mechanism); and one driver for it and for ours.
|
||||
|
||||
Playwright's own Firefox is not a reference for the popups the browser chrome opens (a select dropdown, a tooltip): nothing says its build takes ``-marionette``, and it is not the
|
||||
browser a user runs. The reference of these twins is the official retail build, the one the capture rounds of RetailCaptures measured. The chrome-scope relations (the popup against its
|
||||
element, the tooltip against the pointer) are read in the same way on both sides, from chrome scope through Marionette; the page and its input are driven by one small interface (``Driver``):
|
||||
``goto``, ``eval`` (a JavaScript expression of the top document, as JSON), ``move``, ``click`` (the point of the top document, CSS pixels), ``wait_for_timeout`` and ``chrome``.
|
||||
|
||||
WHERE THE RETAIL BINARY COMES FROM. The file named by the environment variable ``INVPW_RETAIL_FIREFOX`` (the path of ``firefox.exe`` on Windows, of ``firefox`` on Linux, where the reference is Mozilla's own Linux 159 build, fetched and verified the same way
|
||||
and extracted to ``<work>/extracted/firefox/firefox``): a missing variable or file is RED ("MISSING REFERENCE, reference unavailable"), never a skip. The launcher is the same on both: no ``.exe``, the display is one of its own, made as the wrapper makes ours (``_stock_twin.OwnDisplay``: ``make_virtual_display()``, an Xvfb on Linux, the desktop of the job on Windows), not the job's: the rows run pytest without xvfb-run.
|
||||
The legs of the rows ``wrapper.e2e.stock_twin.select`` and ``wrapper.e2e.stock_twin.tooltip`` put it there with the mechanism the retail captures already use, in the repository oss-invisible/core: ``scripts/retail/firefox_build.py fetch
|
||||
--version 159.0 --work DIR`` (it downloads ``Firefox Setup 159.0.exe`` and SHA256SUMS and SHA256SUMS.asc from archive.mozilla.org, checks the signature against the release key committed in
|
||||
``captures/runner/``, checks the installer's sha256 against SHA256SUMS, extracts it with 7z and writes DIR/build.json with the path of firefox.exe).
|
||||
|
||||
HOW IT IS LAUNCHED (what ``scripts/retail/window_geometry/run_scale.py`` does for the captures): ``firefox -no-remote -profile <empty directory> -marionette``, with ``-remote-allow-system-access`` for the
|
||||
chrome scope; the profile holds only ``user.js`` with ``marionette.port`` 0 (a free port, written to ``MarionetteActivePort``) and ``layout.css.devPixelsPerPx`` (the display scale of the case, the pref
|
||||
ours and stock are launched with), and the prefs that stop the first-run pages. No policy file. The browser is closed with its whole tree when the block ends.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, Optional, Tuple
|
||||
|
||||
from _stock_twin import MARIONETTE_ARGS, SCALES_JS, BrokenControl, Chrome, OwnDisplay
|
||||
from _waits import wait_until
|
||||
from _window_origin import CASES, DEADLINE_S, launch_case
|
||||
|
||||
ENV_VARIABLE = "INVPW_RETAIL_FIREFOX"
|
||||
|
||||
#: What the profile of the retail browser holds besides the two prefs of the case: the first-run pages and the updater are off, nothing else.
|
||||
PROFILE_PREFS = {
|
||||
"marionette.port": 0,
|
||||
"browser.shell.checkDefaultBrowser": False,
|
||||
"browser.aboutwelcome.enabled": False,
|
||||
"browser.startup.page": 0,
|
||||
"browser.startup.homepage": "about:blank",
|
||||
"startup.homepage_welcome_url": "",
|
||||
"startup.homepage_override_url": "",
|
||||
"browser.startup.homepage_override.mstone": "ignore",
|
||||
"datareporting.policy.dataSubmissionPolicyBypassNotification": True,
|
||||
"toolkit.telemetry.reportingpolicy.firstRun": False,
|
||||
"app.update.auto": False,
|
||||
"app.update.checkInstallTime": False,
|
||||
"browser.tabs.warnOnClose": False,
|
||||
}
|
||||
|
||||
PAGE_SCALES_EXPR = "({devicePixelRatio: window.devicePixelRatio, inner: [innerWidth, innerHeight], screen: [screen.width, screen.height]})"
|
||||
|
||||
|
||||
class MissingReference(AssertionError):
|
||||
"""No retail binary to compare with: red, and no finding about ours."""
|
||||
|
||||
|
||||
def retail_executable() -> str:
|
||||
path = os.environ.get(ENV_VARIABLE, "")
|
||||
if not path or not Path(path).is_file():
|
||||
raise MissingReference("MISSING REFERENCE, no finding about ours: %s names no retail Firefox 159 (%r). The leg of the rows wrapper.e2e.stock_twin.select and wrapper.e2e.stock_twin.tooltip installs it with "
|
||||
"oss-invisible/core scripts/retail/firefox_build.py fetch --version 159.0 and sets the variable to the path of firefox.exe" % (ENV_VARIABLE, path))
|
||||
return path
|
||||
|
||||
|
||||
def _user_js(prefs: Dict[str, Any]) -> str:
|
||||
return "".join("user_pref(%s, %s);\n" % (json.dumps(name), json.dumps(value)) for name, value in sorted(prefs.items()))
|
||||
|
||||
|
||||
class Driver:
|
||||
"""What a twin does with a page, on any browser. ``chrome.script(js, args)`` is chrome scope through Marionette."""
|
||||
|
||||
chrome: Any
|
||||
#: Which browser this is, in the names of a record and of its evidence file.
|
||||
kind = "driver"
|
||||
#: The last ``click``, as the driver sent it: ``{"point": [x, y], "unit": ..., "device": [x, y]}`` (None before the first click).
|
||||
last_click: Optional[Dict[str, Any]] = None
|
||||
|
||||
def goto(self, url: str) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def eval(self, expression: str) -> Any:
|
||||
"""The value of a JavaScript expression in the top document (a JSON-able value)."""
|
||||
raise NotImplementedError
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
"""The value of a JavaScript expression in the document of the first frame of the top document (a JSON-able value)."""
|
||||
raise NotImplementedError
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def scales(self) -> Dict[str, Any]:
|
||||
"""The record of the scales: the page's (declared) and the chrome's, with the real ones of the screen."""
|
||||
out = {"page": self.eval(PAGE_SCALES_EXPR)}
|
||||
out.update(self.chrome.script(SCALES_JS))
|
||||
return out
|
||||
|
||||
|
||||
class PlaywrightDriver(Driver):
|
||||
"""Ours: a page of the wrapper's client, and the chrome of the engine through Marionette."""
|
||||
|
||||
kind = "ours"
|
||||
|
||||
def __init__(self, page, chrome: Chrome) -> None:
|
||||
self.page, self.chrome = page, chrome
|
||||
|
||||
def goto(self, url: str) -> None:
|
||||
self.page.goto(url, wait_until="load", timeout=30000)
|
||||
|
||||
def eval(self, expression: str) -> Any:
|
||||
return self.page.evaluate("() => (%s)" % expression)
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
frames = [frame for frame in self.page.frames if frame != self.page.main_frame]
|
||||
return frames[0].evaluate("() => (%s)" % expression)
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
self.page.mouse.move(x, y, steps=steps)
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
# the client sends the point in CSS pixels of the page; the device point is that times the page's (declared) scale
|
||||
try:
|
||||
scale = self.page.evaluate("() => window.devicePixelRatio")
|
||||
device: Optional[list] = [x * scale, y * scale]
|
||||
except Exception: # noqa: BLE001 a record of the click never stops the click
|
||||
device = None
|
||||
self.last_click = {"point": [x, y], "unit": "CSS pixels of the page, as page.mouse.click sends them", "device": device}
|
||||
self.page.mouse.click(x, y)
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
self.page.wait_for_timeout(ms)
|
||||
|
||||
|
||||
class RetailChrome:
|
||||
def __init__(self, session: "RetailSession") -> None:
|
||||
self._session = session
|
||||
|
||||
def script(self, script: str, args: Tuple[Any, ...] = ()) -> Dict[str, Any]:
|
||||
return json.loads(self._session.call("chrome", "WebDriver:ExecuteScript", {"script": script, "args": list(args)})["value"])
|
||||
|
||||
|
||||
#: Moves and presses at a point of the browser's content, from chrome, through the widget: a point of the top document (CSS pixels) plus the content area's own place in the window. Firefox 159's chrome
|
||||
#: input is ``Window.synthesizeMouseEvent`` (offsets in CSS pixels of that window, a dictionary of Mozilla's fields for the event and one for the options); ``nsIDOMWindowUtils`` has no ``sendMouseEvent``
|
||||
#: in 159 (tests/test_the_chrome_calls_of_the_tests_exist_in_firefox.py reads the names from Mozilla's sources). ``inputSource: 1`` is a mouse, as a user's.
|
||||
#: ``isAsyncEnabled: true`` is the field of Mozilla's SynthesizeMouseEventOptions that Mozilla's own EventUtils.js sets when a test asks for ``asyncEnabled`` (EventUtils.js, synthesizeMouse, around
|
||||
#: lines 784-851, passes it as ``isAsyncEnabled``). Without it (the webidl default is false) nsContentUtils::SendMouseEvent dispatches through ``widget->DispatchEvent`` and never through APZ
|
||||
#: (nsContentUtils.cpp 10552-10560 at FIREFOX_159_0_RELEASE), the event has no valid layers id, and EventStateManager::DispatchCrossProcessEvent falls back to the TOP process
|
||||
#: (EventStateManager.cpp 2199): a frame in another process never gets the move or the click, and the tooltip and the select of that frame fail on retail for a reason that is the driver's.
|
||||
SEND_JS = """
|
||||
const [type, x, y, button, clicks] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const b = win.gBrowser.selectedBrowser.getBoundingClientRect();
|
||||
win.focus();
|
||||
win.synthesizeMouseEvent(type, b.left + x, b.top + y, {button, clickCount: clicks, modifiers: 0, inputSource: 1}, {ignoreRootScrollFrame: false, isDOMEventSynthesized: true, isAsyncEnabled: true});
|
||||
return JSON.stringify({ok: true, at: [b.left + x, b.top + y], dpr: win.devicePixelRatio});
|
||||
"""
|
||||
|
||||
|
||||
SIZE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
return JSON.stringify({outer: [win.outerWidth, win.outerHeight], inner: [win.innerWidth, win.innerHeight]});
|
||||
"""
|
||||
|
||||
|
||||
class RetailSession:
|
||||
"""Retail Firefox 159 with Marionette, headed, one profile; closed with its whole tree."""
|
||||
|
||||
def __init__(self, executable: str, dpr: float) -> None:
|
||||
self.executable, self.dpr = executable, dpr
|
||||
self._context: Optional[str] = None
|
||||
self._process: Optional[subprocess.Popen] = None
|
||||
self._profile: Optional[str] = None
|
||||
self._marionette = None
|
||||
self._display: Optional[OwnDisplay] = None
|
||||
|
||||
def __enter__(self) -> "RetailSession":
|
||||
import webfont_probe
|
||||
|
||||
try:
|
||||
self._profile = tempfile.mkdtemp(prefix="invpw-retail-")
|
||||
prefs = dict(PROFILE_PREFS)
|
||||
prefs["layout.css.devPixelsPerPx"] = str(self.dpr)
|
||||
Path(self._profile, "user.js").write_text(_user_js(prefs), encoding="utf-8")
|
||||
self._display = OwnDisplay().__enter__()
|
||||
env = self._display.environ(dict(os.environ, MOZ_REMOTE_ALLOW_SYSTEM_ACCESS="1", MOZ_CRASHREPORTER_DISABLE="1"))
|
||||
self._process = subprocess.Popen([self.executable, "-no-remote", "-profile", self._profile] + MARIONETTE_ARGS + ["about:blank"], env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
port = webfont_probe.marionette_active_port(Path(self._profile), timeout=120)
|
||||
self._marionette = webfont_probe._Marionette(port)
|
||||
self._marionette.call("WebDriver:NewSession", {"capabilities": {"alwaysMatch": {}}})
|
||||
except BaseException:
|
||||
self.__exit__(None, None, None)
|
||||
raise
|
||||
return self
|
||||
|
||||
def call(self, context: str, command: str, params: Dict[str, Any]) -> Any:
|
||||
if self._context != context:
|
||||
self._marionette.call("Marionette:SetContext", {"value": context})
|
||||
self._context = context
|
||||
return self._marionette.call(command, params)
|
||||
|
||||
def set_window_size(self, outer: Tuple[float, float]) -> Dict[str, Any]:
|
||||
"""Sets the window's outer size to ``outer`` (CSS pixels of the chrome), at the origin of the screen, and reads back the sizes the chrome window answers."""
|
||||
self.call("content", "WebDriver:SetWindowRect", {"x": 0, "y": 0, "width": int(outer[0]), "height": int(outer[1])})
|
||||
read = SIZE_JS
|
||||
out: Dict[str, Any] = {}
|
||||
for _ in range(int(DEADLINE_S * 10)):
|
||||
out = json.loads(self.call("chrome", "WebDriver:ExecuteScript", {"script": read, "args": []})["value"])
|
||||
if out["outer"] == [outer[0], outer[1]]:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
return out
|
||||
|
||||
def __exit__(self, *exc) -> None:
|
||||
if self._marionette is not None:
|
||||
self._marionette.close()
|
||||
if self._process is not None:
|
||||
try:
|
||||
import psutil
|
||||
|
||||
root = psutil.Process(self._process.pid)
|
||||
for child in root.children(recursive=True):
|
||||
try:
|
||||
child.kill()
|
||||
except psutil.Error:
|
||||
pass
|
||||
root.kill()
|
||||
except Exception: # the process is gone already
|
||||
pass
|
||||
try:
|
||||
self._process.wait(30)
|
||||
except Exception:
|
||||
pass
|
||||
if self._display is not None:
|
||||
self._display.__exit__(None, None, None)
|
||||
self._display = None
|
||||
if self._profile is not None:
|
||||
shutil.rmtree(self._profile, ignore_errors=True)
|
||||
|
||||
|
||||
class RetailDriver(Driver):
|
||||
kind = "retail"
|
||||
|
||||
def __init__(self, session: RetailSession) -> None:
|
||||
self.session = session
|
||||
self.chrome = RetailChrome(session)
|
||||
|
||||
def goto(self, url: str) -> None:
|
||||
self.session.call("content", "WebDriver:Navigate", {"url": url})
|
||||
wait_until(lambda: self.eval("document.readyState") == "complete", DEADLINE_S, lambda: self.wait_for_timeout(100))
|
||||
|
||||
def eval(self, expression: str) -> Any:
|
||||
value = self.session.call("content", "WebDriver:ExecuteScript", {"script": "return JSON.stringify(%s);" % expression, "args": []})["value"]
|
||||
return json.loads(value) if value is not None else None
|
||||
|
||||
def eval_in_frame(self, expression: str) -> Any:
|
||||
"""Through Marionette: the first frame element becomes the context of the script, and the top document is the context again when the read ends."""
|
||||
found = self.session.call("content", "WebDriver:FindElement", {"using": "css selector", "value": "iframe"})["value"]
|
||||
self.session.call("content", "WebDriver:SwitchToFrame", {"id": found})
|
||||
try:
|
||||
value = self.session.call("content", "WebDriver:ExecuteScript", {"script": "return JSON.stringify(%s);" % expression, "args": []})["value"]
|
||||
finally:
|
||||
self.session.call("content", "WebDriver:SwitchToParentFrame", {})
|
||||
return json.loads(value) if value is not None else None
|
||||
|
||||
def _send(self, kind: str, x: float, y: float, button: int = 0, clicks: int = 0) -> Dict[str, Any]:
|
||||
return self.chrome.script(SEND_JS, (kind, x, y, button, clicks))
|
||||
|
||||
def move(self, x: float, y: float, steps: int = 1) -> None:
|
||||
# the pointer comes to the point in ``steps`` moves from the last one it made (a move to the point it is on makes no event, as on every browser)
|
||||
last = getattr(self, "_at", (x - 1, y - 1))
|
||||
for i in range(1, steps + 1):
|
||||
self._send("mousemove", last[0] + (x - last[0]) * i / steps, last[1] + (y - last[1]) * i / steps)
|
||||
self._at = (x, y)
|
||||
|
||||
def click(self, x: float, y: float) -> None:
|
||||
self.move(x, y)
|
||||
down = self._send("mousedown", x, y, 0, 1)
|
||||
self._send("mouseup", x, y, 0, 1)
|
||||
# the point goes to the window's widget in CSS pixels of the chrome (the content area's place added); the device point is that times the chrome's scale
|
||||
at, scale = down.get("at"), down.get("dpr")
|
||||
self.last_click = {"point": at, "unit": "CSS pixels of the chrome window, as Window.synthesizeMouseEvent takes them",
|
||||
"device": [at[0] * scale, at[1] * scale] if at and scale else None}
|
||||
|
||||
def wait_for_timeout(self, ms: int) -> None:
|
||||
time.sleep(ms / 1000.0)
|
||||
|
||||
|
||||
def run_retail_twin(case: str, firefox_binary: str, measure: Callable[[Driver], Dict[str, Any]]) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||
"""(retail's record, ours): the same ``measure(driver)`` on our engine and on the retail reference, one browser at a time. Needs MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1 for ours.
|
||||
|
||||
Ours goes first, for its window: the retail window is given the SAME outer size as ours (the maximized window of the case's declared screen, as ``launch_case`` makes it, read from the
|
||||
chrome window's ``outerWidth`` and ``outerHeight``), and the inner sizes both chrome windows answer are compared before anything is measured: when they differ the verdict is BROKEN CONTROL,
|
||||
not a finding about ours. Both sizes are in each record (``scales.chrome_outer``, ``scales.chrome_inner``), with the size the retail window was asked (``scales.window_asked_outer``)."""
|
||||
executable = retail_executable()
|
||||
with launch_case(firefox_binary, case, extra_args=MARIONETTE_ARGS, extra_prefs={"marionette.port": 0}) as browser:
|
||||
page = browser.new_page() # first: the window the session below waits for
|
||||
chrome = Chrome(page)
|
||||
try:
|
||||
ours = measure(PlaywrightDriver(page, chrome))
|
||||
finally:
|
||||
chrome.close()
|
||||
asked = ours["scales"]["chrome_outer"]
|
||||
with RetailSession(executable, CASES[case][0]) as session:
|
||||
got = session.set_window_size((asked[0], asked[1]))
|
||||
if got.get("outer") != asked or got.get("inner") != ours["scales"]["chrome_inner"]:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: the retail window was asked the outer size of ours %r and answers outer %r and inner %r; ours has inner %r (case %s)"
|
||||
% (asked, got.get("outer"), got.get("inner"), ours["scales"]["chrome_inner"], case))
|
||||
retail = measure(RetailDriver(session))
|
||||
retail["scales"]["window_asked_outer"] = asked
|
||||
return retail, ours
|
||||
@@ -1,111 +0,0 @@
|
||||
"""The stack watchdog of the e2e tests: a Python thread that writes the stack of every thread of the process, holding the GIL.
|
||||
|
||||
``tests/conftest.py`` arms it for each e2e test and cancels it in the teardown. Once the threshold of a test is passed, and then every period until the
|
||||
test ends, it appends one dump to the file it was given: ``Timeout (h:mm:ss)!`` (the time since the arming) and then, for every thread, ``Thread 0x... (most
|
||||
recent call first):`` and its frames as `` File "...", line N in name``. Two identical dumps mean a stuck test, two different ones a slow test.
|
||||
|
||||
Why a Python thread and not ``faulthandler.dump_traceback_later``: that watchdog is a C thread, and it copies the frames of every thread WITHOUT the GIL
|
||||
(``_Py_DumpTracebackThreads``, which CPython documents as "for debug purpose only ... after a segmentation fault, at fatal error") while the other threads
|
||||
keep running and keep changing their frames. On Windows two full dumps of a pytest worker show it dead inside ``dump_frame`` of ``faulthandler_thread``,
|
||||
reading a frame another thread was freeing. This thread takes ``sys._current_frames()`` with the GIL held, so a frame it reads cannot change under it.
|
||||
|
||||
One thread per process, started by the first ``arm`` and reused by every later test. It writes nothing to stdout or stderr. After ``cancel`` returns, nothing
|
||||
more is written for that test: the dump is written under the lock that ``cancel`` takes.
|
||||
|
||||
Known limit: a thread that holds the GIL and never releases it (a C call that does not let go) keeps this thread from running, so it cannot write. That case
|
||||
is pytest's ``faulthandler.enable()``, which writes only when the process dies. The 420 s limit of the run (``--timeout-method thread``) still names the test.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
def _clock(seconds: float) -> str:
|
||||
whole = int(seconds)
|
||||
return "%d:%02d:%02d" % (whole // 3600, whole % 3600 // 60, whole % 60)
|
||||
|
||||
|
||||
class StackWatchdog:
|
||||
def __init__(self) -> None:
|
||||
self._cond = threading.Condition()
|
||||
self._thread: threading.Thread | None = None
|
||||
self._armed = False
|
||||
self._file = None
|
||||
self._started = 0.0
|
||||
self._period = 0.0
|
||||
self._due = 0.0
|
||||
|
||||
@property
|
||||
def thread(self) -> threading.Thread | None:
|
||||
"""The one thread of the process (None until the first ``arm``)."""
|
||||
return self._thread
|
||||
|
||||
def arm(self, nodeid: str, threshold_s: float, period_s: float | None = None, file=None) -> None:
|
||||
"""From ``threshold_s`` seconds on, and then every ``period_s`` (the threshold by default), write the stacks of all threads to ``file`` until ``cancel``."""
|
||||
period = threshold_s if period_s is None else period_s
|
||||
with self._cond:
|
||||
self._file = file
|
||||
self._started = time.monotonic()
|
||||
self._period = max(period, 0.0005)
|
||||
self._due = self._started + threshold_s
|
||||
self._armed = True
|
||||
try:
|
||||
file.write("\n--- %s ---\n" % nodeid)
|
||||
file.flush()
|
||||
except Exception:
|
||||
pass
|
||||
if self._thread is None or not self._thread.is_alive():
|
||||
self._thread = threading.Thread(target=self._run, name="invpw-stack-watchdog", daemon=True)
|
||||
self._thread.start()
|
||||
self._cond.notify_all()
|
||||
|
||||
def cancel(self) -> None:
|
||||
"""Nothing more is written for the armed test once this returns: a dump in progress finishes first, because it is written under the same lock."""
|
||||
with self._cond:
|
||||
self._armed = False
|
||||
self._file = None
|
||||
self._cond.notify_all()
|
||||
|
||||
def _run(self) -> None:
|
||||
with self._cond:
|
||||
while True:
|
||||
if not self._armed:
|
||||
self._cond.wait()
|
||||
continue
|
||||
left = self._due - time.monotonic()
|
||||
if left > 0:
|
||||
# Waiting lets go of the lock, so that a cancel or a new arm is never kept out by a watchdog with a short period.
|
||||
self._cond.wait(left)
|
||||
continue
|
||||
self._write_one_dump()
|
||||
self._due = time.monotonic() + self._period
|
||||
|
||||
def _write_one_dump(self) -> None:
|
||||
mine = threading.get_ident()
|
||||
names = {t.ident: t.name for t in threading.enumerate()}
|
||||
out = ["Timeout (%s)!\n" % _clock(time.monotonic() - self._started)]
|
||||
for ident, frame in sys._current_frames().items():
|
||||
if ident == mine:
|
||||
continue
|
||||
name = names.get(ident)
|
||||
out.append("\nThread 0x%016x%s (most recent call first):\n" % (ident, " [%s]" % name if name else ""))
|
||||
while frame is not None:
|
||||
out.append(' File "%s", line %d in %s\n' % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name))
|
||||
frame = frame.f_back
|
||||
try:
|
||||
self._file.write("".join(out))
|
||||
self._file.flush()
|
||||
except Exception:
|
||||
# A watchdog that fails the suite over its OWN problem is worse than the defect it is watching for.
|
||||
pass
|
||||
|
||||
|
||||
_the_watchdog = StackWatchdog()
|
||||
arm = _the_watchdog.arm
|
||||
cancel = _the_watchdog.cancel
|
||||
|
||||
|
||||
def the_thread() -> threading.Thread | None:
|
||||
return _the_watchdog.thread
|
||||
@@ -1,261 +0,0 @@
|
||||
"""What the stock twins share: the same steps on Playwright's own Firefox and on our engine, one browser at a time, and a record of each.
|
||||
|
||||
A twin test measures a relation (the dropdown of a select against its element, the drop of a real drag, what an observer reads of a scrolled frame) and its
|
||||
verdict is "the same as stock Firefox with stock Playwright", never a number of ours: an expected value comes from a capture of retail or from stock in the same job.
|
||||
|
||||
HOW STOCK RUNS. The mechanism is the one of the fake web (``scripts/run_fakeweb.py``, ``tests/fakeweb/profile_p2.py::run_on_stock``): the stock Playwright client
|
||||
(``playwright.sync_api``, imported by name: the fork's guard forbids a static import), ``p.firefox.launch()``, which starts Playwright's own Firefox build that
|
||||
``python -m playwright install firefox`` put on the runner. That is a row with ``"stock_firefox": true`` of ``ci/required-suites.json``, whose leg the gate gives the
|
||||
archives, checked against ``ci/py-lock/playwright-browsers.json``. Stock goes FIRST and is closed before ours starts (ci-release-18: one browser at a time). The stock
|
||||
part runs in a thread of its own (a sync client keeps its loop marked as running in its thread, and ours is a sync client too).
|
||||
|
||||
THE SAME WINDOW. Stock is launched HEADED (``headless=False``: a real window, on a display of its own that ``OwnDisplay`` makes the way the wrapper makes ours: ``invisible_core.make_virtual_display()``, an Xvfb of 1920x1080x24 on Linux; on Windows the desktop of the job, a stock client cannot be put on another desktop), as ours is (``launch_case``: the wrapper gives the engine a display of its own, so its windows are real ones; Firefox's ``-headless`` mode is on neither, because popups, drag and drop and window geometry behave differently in it), with the display scale of the case as ``layout.css.devPixelsPerPx`` (the pref ours is launched with for the same case: the scale
|
||||
is then the one of the page AND of the browser chrome) and a context viewport of the inner size retail reads at that case (``RETAIL_CASES``: the maximized window's
|
||||
``innerWidth`` x ``innerHeight``). Ours is the maximized window of the same case (``_window_origin.launch_case``).
|
||||
|
||||
THE RECORD. Each twin saves, for each browser, what it measured with the scales that could make the two differ: ``scales.page`` (``window.devicePixelRatio`` of the page, its
|
||||
inner size, ``screen.width/height``: the DECLARED ones of ours) and ``scales.chrome`` read from chrome scope through Marionette (``devicePixelRatio`` of the browser window,
|
||||
the inner and outer size of the window, and the REAL scale of the screen: ``nsIScreen.contentsScaleFactor`` and ``defaultCSSScaleFactor``, ``windowUtils.displayDPI``). The failure message
|
||||
prints both records whole. A stock browser that cannot be driven (no Marionette, no dropdown, no drag) is a BROKEN CONTROL: red, and the message says it is no finding about ours.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import fnmatch
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple
|
||||
|
||||
from invisible_core import make_virtual_display
|
||||
|
||||
from _popup_geometry import in_a_thread_of_its_own
|
||||
from _window_origin import launch_case, scale_pref
|
||||
from test_the_maximized_window_frames_and_popups_read_retail_e2e import CASES as RETAIL_CASES
|
||||
|
||||
MARIONETTE_ARGS = ["-marionette", "-remote-allow-system-access"]
|
||||
|
||||
SCALES_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const screen = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager).primaryScreen;
|
||||
return JSON.stringify({
|
||||
chrome_devicePixelRatio: win.devicePixelRatio,
|
||||
chrome_inner: [win.innerWidth, win.innerHeight],
|
||||
chrome_outer: [win.outerWidth, win.outerHeight],
|
||||
real_screen_contentsScaleFactor: screen.contentsScaleFactor,
|
||||
real_screen_defaultCSSScaleFactor: screen.defaultCSSScaleFactor,
|
||||
real_displayDPI: win.windowUtils.displayDPI,
|
||||
});
|
||||
"""
|
||||
PAGE_SCALES = """() => ({devicePixelRatio: window.devicePixelRatio, inner: [innerWidth, innerHeight], screen: [screen.width, screen.height]})"""
|
||||
|
||||
|
||||
def on_linux() -> bool:
|
||||
return sys.platform.startswith("linux")
|
||||
|
||||
|
||||
class OwnDisplay:
|
||||
"""The display a browser that is not ours is launched on: the wrapper's own mechanism (``make_virtual_display``, what ``InvisiblePlaywright`` starts for ours), never the job's.
|
||||
|
||||
On Linux a fresh Xvfb (the core's: 1920x1080x24, access control on, its cookie in ``XAUTHORITY``), one per launch, started before the browser and stopped after it; the browser's environment
|
||||
gets ``DISPLAY`` and ``XAUTHORITY`` from it and loses the Wayland variables, so a job that runs pytest without ``xvfb-run`` (the rows of the stock twins) still has a screen. On Windows there is
|
||||
nothing to make: a stock client cannot spawn its browser on another desktop, so it is on the one of the job, and ``environ`` is the environment as it is."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._display: Any = None
|
||||
|
||||
def __enter__(self) -> "OwnDisplay":
|
||||
if on_linux():
|
||||
display = make_virtual_display()
|
||||
display.start()
|
||||
self._display = display
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc: Any) -> None:
|
||||
display, self._display = self._display, None
|
||||
if display is not None:
|
||||
display.stop()
|
||||
|
||||
def environ(self, base: Optional[Mapping[str, str]] = None) -> Dict[str, str]:
|
||||
"""``base`` (the process's environment by default) as the browser is launched with it: what the display names set, what it names ``None`` removed."""
|
||||
env = dict(os.environ if base is None else base)
|
||||
for name, value in (self._display.launch_env() if self._display is not None else {}).items():
|
||||
if value is None:
|
||||
env.pop(name, None)
|
||||
else:
|
||||
env[name] = value
|
||||
return env
|
||||
|
||||
|
||||
class BrokenControl(AssertionError):
|
||||
"""Stock Firefox could not be driven through the steps: not a finding about ours."""
|
||||
|
||||
|
||||
class Chrome:
|
||||
"""Chrome scope of the browser below this process, through Marionette (the route of ``test_software_compositing_is_declared_e2e.py``).
|
||||
|
||||
``page`` is the page the browser of this launch already opened, and it is required on purpose: ``WebDriver:NewSession`` waits for the end of the browser's start-up, which only a window
|
||||
ends, and the wrapper launches with ``-silent`` (no window at start-up). A session asked before the first page never gets its answer (the socket times out after 300 s). With the page
|
||||
as an argument the wrong order cannot be written."""
|
||||
|
||||
def __init__(self, page) -> None:
|
||||
if page is None:
|
||||
raise TypeError("Chrome needs the page this launch opened first: Marionette's NewSession is answered only once a window exists")
|
||||
import webfont_probe
|
||||
|
||||
self._page = page
|
||||
|
||||
self._m = webfont_probe._Marionette(webfont_probe.marionette_active_port())
|
||||
self._m.call("WebDriver:NewSession", {"capabilities": {"alwaysMatch": {}}})
|
||||
self._m.call("Marionette:SetContext", {"value": "chrome"})
|
||||
|
||||
def script(self, script: str, args: Tuple[Any, ...] = ()) -> Dict[str, Any]:
|
||||
return json.loads(self._m.call("WebDriver:ExecuteScript", {"script": script, "args": list(args)})["value"])
|
||||
|
||||
def scales(self) -> Dict[str, Any]:
|
||||
"""The record of the scales: the page's (declared) and the chrome's, with the real ones of the screen."""
|
||||
out = {"page": self._page.evaluate(PAGE_SCALES)}
|
||||
out.update(self.script(SCALES_JS))
|
||||
return out
|
||||
|
||||
def close(self) -> None:
|
||||
self._m.close()
|
||||
|
||||
|
||||
def stock_client():
|
||||
"""The stock Playwright client, imported by name."""
|
||||
try:
|
||||
return importlib.import_module("playwright.sync_api").sync_playwright
|
||||
except ImportError as exc: # a broken environment, not a reason to skip: a skipped gate checks nothing
|
||||
raise BrokenControl("the stock Playwright client is missing (%s): install the wrapper with its dev extra" % exc) from exc
|
||||
|
||||
|
||||
def viewport(case: str) -> Dict[str, int]:
|
||||
"""The inner size retail reads for the maximized window of ``case``, CSS pixels."""
|
||||
maximized = RETAIL_CASES[case]["maximized"]
|
||||
return {"width": int(maximized["iw"]), "height": int(maximized["ih"])}
|
||||
|
||||
|
||||
def stock_user_prefs(case: str) -> Dict[str, Any]:
|
||||
"""The user prefs stock Playwright's Firefox is launched with for ``case``: the display scale as the STRING ours is launched with (``scale_pref``), and a free Marionette port.
|
||||
|
||||
A number would be set with ``setIntPref`` by the Juggler of Playwright's build, and ``layout.css.devPixelsPerPx`` is a string pref: ``Browser.enable`` fails and no case launches."""
|
||||
return {"layout.css.devPixelsPerPx": scale_pref(case), "marionette.port": 0}
|
||||
|
||||
|
||||
def _on_stock(case: str, measure: Callable[[Any, Chrome], Dict[str, Any]]) -> Dict[str, Any]:
|
||||
def run() -> Dict[str, Any]:
|
||||
sync_playwright = stock_client()
|
||||
with sync_playwright() as p, OwnDisplay() as display:
|
||||
browser = p.firefox.launch(headless=False, args=MARIONETTE_ARGS, env=display.environ(),
|
||||
firefox_user_prefs=stock_user_prefs(case))
|
||||
chrome = None
|
||||
try:
|
||||
page = browser.new_context(viewport=viewport(case)).new_page()
|
||||
chrome = Chrome(page)
|
||||
return measure(page, chrome)
|
||||
finally:
|
||||
if chrome is not None:
|
||||
chrome.close()
|
||||
browser.close()
|
||||
|
||||
try:
|
||||
return in_a_thread_of_its_own(run)
|
||||
except BrokenControl:
|
||||
raise
|
||||
except Exception as exc:
|
||||
raise BrokenControl("BROKEN CONTROL, no finding about ours: stock Firefox (Playwright's own build) could not be driven through the steps of %s: %s: %s"
|
||||
% (case, type(exc).__name__, exc)) from exc
|
||||
|
||||
|
||||
def _on_ours(case: str, firefox_binary: str, measure: Callable[[Any, Chrome], Dict[str, Any]]) -> Dict[str, Any]:
|
||||
with launch_case(firefox_binary, case, extra_args=MARIONETTE_ARGS, extra_prefs={"marionette.port": 0}) as browser:
|
||||
page = browser.new_page() # first: the window the session below waits for
|
||||
chrome = Chrome(page)
|
||||
try:
|
||||
return measure(page, chrome)
|
||||
finally:
|
||||
chrome.close()
|
||||
|
||||
|
||||
def run_twin(case: str, firefox_binary: str, measure: Callable[[Any, Chrome], Dict[str, Any]]) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||
"""(stock's record, ours): the same ``measure(page, chrome)`` on Playwright's own Firefox first and on our engine second. Needs MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1."""
|
||||
stock = _on_stock(case, measure)
|
||||
ours = _on_ours(case, firefox_binary, measure)
|
||||
return stock, ours
|
||||
|
||||
|
||||
def both(case: str, stock: Dict[str, Any], ours: Dict[str, Any], reference: str = "stock") -> str:
|
||||
"""The two records whole, for the message of a red twin (``reference`` names the first: stock, or retail)."""
|
||||
return "\n case %s\n %s: %s\n ours: %s" % (case, reference, json.dumps(stock, sort_keys=True), json.dumps(ours, sort_keys=True))
|
||||
|
||||
|
||||
def differences(stock: Any, ours: Any, tolerances: Dict[str, float] = None, path: str = "") -> List[str]:
|
||||
"""Every place where the two records differ, as ``path: stock X, ours Y``. A number differs by more than the tolerance of its key (the last name of its path; 0 when none);
|
||||
everything else must be equal."""
|
||||
tolerances = tolerances or {}
|
||||
out: List[str] = []
|
||||
if isinstance(stock, dict) and isinstance(ours, dict):
|
||||
for key in sorted(set(stock) | set(ours)):
|
||||
if key not in stock or key not in ours:
|
||||
out.append("%s.%s: only %s has it" % (path, key, "stock" if key in stock else "ours"))
|
||||
else:
|
||||
out += differences(stock[key], ours[key], tolerances, "%s.%s" % (path, key))
|
||||
elif isinstance(stock, list) and isinstance(ours, list) and len(stock) == len(ours):
|
||||
for i, (a, b) in enumerate(zip(stock, ours)):
|
||||
out += differences(a, b, tolerances, "%s[%d]" % (path, i))
|
||||
elif isinstance(stock, (int, float)) and isinstance(ours, (int, float)) and not isinstance(stock, bool) and not isinstance(ours, bool):
|
||||
tolerance = tolerances.get(path.rsplit(".", 1)[-1].split("[", 1)[0], 0.0)
|
||||
if abs(stock - ours) > tolerance:
|
||||
out.append("%s: stock %r, ours %r (tolerance %r)" % (path, stock, ours, tolerance))
|
||||
elif stock != ours:
|
||||
out.append("%s: stock %r, ours %r" % (path, stock, ours))
|
||||
return out
|
||||
|
||||
|
||||
#: The two reasons a field of a stock twin's record can be left out of the comparison with stock (the retail capture of the case decides it instead).
|
||||
IN_PROCESS_FRAME = "in-process frame in stock"
|
||||
SYNTHETIC_DRAG = "synthetic drag in stock"
|
||||
REASONS = {
|
||||
IN_PROCESS_FRAME: "stock Playwright's Firefox sets fission.webContentIsolationStrategy=0, so its cross-site frame shares the top's process and ours is in another process: a field that depends on "
|
||||
"the frame being in another process is not what stock reads",
|
||||
SYNTHETIC_DRAG: "stock's drag is Juggler's synthetic one: no OLE drag loop, so no timer-driven drag event and no buttons held, and nothing a real drag has beyond the events themselves",
|
||||
}
|
||||
|
||||
|
||||
def canonical(path: str, root: str) -> str:
|
||||
"""``path`` of a difference less its root, with every list index as ``[]``: ``drag drop.top.once[3].buttons`` is ``top.once[].buttons`` for the root ``drag drop``."""
|
||||
rest = path[len(root):].lstrip(".") if path.startswith(root) else path
|
||||
return re.sub(r"\[\d+\]", "[]", rest)
|
||||
|
||||
|
||||
def leaf_paths(node: Any, prefix: str = "") -> List[str]:
|
||||
"""The canonical path of every leaf of a record (what a declared field has to name to exist in it)."""
|
||||
if isinstance(node, dict):
|
||||
return [p for k, v in node.items() for p in leaf_paths(v, "%s.%s" % (prefix, k) if prefix else str(k))] or [prefix]
|
||||
if isinstance(node, list):
|
||||
return [p for v in node for p in leaf_paths(v, prefix + "[]")] or [prefix + "[]"]
|
||||
return [prefix]
|
||||
|
||||
|
||||
def stale_entries(declared: Mapping[str, str], *records: Any) -> List[str]:
|
||||
"""The declared fields (a pattern of canonical paths, ``*`` for any run of characters) that name nothing in any of ``records``, and the reasons that are not one of ``REASONS``."""
|
||||
paths = [p for record in records for p in leaf_paths(record)]
|
||||
out = ["%s names no field of the record" % field for field in declared if not any(fnmatch.fnmatchcase(p, field) for p in paths)]
|
||||
return out + ["%s has the reason %r, which is not one of %s" % (field, why, sorted(REASONS)) for field, why in declared.items() if why not in REASONS]
|
||||
|
||||
|
||||
def split_differences(stock: Any, ours: Any, declared: Mapping[str, str], tolerances: Dict[str, float] = None, path: str = "") -> Tuple[List[str], List[str]]:
|
||||
"""``(red, recorded)``: the differences of ``differences`` split by the declared list of the twin. A difference at a declared field is recorded (with its reason, for the report) and does not
|
||||
decide the verdict; every other one is red. ``declared`` maps a pattern of canonical paths (``canonical``) to one of ``REASONS``."""
|
||||
red: List[str] = []
|
||||
recorded: List[str] = []
|
||||
for difference in differences(stock, ours, tolerances, path):
|
||||
where = canonical(difference.split(": ", 1)[0], path)
|
||||
why = next((reason for field, reason in declared.items() if fnmatch.fnmatchcase(where, field)), None)
|
||||
if why is None:
|
||||
red.append(difference)
|
||||
else:
|
||||
recorded.append("%s [recorded, not compared: %s]" % (difference, why))
|
||||
return red, recorded
|
||||
+6
-70
@@ -93,15 +93,6 @@ def _attrs(data: bytes) -> Dict[int, bytes]:
|
||||
return out
|
||||
|
||||
|
||||
def is_deallocation(data: bytes) -> bool:
|
||||
"""Whether a datagram is a TURN deallocation, by what it means (RFC 5766 section 7.1): a STUN Refresh (0x0004) whose LIFETIME (0x000D) is 0. A Refresh with a lifetime above 0, with
|
||||
none, or any other message type, is not one. The one reading of it: the TURN server of the lab and the gateway of the lab both use it."""
|
||||
if len(data) < 20 or struct.unpack("!I", data[4:8])[0] != MAGIC or struct.unpack("!H", data[:2])[0] != 0x0004:
|
||||
return False
|
||||
lifetime = _attrs(data).get(0x000D)
|
||||
return lifetime is not None and len(lifetime) == 4 and struct.unpack("!I", lifetime)[0] == 0
|
||||
|
||||
|
||||
def _attr(t: int, v: bytes) -> bytes:
|
||||
return struct.pack("!HH", t, len(v)) + v + b"\x00" * (-len(v) % 4)
|
||||
|
||||
@@ -120,39 +111,11 @@ def _message(mtype: int, tid: bytes, attrs: bytes, key: Optional[bytes] = None)
|
||||
return head + attrs + _attr(0x0008, mac)
|
||||
|
||||
|
||||
def long_term_key(user: str) -> bytes:
|
||||
"""The long-term credential key of RFC 5389 section 15.4: md5(username:realm:password)."""
|
||||
return hashlib.md5(("%s:%s:%s" % (user, REALM, PASSWORD)).encode(), usedforsecurity=False).digest()
|
||||
|
||||
|
||||
def integrity_valid(data: bytes, user: str) -> bool:
|
||||
"""Whether the MESSAGE-INTEGRITY of a request is the HMAC-SHA1 under the long-term key of ``user`` (RFC 5389 section 15.4): over the message up to the
|
||||
attribute, with the length field of the header set as if the message ended with that attribute (24 bytes more than what came before it). A request
|
||||
with no MESSAGE-INTEGRITY, or a truncated one, is not valid."""
|
||||
i = 20
|
||||
while i + 4 <= len(data):
|
||||
t, n = struct.unpack("!HH", data[i:i + 4])
|
||||
if t == 0x0008:
|
||||
if n != 20 or i + 24 > len(data):
|
||||
return False
|
||||
head = data[:2] + struct.pack("!H", i + 24 - 20) + data[4:20]
|
||||
return hmac.compare_digest(hmac.new(long_term_key(user), head + data[20:i], hashlib.sha1).digest(), data[i + 4:i + 24])
|
||||
i += 4 + ((n + 3) & ~3)
|
||||
return False
|
||||
|
||||
|
||||
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); ``deallocations`` the requests that END an allocation as (source ip, source
|
||||
port, transaction id, time, index in ``allocations`` of the allocation they end, or None when that source has none): a deallocation is recognised by what it means, a
|
||||
Refresh (0x0004) whose LIFETIME (0x000D) is 0 (RFC 5766 section 7.1), not by its type: a Refresh with a lifetime above 0 keeps the allocation and is not one. The server
|
||||
answers it as it answers any Refresh; a retransmission is another datagram of the same transaction (:meth:`deallocation_transactions`).
|
||||
|
||||
A request that carries USERNAME is checked: its MESSAGE-INTEGRITY must be the HMAC under the long-term key of that user (``PASSWORD``).
|
||||
A missing or wrong one is answered 401 with the realm and the nonce, makes no allocation, and is written in ``refused`` as
|
||||
(source ip, source port, username, transaction id, time): a client with the wrong password never gets a relay here, as on a real server."""
|
||||
``allocations`` the successful Allocates as (source ip, source port, username, time)."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
@@ -161,8 +124,6 @@ class TurnServer:
|
||||
self.seen: List[Tuple[str, int, int]] = []
|
||||
self.allocations: List[Tuple[str, int, str, float]] = []
|
||||
self.requests: List[Tuple[float, bytes, int, bool]] = []
|
||||
self.deallocations: List[Tuple[str, int, bytes, float, Optional[int]]] = []
|
||||
self.refused: List[Tuple[str, int, str, bytes, float]] = []
|
||||
self._closed = False
|
||||
threading.Thread(target=self._serve, daemon=True).start()
|
||||
|
||||
@@ -174,17 +135,6 @@ class TurnServer:
|
||||
first.setdefault(request[1], request)
|
||||
return sorted(first.values(), key=lambda r: r[0])
|
||||
|
||||
def deallocation_transactions(self) -> List[Tuple[str, int, bytes, float, Optional[int]]]:
|
||||
"""The first datagram of each deallocation transaction, in order: a retransmission of it is not another deallocation."""
|
||||
first: Dict[bytes, Tuple[str, int, bytes, float, Optional[int]]] = {}
|
||||
for record in list(self.deallocations):
|
||||
first.setdefault(record[2], record)
|
||||
return sorted(first.values(), key=lambda r: r[3])
|
||||
|
||||
def deallocation_tids(self) -> set:
|
||||
"""The transaction ids (bytes) of every deallocation received: what ties its datagrams on the wire to the server's record of it."""
|
||||
return {record[2] for record in list(self.deallocations)}
|
||||
|
||||
def close(self) -> None:
|
||||
self._closed = True
|
||||
self.sock.close()
|
||||
@@ -198,40 +148,26 @@ class TurnServer:
|
||||
if len(data) < 20 or struct.unpack("!I", data[4:8])[0] != MAGIC:
|
||||
continue
|
||||
mtype, tid = struct.unpack("!H", data[:2])[0], data[8:20]
|
||||
attrs = _attrs(data)
|
||||
if is_deallocation(data): # recorded BEFORE the request: whoever reads `requests` already knows which of them it ended
|
||||
held = [i for i, a in enumerate(self.allocations) if a[:2] == (src[0], src[1])]
|
||||
self.deallocations.append((src[0], src[1], tid, time.monotonic(), held[-1] if held else None))
|
||||
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))
|
||||
user_raw = attrs.get(0x0006)
|
||||
if mtype in (0x0003, 0x0004, 0x0008, 0x0009) and user_raw is not None:
|
||||
user = user_raw.decode(errors="replace")
|
||||
if not integrity_valid(data, user): # the wrong password, or no MESSAGE-INTEGRITY: 401, no allocation
|
||||
self.refused.append((src[0], src[1], user, tid, time.monotonic()))
|
||||
self.sock.sendto(_message(mtype | 0x0110, tid, self._unauthorized()), src)
|
||||
continue
|
||||
if mtype == 0x0003: # Allocate
|
||||
if 0x0008 not in attrs or 0x0006 not in attrs: # no credentials: 401 with a realm and a nonce
|
||||
self.sock.sendto(_message(0x0113, tid, self._unauthorized()), src)
|
||||
err = _attr(0x0009, b"\x00\x00\x04\x01Unauthorized") + _attr(0x0014, REALM.encode()) + _attr(0x0015, NONCE.encode())
|
||||
self.sock.sendto(_message(0x0113, tid, err), src)
|
||||
continue
|
||||
user = attrs[0x0006].decode(errors="replace")
|
||||
key = long_term_key(user)
|
||||
key = hashlib.md5(("%s:%s:%s" % (user, REALM, PASSWORD)).encode(), usedforsecurity=False).digest()
|
||||
body = (_attr(0x0016, _xor_addr(*RELAYED)) + _attr(0x0020, _xor_addr(src[0], src[1])) +
|
||||
_attr(0x000D, struct.pack("!I", 600)))
|
||||
self.allocations.append((src[0], src[1], user, time.monotonic()))
|
||||
self.sock.sendto(_message(0x0103, tid, body, key), src)
|
||||
elif mtype in (0x0004, 0x0008, 0x0009): # Refresh, CreatePermission, ChannelBind
|
||||
user = attrs.get(0x0006, b"").decode(errors="replace")
|
||||
key = long_term_key(user)
|
||||
key = hashlib.md5(("%s:%s:%s" % (user, REALM, PASSWORD)).encode(), usedforsecurity=False).digest()
|
||||
body = _attr(0x000D, struct.pack("!I", 600)) if mtype == 0x0004 else b""
|
||||
self.sock.sendto(_message(mtype | 0x0100, tid, body, key), src)
|
||||
|
||||
@staticmethod
|
||||
def _unauthorized() -> bytes:
|
||||
"""The attributes of a 401: ERROR-CODE, the realm and the nonce of the long-term credential."""
|
||||
return _attr(0x0009, b"\x00\x00\x04\x01Unauthorized") + _attr(0x0014, REALM.encode()) + _attr(0x0015, NONCE.encode())
|
||||
|
||||
|
||||
# ── the gateway ────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
"""Where the e2e stack watchdog (``tests/_stack_watchdog.py``, armed by ``tests/conftest.py``) writes its stacks."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Mapping
|
||||
|
||||
#: The folder under ``$RUNNER_TEMP`` that every e2e job uploads whatever the result ("Keep what the tests saved", ``invpw-evidence-*``).
|
||||
EVIDENCE_FOLDER = "invpw-evidence"
|
||||
LOG_NAME = "e2e-watchdog.log"
|
||||
|
||||
|
||||
def default_log_path(environ: Mapping[str, str], tempdir: str) -> str:
|
||||
"""The file the stacks go to.
|
||||
|
||||
``INVPW_TEST_WATCHDOG_FILE`` when it is set (the workflows of the wrapper name their own file). On a runner (``RUNNER_TEMP`` set) the evidence folder, which the gate uploads with
|
||||
the result of the leg, so that the stack of a hung test is in the artifact of the run that hung. Elsewhere ``invpw-e2e-watchdog.log`` in the temporary folder."""
|
||||
named = environ.get("INVPW_TEST_WATCHDOG_FILE")
|
||||
if named:
|
||||
return named
|
||||
runner = environ.get("RUNNER_TEMP")
|
||||
if runner:
|
||||
return os.path.join(runner, EVIDENCE_FOLDER, "watchdog", LOG_NAME)
|
||||
return os.path.join(tempdir, "invpw-e2e-watchdog.log")
|
||||
@@ -1,27 +0,0 @@
|
||||
"""What a test that cannot get a WebGL context writes down, so that the red says why (a pure helper, no browser).
|
||||
|
||||
A page asks for a context and gets ``null``: the page learns nothing more unless it listens for ``webglcontextcreationerror`` on the canvas
|
||||
before it asks (``statusMessage``). The probe of the test returns an object with ``unavailable: true`` and what it heard instead of ``null``;
|
||||
``split_probe`` turns that into the old ``None`` (so that the assertion stays as it was) and the record of the attempt, and ``unavailable_message``
|
||||
is the sentence of the assertion with both attempts appended.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
#: The pause, in milliseconds, between the first attempt and the second one (a diagnostic: the verdict is the first attempt's).
|
||||
SECOND_ATTEMPT_AFTER_MS = 2000
|
||||
UNAVAILABLE = "webgl is unavailable: a WebGL canvas cannot be read"
|
||||
|
||||
|
||||
def split_probe(result: Any) -> Tuple[Optional[Any], Optional[dict]]:
|
||||
"""``(got, first)``: ``got`` is what the test reads (``None`` when there was no context, exactly as the old probe returned), ``first`` the
|
||||
record of the failed attempt (``None`` when a context was made)."""
|
||||
if isinstance(result, dict) and result.get("unavailable") is True:
|
||||
return None, result
|
||||
return result, None
|
||||
|
||||
|
||||
def unavailable_message(first: Optional[dict], second: Any) -> str:
|
||||
"""The message of the assertion: the old sentence, then what the first attempt and the second one (2 s later) reported."""
|
||||
return "%s | first: %r; second after 2 s: %r" % (UNAVAILABLE, first, second)
|
||||
@@ -1,56 +0,0 @@
|
||||
"""Every pytest process of a Windows job that keeps WER dumps lets Windows Error Reporting see its crash: the bit SEM_NOGPFAULTERRORBOX of its error mode is cleared.
|
||||
|
||||
A process whose error mode carries SEM_NOGPFAULTERRORBOX (0x0002) never invokes Windows Error Reporting when it dies from an unhandled exception, so the
|
||||
LocalDumps key of python.exe that e2e.yml sets (a full dump into ``$RUNNER_TEMP/invpw-evidence/dumps/python``) is never read: the pytest controllers of the
|
||||
runner are born with 0x0003 (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX), and every child inherits the mode of its parent, so every xdist worker is born
|
||||
with it too and a worker that crashes leaves no dump.
|
||||
https://learn.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode
|
||||
|
||||
``clear_for_wer_dumps()``: tests/conftest.py calls it in ``pytest_configure``, which the controller and every xdist worker run. It acts only when ALL of this
|
||||
holds, so nothing changes on a developer's machine, on Linux, or in a job that did not set LocalDumps:
|
||||
|
||||
* the system is Windows;
|
||||
* ``$INVPW_WER_DUMPS`` (the one variable the "Windows Error Reporting keeps a full dump..." step of each Windows job of e2e.yml exports to ``$GITHUB_ENV``) names an
|
||||
existing folder: the folder the dumps go to.
|
||||
|
||||
It clears bit 0x0002 and keeps every other bit of the mode, and appends one line to ``error-mode.log`` in the parent of that folder (``invpw-evidence/dumps``, inside the evidence the job
|
||||
uploads): ``pid <n> error mode born 0x<hex>, now 0x<hex>``, so the evidence shows the bit was cleared in every process. It writes nothing to stdout or stderr, and it
|
||||
never raises: a failure is a line of that log, not a failed test.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
#: The variable the Windows jobs export: the folder LocalDumps of python.exe writes to.
|
||||
ENV_VAR = "INVPW_WER_DUMPS"
|
||||
LOG_NAME = "error-mode.log"
|
||||
#: SEM_NOGPFAULTERRORBOX: the process is not reported to Windows Error Reporting.
|
||||
SEM_NOGPFAULTERRORBOX = 0x0002
|
||||
|
||||
|
||||
def clear_for_wer_dumps(environ=None) -> None:
|
||||
environ = os.environ if environ is None else environ
|
||||
if sys.platform != "win32":
|
||||
return
|
||||
folder = environ.get(ENV_VAR)
|
||||
if not folder or not os.path.isdir(folder):
|
||||
return
|
||||
log = Path(folder).resolve().parent / LOG_NAME
|
||||
try:
|
||||
import ctypes
|
||||
kernel32 = ctypes.WinDLL("kernel32")
|
||||
kernel32.GetErrorMode.restype = ctypes.c_uint
|
||||
kernel32.SetErrorMode.argtypes = [ctypes.c_uint]
|
||||
kernel32.SetErrorMode.restype = ctypes.c_uint
|
||||
born = kernel32.GetErrorMode()
|
||||
kernel32.SetErrorMode(born & ~SEM_NOGPFAULTERRORBOX)
|
||||
line = "pid %d error mode born 0x%04x, now 0x%04x\n" % (os.getpid(), born, kernel32.GetErrorMode())
|
||||
except Exception as exc: # best effort: the evidence says what went wrong, the test run goes on
|
||||
line = "pid %d error mode not cleared: %s: %s\n" % (os.getpid(), type(exc).__name__, exc)
|
||||
try:
|
||||
with open(log, "a", encoding="utf-8") as handle:
|
||||
handle.write(line)
|
||||
except OSError:
|
||||
pass
|
||||
@@ -1,78 +0,0 @@
|
||||
"""What the window-origin e2e files share: the four display cases, a browser pinned to one of them, and waits on a reading of a page.
|
||||
|
||||
The four cases are the ones of the window tests against retail (``test_the_maximized_window_frames_and_popups_read_retail_e2e.py``): scale 1.0, 1.25 and 1.5
|
||||
on a 1920x1080 panel (device pixels) and 2.0 on a 1600x1200 one. The engine declares the window, so the page reads the same on Linux and on Windows.
|
||||
|
||||
Waits are CONDITIONS with a deadline (``_waits``), never a pause; ``observe`` is the one bounded look at a value that must NOT change, and it says so.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from typing import Any, Callable, Dict, List, Tuple
|
||||
|
||||
from _waits import wait_until
|
||||
|
||||
#: The deadline of a wait for something that must happen, in seconds.
|
||||
DEADLINE_S = 30
|
||||
#: Floats of a page (``mozInnerScreenY`` 72.667 is 72.6666...).
|
||||
FLOAT = 0.001
|
||||
|
||||
#: case id -> (display scale, panel in device pixels).
|
||||
CASES: Dict[str, Tuple[float, Tuple[int, int]]] = {
|
||||
"1920x1080-dpr1.0": (1.0, (1920, 1080)),
|
||||
"1920x1080-dpr1.25": (1.25, (1920, 1080)),
|
||||
"1920x1080-dpr1.5": (1.5, (1920, 1080)),
|
||||
"1600x1200-dpr2.0": (2.0, (1600, 1200)),
|
||||
}
|
||||
|
||||
|
||||
def scale_pref(case: str) -> str:
|
||||
"""``layout.css.devPixelsPerPx`` of a case, as the core declares it for ours (``str(profile.screen.dpr)``: "1.0", "1.25", "1.5", "2.0").
|
||||
|
||||
The pref is a STRING pref of Firefox. A client that sends a number (stock Playwright puts a number through ``Browser.enable`` as ``setIntPref``) makes the browser refuse
|
||||
the launch with NS_ERROR_UNEXPECTED, so every browser that is not ours gets the scale in this form, from here."""
|
||||
return str(CASES[case][0])
|
||||
|
||||
|
||||
def launch_case(firefox_binary: str, case: str, **extra: Any):
|
||||
"""The product on one case: seed 42, the panel and the scale pinned, headless, no humanizing. ``extra`` is for the keywords a test needs on top
|
||||
(``extra_args``, ``extra_prefs``)."""
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
dpr, panel = CASES[case]
|
||||
pin = {"screen.width": panel[0], "screen.height": panel[1], "screen.dpr": dpr}
|
||||
return InvisiblePlaywright(seed=42, pin=pin, binary_path=firefox_binary, headless=True, humanize=False, **extra)
|
||||
|
||||
|
||||
def settled(page, read: Callable[[], Any], seconds: float = DEADLINE_S) -> Any:
|
||||
"""``read()`` once two looks in a row, 100 ms apart, give the same value (or the last one at the deadline: a window that never settles is red where
|
||||
the caller's assertion names what was read)."""
|
||||
seen: Dict[str, Any] = {"now": None, "before": None}
|
||||
|
||||
def look() -> bool:
|
||||
seen["before"], seen["now"] = seen["now"], read()
|
||||
return seen["now"] == seen["before"]
|
||||
|
||||
wait_until(look, seconds, lambda: page.wait_for_timeout(100))
|
||||
return seen["now"]
|
||||
|
||||
|
||||
def wait_for(page, condition: Callable[[], Any], seconds: float = DEADLINE_S) -> bool:
|
||||
"""Until ``condition()`` is true, reading the client's events between two looks; False at the deadline."""
|
||||
return wait_until(condition, seconds, lambda: page.wait_for_timeout(100))
|
||||
|
||||
|
||||
def observe(page, read: Callable[[], Any], seconds: float) -> List[Any]:
|
||||
"""The distinct values ``read()`` gives over ``seconds``, in the order they were seen (the first look is always taken).
|
||||
|
||||
The ONE bounded look of these files: for a value that must stay as it is (a window after ``resizeBy(0, 0)``, a frame that must not have loaded yet).
|
||||
A change that comes later than ``seconds`` is not seen; a change inside it always is, so the check can be late to catch a bug and never red for nothing."""
|
||||
values: List[Any] = []
|
||||
end = time.monotonic() + seconds
|
||||
while True:
|
||||
value = read()
|
||||
if not values or values[-1] != value:
|
||||
values.append(value)
|
||||
if time.monotonic() >= end:
|
||||
return values
|
||||
page.wait_for_timeout(100)
|
||||
+8
-86
@@ -1,3 +1,4 @@
|
||||
import faulthandler
|
||||
import http.server
|
||||
import os
|
||||
import random
|
||||
@@ -9,8 +10,6 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import _stack_watchdog
|
||||
import _watchdog_log
|
||||
from _servers import LocalServer
|
||||
from _browser_census import _a_module_leaves_no_browser_open, _the_connections_a_test_made_are_closed_with_it # noqa: F401 (autouse)
|
||||
|
||||
@@ -43,7 +42,9 @@ from _browser_census import _a_module_leaves_no_browser_open, _the_connections_a
|
||||
# under pytest. A file survives the kill and gets uploaded as an artifact on
|
||||
# CI.
|
||||
_WATCHDOG_S = float(os.environ.get("INVPW_TEST_WATCHDOG_S", "150"))
|
||||
_WATCHDOG_FILE = _watchdog_log.default_log_path(os.environ, tempfile.gettempdir())
|
||||
_WATCHDOG_FILE = os.environ.get(
|
||||
"INVPW_TEST_WATCHDOG_FILE",
|
||||
str(Path(tempfile.gettempdir()) / "invpw-e2e-watchdog.log"))
|
||||
_watchdog_handle = None
|
||||
|
||||
|
||||
@@ -59,7 +60,6 @@ def _watchdog_open():
|
||||
if _watchdog_handle is not None or _WATCHDOG_S <= 0:
|
||||
return _watchdog_handle
|
||||
try:
|
||||
os.makedirs(os.path.dirname(_WATCHDOG_FILE) or ".", exist_ok=True)
|
||||
_watchdog_handle = open(_WATCHDOG_FILE, "a", buffering=1, encoding="utf-8")
|
||||
except OSError:
|
||||
# A watchdog that fails the suite over its OWN problem is worse than
|
||||
@@ -71,10 +71,6 @@ def _watchdog_open():
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
# Windows jobs that keep WER dumps (INVPW_WER_DUMPS, exported by the job): the controller and every xdist worker clear SEM_NOGPFAULTERRORBOX of their error mode,
|
||||
# which the runner gives them (0x0003) and which keeps a crashing worker from ever reaching Windows Error Reporting (tests/_wer_error_mode.py).
|
||||
import _wer_error_mode
|
||||
_wer_error_mode.clear_for_wer_dumps()
|
||||
# TEMPORARY, with tests/_crash_cores.py (the -11 at the exit of the security state's generate): on Linux every engine of the run, the core's launches
|
||||
# included, inherits a core limit equal to the hard one, so a crash leaves a core in $INVPW_CORE_DIR (kernel.core_pattern on the e2e jobs).
|
||||
import _crash_cores
|
||||
@@ -95,13 +91,13 @@ def pytest_runtest_setup(item):
|
||||
return
|
||||
handle = _watchdog_open()
|
||||
if handle is not None:
|
||||
# A Python thread that holds the GIL, not faulthandler.dump_traceback_later: that one copies the frames of every thread without the GIL and crashed a worker (tests/_stack_watchdog.py).
|
||||
_stack_watchdog.arm(item.nodeid, _WATCHDOG_S, file=handle)
|
||||
handle.write("\n--- %s ---\n" % item.nodeid)
|
||||
faulthandler.dump_traceback_later(_WATCHDOG_S, repeat=True, file=handle)
|
||||
|
||||
|
||||
def pytest_runtest_teardown(item, nextitem):
|
||||
if _watchdog_handle is not None:
|
||||
_stack_watchdog.cancel()
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
|
||||
|
||||
@pytest.hookimpl(wrapper=True)
|
||||
@@ -129,7 +125,7 @@ def pytest_collection_modifyitems(config, items):
|
||||
def pytest_unconfigure(config):
|
||||
global _watchdog_handle
|
||||
if _watchdog_handle is not None:
|
||||
_stack_watchdog.cancel()
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
_watchdog_handle.close()
|
||||
_watchdog_handle = None
|
||||
|
||||
@@ -181,22 +177,6 @@ def _offline_session_geo(request, monkeypatch):
|
||||
monkeypatch.setattr(_session, "session_geo", lambda *_a, **_k: geo)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _a_test_that_is_not_e2e_never_leaves_the_machine(request, monkeypatch):
|
||||
"""Outside the e2e, every connection, datagram and name lookup goes to this host or is refused, and the test fails naming each
|
||||
destination it tried (tests/_no_network.py), even when the code under test swallowed the refusal."""
|
||||
if request.node.get_closest_marker("e2e") is not None:
|
||||
yield
|
||||
return
|
||||
import _no_network
|
||||
|
||||
guard = _no_network.install(monkeypatch, request.node.nodeid)
|
||||
yield
|
||||
failure = guard.verdict()
|
||||
if failure:
|
||||
pytest.fail(failure, pytrace=False)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _what_the_core_declares_for_a_proxy_is_recorded(monkeypatch):
|
||||
"""The core keeps no UDP verdict in memory, so a test that wants to know what the launch declared reads it where it is
|
||||
@@ -274,64 +254,6 @@ def _no_test_asks_the_world_where_it_leaves_from():
|
||||
pytest.fail("the question of the exit went toward the internet: " + "; ".join(asked), pytrace=False)
|
||||
|
||||
|
||||
def _park_the_os_cursor():
|
||||
"""Windows: the OS cursor goes where no window of the browsers below the test process covers (the bottom-right corner while none is open), read back."""
|
||||
if sys.platform == "win32":
|
||||
import _os_cursor
|
||||
|
||||
_os_cursor.park()
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def _the_os_cursor_is_outside_the_browser_window_of_a_module(request):
|
||||
"""A browser a module-scoped fixture starts opens its window before any test of the module runs: the cursor is parked before that, once per module that has an
|
||||
e2e test (``tests/_os_cursor.py``; Windows only, the Linux e2e run under xvfb-run whose pointer is virtual)."""
|
||||
if sys.platform == "win32" and any(getattr(item, "module", None) is request.module and item.get_closest_marker("e2e") is not None
|
||||
for item in request.session.items):
|
||||
_park_the_os_cursor()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _the_os_cursor_is_outside_the_browser_window(request):
|
||||
"""A headed window that opens under the real cursor gets a native mouse move for it (the runner's cursor is at 512,384, inside the window), and the first
|
||||
native move of a process passes Gecko's filter: the page sees a ``mousemove`` with ``buttons=0`` in the middle of the gesture a test records. Every e2e
|
||||
test on Windows starts with the cursor parked outside the window the engine opens, before its browser starts. A ``headless=True`` browser runs on a desktop of
|
||||
its own and never receives it; the parking is the same for it and costs one system call. The gestures that record pointer events then call
|
||||
``_os_cursor.require_outside()`` at their start."""
|
||||
if request.node.get_closest_marker("e2e") is not None:
|
||||
_park_the_os_cursor()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def lab_exit(monkeypatch, tmp_path):
|
||||
"""The exit of the lab and its GeoIP database, declared for one test that is not e2e (``tests/_lab_egress.py``, as the e2e have it).
|
||||
|
||||
With no proxy the core asks where this machine leaves from once per composition (``prepare_session_geo``: zone, language and position
|
||||
come from the exit, even when the zone is given), and a test that is not e2e never leaves the machine (``tests/_no_network.py``). A test
|
||||
that composes prefs or a session through the core takes this fixture."""
|
||||
import _lab_egress
|
||||
|
||||
return _lab_egress.install(monkeypatch, tmp_path / "lab-geoip")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def declared_engine(monkeypatch, tmp_path):
|
||||
"""An engine executable declared for one test that is not e2e, instead of the one the core resolves.
|
||||
|
||||
Without ``binary_path=`` the launch resolves the engine through ``ensure_binary`` (``_engine.resolve_executable``): with an engine in
|
||||
the cache of the machine it answers at once, and with none it asks GitHub's release index and downloads the archive. So a unit test that
|
||||
composes a launch passed on a machine that had run ``fetch`` and went to the internet on a fresh runner, and a test that is not e2e
|
||||
never leaves the machine (``tests/_no_network.py``). The file is never run: the tests that take this fixture stop at the environment,
|
||||
the arguments or a fake ``launch``. Returns its path."""
|
||||
from invisible_playwright import _engine
|
||||
|
||||
executable = tmp_path / "declared-engine" / ("firefox.exe" if sys.platform == "win32" else "firefox")
|
||||
executable.parent.mkdir(parents=True)
|
||||
executable.write_bytes(b"")
|
||||
monkeypatch.setattr(_engine, "ensure_binary", lambda *a, **k: executable)
|
||||
return executable
|
||||
|
||||
|
||||
@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
|
||||
|
||||
@@ -12,8 +12,6 @@ folder and a `view` of the machine (the real one, or a stand-in in the unit test
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
|
||||
@@ -54,39 +52,3 @@ def maps_of_the_engine_below(root: int, binary_dir: str, machine: Optional[Machi
|
||||
if exe and exe.startswith(binary_dir):
|
||||
found[pid] = machine.maps(pid)
|
||||
return found
|
||||
|
||||
|
||||
def ships_its_own_gl(binary_dir: str) -> bool:
|
||||
"""The engine's own GL is in the package from firefox-59: a test follows the package under
|
||||
test, not the core's version (the gate runs a candidate under the published core)."""
|
||||
return os.path.isfile(os.path.join(binary_dir, "llvmpipe", "libEGL.so.1"))
|
||||
|
||||
|
||||
def gl_maps_of_this_test(firefox_binary: str) -> Optional[Dict[int, List[str]]]:
|
||||
"""The maps of the engine's processes below this test, to be read while the browser is up and a
|
||||
page has had its WebGL context; None where the verdict on the GL does not apply (not Linux,
|
||||
or an engine with no GL of its own)."""
|
||||
if not sys.platform.startswith("linux"):
|
||||
return None
|
||||
binary_dir = os.path.dirname(os.path.realpath(firefox_binary))
|
||||
if not ships_its_own_gl(binary_dir):
|
||||
return None
|
||||
return maps_of_the_engine_below(os.getpid(), binary_dir)
|
||||
|
||||
|
||||
def assert_the_gl_is_the_engines_own(firefox_binary: str, below: Optional[Dict[int, List[str]]]) -> None:
|
||||
"""The rule of the verdict on the GL, written once: some engine process maps the engine's own
|
||||
libEGL.so.1 and its own libgallium-*, and none maps a libEGL that is not under the engine's
|
||||
`llvmpipe/` folder. (GTK still opens the host's GLX at startup to choose its X11 visuals;
|
||||
nothing of it reaches WebGL or a page, so only libEGL is held against the host's.) With
|
||||
`below` None the verdict does not apply."""
|
||||
if below is None:
|
||||
return
|
||||
own = os.path.join(os.path.dirname(os.path.realpath(firefox_binary)), "llvmpipe") + os.sep
|
||||
assert below, "no engine process below this test"
|
||||
drew = [pid for pid, maps in below.items()
|
||||
if own + "libEGL.so.1" in maps and any(m.startswith(own + "libgallium-") for m in maps)]
|
||||
assert drew, {pid: [m for m in maps if "EGL" in m or "gallium" in m] for pid, maps in below.items()}
|
||||
foreign = {pid: [m for m in maps if "libEGL" in os.path.basename(m) and not m.startswith(own)]
|
||||
for pid, maps in below.items()}
|
||||
assert not any(foreign.values()), foreign
|
||||
@@ -28,10 +28,8 @@
|
||||
{"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_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "scope": "_go_back_and_record", "rule": "sleep", "nth": 1, "kind": "instrument", "reason": "Runs only after go_back has already raised: the pause dates a restore that lands after the wait, for the evidence of the red run; the error is raised unchanged and the pause decides nothing."},
|
||||
{"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_canvas_reads_as_drawn.py", "scope": "_non_premultiplied", "rule": "sleep", "nth": 1, "kind": "instrument", "reason": "A diagnostic pause that decides nothing: after a first attempt that gave no WebGL context the test waits 2 s and makes a second attempt only to record what it heard; the assert fails on the first attempt whatever the second says."},
|
||||
{"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."},
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
"""A docs-only change runs nothing heavy in the merge queue, and "nothing to test" is an explicit success the verdict knows.
|
||||
|
||||
GitHub applies no `paths` filter to a merge queue run (`merge_group`), so e2e.yml and fakeweb.yml would run in full for a change to a Markdown file. Both
|
||||
workflows now start with the job `changes` (scripts/ci_changes.py): in a queue run it lists the files between `github.event.merge_group.base_sha` and
|
||||
`head_sha` and applies the path rules the `push` trigger of the same workflow has (e2e: `paths-ignore` of `**.md`, `docs/**`, `LICENSE`; fakeweb: its
|
||||
`paths`); on push and workflow_dispatch it always says run=true. Every other job needs `changes` and runs only on `needs.changes.outputs.run == 'true'`.
|
||||
|
||||
That is NOT a skip the verdict waves through: scripts/ci_gate.py gets the output as CHANGES_RUN, and
|
||||
|
||||
* run=false: `changes` is success, every other job is `skipped` (one that ran anyway is red), and the verdict ends with
|
||||
`ok: nothing to test (<n> files changed, none under the paths of <workflow>)`;
|
||||
* run=true: every job is `success`, a skipped one is red;
|
||||
* a CHANGES_RUN that is missing or is not true or false is red, and so is a `changes` job that did not succeed.
|
||||
|
||||
Known-bad inputs: a heavy job that ran when there was nothing to test, a heavy job skipped when there was something to test, no output at all.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
WORKFLOWS = ROOT / ".github" / "workflows"
|
||||
|
||||
|
||||
def _load(name: str):
|
||||
spec = importlib.util.spec_from_file_location(name + "_for_changes", ROOT / "scripts" / (name + ".py"))
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
ci_changes = _load("ci_changes")
|
||||
ci_gate = _load("ci_gate")
|
||||
CHANGES = ROOT / "scripts" / "ci_changes.py"
|
||||
GATE = ROOT / "scripts" / "ci_gate.py"
|
||||
HEAVY = ("e2e", "fakeweb")
|
||||
RULE = "Rule: ci-13 nothing counts as passed that did not pass"
|
||||
|
||||
# ------------------------------------------------------------------------------ the path rules
|
||||
|
||||
|
||||
@pytest.mark.parametrize("files", [
|
||||
["README.md"],
|
||||
["docs/ARCHITECTURE.md"],
|
||||
["docs/diagram.png"],
|
||||
["docs/deep/er/file.txt"],
|
||||
["LICENSE"],
|
||||
["src/invisible_playwright/NOTES.md"],
|
||||
["README.md", "docs/a.png", "LICENSE"],
|
||||
])
|
||||
def test_a_docs_only_change_gives_run_false_for_both_workflows(files):
|
||||
assert ci_changes.should_run("e2e", files) is False
|
||||
assert ci_changes.should_run("fakeweb", files) is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("files", [
|
||||
["src/invisible_playwright/launcher.py"],
|
||||
["tests/test_a_launch_has_one_deadline.py"],
|
||||
["README.md", "src/invisible_playwright/launcher.py"],
|
||||
["docs/a.md", "tests/test_something_e2e.py"],
|
||||
["pyproject.toml"],
|
||||
["scripts/ci_gate.py"],
|
||||
[".github/workflows/e2e.yml"],
|
||||
["LICENSE.txt"],
|
||||
])
|
||||
def test_a_change_to_a_test_or_to_src_gives_run_true_for_e2e(files):
|
||||
assert ci_changes.should_run("e2e", files) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", [
|
||||
"tests/fakeweb/pages.json",
|
||||
"tests/fakeweb/deep/er/site.py",
|
||||
"tests/test_fakeweb_p4_report.py",
|
||||
"tests/test_fakeweb_p2_e2e.py",
|
||||
"scripts/run_fakeweb.py",
|
||||
"scripts/fakeweb_p4_report.py",
|
||||
"scripts/playwright_pin.txt",
|
||||
".github/workflows/fakeweb.yml",
|
||||
])
|
||||
def test_a_fake_web_file_gives_run_true_for_fakeweb(path):
|
||||
assert ci_changes.should_run("fakeweb", [path]) is True
|
||||
assert ci_changes.should_run("fakeweb", ["docs/a.md", path]) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", [
|
||||
"src/invisible_playwright/launcher.py",
|
||||
"tests/test_a_launch_has_one_deadline.py",
|
||||
"tests/fakewebs/other.py",
|
||||
"tests/sub/test_fakeweb_x.py",
|
||||
"scripts/run_fakeweb.pyc",
|
||||
"README.md",
|
||||
])
|
||||
def test_a_file_that_is_not_the_fake_web_gives_run_false_for_fakeweb(path):
|
||||
assert ci_changes.should_run("fakeweb", [path]) is False
|
||||
|
||||
|
||||
def test_a_change_that_lists_no_file_runs_because_it_cannot_be_told_from_a_broken_diff():
|
||||
assert ci_changes.should_run("e2e", []) is True
|
||||
assert ci_changes.should_run("fakeweb", []) is True
|
||||
|
||||
|
||||
def test_an_unknown_workflow_is_an_error():
|
||||
with pytest.raises(ValueError):
|
||||
ci_changes.should_run("tests", ["README.md"])
|
||||
|
||||
|
||||
def _push_block(workflow_file: str) -> str:
|
||||
text = (WORKFLOWS / workflow_file).read_text(encoding="utf-8")
|
||||
on = re.search(r"^on:\s*\n(.*?)(?=^\S)", text, re.M | re.S).group(1)
|
||||
code = "\n".join(line for line in on.splitlines() if not line.lstrip().startswith("#"))
|
||||
return re.search(r"^ push:\s*\n(.*?)(?=^ \S|\Z)", code + "\n", re.M | re.S).group(1)
|
||||
|
||||
|
||||
def test_the_tables_are_the_path_filters_of_the_push_triggers():
|
||||
ignore = re.findall(r"- '([^']+)'", _push_block("e2e.yml").split("paths-ignore:", 1)[1])
|
||||
assert tuple(ignore) == ci_changes.IGNORE["e2e"]
|
||||
only = re.findall(r"- '([^']+)'", _push_block("fakeweb.yml").split("paths:", 1)[1])
|
||||
assert tuple(only) == ci_changes.ONLY["fakeweb"]
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------ the script on events and on a real diff
|
||||
|
||||
|
||||
def _changes(*args: str, cwd=ROOT) -> subprocess.CompletedProcess:
|
||||
return subprocess.run([sys.executable, str(CHANGES), *args], cwd=str(cwd), capture_output=True, text=True, timeout=60)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("event", ["push", "workflow_dispatch", "schedule", ""])
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_a_push_and_a_dispatch_always_run(workflow, event):
|
||||
done = _changes(workflow, event)
|
||||
assert done.returncode == 0 and done.stdout.splitlines() == ["run=true", "files=0"], (done.stdout, done.stderr)
|
||||
|
||||
|
||||
def test_a_queue_run_without_its_commits_is_an_error():
|
||||
assert _changes("e2e", "merge_group").returncode == 2
|
||||
assert _changes("e2e", "merge_group", "", "").returncode == 2
|
||||
assert _changes("nope", "push").returncode == 2
|
||||
|
||||
|
||||
def _git(cwd, *args: str) -> str:
|
||||
done = subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@users.noreply.github.com", "-c", "commit.gpgsign=false", *args],
|
||||
cwd=str(cwd), capture_output=True, text=True, timeout=60, check=True)
|
||||
return done.stdout.strip()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def repo(tmp_path):
|
||||
_git(tmp_path, "init", "-q")
|
||||
(tmp_path / "src").mkdir()
|
||||
(tmp_path / "docs").mkdir()
|
||||
(tmp_path / "src" / "a.py").write_text("a = 1\n")
|
||||
(tmp_path / "README.md").write_text("one\n")
|
||||
_git(tmp_path, "add", "-A")
|
||||
_git(tmp_path, "commit", "-q", "-m", "base")
|
||||
return tmp_path
|
||||
|
||||
|
||||
def _entry(repo, files: dict) -> tuple:
|
||||
base = _git(repo, "rev-parse", "HEAD")
|
||||
for name, text in files.items():
|
||||
path = repo / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text)
|
||||
_git(repo, "add", "-A")
|
||||
_git(repo, "commit", "-q", "-m", "change")
|
||||
return base, _git(repo, "rev-parse", "HEAD")
|
||||
|
||||
|
||||
def test_a_queue_entry_that_changes_only_markdown_says_run_false_and_the_count(repo):
|
||||
base, head = _entry(repo, {"README.md": "two\n", "docs/new.md": "x\n", "docs/pic.png": "y\n"})
|
||||
for workflow in HEAVY:
|
||||
done = _changes(workflow, "merge_group", base, head, cwd=repo)
|
||||
assert done.returncode == 0 and done.stdout.splitlines() == ["run=false", "files=3"], (workflow, done.stdout, done.stderr)
|
||||
|
||||
|
||||
def test_a_queue_entry_that_changes_src_says_run_true_for_e2e_and_false_for_fakeweb(repo):
|
||||
base, head = _entry(repo, {"src/a.py": "a = 2\n"})
|
||||
assert _changes("e2e", "merge_group", base, head, cwd=repo).stdout.splitlines() == ["run=true", "files=1"]
|
||||
assert _changes("fakeweb", "merge_group", base, head, cwd=repo).stdout.splitlines() == ["run=false", "files=1"]
|
||||
|
||||
|
||||
def test_a_queue_entry_that_changes_a_fake_web_file_says_run_true_for_fakeweb(repo):
|
||||
base, head = _entry(repo, {"tests/fakeweb/pages.json": "{}\n"})
|
||||
assert _changes("fakeweb", "merge_group", base, head, cwd=repo).stdout.splitlines() == ["run=true", "files=1"]
|
||||
|
||||
|
||||
def test_a_commit_that_cannot_be_listed_fails_the_job_instead_of_guessing(repo):
|
||||
done = _changes("e2e", "merge_group", "0" * 40, "1" * 40, cwd=repo)
|
||||
assert done.returncode != 0 and "run=" not in done.stdout
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------ the workflows
|
||||
|
||||
|
||||
def _text(name: str) -> str:
|
||||
return (WORKFLOWS / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _jobs(text: str) -> dict:
|
||||
body = text.split("\njobs:\n", 1)[1]
|
||||
ids = list(re.finditer(r"^ ([A-Za-z0-9_-]+):\s*$", body, re.M))
|
||||
return {m.group(1): body[m.end(): ids[i + 1].start() if i + 1 < len(ids) else len(body)] for i, m in enumerate(ids)}
|
||||
|
||||
|
||||
def _needs(job_text: str) -> list:
|
||||
flow = re.search(r"^ needs: \[([^\]]*)\]\s*$", job_text, re.M)
|
||||
if flow:
|
||||
return [n.strip() for n in flow.group(1).split(",") if n.strip()]
|
||||
one = re.search(r"^ needs: ([A-Za-z0-9_-]+)\s*$", job_text, re.M)
|
||||
return [one.group(1)] if one else []
|
||||
|
||||
|
||||
def problems_changes(name: str, text: str) -> list:
|
||||
workflow = name.split(".")[0]
|
||||
out = []
|
||||
jobs = _jobs(text)
|
||||
if list(jobs)[0:1] != ["changes"]:
|
||||
return ["%s: the first job is not `changes`: %s" % (name, list(jobs)[:1])]
|
||||
body = jobs["changes"]
|
||||
if _needs(body):
|
||||
out.append("%s: `changes` needs %s: it must be the first job and wait for nothing" % (name, _needs(body)))
|
||||
if not re.search(r"^ run: \$\{\{ steps\.changes\.outputs\.run \}\}\s*$", body, re.M):
|
||||
out.append("%s: `changes` has no output `run`" % name)
|
||||
if not re.search(r"^ files: \$\{\{ steps\.changes\.outputs\.files \}\}\s*$", body, re.M):
|
||||
out.append("%s: `changes` has no output `files`" % name)
|
||||
if 'git show origin/main:scripts/ci_changes.py > "$RUNNER_TEMP/ci_changes.py"' not in body or "refs/heads/main:refs/remotes/origin/main" not in body:
|
||||
out.append("%s: `changes` does not read scripts/ci_changes.py from origin/main: a branch could decide that it needs no test" % name)
|
||||
if "ci_changes.py is not on origin/main yet: falling back to the copy of this branch" not in body:
|
||||
out.append("%s: `changes` falls back to the branch copy without saying so" % name)
|
||||
if not re.search(r'^ +python3 "\$RUNNER_TEMP/ci_changes\.py" %s "\$EVENT_NAME" "\$BASE_SHA" "\$HEAD_SHA" \| tee -a "\$GITHUB_OUTPUT"\s*$' % workflow, body, re.M):
|
||||
out.append("%s: `changes` does not run the copy it read from main with the workflow, the event and the two commits" % name)
|
||||
if "BASE_SHA: ${{ github.event.merge_group.base_sha }}" not in body or "HEAD_SHA: ${{ github.event.merge_group.head_sha }}" not in body:
|
||||
out.append("%s: `changes` does not read the base and the head of the queue entry" % name)
|
||||
if not re.search(r"^ shell: bash\s*$", body, re.M):
|
||||
out.append("%s: the step of `changes` has no `shell: bash` (the pipe to tee would hide a failure of the script: no pipefail)" % name)
|
||||
for job, text_ in jobs.items():
|
||||
if job in ("changes", "verdict"):
|
||||
continue
|
||||
if "changes" not in _needs(text_):
|
||||
out.append("%s: job %s does not need `changes`" % (name, job))
|
||||
cond = re.search(r"^ if: (.*)$", text_, re.M)
|
||||
if not cond or "needs.changes.outputs.run == 'true'" not in cond.group(1):
|
||||
out.append("%s: job %s does not run only on `needs.changes.outputs.run == 'true'`" % (name, job))
|
||||
verdict = jobs["verdict"]
|
||||
if "changes" not in _needs(verdict):
|
||||
out.append("%s: the verdict does not need `changes`" % name)
|
||||
if not re.search(r"^ +CHANGES_RUN: \$\{\{ needs\.changes\.outputs\.run \}\}\s*$", verdict, re.M):
|
||||
out.append("%s: the verdict does not pass CHANGES_RUN" % name)
|
||||
return out
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["e2e.yml", "fakeweb.yml"])
|
||||
def test_the_workflow_starts_with_changes_and_every_other_job_waits_for_its_answer(name):
|
||||
assert problems_changes(name, _text(name)) == []
|
||||
|
||||
|
||||
def test_a_workflow_that_forgets_changes_somewhere_is_refused():
|
||||
e2e = _text("e2e.yml")
|
||||
host = _jobs(e2e)["e2e-host"]
|
||||
assert any("job e2e-host does not need" in p for p in problems_changes("e2e.yml", e2e.replace(host, host.replace("needs: [changes, ", "needs: [", 1), 1)))
|
||||
no_if = e2e.replace(" if: needs.changes.outputs.run == 'true'\n uses: ./.github/workflows/core-on-index.yml", " uses: ./.github/workflows/core-on-index.yml", 1)
|
||||
assert no_if != e2e and any("job core-on-index does not run only on" in p for p in problems_changes("e2e.yml", no_if))
|
||||
fake = _text("fakeweb.yml")
|
||||
assert any("CHANGES_RUN" in p for p in problems_changes("fakeweb.yml", fake.replace("CHANGES_RUN: ${{ needs.changes.outputs.run }}", "X: 1", 1)))
|
||||
assert any("from origin/main" in p for p in problems_changes("fakeweb.yml", fake.replace('git show origin/main:scripts/ci_changes.py > "$RUNNER_TEMP/ci_changes.py"', "true", 1)))
|
||||
assert any("pipefail" in p for p in problems_changes("fakeweb.yml", fake.replace(" shell: bash\n env:\n EVENT_NAME", " env:\n EVENT_NAME", 1)))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------ the verdict
|
||||
|
||||
|
||||
def _all_run(workflow: str) -> dict:
|
||||
"""Every job of the workflow as it ends when there was something to test."""
|
||||
needs = {name: {"result": "success", "outputs": {}} for name in ci_gate.TABLES[workflow][1]}
|
||||
needs["changes"]["outputs"] = {"run": "true", "files": "4"}
|
||||
if workflow == "e2e":
|
||||
needs["e2e-page-final-touched"]["outputs"] = {"touched": "true"}
|
||||
return needs
|
||||
|
||||
|
||||
def _nothing_to_test(workflow: str, files: str = "3") -> dict:
|
||||
"""Every job as it ends when `changes` said there was nothing to test."""
|
||||
needs = {name: {"result": "skipped", "outputs": {}} for name in ci_gate.TABLES[workflow][1]}
|
||||
needs["changes"] = {"result": "success", "outputs": {"run": "false", "files": files}}
|
||||
return needs
|
||||
|
||||
|
||||
def _heavy(workflow: str) -> list:
|
||||
return sorted(n for n in ci_gate.TABLES[workflow][1] if n != "changes")
|
||||
|
||||
|
||||
def _run(workflow: str, needs: dict, changes_run, event: str = "merge_group") -> subprocess.CompletedProcess:
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("NEEDS", "EVENT_NAME", "WORKFLOW", "INPUT_ONLY", "CHANGES_RUN")}
|
||||
env.update(NEEDS=json.dumps(needs), EVENT_NAME=event, WORKFLOW=workflow)
|
||||
if changes_run is not None:
|
||||
env["CHANGES_RUN"] = changes_run
|
||||
return subprocess.run([sys.executable, str(GATE)], env=env, capture_output=True, text=True, timeout=60)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_every_job_ran_and_passed_is_ok_when_there_was_something_to_test(workflow):
|
||||
done = _run(workflow, _all_run(workflow), "true")
|
||||
assert done.returncode == 0 and done.stdout.splitlines()[-1] == "ok", done.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_nothing_to_test_with_every_heavy_job_skipped_is_green_and_says_so(workflow):
|
||||
needs = _nothing_to_test(workflow)
|
||||
assert ci_gate.verdict(needs, "merge_group", workflow, "", "false") == []
|
||||
done = _run(workflow, needs, "false")
|
||||
assert done.returncode == 0, done.stdout
|
||||
assert done.stdout.splitlines()[-1] == "ok: nothing to test (3 files changed, none under the paths of %s)" % workflow
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_nothing_to_test_but_a_heavy_job_ran_and_failed_is_red(workflow):
|
||||
for job in _heavy(workflow):
|
||||
needs = _nothing_to_test(workflow)
|
||||
needs[job]["result"] = "failure"
|
||||
done = _run(workflow, needs, "false")
|
||||
assert done.returncode == 1 and "job %s is failure" % job in done.stdout, (job, done.stdout)
|
||||
assert not done.stdout.splitlines()[-1].startswith("ok"), job
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_nothing_to_test_but_a_heavy_job_ran_is_red_even_when_it_passed(workflow):
|
||||
for job in _heavy(workflow):
|
||||
needs = _nothing_to_test(workflow)
|
||||
needs[job]["result"] = "success"
|
||||
assert any("job %s is success" % job in line for line in ci_gate.verdict(needs, "merge_group", workflow, "", "false")), job
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
def test_something_to_test_but_a_heavy_job_skipped_is_red(workflow):
|
||||
for job in _heavy(workflow):
|
||||
if workflow == "e2e" and job in ci_gate.E2E_BY_OUTPUT:
|
||||
continue # skipped on purpose when the page oracle is not touched (run=true and touched=false)
|
||||
needs = _all_run(workflow)
|
||||
needs[job]["result"] = "skipped"
|
||||
done = _run(workflow, needs, "true")
|
||||
assert done.returncode == 1 and "FAIL %s: job %s is skipped. Fix: " % (ci_gate.TABLES[workflow][0], job) in done.stdout, (job, done.stdout)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
@pytest.mark.parametrize("value", [None, "", "maybe", "True", "1"])
|
||||
def test_a_missing_or_unreadable_answer_is_red_whatever_the_jobs_say(workflow, value):
|
||||
for needs in (_all_run(workflow), _nothing_to_test(workflow)):
|
||||
done = _run(workflow, needs, value)
|
||||
assert done.returncode == 1, (value, done.stdout)
|
||||
assert "FAIL %s: the output run of the job changes is" % ci_gate.TABLES[workflow][0] in done.stdout and RULE in done.stdout
|
||||
assert "ok" not in done.stdout.splitlines()
|
||||
assert ci_gate.verdict(_all_run(workflow), "merge_group", workflow)[0].startswith("FAIL "), "no answer given at all"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("workflow", HEAVY)
|
||||
@pytest.mark.parametrize("result", ["failure", "cancelled", "skipped"])
|
||||
@pytest.mark.parametrize("run", ["true", "false"])
|
||||
def test_a_changes_job_that_did_not_succeed_is_red_either_way(workflow, result, run):
|
||||
needs = _all_run(workflow) if run == "true" else _nothing_to_test(workflow)
|
||||
needs["changes"]["result"] = result
|
||||
assert any("job changes is %s" % result in line for line in ci_gate.verdict(needs, "merge_group", workflow, "", run))
|
||||
|
||||
|
||||
def test_a_push_and_a_dispatch_run_everything_so_nothing_there_may_be_skipped():
|
||||
for event in ("push", "workflow_dispatch"):
|
||||
needs = _all_run("fakeweb")
|
||||
needs["walk"]["result"] = "skipped"
|
||||
assert any("job walk is skipped" in line for line in ci_gate.verdict(needs, event, "fakeweb", "", "true"))
|
||||
|
||||
|
||||
def test_the_tests_workflow_has_no_changes_job_and_is_judged_as_before():
|
||||
assert "changes" not in ci_gate.FIX and "tests" not in ci_gate.HAS_CHANGES
|
||||
assert ci_gate.verdict({n: {"result": "success", "outputs": {}} for n in ci_gate.FIX}, "pull_request") == []
|
||||
@@ -1,123 +0,0 @@
|
||||
"""A real drag from the top document ends as it does on stock Firefox with stock Playwright, in a frame of another site and in the top document.
|
||||
|
||||
The drag-and-drop points cross the process boundary as whole numbers: the parent sends the drop point to the frame's process, and the end point of the drag
|
||||
to the source's. If either one is off by the offset between the window's real chrome and its declared chrome, the frame's element under the cursor is not the
|
||||
element that gets the drop, and ``dragend`` carries a point that is not the last one the drag reported.
|
||||
|
||||
THE VERDICT IS "THE SAME AS STOCK" (``_stock_twin``): Playwright's own Firefox, driven by the stock Playwright client, does the same drag first, on the same local pages, at the same
|
||||
window size and scale, and ours must read what stock reads. What the page reads is the relation, and no number of ours is its expected value.
|
||||
|
||||
What it does, per display case (the four of the window tests), on each browser, with the client's own mouse (``page.mouse.move``, ``down``, ``move`` in steps, ``up``), twice: a page of the top
|
||||
site holds a draggable box at its top left, a drop box in the top document (120x120 at (20, 200)) and, lower right, a frame of another site, 400x300 at (200, 100). The frame holds two boxes,
|
||||
120x120, at (40, 60) (``target``) and (220, 60) (``other``). The mouse goes down on the dragged box and moves in twelve steps to the centre of ``target`` (300, 220 in the top document), and then,
|
||||
on a fresh load of the page, to the centre of the drop box of the top document (80, 260). Both pages record every drag event they hear (``_drag_record``): for ``dragstart`` and ``drag``
|
||||
at the source, ``dragenter``, ``dragover``, ``dragleave`` and ``drop`` where the drag goes, and ``dragend`` at the source, the type, the target's id, the id of the element under the cursor, the
|
||||
client and screen points, ``buttons``, ``mozInputSource``, ``dataTransfer.types``, ``effectAllowed``, ``dropEffect``, ``mozUserCancelled``, whether ``mozSourceNode`` is null and ``isTrusted``;
|
||||
the ``dragend`` point; and ``dragend``'s client point less the last ``drag``'s.
|
||||
|
||||
THE TWIN RULE (``_drag_record.DECLARED``): stock's frame is in-process (stock Playwright's Firefox sets ``fission.webContentIsolationStrategy=0``) and its drag is Juggler's synthetic one, so
|
||||
the buttons, ``drag`` at the source (count and presence), the ``dragend`` point less the last ``drag`` and, in the frame, ``effectAllowed``, ``dropEffect`` and ``mozSourceNode`` are in the record
|
||||
and NOT compared with stock; so are, for the drop in the frame only, the top document's ``dragleave`` into the frame (stock's top hears one at the body when the cursor enters the subdocument;
|
||||
retail with the frame out of process has none) and the ``dropEffect`` of the top ``dragend`` (the frame's drop result, which crosses processes). The report of the test lists what differs there
|
||||
(``recorded_differences``), and the retail capture (the round ``drag`` of the core's window-geometry workflow) decides them. Routing and targets, client points, ``rel``, types, trusted, the input
|
||||
source, and the effects of the top document (``dragend``'s too, in the drop in the top document) are compared.
|
||||
|
||||
Ours equals stock in every compared field, within one CSS pixel in a client point, and through the relation of the screen point to the client point (stock's window
|
||||
stands where it stands and ours where it declares, so the screen numbers themselves are in the record and not in the verdict; ``_drag_record`` says why, field by field). The record also has
|
||||
the scales of each browser (page and chrome ``devicePixelRatio``, and the real scale of the screen from chrome scope), printed when it differs.
|
||||
|
||||
The engine that answers these values is not released yet: with the real chrome offset in the points the drop target or ``dragend`` is off, so this test is RED on the engine of the pin
|
||||
where they differ, on purpose. It enters the suite with the engine release.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import pytest
|
||||
from _drag_record import RECORDER_JS, read_events, read_record, recorded, verdict
|
||||
from _fission_frames import Sites, wait_frame
|
||||
from _stock_twin import Chrome, run_twin
|
||||
from _window_origin import CASES, DEADLINE_S, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The box that is dragged: 80x50 at (20, 20) of the top document; the mouse goes down at its centre.
|
||||
SOURCE = (60, 45)
|
||||
#: The frame: 400x300 at (200, 100). The centre of ``target`` in the frame is (100, 120), so (300, 220) in the top document.
|
||||
FRAME_AT = (200, 100)
|
||||
TARGET_IN_FRAME = (100, 120)
|
||||
#: The drop box of the top document: 120x120 at (20, 200); its centre.
|
||||
TOP_DROP = (80, 260)
|
||||
STEPS = 12
|
||||
#: The two drops, in this order: the one the engine's fission path serves and the one that must keep working. kind -> where the mouse goes up.
|
||||
DROPS: Dict[str, Tuple[int, int]] = {"frame": (FRAME_AT[0] + TARGET_IN_FRAME[0], FRAME_AT[1] + TARGET_IN_FRAME[1]), "top": TOP_DROP}
|
||||
|
||||
TOP = """<!doctype html><meta charset=utf-8><title>drag</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%%}
|
||||
#src{position:absolute;left:20px;top:20px;width:80px;height:50px;background:#9bd}
|
||||
#top_target{position:absolute;left:20px;top:200px;width:120px;height:120px;background:#bd9}
|
||||
#f{position:absolute;left:200px;top:100px;width:400px;height:300px;border:0}</style>
|
||||
<body><div id=src draggable=true>drag</div><div id=top_target>drop</div><iframe id=f src="%s"></iframe><script>
|
||||
document.getElementById('src').addEventListener('dragstart', e => {
|
||||
e.dataTransfer.setData('text/plain', 'x');
|
||||
e.dataTransfer.effectAllowed = 'copy';
|
||||
});
|
||||
document.getElementById('top_target').addEventListener('dragover', e => e.preventDefault());
|
||||
document.getElementById('top_target').addEventListener('drop', e => e.preventDefault());
|
||||
</script><script>""" + RECORDER_JS + """</script>"""
|
||||
|
||||
FRAME = """<!doctype html><meta charset=utf-8><title>drop</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%}
|
||||
.box{position:absolute;top:60px;width:120px;height:120px}
|
||||
#target{left:40px;background:#bd9}#other{left:220px;background:#db9}</style>
|
||||
<body><div id=target class=box>target</div><div id=other class=box>other</div><script>
|
||||
document.addEventListener('dragover', e => e.preventDefault(), true);
|
||||
document.addEventListener('drop', e => e.preventDefault(), true);
|
||||
</script><script>""" + RECORDER_JS + """</script>"""
|
||||
|
||||
|
||||
def _drag(page, to: Tuple[int, int]) -> None:
|
||||
page.mouse.move(*SOURCE)
|
||||
page.mouse.down()
|
||||
page.mouse.move(to[0], to[1], steps=STEPS)
|
||||
page.mouse.up()
|
||||
|
||||
|
||||
def _heard(document, kind: str) -> bool:
|
||||
return any(e["type"] == kind for e in read_events(document))
|
||||
|
||||
|
||||
def _one_drop(sites, page, kind: str) -> Dict[str, Any]:
|
||||
"""A fresh load of the page, one drag that ends at ``kind``'s point, and the record of what both documents heard."""
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
frame = wait_frame(page, sites.origin["B"], "/drop", seconds=DEADLINE_S)
|
||||
wait_for(page, lambda: frame.evaluate("() => document.readyState") == "complete")
|
||||
origin = page.evaluate("() => { const r = document.getElementById('f').getBoundingClientRect(); return [r.left, r.top]; }")
|
||||
assert tuple(origin) == FRAME_AT, "the frame is at %r in the top document, the test placed it at %r" % (origin, FRAME_AT)
|
||||
|
||||
_drag(page, DROPS[kind])
|
||||
|
||||
wait_for(page, lambda: _heard(page, "dragend") or not _heard(page, "dragstart"), 10)
|
||||
receiver = frame if kind == "frame" else page
|
||||
wait_for(page, lambda: _heard(receiver, "drop"), 5) # stock may drop nothing: then the wait ends and the record says so
|
||||
return read_record(page, frame)
|
||||
|
||||
|
||||
def _steps(sites, page, chrome: Chrome) -> Dict[str, Any]:
|
||||
"""What one browser does and what the page reads of it. {"scales": ..., "measured": {"frame": record, "top": record}}."""
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
scales = chrome.scales()
|
||||
return {"scales": scales, "measured": {kind: _one_drop(sites, page, kind) for kind in DROPS}}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_drag_from_the_top_into_a_frame_of_another_site_ends_as_on_stock(firefox_binary, monkeypatch, case, record_property):
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads of the record
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/drop"))
|
||||
sites.route("B", "/drop", FRAME)
|
||||
stock, ours = run_twin(case, firefox_binary, lambda page, chrome: _steps(sites, page, chrome))
|
||||
for kind in DROPS:
|
||||
record_property("recorded_differences_%s" % kind, "\n".join(recorded(stock["measured"][kind], ours["measured"][kind], kind, "%s drop" % kind)))
|
||||
message = verdict(case, kind, stock["measured"][kind], ours["measured"][kind])
|
||||
assert not message, message
|
||||
@@ -1,128 +0,0 @@
|
||||
"""A frame reads its ``mozInnerScreen`` only as (0, 0), as the client origin of the window, or as its settled value, from the first line of its script to ``load``.
|
||||
|
||||
Retail Firefox 159.0 on Windows, round 7 of the window-geometry capture (RetailCaptures ``captures/WINDOW_GEOMETRY_FRAME_EARLY.csv``, steps ``iframes_max``
|
||||
and ``iframes_transformed``, columns ``moment``, ``mozInnerScreenX/Y``, ``settled_mozInnerScreenX/Y``, ``client_origin_css_x/y``): in a maximized window every
|
||||
reading of a frame, at parse, ``DOMContentLoaded``, the first two animation frames and ``load``, is one of
|
||||
three values and no other:
|
||||
|
||||
* (0, 0): the frame has no place yet (a frame of another process before the parent has sent the first matrix, and any frame before its first layout);
|
||||
* the window's client origin, ``client_origin_css_x/y``: (0, 0) in every row of the maximized window (the popup of the same round has (12, 4) at scale 1.0,
|
||||
and is not read here);
|
||||
* the value the frame settles at.
|
||||
|
||||
A reading that is none of them is a value the page can tell from retail: a frame of another process that, before its first matrix, reads the real offset of the
|
||||
browser chrome in the host's window, or the real window origin, instead of what the declaration gives. Those values are what the host's window has, and they
|
||||
are not the declared ones.
|
||||
|
||||
What it does, per display case (the four of the window tests): a page of the top site loads a frame of the same site and a frame of another site, and the same two
|
||||
inside a container under ``transform: scale(1.5)`` and ``rotate(10deg)`` (``transform-origin: 0 0``), the six kinds of round 7. The frame's page has an inline
|
||||
script FIRST in ``<head>``: it records ``mozInnerScreenX/Y`` at parse, at ``DOMContentLoaded``, in the first two ``requestAnimationFrame`` callbacks it asked for at
|
||||
parse, and at ``load``. Each kind loads three times (a new frame each time: the reading at parse is a race the first load can win by luck). The settled value is the
|
||||
frame's reading once two looks 100 ms apart are equal, after ``load``. The assertion names the case, the kind, the moment and the three values it allowed.
|
||||
|
||||
The engine that answers these values is not released yet: on the engine of the pin this test is RED where the frame reads the real offsets, on purpose. It enters
|
||||
the suite with the engine release.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites, wait_frame
|
||||
from _window_origin import CASES, DEADLINE_S, FLOAT, launch_case, settled, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The window's client origin in CSS pixels: ``client_origin_css_x/y`` of every ``iframes_max`` and ``iframes_transformed`` row of round 7 (maximized: the client
|
||||
#: area starts at the window's origin).
|
||||
CLIENT_ORIGIN: Tuple[float, float] = (0.0, 0.0)
|
||||
#: The moments of the capture, and the frames each load must have recorded before it is read.
|
||||
MOMENTS = ("parse", "dcl", "raf1", "raf2", "load")
|
||||
#: Loads of each kind.
|
||||
LOADS = 3
|
||||
|
||||
TOP = """<!doctype html><meta charset=utf-8><title>early</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%}</style><body></body>"""
|
||||
|
||||
# The page of every frame. The script is the first thing in <head>, as in the capture.
|
||||
EARLY = """<!doctype html><html><head><script>
|
||||
window.__early = [];
|
||||
function rec(moment) { window.__early.push({m: moment, x: mozInnerScreenX, y: mozInnerScreenY}); }
|
||||
rec('parse');
|
||||
document.addEventListener('DOMContentLoaded', function () { rec('dcl'); });
|
||||
requestAnimationFrame(function () { rec('raf1'); requestAnimationFrame(function () { rec('raf2'); }); });
|
||||
window.addEventListener('load', function () { rec('load'); });
|
||||
</script><meta charset=utf-8><style>html,body{margin:0;padding:0;height:100%}</style></head><body></body></html>"""
|
||||
|
||||
#: A frame in the page, 300x120 at (10, 60) (same site) or (10, 200) (another site), or in a container at (10, 200) under a transform.
|
||||
ADD = """([src, top, transform]) => {
|
||||
const f = document.createElement('iframe');
|
||||
f.src = src;
|
||||
f.style.cssText = 'display:block;width:300px;height:120px;border:0;margin:0;padding:0';
|
||||
const box = document.createElement('div');
|
||||
box.className = 'early-box';
|
||||
if (transform) {
|
||||
box.style.cssText = 'position:fixed;left:10px;top:200px;width:300px;height:120px;margin:0;padding:0;transform-origin:0 0;transform:' + transform;
|
||||
} else {
|
||||
box.style.cssText = 'position:absolute;left:10px;top:' + top + 'px;width:300px;height:120px;margin:0;padding:0';
|
||||
}
|
||||
box.appendChild(f);
|
||||
document.body.appendChild(box);
|
||||
}"""
|
||||
REMOVE = "() => { document.querySelectorAll('.early-box').forEach(b => b.remove()); }"
|
||||
|
||||
#: kind -> (site of the frame, top in the page, transform)
|
||||
KINDS: Dict[str, Tuple[str, int, str]] = {
|
||||
"same": ("A", 60, ""),
|
||||
"cross": ("B", 200, ""),
|
||||
"same_scale": ("A", 200, "scale(1.5)"),
|
||||
"cross_scale": ("B", 200, "scale(1.5)"),
|
||||
"same_rotate": ("A", 200, "rotate(10deg)"),
|
||||
"cross_rotate": ("B", 200, "rotate(10deg)"),
|
||||
}
|
||||
|
||||
|
||||
def _near(reading: Tuple[float, float], other: Tuple[float, float]) -> bool:
|
||||
return abs(reading[0] - other[0]) <= FLOAT and abs(reading[1] - other[1]) <= FLOAT
|
||||
|
||||
|
||||
def _recorded(frame) -> List[Dict[str, Any]]:
|
||||
try:
|
||||
return frame.evaluate("() => window.__early || []")
|
||||
except Exception: # the frame is between two documents: not recorded yet
|
||||
return []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_frame_reads_only_declared_origins_while_it_loads(firefox_binary, case):
|
||||
problems: List[str] = []
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", TOP)
|
||||
sites.route("A", "/early", EARLY)
|
||||
sites.route("B", "/early", EARLY)
|
||||
with launch_case(firefox_binary, case) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
for kind, (site, top, transform) in KINDS.items():
|
||||
for load in range(LOADS):
|
||||
path = "/early?%s&load=%d" % (kind, load)
|
||||
page.evaluate(ADD, [sites.url(site, path), top, transform])
|
||||
try:
|
||||
frame = wait_frame(page, sites.origin[site], path, seconds=DEADLINE_S)
|
||||
wait_for(page, lambda: {r["m"] for r in _recorded(frame)} >= set(MOMENTS))
|
||||
records = {r["m"]: r for r in _recorded(frame)}
|
||||
missing = [m for m in MOMENTS if m not in records]
|
||||
if missing:
|
||||
problems.append("%s, %s, load %d: the frame never recorded %s (recorded %r)" % (case, kind, load, missing, _recorded(frame)))
|
||||
continue
|
||||
final = settled(page, lambda: tuple(frame.evaluate("() => [mozInnerScreenX, mozInnerScreenY]")))
|
||||
allowed = [(0.0, 0.0), CLIENT_ORIGIN, final]
|
||||
for moment in MOMENTS:
|
||||
reading = (records[moment]["x"], records[moment]["y"])
|
||||
if not any(_near(reading, a) for a in allowed):
|
||||
problems.append(
|
||||
"%s, %s frame, load %d, at %s: mozInnerScreen reads (%r, %r); allowed (0, 0), the client origin %r, or the settled value %r"
|
||||
% (case, kind, load, moment, reading[0], reading[1], CLIENT_ORIGIN, final))
|
||||
finally:
|
||||
page.evaluate(REMOVE)
|
||||
assert not problems, "a frame read a value that is not declared while it loaded (%d):\n %s" % (len(problems), "\n ".join(problems))
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
"""faulthandler's thread dump crashes a process whose threads churn frames, and the e2e stack watchdog does not: the hazard behind the Windows part 3 deaths.
|
||||
|
||||
Both halves run the same load in a child python: 32 threads that call a recursive function and start and join a short thread, over and over, so that frames
|
||||
are created and freed all the time, while a watchdog dumps the stacks of every thread every millisecond.
|
||||
|
||||
* The old mechanism, ``faulthandler.dump_traceback_later(0.001, repeat=True)``, copies the frames of every thread without the GIL. The child must die with a
|
||||
crash status (a signal on Linux, an NT status such as 0xC0000005 on Windows), never end well and never end with an exception (status 1). It dies in under 100 ms
|
||||
on CPython 3.11 and 3.12, and the child gets 60 s before the test says that this Python did not show the hazard. This is the proof that the hazard is real.
|
||||
* The new watchdog (``tests/_stack_watchdog.py``) at a period of 1 ms, on the same load, must let the child run for SURVIVAL_S = 6 s (sixty times what the old
|
||||
one lasts) and end with status 0, with the file holding a dump of the threads for at least 20 dumps.
|
||||
|
||||
The child sets itself up not to leave a trace of its crash: on Windows the error mode without the crash box (no Windows Error Reporting dialog and no dump
|
||||
in the LocalDumps folder of a job that keeps them), on Linux a core limit of 0.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
SURVIVAL_S = 6.0
|
||||
THREADS = 32
|
||||
HAZARD_DEADLINE_S = 60.0
|
||||
|
||||
CHILD = '''
|
||||
import json, os, sys, threading, time
|
||||
|
||||
mode, seconds, threads, tests_dir, log_path = sys.argv[1], float(sys.argv[2]), int(sys.argv[3]), sys.argv[4], sys.argv[5]
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
ctypes.windll.kernel32.SetErrorMode(0x8003)
|
||||
else:
|
||||
import resource
|
||||
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
|
||||
sys.path.insert(0, tests_dir)
|
||||
|
||||
stop = threading.Event()
|
||||
|
||||
|
||||
def deep(n):
|
||||
if n == 0:
|
||||
return sum(i for i in range(5))
|
||||
return deep(n - 1) + 1
|
||||
|
||||
|
||||
def churn():
|
||||
while not stop.is_set():
|
||||
deep(30)
|
||||
t = threading.Thread(target=deep, args=(10,))
|
||||
t.start()
|
||||
t.join()
|
||||
|
||||
|
||||
class Sink:
|
||||
"""Counts the dumps and keeps the first megabyte of them in the file: a dump every millisecond would fill a disk."""
|
||||
|
||||
def __init__(self, path):
|
||||
self.file = open(path, "w", encoding="utf-8")
|
||||
self.kept = 0
|
||||
self.dumps = 0
|
||||
|
||||
def write(self, text):
|
||||
self.dumps += text.count("Timeout (")
|
||||
if self.kept < 1000000:
|
||||
self.kept += self.file.write(text)
|
||||
|
||||
def flush(self):
|
||||
self.file.flush()
|
||||
|
||||
|
||||
if mode == "old":
|
||||
import faulthandler
|
||||
faulthandler.dump_traceback_later(0.001, repeat=True, file=open(os.devnull, "w"))
|
||||
else:
|
||||
import _stack_watchdog as dog
|
||||
sink = Sink(log_path)
|
||||
dog.arm("stress", 0.001, 0.001, file=sink)
|
||||
|
||||
workers = [threading.Thread(target=churn, daemon=True) for _ in range(threads)]
|
||||
for w in workers:
|
||||
w.start()
|
||||
time.sleep(seconds)
|
||||
stop.set()
|
||||
if mode == "old":
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
else:
|
||||
dog.cancel()
|
||||
for w in workers:
|
||||
w.join()
|
||||
print(json.dumps({"survived": True, "dumps": 0 if mode == "old" else sink.dumps}))
|
||||
'''
|
||||
|
||||
|
||||
def _run(tmp_path: Path, mode: str, seconds: float, timeout: float):
|
||||
script = tmp_path / ("child_%s.py" % mode)
|
||||
script.write_text(CHILD, encoding="utf-8")
|
||||
log = tmp_path / "dumps.log"
|
||||
done = subprocess.run([sys.executable, str(script), mode, str(seconds), str(THREADS), str(TESTS), str(log)], capture_output=True, text=True, timeout=timeout)
|
||||
return done, log
|
||||
|
||||
|
||||
def _crashed(returncode: int) -> bool:
|
||||
"""A signal on POSIX (negative), an NT status (0xC0000005 and the like, from 0x80000000) on Windows. An exception of Python is 1, a good end is 0."""
|
||||
return returncode < 0 or returncode >= 0x80000000
|
||||
|
||||
|
||||
def test_the_dump_of_faulthandler_kills_a_process_that_churns_frames(tmp_path):
|
||||
done, _ = _run(tmp_path, "old", HAZARD_DEADLINE_S, HAZARD_DEADLINE_S + 60)
|
||||
assert _crashed(done.returncode), (
|
||||
"faulthandler.dump_traceback_later(0.001, repeat=True) did not crash the child on this Python (%s, status %s): the GIL-free copy of the frames "
|
||||
"did not show on %d threads in %d s. stdout %r, stderr %r" % (sys.version.split()[0], done.returncode, THREADS, HAZARD_DEADLINE_S, done.stdout[-200:], done.stderr[-500:]))
|
||||
|
||||
|
||||
def test_the_stack_watchdog_survives_the_same_load_for_sixty_times_as_long(tmp_path):
|
||||
done, log = _run(tmp_path, "new", SURVIVAL_S, SURVIVAL_S + 120)
|
||||
assert done.returncode == 0, "the child ended with status %s after at most %s s, stderr %r" % (done.returncode, SURVIVAL_S, done.stderr[-800:])
|
||||
result = json.loads(done.stdout)
|
||||
assert result["survived"] and result["dumps"] >= 20, result
|
||||
text = log.read_text(encoding="utf-8", errors="replace")
|
||||
assert "Timeout (" in text and "Thread 0x" in text and "in churn" in text
|
||||
@@ -1,274 +0,0 @@
|
||||
"""A Marionette session is asked for only after the launch has a window: the twins no longer wait 300 s for an answer that cannot come.
|
||||
|
||||
The wrapper launches the engine with ``-silent``: there is no window at start-up. Marionette's ``WebDriver:NewSession`` waits for the end of the browser's start-up, which only a window ends,
|
||||
so a test that asked for the session before its first ``new_page()`` never got its answer and the socket gave up after 300 s (the twins ``run_retail_twin`` and ``_on_ours``: every
|
||||
stock twin and every retail twin of the engine candidate, both systems). Two checks, no browser:
|
||||
|
||||
1. The order is written in the signature and the call sites. ``Chrome`` takes the page of the launch as a required argument, and a scan of every test and script (ast) refuses a function that
|
||||
makes a session (``_Marionette(...)``, ``marionette_active_port(...)``, ``WebDriver:NewSession``, or a helper or class that does, found by name across the files) before the
|
||||
first ``new_page()`` of the same function, or a ``Popen`` that opens ``about:blank``. A helper that opens no window of its own is checked at its callers.
|
||||
2. The behaviour, on a Marionette that answers ``NewSession`` only once a window exists, as the engine does: ``_on_ours`` and ``run_retail_twin`` get their answer, and the same fake
|
||||
times out for a session asked first.
|
||||
|
||||
Known-bad input: ``chrome = Chrome()`` before ``browser.new_page()`` (both twins, the old files), and the synthetic old order below. Green: the page first, then ``Chrome(page)``.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import contextlib
|
||||
import inspect
|
||||
import pathlib
|
||||
from typing import Dict, List, Optional, Set, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
import _retail_reference
|
||||
import _stock_twin
|
||||
import webfont_probe
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
HERE = pathlib.Path(__file__).resolve().parent
|
||||
ROOT = HERE.parent
|
||||
|
||||
NEW_SESSION = "WebDriver:NewSession"
|
||||
#: The names that open a Marionette connection; a function that calls one is a session helper or a launcher with a session, and the names it carries join the set.
|
||||
PRIMITIVES = {"_Marionette", "marionette_active_port"}
|
||||
#: What starts a browser: a function that calls one of these is a launcher, and every session it asks for needs a window before it.
|
||||
LAUNCHERS = {"InvisiblePlaywright", "launch_case", "launch", "Popen"}
|
||||
|
||||
|
||||
def _name(call: ast.Call) -> Optional[str]:
|
||||
target = call.func
|
||||
return target.id if isinstance(target, ast.Name) else target.attr if isinstance(target, ast.Attribute) else None
|
||||
|
||||
|
||||
def _own_calls(function: ast.AST) -> List[ast.Call]:
|
||||
"""The calls in the body of ``function`` itself, not in a function, lambda or class defined inside it."""
|
||||
calls: List[ast.Call] = []
|
||||
stack = list(function.body)
|
||||
while stack:
|
||||
node = stack.pop()
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda, ast.ClassDef)):
|
||||
continue
|
||||
if isinstance(node, ast.Call):
|
||||
calls.append(node)
|
||||
stack.extend(ast.iter_child_nodes(node))
|
||||
return calls
|
||||
|
||||
|
||||
def _opens_a_window(call: ast.Call) -> bool:
|
||||
if _name(call) == "new_page":
|
||||
return True
|
||||
if _name(call) == "Popen":
|
||||
return any(isinstance(x, ast.Constant) and x.value == "about:blank" for arg in call.args for x in ast.walk(arg))
|
||||
return False
|
||||
|
||||
|
||||
def _functions(tree: ast.AST) -> List[Tuple[ast.AST, Optional[str]]]:
|
||||
"""Every function with the class it is a method of (None for the others), nested ones too."""
|
||||
found: List[Tuple[ast.AST, Optional[str]]] = []
|
||||
|
||||
def visit(node: ast.AST, owner: Optional[str]) -> None:
|
||||
for child in ast.iter_child_nodes(node):
|
||||
if isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
||||
found.append((child, owner))
|
||||
visit(child, None)
|
||||
elif isinstance(child, ast.ClassDef):
|
||||
visit(child, child.name)
|
||||
else:
|
||||
visit(child, owner)
|
||||
|
||||
visit(tree, None)
|
||||
return found
|
||||
|
||||
|
||||
def sessions_before_a_window(sources: Dict[str, str]) -> List[str]:
|
||||
"""Where a session is asked for before the first window of its function: one line per place, ``file:line``, what and how to correct it."""
|
||||
functions = [(path, function, owner, _own_calls(function)) for path, source in sources.items() for function, owner in _functions(ast.parse(source))]
|
||||
creators: Set[str] = set(PRIMITIVES)
|
||||
|
||||
def asks(call: ast.Call) -> bool:
|
||||
return _name(call) in creators or (bool(call.args) and isinstance(call.args[0], ast.Constant) and call.args[0].value == NEW_SESSION)
|
||||
|
||||
helpers: Set[int] = set()
|
||||
grew = True
|
||||
while grew:
|
||||
grew = False
|
||||
for index, (_, function, owner, calls) in enumerate(functions):
|
||||
if index in helpers or not any(asks(c) for c in calls):
|
||||
continue
|
||||
if not any(_opens_a_window(c) or _name(c) in LAUNCHERS for c in calls):
|
||||
helpers.add(index)
|
||||
creators.add(owner if function.name == "__init__" and owner else function.name)
|
||||
grew = True
|
||||
out: List[str] = []
|
||||
for index, (path, function, _, calls) in enumerate(functions):
|
||||
if index in helpers:
|
||||
continue
|
||||
windows = [(c.lineno, c.col_offset) for c in calls if _opens_a_window(c)]
|
||||
for call in calls:
|
||||
if asks(call) and not any(at < (call.lineno, call.col_offset) for at in windows):
|
||||
out.append("%s:%d: %s asks for a Marionette session before any page of %s() is open (NewSession is answered only once a window exists, and the wrapper launches "
|
||||
"with -silent: the socket times out after 300 s); open the page first (page = browser.new_page()), then ask for the session" % (path, call.lineno, _name(call) or NEW_SESSION, function.name))
|
||||
return out
|
||||
|
||||
|
||||
def _sources() -> Dict[str, str]:
|
||||
files: Dict[str, str] = {}
|
||||
for folder in ("tests", "scripts"):
|
||||
for path in sorted((ROOT / folder).rglob("*.py")):
|
||||
if "vendor" in path.parts or "__pycache__" in path.parts:
|
||||
continue
|
||||
files[path.relative_to(ROOT).as_posix()] = path.read_text(encoding="utf-8")
|
||||
return files
|
||||
|
||||
|
||||
def test_no_test_or_script_asks_for_a_session_before_its_first_page():
|
||||
found = sessions_before_a_window(_sources())
|
||||
assert not found, "\n".join(found)
|
||||
|
||||
|
||||
OLD_ORDER = """
|
||||
def run(firefox_binary, case):
|
||||
with launch_case(firefox_binary, case) as browser:
|
||||
chrome = Chrome()
|
||||
return measure(browser.new_page(), chrome)
|
||||
"""
|
||||
OLD_ORDER_THROUGH_A_HELPER = """
|
||||
def open_chrome(port):
|
||||
m = _Marionette(port)
|
||||
m.call("WebDriver:NewSession", {})
|
||||
return m
|
||||
|
||||
def test_it(firefox_binary):
|
||||
with InvisiblePlaywright(binary_path=firefox_binary) as browser:
|
||||
m = open_chrome(1)
|
||||
browser.new_page()
|
||||
"""
|
||||
OLD_ORDER_RAW = """
|
||||
def test_it(firefox_binary):
|
||||
with InvisiblePlaywright(binary_path=firefox_binary) as browser:
|
||||
m = _Marionette(marionette_active_port())
|
||||
m.call("WebDriver:NewSession", {})
|
||||
page = browser.new_page()
|
||||
"""
|
||||
NEW_ORDER = """
|
||||
class Chrome:
|
||||
def __init__(self, page):
|
||||
self._m = _Marionette(marionette_active_port())
|
||||
|
||||
def run(firefox_binary, case):
|
||||
with launch_case(firefox_binary, case) as browser:
|
||||
page = browser.new_page()
|
||||
chrome = Chrome(page)
|
||||
return measure(page, chrome)
|
||||
|
||||
def retail():
|
||||
process = subprocess.Popen([exe, "-no-remote", "about:blank"])
|
||||
m = _Marionette(marionette_active_port())
|
||||
m.call("WebDriver:NewSession", {})
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", [OLD_ORDER, OLD_ORDER_THROUGH_A_HELPER, OLD_ORDER_RAW], ids=["class", "helper", "raw"])
|
||||
def test_the_scan_sees_the_old_order(source):
|
||||
sources = {"synthetic.py": source + "\nclass Chrome:\n def __init__(self):\n self._m = _Marionette(marionette_active_port())\n"}
|
||||
assert sessions_before_a_window(sources), "the scan does not see a session asked for before the first page:\n" + source
|
||||
|
||||
|
||||
def test_the_scan_lets_the_page_first_through():
|
||||
assert sessions_before_a_window({"synthetic.py": NEW_ORDER}) == []
|
||||
|
||||
|
||||
def test_chrome_takes_the_page_and_nothing_makes_it_without():
|
||||
parameters = list(inspect.signature(_stock_twin.Chrome).parameters.values())
|
||||
assert [p.name for p in parameters] == ["page"] and parameters[0].default is inspect.Parameter.empty, (
|
||||
"Chrome must take the page of the launch as its one required argument (found %r): without it the session can be asked before the window exists" % (parameters,))
|
||||
with pytest.raises(TypeError):
|
||||
_stock_twin.Chrome(None)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------- the behaviour, on a Marionette that waits for a window
|
||||
|
||||
class World:
|
||||
"""The engine started with ``-silent``: no window until a page is opened. ``NewSession`` is answered then, and times out as the socket does before it."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.window = False
|
||||
self.sessions = 0
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def world(monkeypatch):
|
||||
state = World()
|
||||
|
||||
class FakeMarionette:
|
||||
def __init__(self, port, timeout=120.0):
|
||||
self.closed = False
|
||||
|
||||
def call(self, name, params=None):
|
||||
if name == NEW_SESSION:
|
||||
if not state.window:
|
||||
raise TimeoutError("timed out: no answer to WebDriver:NewSession (the engine has no window)")
|
||||
state.sessions += 1
|
||||
return {"value": "{}"}
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
class FakePage:
|
||||
def evaluate(self, expression):
|
||||
return {}
|
||||
|
||||
class FakeBrowser:
|
||||
def new_page(self):
|
||||
state.window = True
|
||||
return FakePage()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def launch_case(binary, case, **kwargs):
|
||||
state.window = False
|
||||
yield FakeBrowser()
|
||||
|
||||
monkeypatch.setattr(webfont_probe, "_Marionette", FakeMarionette)
|
||||
monkeypatch.setattr(webfont_probe, "marionette_active_port", lambda *a, **k: 1)
|
||||
monkeypatch.setattr(_stock_twin, "launch_case", launch_case)
|
||||
monkeypatch.setattr(_retail_reference, "launch_case", launch_case)
|
||||
return state
|
||||
|
||||
|
||||
def test_the_fake_engine_does_not_answer_a_session_asked_before_its_first_page(world):
|
||||
marionette = webfont_probe._Marionette(webfont_probe.marionette_active_port())
|
||||
with pytest.raises(TimeoutError):
|
||||
marionette.call(NEW_SESSION, {"capabilities": {"alwaysMatch": {}}})
|
||||
|
||||
|
||||
def test_ours_gets_the_answer_of_its_session_in_a_twin(world):
|
||||
record = _stock_twin._on_ours("1920x1080-dpr1.0", "not-launched", lambda page, chrome: {"scales": chrome.scales()})
|
||||
assert world.sessions == 1
|
||||
assert record["scales"]["page"] == {}
|
||||
|
||||
|
||||
def test_ours_gets_the_answer_of_its_session_in_a_retail_twin(world, monkeypatch):
|
||||
scales = {"scales": {"chrome_outer": [800, 600], "chrome_inner": [790, 500]}}
|
||||
|
||||
class FakeRetail:
|
||||
def __init__(self, executable, dpr):
|
||||
pass
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
return False
|
||||
|
||||
def set_window_size(self, outer):
|
||||
return {"outer": [800, 600], "inner": [790, 500]}
|
||||
|
||||
monkeypatch.setattr(_retail_reference, "retail_executable", lambda: "retail")
|
||||
monkeypatch.setattr(_retail_reference, "RetailSession", FakeRetail)
|
||||
monkeypatch.setattr(_retail_reference, "RetailDriver", lambda session: object())
|
||||
retail, ours = _retail_reference.run_retail_twin("1920x1080-dpr1.0", "not-launched", lambda driver: {"scales": dict(scales["scales"])})
|
||||
assert world.sessions == 1
|
||||
assert ours["scales"]["chrome_outer"] == [800, 600] and retail["scales"]["window_asked_outer"] == [800, 600]
|
||||
@@ -3,9 +3,9 @@
|
||||
`new Worker("chrome://<name>/...")` returns for a chrome package the browser
|
||||
registers and throws SecurityError at once for one it does not: the parent sends
|
||||
every registered package to each content process. Every engine until firefox-47
|
||||
registered `juggler`, and captcha vendors probed it from 2026-10-06 (the script of a
|
||||
captcha vendor runs `new Worker("chrome://juggler/content/content/WorkerMain.js")`,
|
||||
reported on another project's tracker): a challenge solved by hand was refused on our engine while
|
||||
registered `juggler`, and captcha vendors probed it from 2026-10-06 (hCaptcha's
|
||||
hsw.js runs `new Worker("chrome://juggler/content/content/WorkerMain.js")`,
|
||||
camoufox #847): a challenge solved by hand was refused on our engine while
|
||||
retail Firefox passed. Measured from a page on firefox-46 and on retail Firefox
|
||||
151 under geckodriver, 2026-10-14: of the 65 chrome packages and resource
|
||||
substitutions the engine registers, `juggler` was the one retail does not; retail
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
"""A popup of the maximized window moves, resizes and clamps in the DECLARED window, not in the host's.
|
||||
|
||||
The page's ``moveBy``, ``moveTo``, ``resizeBy`` and ``resizeTo`` read the declared position and size of the window, add what the page asked, and send the
|
||||
absolute result to the parent, which applies it to the real window. A popup whose declared position or frame is not its real one (on Linux the window manager
|
||||
puts the popup where it likes, and its frame is the host's) must still answer these calls as the retail window does. Three things, per display case (the four of
|
||||
the window tests), each in a popup of its own opened by a real click, ``window.open(url, '_blank', 'width=500,height=400')``:
|
||||
|
||||
1. ``resizeBy(0, 0)``: ``innerWidth``, ``innerHeight``, ``outerWidth`` and ``outerHeight`` stay what they were. A call that adds nothing must change nothing; if the
|
||||
parent converted the declared outer size into the real one with the wrong frame, the real inner size would move by the difference of the two frames (retail
|
||||
measures nothing here: the call is a no-op in its window). The page is watched for 1.5 s after the call, so a change that arrives late is seen.
|
||||
2. ``moveBy(10, 10)``: ``screenX`` and ``screenY`` grow by exactly 10 CSS pixels, from the position the popup read before. If the parent took the real position of
|
||||
the window as the base, the declared and the real positions would differ by what the host's window manager decided, and the popup would jump.
|
||||
3. ``moveBy(10, 10)`` and then ``moveTo(99999, 0)``, the sequence the retail capture ran: ``screenX`` and ``screenY`` after each call are the numbers RETAIL read
|
||||
(``RETAIL``, below, with the capture and the derivation). The clamp is the page's (``nsGlobalWindowOuter::CheckSecurityLeftAndTop``: it keeps the window inside
|
||||
the available rectangle of the screen the page reads, with the outer width in CSS pixels that Mozilla rounds by its edges), so the page can learn the real
|
||||
frame of the window from where the popup stops if the clamp reads any of it from the host.
|
||||
|
||||
Why a page reads it: a script that moves a window by ten and sees it move by another number, or that throws a window to the far right and reads where it stops,
|
||||
is reading the host's window manager and its frame.
|
||||
|
||||
The engine that answers these values is not released yet: on the engine of the pin the clamp and the moves are the host's where the declared and the real window
|
||||
differ, so this test is RED there, on purpose. It enters the suite with the engine release.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _window_origin import CASES, DEADLINE_S, launch_case, observe, settled, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: What RETAIL read, per case, in the round ``popup_move_resize`` of the capture ``retail-window-geometry`` (workflow of oss-invisible/core, run 46215774874, commit
|
||||
#: 29f3e82, Firefox 159.0; the two machines a and b agree): a popup opened with ``width=500,height=400``, then ``moveBy(10, 10)``, then ``moveTo(99999, 0)``.
|
||||
#: case -> (moved (screenX, screenY), moved_to (screenX, screenY), outerWidth). The numbers are the capture's, never computed here.
|
||||
#:
|
||||
#: Why ``moveTo(99999, 0)`` stops at 1022 at scale 1.25: Mozilla's ``CheckSecurityLeftAndTop`` (dom/base/nsGlobalWindowOuter.cpp) clamps
|
||||
#: ``x_css = availLeft + availWidth - W``, where ``W`` is the outer width ROUNDED BY ITS EDGES, ``CSSIntRect::Round(deviceRect / scale).width``
|
||||
#: (gfx/2d/BaseRect.h: ``W = round(x_dev / s + w_dev / s) - round(x_dev / s)``), not the ``outerWidth`` the page reads. At 1.25 the window is at x_dev 16 and
|
||||
#: w_dev 643: ``W = round(12.8 + 514.4) - round(12.8) = 527 - 13 = 514``, so ``x_css = 1536 - 514 = 1022`` (availLeft + availWidth is 1920 / 1.25 = 1536).
|
||||
#: The parent then moves to ``devPos = RoundedToInt(1022 * 1.25) = 1278`` (1277.5 rounds up), and the page reads back ``screenX = RoundedToInt(1278 / 1.25) =
|
||||
#: round(1022.4) = 1022``. The stop is a result of the clamp, the device rounding and the read-back, so it is the capture's number and not a formula of the page.
|
||||
RETAIL: Dict[str, Tuple[Tuple[int, int], Tuple[int, int], int]] = {
|
||||
"1920x1080-dpr1.0": ((14, 14), (1404, 0), 516),
|
||||
"1920x1080-dpr1.25": ((13, 13), (1022, 0), 514),
|
||||
"1920x1080-dpr1.5": ((13, 13), (764, 0), 515),
|
||||
"1600x1200-dpr2.0": ((12, 12), (287, 0), 513),
|
||||
}
|
||||
#: The button that opens the popup: ``position:fixed`` at (20, 20), 160x40 CSS pixels; its centre is the point of the real click.
|
||||
OPEN = (100, 40)
|
||||
FEATURES = "width=500,height=400"
|
||||
#: How long the window is watched after a call that must change nothing, in seconds.
|
||||
WATCH_S = 1.5
|
||||
|
||||
TOP = """<!doctype html><meta charset=utf-8><title>popup</title>
|
||||
<style>html,body{margin:0;padding:0;height:100%}
|
||||
#open{position:fixed;left:20px;top:20px;width:160px;height:40px;margin:0}</style>
|
||||
<body><button id=open>popup</button><script>
|
||||
document.getElementById('open').addEventListener('click', () => { window.open(window.__popupUrl, '_blank', window.__popupFeatures); });
|
||||
</script>"""
|
||||
|
||||
POPUP = "<!doctype html><meta charset=utf-8><title>popup</title><body style=margin:0>x"
|
||||
|
||||
READ = """() => ({iw: innerWidth, ih: innerHeight, ow: outerWidth, oh: outerHeight, sx: screenX, sy: screenY,
|
||||
availL: screen.availLeft, availW: screen.availWidth})"""
|
||||
SIZE = "() => [innerWidth, innerHeight, outerWidth, outerHeight]"
|
||||
POSITION = "() => [screenX, screenY]"
|
||||
|
||||
|
||||
def _open(page, sites) -> Any:
|
||||
"""``window.open`` from a real click on the page's button; the popup, loaded."""
|
||||
page.evaluate("([url, features]) => { window.__popupUrl = url; window.__popupFeatures = features; }", [sites.url("A", "/popup"), FEATURES])
|
||||
with page.expect_popup(timeout=30000) as opened:
|
||||
page.mouse.click(*OPEN) # the client's own click: a trusted event, so window.open is allowed
|
||||
popup = opened.value
|
||||
popup.wait_for_load_state("load", timeout=30000)
|
||||
return popup
|
||||
|
||||
|
||||
def _settled_popup(popup) -> Dict[str, Any]:
|
||||
"""The popup once it is the size it was asked and two looks in a row agree."""
|
||||
return settled(popup, lambda: popup.evaluate(READ))
|
||||
|
||||
|
||||
def _phase_resize_by_zero(page, sites, case: str) -> None:
|
||||
popup = _open(page, sites)
|
||||
try:
|
||||
before = _settled_popup(popup)
|
||||
assert (before["iw"], before["ih"]) == (500, 400), "%s: the popup is %rx%r inside before the call, it was asked 500x400 (%r)" % (
|
||||
case, before["iw"], before["ih"], before)
|
||||
popup.evaluate("() => { window.resizeBy(0, 0); }")
|
||||
after = observe(popup, lambda: tuple(popup.evaluate(SIZE)), WATCH_S)
|
||||
was = (before["iw"], before["ih"], before["ow"], before["oh"])
|
||||
assert after == [was], (
|
||||
"%s: resizeBy(0, 0) changed the window: (innerWidth, innerHeight, outerWidth, outerHeight) was %r and the page then read %r" % (case, was, after))
|
||||
finally:
|
||||
popup.close()
|
||||
|
||||
|
||||
def _phase_move_by(page, sites, case: str) -> None:
|
||||
popup = _open(page, sites)
|
||||
try:
|
||||
before = _settled_popup(popup)
|
||||
popup.evaluate("() => { window.moveBy(10, 10); }")
|
||||
expected: Tuple[int, int] = (before["sx"] + 10, before["sy"] + 10)
|
||||
wait_for(popup, lambda: tuple(popup.evaluate(POSITION)) == expected, DEADLINE_S)
|
||||
after = settled(popup, lambda: tuple(popup.evaluate(POSITION)))
|
||||
assert tuple(after) == expected, (
|
||||
"%s: moveBy(10, 10) from (screenX, screenY) = (%r, %r) leaves it at %r, it must be exactly %r" % (case, before["sx"], before["sy"], tuple(after), expected))
|
||||
finally:
|
||||
popup.close()
|
||||
|
||||
|
||||
def _phase_move_to_the_far_right(page, sites, case: str) -> None:
|
||||
"""The retail capture's sequence: the popup, ``moveBy(10, 10)``, ``moveTo(99999, 0)``; where the popup is after each call is what retail read."""
|
||||
moved, moved_to, outer_width = RETAIL[case]
|
||||
popup = _open(page, sites)
|
||||
try:
|
||||
before = _settled_popup(popup)
|
||||
popup.evaluate("() => { window.moveBy(10, 10); }")
|
||||
wait_for(popup, lambda: tuple(popup.evaluate(POSITION)) == moved, DEADLINE_S)
|
||||
after_by = _settled_popup(popup)
|
||||
assert (after_by["sx"], after_by["sy"]) == moved, (
|
||||
"%s: after moveBy(10, 10) the popup is at (screenX, screenY) = (%r, %r); retail read %r (the popup was %r before the call)"
|
||||
% (case, after_by["sx"], after_by["sy"], moved, before))
|
||||
popup.evaluate("() => { window.moveTo(99999, 0); }")
|
||||
wait_for(popup, lambda: tuple(popup.evaluate(POSITION)) == moved_to, DEADLINE_S)
|
||||
after = _settled_popup(popup)
|
||||
assert (after["sx"], after["sy"]) == moved_to, (
|
||||
"%s: after moveTo(99999, 0) the popup is at (screenX, screenY) = (%r, %r); retail read %r (availLeft %r, availWidth %r, outerWidth %r; "
|
||||
"the popup was at %r after moveBy)" % (case, after["sx"], after["sy"], moved_to, after["availL"], after["availW"], after["ow"], (after_by["sx"], after_by["sy"])))
|
||||
assert after["ow"] == outer_width, "%s: outerWidth is %r after the moves; retail read %r" % (case, after["ow"], outer_width)
|
||||
finally:
|
||||
popup.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_popup_moves_and_resizes_as_declared(firefox_binary, case):
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", TOP)
|
||||
sites.route("A", "/popup", POPUP)
|
||||
with launch_case(firefox_binary, case) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(sites.url("A", "/page"), wait_until="load", timeout=30000)
|
||||
_phase_resize_by_zero(page, sites, case)
|
||||
_phase_move_by(page, sites, case)
|
||||
_phase_move_to_the_far_right(page, sites, case)
|
||||
@@ -1,198 +0,0 @@
|
||||
"""A screenshot parameter that Playwright honours by MODIFYING THE PAGE is refused by name, not silently ignored.
|
||||
|
||||
Stock Playwright 1.61 takes `mask` (an overlay painted on the page), `style` (a `<style>` element injected), `animations="disabled"` (finite animations finished,
|
||||
infinite ones cancelled) and `caret` (hidden with `caret-color: transparent`, drawn only for `"initial"`) by changing the page before the picture and putting it back
|
||||
after. `PageDispatcher.op_screenshot` never read any of them: the call succeeded and the picture came back as if the parameter had not been written. The caller cannot tell
|
||||
a masked picture from an unmasked one, and the picture is the one thing that must not lie. They are refused now, each by its name, with what to do instead.
|
||||
|
||||
The single check is `_refuse_unserved_screenshot_parameters`, the first thing in `PageDispatcher.op_screenshot` and in `ElementHandleDispatcher.op_screenshot` (a locator's is the
|
||||
element's), so the page, the full page, a clip, an element and a locator are checked at the wire, and the element's refusal comes before it scrolls or measures. What passes: `animations="allow"`, `caret="hide"` (the engine never draws the caret, which is what stock's
|
||||
default produces), an empty `mask`, an empty `style`, a `maskColor` with no mask, and `omitBackground` with jpeg (stock does nothing there).
|
||||
|
||||
`omitBackground` with png is Firefox's own: stock's `setBackgroundColor` throws `Not implemented` there (`FFPage.setBackgroundColor`, reached from `Screenshotter._screenshot`
|
||||
for png only), and the text is the same here.
|
||||
|
||||
No browser: the dispatchers are built as tests/test_a_screenshot_sends_its_scale_to_the_engine.py builds them.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from invisible_core.juggler.connection import EventListeners
|
||||
from invisible_core.juggler.lifecycle import Lifecycle
|
||||
from invisible_playwright._juggler.dispatcher import Dispatcher, ProtocolException
|
||||
from invisible_playwright._juggler.server import (
|
||||
ElementHandleDispatcher,
|
||||
FrameDispatcher,
|
||||
JugglerServer,
|
||||
PageDispatcher,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
BOX = {"x": 0, "y": 0, "width": 1280, "height": 720, "fullWidth": 1280, "fullHeight": 3000}
|
||||
|
||||
# what the vendored client puts on the wire for `mask=[page.locator("#a")]`
|
||||
MASK = [{"frame": "frame@1", "selector": "#a"}]
|
||||
|
||||
|
||||
def make_page():
|
||||
server = JugglerServer()
|
||||
server.attach(SimpleNamespace(emit_message=lambda m: None))
|
||||
context = Dispatcher(server, None)
|
||||
context.options = {}
|
||||
page = object.__new__(PageDispatcher)
|
||||
page.context = context
|
||||
page.lifecycle = Lifecycle(EventListeners(), "session")
|
||||
page.injected = Mock()
|
||||
page.injected.evaluate.return_value = dict(BOX)
|
||||
page.actions = Mock()
|
||||
page._frames = {}
|
||||
page._navigation_requests = {}
|
||||
page._announced_closed = False
|
||||
Dispatcher.__init__(page, server, context)
|
||||
page.frame = FrameDispatcher(server, page, "main")
|
||||
page.lifecycle._on_event("Page.frameAttached", {"frameId": "main", "parentFrameId": None})
|
||||
page.send = Mock(return_value={"data": "AAAA"})
|
||||
return page
|
||||
|
||||
|
||||
def _page_shot(page, params):
|
||||
return page.op_screenshot(params)
|
||||
|
||||
|
||||
def _full_page_shot(page, params):
|
||||
return page.op_screenshot(dict(params, fullPage=True))
|
||||
|
||||
|
||||
def _clip_shot(page, params):
|
||||
return page.op_screenshot(dict(params, clip={"x": 5, "y": 6, "width": 100, "height": 50}))
|
||||
|
||||
|
||||
def _element_shot(page, params):
|
||||
handle = ElementHandleDispatcher(page.server, page.frame, "object-1")
|
||||
page.injected.bounding_box.return_value = {"x": 10, "y": 20, "width": 30, "height": 40}
|
||||
return handle.op_screenshot(params)
|
||||
|
||||
|
||||
# a locator's screenshot is the element handle's (`Locator.screenshot` -> `_with_element` -> `ElementHandle.screenshot`), with the same parameters
|
||||
KINDS = [_page_shot, _full_page_shot, _clip_shot, _element_shot]
|
||||
KIND_IDS = ["page", "full_page", "clip", "element_or_locator"]
|
||||
|
||||
REFUSED = [
|
||||
({"mask": MASK}, "mask"),
|
||||
({"mask": MASK, "maskColor": "#00f"}, "mask"),
|
||||
({"style": "* { color: red }"}, "style"),
|
||||
({"animations": "disabled"}, "animations"),
|
||||
({"caret": "initial"}, "caret"),
|
||||
]
|
||||
REFUSED_IDS = ["mask", "mask_with_color", "style", "animations_disabled", "caret_initial"]
|
||||
|
||||
ACCEPTED = [
|
||||
{},
|
||||
{"animations": "allow"},
|
||||
{"caret": "hide"},
|
||||
{"mask": []},
|
||||
{"mask": [], "maskColor": "#00f"},
|
||||
{"maskColor": "#00f"},
|
||||
{"style": ""},
|
||||
{"omitBackground": False},
|
||||
{"omitBackground": True, "type": "jpeg"},
|
||||
{"animations": "allow", "caret": "hide", "mask": [], "style": "", "scale": "css"},
|
||||
]
|
||||
ACCEPTED_IDS = ["nothing", "animations_allow", "caret_hide", "empty_mask", "empty_mask_with_color", "color_alone", "empty_style",
|
||||
"omit_background_false", "omit_background_jpeg", "all_the_harmless_ones"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", KINDS, ids=KIND_IDS)
|
||||
@pytest.mark.parametrize("params,name", REFUSED, ids=REFUSED_IDS)
|
||||
def test_a_parameter_that_would_modify_the_page_is_refused_by_name(kind, params, name):
|
||||
page = make_page()
|
||||
with pytest.raises(ProtocolException) as refused:
|
||||
kind(page, params)
|
||||
message = str(refused.value)
|
||||
assert "screenshot(%s" % name in message
|
||||
assert "not served" in message
|
||||
page.send.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("params,name,instead", [
|
||||
({"mask": MASK}, "mask", "Hide the elements yourself"),
|
||||
({"style": "p { color: red }"}, "style", "add_style_tag"),
|
||||
({"animations": "disabled"}, "animations", "document.getAnimations"),
|
||||
({"caret": "initial"}, "caret", 'Leave caret out or pass "hide"'),
|
||||
], ids=["mask", "style", "animations", "caret"])
|
||||
def test_the_refusal_says_why_and_what_to_do_instead(params, name, instead):
|
||||
page = make_page()
|
||||
with pytest.raises(ProtocolException) as refused:
|
||||
page.op_screenshot(params)
|
||||
message = str(refused.value)
|
||||
if name != "caret":
|
||||
assert "modifying the page" in message
|
||||
assert instead in message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", KINDS, ids=KIND_IDS)
|
||||
@pytest.mark.parametrize("params", ACCEPTED, ids=ACCEPTED_IDS)
|
||||
def test_what_does_not_modify_the_page_is_taken(kind, params):
|
||||
page = make_page()
|
||||
assert kind(page, params) == {"binary": "AAAA"}
|
||||
(method, sent), _kw = page.send.call_args
|
||||
assert method == "Page.screenshot"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", KINDS, ids=KIND_IDS)
|
||||
@pytest.mark.parametrize("params", [{"omitBackground": True}, {"omitBackground": True, "type": "png"}], ids=["default_type", "png"])
|
||||
def test_omit_background_with_png_answers_firefoxs_own_error(kind, params):
|
||||
page = make_page()
|
||||
with pytest.raises(ProtocolException) as refused:
|
||||
kind(page, params)
|
||||
assert str(refused.value) == "Not implemented"
|
||||
page.send.assert_not_called()
|
||||
|
||||
|
||||
def test_the_first_refusal_wins_and_nothing_is_sent_when_several_are_asked():
|
||||
page = make_page()
|
||||
with pytest.raises(ProtocolException):
|
||||
page.op_screenshot({"mask": MASK, "style": "p {}", "animations": "disabled", "caret": "initial", "omitBackground": True})
|
||||
page.send.assert_not_called()
|
||||
|
||||
|
||||
# ── the refusal comes FIRST: a refused element's or locator's call neither scrolls nor measures the page ────────────────────
|
||||
REFUSED_ELEMENT = REFUSED + [({"omitBackground": True}, "omitBackground")]
|
||||
REFUSED_ELEMENT_IDS = REFUSED_IDS + ["omit_background_png"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("params,name", REFUSED_ELEMENT, ids=REFUSED_ELEMENT_IDS)
|
||||
def test_a_refused_element_screenshot_sends_nothing_to_the_engine_not_even_a_scroll_or_a_measure(params, name):
|
||||
page = make_page()
|
||||
handle = ElementHandleDispatcher(page.server, page.frame, "object-1")
|
||||
page.injected.bounding_box.return_value = {"x": 10, "y": 20, "width": 30, "height": 40}
|
||||
with pytest.raises(ProtocolException):
|
||||
handle.op_screenshot(params)
|
||||
# the scroll (`scroll_into_view`), the box (`bounding_box`) and the document's scroll (`evaluate`) all go through `injected`,
|
||||
# the picture through `send`: not one of them was called
|
||||
assert page.injected.mock_calls == []
|
||||
page.send.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("params,name", REFUSED_ELEMENT, ids=REFUSED_ELEMENT_IDS)
|
||||
def test_a_refused_page_screenshot_measures_nothing_either(params, name):
|
||||
page = make_page()
|
||||
with pytest.raises(ProtocolException):
|
||||
page.op_screenshot(params)
|
||||
assert page.injected.mock_calls == []
|
||||
page.send.assert_not_called()
|
||||
|
||||
|
||||
def test_the_element_screenshot_that_is_taken_still_scrolls_and_measures_first():
|
||||
page = make_page()
|
||||
page.injected.bounding_box.return_value = {"x": 10, "y": 20, "width": 30, "height": 40}
|
||||
handle = ElementHandleDispatcher(page.server, page.frame, "object-1")
|
||||
handle.op_screenshot({})
|
||||
names = [call[0] for call in page.injected.mock_calls]
|
||||
assert names[:2] == ["scroll_into_view", "bounding_box"]
|
||||
assert page.send.call_args[0][0] == "Page.screenshot"
|
||||
@@ -1,221 +0,0 @@
|
||||
"""A screenshot parameter that Playwright honours by modifying the page is refused with a clear error, and a caret is not in our picture.
|
||||
|
||||
Stock Playwright takes `mask`, `style` and `animations="disabled"` by changing the page before the picture and putting it back after, hides the caret by default
|
||||
(`caret-color: transparent`) and draws it for `caret="initial"`, and its Firefox throws `Not implemented` for `omitBackground` with png. This package never read those
|
||||
parameters and answered a picture as if they had not been written. Here the real server is asked, through the client, on a page, a locator and an element handle:
|
||||
|
||||
* `mask` (with `maskColor`), `style`, `animations="disabled"` and `caret="initial"` raise an `Error` that names the parameter, and the page is left as it was (no `<style>`, no
|
||||
overlay, the next screenshot works);
|
||||
* `omitBackground` with png raises `Not implemented`; with jpeg it takes the picture;
|
||||
* `animations="allow"`, `caret="hide"`, an empty `mask` and an empty `style` take the picture;
|
||||
* the caret: the client sends `caret` only when the caller writes it, so a call that does not write it takes the picture the way `caret="hide"` does. Measured: a focused `<input>` with
|
||||
`caret-color: red` photographed with `caret` absent and with `"hide"` has no red pixel in it; a red border on the same input is found by the same reading, so the reading is not blind.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
import _page_bytes
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
HTML = (
|
||||
"<!doctype html><html style='background:#fff'><body style='margin:20px;background:#fff'>"
|
||||
"<p id='a' style='margin:0;width:200px;height:40px;background:#0a0'>masked</p>"
|
||||
"<input id='i' value='' style='display:block;margin-top:20px;width:200px;height:40px;border:0;outline:0;background:#fff;color:#000;caret-color:#f00;font-size:24px'>"
|
||||
"<input id='b' value='' style='display:block;margin-top:20px;width:200px;height:40px;border:0;border-right:6px solid #f00;background:#fff;color:#000;font-size:24px'>"
|
||||
"</body></html>"
|
||||
)
|
||||
|
||||
JPEG, PNG = b"\xff\xd8", b"\x89PNG"
|
||||
_SET = [None] # the document as the page serialises it right after set_content
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(firefox_binary):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=4281, binary_path=firefox_binary, headless=True) as browser:
|
||||
context = browser.new_context(viewport={"width": 800, "height": 400})
|
||||
page = context.new_page()
|
||||
page.set_content(HTML, wait_until="load")
|
||||
_SET[0] = page.content()
|
||||
yield page
|
||||
context.close()
|
||||
|
||||
|
||||
def _red_pixels(png: bytes) -> int:
|
||||
image = _page_bytes.unfiltered(png)
|
||||
w, channels, data = image["w"], image["channels"], image["data"]
|
||||
count = 0
|
||||
for at in range(0, len(data), channels):
|
||||
r, g, b = data[at], data[at + 1], data[at + 2]
|
||||
if r > 200 and g < 60 and b < 60:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def _the_page_is_as_it_was(page):
|
||||
"""No `<style>` was injected, no overlay was added, the document is the one that was set, and the next screenshot works."""
|
||||
assert page.evaluate("document.querySelectorAll('style').length") == 0
|
||||
assert page.content() == _SET[0]
|
||||
assert page.screenshot()[:4] == PNG
|
||||
|
||||
|
||||
def _calls(page):
|
||||
"""Each way of asking: the page, a locator, an element handle. Every one is a function of the keyword arguments."""
|
||||
handle = page.query_selector("#a")
|
||||
return {
|
||||
"page": lambda **k: page.screenshot(**k),
|
||||
"locator": lambda **k: page.locator("#a").screenshot(**k),
|
||||
"handle": lambda **k: handle.screenshot(**k),
|
||||
}
|
||||
|
||||
|
||||
WAYS = ("page", "locator", "handle")
|
||||
|
||||
# The first line of stock Playwright's error for `omitBackground` with png on Firefox, read from Playwright 1.61.1's own code: the server's
|
||||
# `FFPage.setBackgroundColor` throws `new Error("Not implemented")` (driver `coreBundle.js`, called when `options.omitBackground && format === "png"`),
|
||||
# and the Python client prefixes the API name (`playwright/_impl/_connection.py`: `rewrite_error(error, f"{apiName}: {error}")`).
|
||||
NOT_IMPLEMENTED = {
|
||||
"page": "Page.screenshot: Not implemented",
|
||||
"locator": "Locator.screenshot: Not implemented",
|
||||
"handle": "ElementHandle.screenshot: Not implemented",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_a_mask_is_refused_by_name_and_the_page_is_untouched(page, way):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
shoot = _calls(page)[way]
|
||||
with pytest.raises(Error, match=r"screenshot\(mask=") as refused:
|
||||
shoot(mask=[page.locator("#a")])
|
||||
assert "maskColor" in str(refused.value)
|
||||
with pytest.raises(Error, match=r"screenshot\(mask="):
|
||||
shoot(mask=[page.locator("#a")], mask_color="#00f")
|
||||
_the_page_is_as_it_was(page)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_a_style_is_refused_by_name_and_the_page_is_untouched(page, way):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
with pytest.raises(Error, match=r"screenshot\(style=.*add_style_tag"):
|
||||
_calls(page)[way](style="p { visibility: hidden }")
|
||||
_the_page_is_as_it_was(page)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_animations_disabled_is_refused_by_name_and_the_page_is_untouched(page, way):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
with pytest.raises(Error, match=r'screenshot\(animations="disabled"\)'):
|
||||
_calls(page)[way](animations="disabled")
|
||||
_the_page_is_as_it_was(page)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_a_caret_that_is_asked_to_be_drawn_is_refused_by_name(page, way):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
with pytest.raises(Error, match=r'screenshot\(caret="initial"\)'):
|
||||
_calls(page)[way](caret="initial")
|
||||
_the_page_is_as_it_was(page)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_omit_background_with_png_is_firefoxs_not_implemented(page, way):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
with pytest.raises(Error) as refused:
|
||||
_calls(page)[way](omit_background=True)
|
||||
assert str(refused.value).split("\n")[0] == NOT_IMPLEMENTED[way]
|
||||
with pytest.raises(Error) as refused:
|
||||
_calls(page)[way](omit_background=True, type="png")
|
||||
assert str(refused.value).split("\n")[0] == NOT_IMPLEMENTED[way]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_omit_background_with_jpeg_takes_the_picture(page, way):
|
||||
assert _calls(page)[way](omit_background=True, type="jpeg")[:2] == JPEG
|
||||
|
||||
|
||||
@pytest.mark.parametrize("way", WAYS)
|
||||
def test_what_does_not_modify_the_page_takes_the_picture(page, way):
|
||||
shoot = _calls(page)[way]
|
||||
assert shoot(animations="allow")[:4] == PNG
|
||||
assert shoot(caret="hide")[:4] == PNG
|
||||
assert shoot(mask=[])[:4] == PNG
|
||||
assert shoot(style="")[:4] == PNG
|
||||
assert shoot()[:4] == PNG
|
||||
|
||||
|
||||
def _caret_shots(page, **kwargs):
|
||||
page.locator("#i").focus()
|
||||
assert page.evaluate("document.activeElement.id") == "i"
|
||||
return [page.locator("#i").screenshot(**kwargs) for _ in range(3)]
|
||||
|
||||
|
||||
def test_the_reading_of_red_is_not_blind(page):
|
||||
"""The control: a red border on an input of the same size is found by the same reading, so `0` in the two tests below is a measurement."""
|
||||
assert _red_pixels(page.locator("#b").screenshot()) > 100
|
||||
|
||||
|
||||
def test_no_caret_is_in_the_picture_when_the_caller_does_not_write_caret(page):
|
||||
assert [_red_pixels(png) for png in _caret_shots(page)] == [0, 0, 0]
|
||||
|
||||
|
||||
def test_no_caret_is_in_the_picture_with_caret_hide(page):
|
||||
assert [_red_pixels(png) for png in _caret_shots(page, caret="hide")] == [0, 0, 0]
|
||||
|
||||
|
||||
# ── a refused call does not touch the page's scroll: the refusal comes before the element is scrolled into view ────────────────
|
||||
TALL = (
|
||||
"<!doctype html><html style='background:#fff'><body style='margin:0;background:#fff'>"
|
||||
"<div style='height:3000px;background:#eee'>above the fold</div>"
|
||||
"<p id='below' style='margin:0;width:200px;height:40px;background:#0a0'>below the fold</p>"
|
||||
"<div style='height:3000px;background:#eee'>after</div>"
|
||||
"</body></html>"
|
||||
)
|
||||
SCROLLED_TO = 100
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def scrolled(page):
|
||||
"""A page scrolled to a known position with the element well below the fold."""
|
||||
other = page.context.new_page()
|
||||
other.set_content(TALL, wait_until="load")
|
||||
other.evaluate("window.scrollTo(0, %d)" % SCROLLED_TO)
|
||||
assert other.evaluate("window.scrollY") == SCROLLED_TO
|
||||
assert other.evaluate("document.getElementById('below').getBoundingClientRect().top") > 400
|
||||
yield other
|
||||
other.close()
|
||||
|
||||
|
||||
REFUSALS = [
|
||||
("mask", r"screenshot\(mask=", lambda p: {"mask": [p.locator("#below")]}),
|
||||
("style", r"screenshot\(style=", lambda p: {"style": "p { visibility: hidden }"}),
|
||||
("animations", r'screenshot\(animations="disabled"\)', lambda p: {"animations": "disabled"}),
|
||||
("caret", r'screenshot\(caret="initial"\)', lambda p: {"caret": "initial"}),
|
||||
("omit_background", None, lambda p: {"omit_background": True}),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name,pattern,kwargs", REFUSALS, ids=[r[0] for r in REFUSALS])
|
||||
@pytest.mark.parametrize("way", ["locator", "handle"])
|
||||
def test_a_refused_element_screenshot_does_not_scroll_the_page(scrolled, way, name, pattern, kwargs):
|
||||
from invisible_playwright.sync_api import Error
|
||||
|
||||
shoot = {
|
||||
"locator": lambda **k: scrolled.locator("#below").screenshot(**k),
|
||||
"handle": lambda **k: scrolled.query_selector("#below").screenshot(**k),
|
||||
}[way]
|
||||
with pytest.raises(Error, match=pattern) as refused:
|
||||
shoot(**kwargs(scrolled))
|
||||
if pattern is None:
|
||||
assert str(refused.value).split("\n")[0] == NOT_IMPLEMENTED[way]
|
||||
assert scrolled.evaluate("window.scrollY") == SCROLLED_TO
|
||||
# the control: the same call without the refused parameter DOES scroll the element in, so the unchanged scroll above is a measurement
|
||||
assert shoot()[:4] == PNG
|
||||
assert scrolled.evaluate("window.scrollY") != SCROLLED_TO
|
||||
@@ -1,201 +0,0 @@
|
||||
"""The dropdown of a ``<select>`` opens at its element as it does on retail Firefox 159, in the top document and in a frame of another site.
|
||||
|
||||
THIS IS A PRODUCT MEASUREMENT, NOT A PAGE-VISIBLE ONE. A page cannot read where a dropdown opens. But the engine declares to the content process the window origin and the
|
||||
chrome offset the page reads (not the host's), and the chrome actors of the browser that anchor a popup on screen (the select dropdown, the autocomplete list, the pickers,
|
||||
the form validation bubble) compute their anchor in the content process with ``windowUtils.getElementBoundingScreenRect``: the declared window origin plus the box of the
|
||||
element. The parent then opens the popup at those numbers, on the REAL screen. Unless the parent maps the declared point back to the real one, the dropdown opens away
|
||||
from its element by the difference between the declared window and the real one (and, in a frame of another process, by the declared chrome offset too: the matrix of that process).
|
||||
|
||||
THE VERDICT IS "THE SAME AS RETAIL". The relation that is measured is not a number of ours: retail Firefox 159 (the official build, driven by Marionette alone, no Playwright, headed on
|
||||
a display of its own: ``_retail_reference``) does the same steps, one browser at a time, on the same local pages, at the same display scale and in a window of the same outer size as ours (the retail window is set to it, and both inner sizes are compared first: a difference is BROKEN CONTROL), and ours must give the same relation. What retail does with the popup
|
||||
(a margin, a flip, a rounding) is then in both, and what differs is ours. Playwright's own Firefox is not the reference here: it is not what a user runs, and it is not known to take Marionette.
|
||||
|
||||
What it does, per display case (the four of the window tests), on each browser, which is launched with Marionette so that the test can read the chrome of the browser. A page of the top site has a
|
||||
``<select>`` (160x28 at (30, 20), page margin 0) and a frame of another site, 420x200 at (30, 120), with the same ``<select>`` at (40, 20) of its document. The rectangles are the ones the CSS of
|
||||
the pages gives (everything is absolute, the margins are 0, nothing scrolls). For each of the two selects:
|
||||
|
||||
* a real click at its centre (the client's mouse on ours, a mouse event through the window's widget from chrome scope on retail) opens the dropdown, and the test waits for the menulist popup of
|
||||
``ContentSelectDropdown`` to be ``open``;
|
||||
* from chrome, two rectangles are read, in the CSS pixels of the chrome: the popup's real screen rectangle (``popup.getOuterScreenRect()``, the bounds of the popup's own widget) and the select's REAL
|
||||
screen rectangle, computed in the parent from the real geometry of the browser: the content-area rectangle of the ``<browser>`` plus the select's rectangle in the page, converted with the chrome
|
||||
window's ``windowUtils.toScreenRectInCSSUnits``;
|
||||
* ``dx`` and ``dy`` are the popup's left less the element's left and the popup's top less the element's bottom, in DEVICE pixels (the chrome's CSS pixels times the chrome's ``devicePixelRatio``,
|
||||
so the two browsers are compared in one unit); ours equals retail's within ONE device pixel, in the top document and in the frame.
|
||||
|
||||
THE RECORD: for each browser, the rectangles, and the scales: the page's ``devicePixelRatio`` (declared), the chrome's ``devicePixelRatio``, and the real scale of the screen read from chrome
|
||||
(``nsIScreen.contentsScaleFactor``, ``defaultCSSScaleFactor``, ``displayDPI``). The element's rectangle is computed in the chrome's CSS pixels from the page's CSS pixels, so a page whose scale is
|
||||
not the chrome's puts the element at the wrong place by their ratio: the record also keeps ``dx_scaled`` and ``dy_scaled``, against the element scaled by page ratio over chrome ratio, so a red twin
|
||||
shows whether a scale mismatch between the page's CSS pixels and the chrome's is what moves the popup.
|
||||
|
||||
THE DIAGNOSIS (``_popup_evidence``): for each select, every failure of the steps and the verdict of the twin carry the click (CSS point, and the point the driver sent with its unit and its device point),
|
||||
the scales, the select's box in its own document and, for the frame, the frame element's box in the top document, ``mozInnerScreenX/Y`` of the top and of the frame, whether the window was the active one and
|
||||
had the focus when the click was sent and after it (chrome ``Services.focus.activeWindow``, ``document.hasFocus()``, the browsing context's ``isActive``, the content document's ``hasFocus()`` and ``visibilityState``, the
|
||||
driver's ack of the click), and the popup's state after the click, at
|
||||
the deadline and at a second look (a short wait on the same condition). The same record is written for every case, green or red, to ``$RUNNER_TEMP/invpw-evidence/popup-diagnostics/<case>-<browser>.json`` (the folder every job uploads), so
|
||||
a green run leaves the numbers to compare with a red one. Without browsers: ``test_the_select_twin_says_what_it_clicked_and_where.py``.
|
||||
|
||||
The engine that answers these values is not released yet: this test is red on an engine that declares the window origin without the map of the popups, on purpose.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _popup_evidence import Diagnostics, click_record, look_at_activation, look_at_geometry
|
||||
from _retail_reference import Driver, run_retail_twin
|
||||
from _stock_twin import both, differences
|
||||
from _window_origin import CASES, DEADLINE_S, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
TOP = """<!doctype html><meta charset=utf-8><title>select</title>
|
||||
<style>html,body{margin:0;padding:0}
|
||||
select{position:absolute;box-sizing:border-box;width:160px;height:28px;margin:0}
|
||||
#s{left:30px;top:20px}#f{position:absolute;left:30px;top:120px;width:420px;height:200px;border:0}</style>
|
||||
<body><select id=s><option>one</option><option>two</option><option>three</option></select><iframe id=f src="%s"></iframe>"""
|
||||
|
||||
FRAME = """<!doctype html><meta charset=utf-8><title>select in a frame</title>
|
||||
<style>html,body{margin:0;padding:0}select{position:absolute;box-sizing:border-box;width:160px;height:28px;margin:0;left:40px;top:20px}</style>
|
||||
<body><select id=s><option>one</option><option>two</option><option>three</option></select>"""
|
||||
|
||||
#: How long the second look at a popup that missed its deadline lasts (a diagnosis, after the verdict).
|
||||
SECOND_LOOK_S = 2
|
||||
|
||||
#: The selects' rectangles in the top document's viewport, CSS pixels, as the CSS above gives them: x, y, width, height.
|
||||
SELECTS = {"top": {"x": 30, "y": 20, "w": 160, "h": 28}, "frame": {"x": 30 + 40, "y": 120 + 20, "w": 160, "h": 28}}
|
||||
|
||||
# The reads of the browser chrome, in the script of Marionette (chrome scope).
|
||||
POPUP_STATE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.querySelector("#ContentSelectDropdown > menupopup");
|
||||
return JSON.stringify({state: popup ? popup.state : "no popup"});
|
||||
"""
|
||||
|
||||
MEASURE_JS = """
|
||||
const [rect] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.querySelector("#ContentSelectDropdown > menupopup");
|
||||
const browser = win.gBrowser.selectedBrowser;
|
||||
const b = browser.getBoundingClientRect();
|
||||
const el = win.windowUtils.toScreenRectInCSSUnits(b.left + rect.x, b.top + rect.y, rect.w, rect.h);
|
||||
const p = popup.getOuterScreenRect();
|
||||
const plain = r => ({left: r.left, top: r.top, right: r.right, bottom: r.bottom});
|
||||
return JSON.stringify({state: popup.state, element: plain(el), popup: plain(p), dpr: win.devicePixelRatio});
|
||||
"""
|
||||
|
||||
CLOSE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const popup = win.document.querySelector("#ContentSelectDropdown > menupopup");
|
||||
popup.hidePopup();
|
||||
return JSON.stringify({state: popup.state});
|
||||
"""
|
||||
|
||||
|
||||
def _wait_state(driver: Driver, state: str) -> Dict[str, Any]:
|
||||
"""The popup's state once it is ``state`` (open or closed), polled. ``state`` is the last reading (at the deadline when it never came), ``after_click`` the first one."""
|
||||
reads: list = []
|
||||
|
||||
def look() -> bool:
|
||||
reads.append(driver.chrome.script(POPUP_STATE_JS))
|
||||
return reads[-1]["state"] == state
|
||||
|
||||
wait_for(driver, look, DEADLINE_S)
|
||||
return {"state": reads[-1]["state"], "after_click": reads[0], "at_deadline": reads[-1], "looks": len(reads)}
|
||||
|
||||
|
||||
def _second_look(driver: Driver, state: str) -> Dict[str, Any]:
|
||||
"""After a deadline that was missed: the same condition once more for ``SECOND_LOOK_S``, to say whether the popup came late (``reached``) and what it was when it did not. A diagnosis: the verdict is already red."""
|
||||
reads: list = []
|
||||
|
||||
def look() -> bool:
|
||||
try:
|
||||
reads.append(driver.chrome.script(POPUP_STATE_JS))
|
||||
except Exception as exc: # noqa: BLE001 the diagnosis never replaces the finding
|
||||
reads.append({"state": "unreadable: %s: %s" % (type(exc).__name__, str(exc)[:200])})
|
||||
return reads[-1]["state"] == state
|
||||
|
||||
reached = wait_for(driver, look, SECOND_LOOK_S)
|
||||
return {"state": reads[-1]["state"], "reached": reached, "looks": len(reads)}
|
||||
|
||||
|
||||
def _measure(driver: Driver, rect: Dict[str, float]) -> Dict[str, Any]:
|
||||
"""Opens nothing: reads the open popup and the select's real screen rectangle, both in CSS pixels of the chrome, once two looks agree."""
|
||||
read = driver.chrome.script(MEASURE_JS, (rect,))
|
||||
for _ in range(int(DEADLINE_S * 10)):
|
||||
driver.wait_for_timeout(100)
|
||||
again = driver.chrome.script(MEASURE_JS, (rect,))
|
||||
if again == read:
|
||||
return again
|
||||
read = again
|
||||
return read
|
||||
|
||||
|
||||
def _relation(read: Dict[str, Any], page_dpr: float) -> Dict[str, Any]:
|
||||
"""The rectangles and the relation between them: dx and dy in device pixels of the chrome, and the same against the element scaled by page ratio over chrome ratio."""
|
||||
chrome_dpr = read["dpr"]
|
||||
element, popup = read["element"], read["popup"]
|
||||
ratio = page_dpr / chrome_dpr
|
||||
scaled_left = element["left"] * ratio
|
||||
scaled_bottom = element["bottom"] * ratio
|
||||
return {"element": element, "popup": popup,
|
||||
"dx": round((popup["left"] - element["left"]) * chrome_dpr, 3), "dy": round((popup["top"] - element["bottom"]) * chrome_dpr, 3),
|
||||
"dx_scaled": round((popup["left"] - scaled_left) * chrome_dpr, 3), "dy_scaled": round((popup["top"] - scaled_bottom) * chrome_dpr, 3)}
|
||||
|
||||
|
||||
def _steps(sites, driver: Driver, case: str = "unknown") -> Dict[str, Any]:
|
||||
"""What one browser does: click each select, read the popup against its element, close it. {"scales": ..., "measured": {top, frame}, "diagnostics": the record of each select}.
|
||||
|
||||
Every failure here carries the record of the select it is about (``Diagnostics.message``), and the record is saved whatever the result."""
|
||||
diagnostics = Diagnostics(case, driver.kind)
|
||||
try:
|
||||
driver.goto(sites.url("A", "/page"))
|
||||
scales = driver.scales()
|
||||
diagnostics.scales = scales
|
||||
measured: Dict[str, Any] = {}
|
||||
for name, rect in SELECTS.items():
|
||||
entry = diagnostics.entry(name)
|
||||
entry.update(look_at_geometry(driver, in_frame=name == "frame"))
|
||||
point = (rect["x"] + rect["w"] / 2, rect["y"] + rect["h"] / 2)
|
||||
entry["activation_at_click"] = look_at_activation(driver)
|
||||
driver.click(*point)
|
||||
entry["click"] = click_record(driver, point)
|
||||
entry["activation_after_click"] = look_at_activation(driver)
|
||||
opened = _wait_state(driver, "open")
|
||||
entry["popup"] = {"after_click": opened["after_click"], "at_deadline": opened["at_deadline"], "looks": opened["looks"]}
|
||||
if opened["state"] != "open":
|
||||
entry["popup"]["second_look"] = _second_look(driver, "open")
|
||||
raise AssertionError(diagnostics.message("the dropdown did not open after a click on the select of the %s document (popup state %r)" % (name, opened["state"]), name))
|
||||
measured[name] = _relation(_measure(driver, rect), scales["page"]["devicePixelRatio"])
|
||||
entry["relation"] = measured[name]
|
||||
driver.chrome.script(CLOSE_JS)
|
||||
closed = _wait_state(driver, "closed")
|
||||
entry["popup"]["closed"] = closed["at_deadline"]
|
||||
if closed["state"] != "closed":
|
||||
entry["popup"]["second_look"] = _second_look(driver, "closed")
|
||||
raise AssertionError(diagnostics.message("the dropdown of the %s document did not close (popup state %r)" % (name, closed["state"]), name))
|
||||
finally:
|
||||
diagnostics.save()
|
||||
return {"scales": scales, "measured": measured, "diagnostics": diagnostics.entries}
|
||||
|
||||
|
||||
def _verdict(case: str, retail: Dict[str, Any], ours: Dict[str, Any]) -> str:
|
||||
"""The message of a twin that differs: where the two relations differ, then both records whole (the scales and the diagnostics of each select are in them). Empty when equal."""
|
||||
# one device pixel of the chrome: the popup's position is rounded once, the element's once
|
||||
relation = lambda record: {name: {key: value[key] for key in ("dx", "dy", "dx_scaled", "dy_scaled")} for name, value in record["measured"].items()} # noqa: E731
|
||||
differing = differences(relation(retail), relation(ours), {"dx": 1.0, "dy": 1.0, "dx_scaled": 1.0, "dy_scaled": 1.0}, "measured")
|
||||
if not differing:
|
||||
return ""
|
||||
return ("%s: the dropdown of ours is not where retail's is against its element (dx, dy in device pixels of each chrome, both measured against the element's real rectangle):\n %s%s"
|
||||
% (case, "\n ".join(differing), both(case, retail, ours, "retail")))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_select_dropdown_opens_at_its_element_as_on_retail(firefox_binary, monkeypatch, case):
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/select"))
|
||||
sites.route("B", "/select", FRAME)
|
||||
retail, ours = run_retail_twin(case, firefox_binary, lambda driver: _steps(sites, driver, case))
|
||||
message = _verdict(case, retail, ours)
|
||||
assert not message, message
|
||||
@@ -1,157 +0,0 @@
|
||||
"""A select's dropdown that a mouse press opened stays open when the button is released and while the pointer sits still, as on every Firefox: only a press elsewhere or the wheel closes a menu.
|
||||
|
||||
A menu popup is closed by the platform on a mouse DOWN outside it and on the wheel (``nsWindow::DealWithPopups``), never on a mouse UP or a mouse MOVE. The automation's input used to close the
|
||||
open menus on the release and on a move too, so a page that pressed the button on a select and let go saw the dropdown vanish: the dropdown of a select that a real user opens with a click is open
|
||||
after the click, and a page can read that from the select's own events (``blur``, a ``change`` that never comes) and from where the next click lands.
|
||||
|
||||
Per case, ``top`` (the select of the top document) and ``frame`` (the select of a frame of another site), on one display case (``CASE``, the 1920x1080 panel at scale 1.0), with the client's own mouse:
|
||||
the pointer moves to the centre of the select, the button goes down, the test waits until the chrome-scope state of ``#ContentSelectDropdown > menupopup`` is ``open`` (the wait of the select twin,
|
||||
a condition with a deadline), the button goes up, and the state is read over the next second (``observe``, the one bounded look of ``_window_origin``) and must have been ``open`` at every look and
|
||||
never anything else. Then the popup is closed from chrome and the wait is for ``closed``.
|
||||
|
||||
The page also sees the release. A release that the parent handles in chrome (the dropdown is open) is answered without waiting for the content process, and on retail the page then gets a trusted ``mouseup`` and
|
||||
``click`` on the ``<select>``, dispatched by ``SelectChild`` after the parent's ``Forms:MouseUp``, asynchronously. The pages record both on the select (``RECORD``), and the test WAITS for them as a page observes them
|
||||
(``wait_for`` on the page's own log, the deadline of the file): they are never assumed to have arrived by the time ``page.mouse.up()`` returned.
|
||||
|
||||
The negative control, per place: the same flow with a chrome ``hidePopup`` between the press and the release must read ``closed`` after the release, so the reader is shown to see a closed popup (a
|
||||
reader that answered ``open`` whatever the popup did would pass the first test for nothing).
|
||||
|
||||
One more test, the case the engine's old unguarded call was there for: a chrome context menu that captures the mouse (on Linux it opens at the press). A right click on the page opens
|
||||
``#contentAreaContextMenu``; then several moves across the page, a left click elsewhere and a move again must each RETURN (no call hangs, none throws the client's ack timeout, the duration of
|
||||
each is in the message of a failure), and the menu is ``closed`` after the press of that click (the platform closes a menu on a press outside it).
|
||||
|
||||
The pages, the reads of the chrome and the wait are those of ``test_a_select_dropdown_opens_at_its_element_e2e.py`` (imported, not copied). Needs ``MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1`` for the chrome reads.
|
||||
Red on an engine whose Juggler closes menus on a release or a move: the dropdown reads ``closed`` after the button went up.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import time
|
||||
from typing import Any, Dict, Iterator, List, Tuple
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _retail_reference import PlaywrightDriver
|
||||
from _stock_twin import MARIONETTE_ARGS, Chrome
|
||||
from _window_origin import DEADLINE_S, launch_case, observe, wait_for
|
||||
from test_a_select_dropdown_opens_at_its_element_e2e import CLOSE_JS, FRAME, POPUP_STATE_JS, SELECTS, TOP, _wait_state
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: The display case of every test here: the maximized 1920x1080 window at scale 1.0.
|
||||
CASE = "1920x1080-dpr1.0"
|
||||
#: How long the state is watched after the release.
|
||||
WATCH_S = 1.0
|
||||
#: What each page (the top document and the frame) records on its ``<select>``: the events of the release, as the page sees them, in the order they came, with whether they are trusted.
|
||||
RECORD = """<script>window.__log = [];
|
||||
for (const type of ['mouseup', 'click']) document.getElementById('s').addEventListener(type, e => window.__log.push([type, e.isTrusted]));</script>"""
|
||||
|
||||
|
||||
def _centre(name: str) -> Tuple[float, float]:
|
||||
rect = SELECTS[name]
|
||||
return rect["x"] + rect["w"] / 2, rect["y"] + rect["h"] / 2
|
||||
|
||||
|
||||
def _state(driver: PlaywrightDriver) -> str:
|
||||
return driver.chrome.script(POPUP_STATE_JS)["state"]
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _page(firefox_binary: str, monkeypatch) -> Iterator[Tuple[Any, Chrome, PlaywrightDriver, Sites]]:
|
||||
"""Our browser on ``CASE`` with the pages of the select twin served: ``(page, chrome, driver, sites)``, on the A page."""
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites, launch_case(firefox_binary, CASE, extra_args=MARIONETTE_ARGS, extra_prefs={"marionette.port": 0}) as browser:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/select") + RECORD)
|
||||
sites.route("B", "/select", FRAME + RECORD)
|
||||
page = browser.new_page() # first: the window the chrome session waits for
|
||||
chrome = Chrome(page)
|
||||
try:
|
||||
driver = PlaywrightDriver(page, chrome)
|
||||
driver.goto(sites.url("A", "/page"))
|
||||
yield page, chrome, driver, sites
|
||||
finally:
|
||||
chrome.close()
|
||||
|
||||
|
||||
def _flow(firefox_binary: str, monkeypatch, name: str, hide_between: bool) -> Dict[str, Any]:
|
||||
"""Press on the select, wait for ``open``, optionally hide the popup from chrome, release, and read the state for ``WATCH_S``. What was seen, step by step."""
|
||||
x, y = _centre(name)
|
||||
with _page(firefox_binary, monkeypatch) as (page, chrome, driver, sites):
|
||||
page.mouse.move(x, y)
|
||||
page.mouse.down()
|
||||
opened = _wait_state(driver, "open")
|
||||
seen: Dict[str, Any] = {"at": [x, y], "after_press": opened["state"], "deadline_s": DEADLINE_S}
|
||||
if hide_between:
|
||||
chrome.script(CLOSE_JS)
|
||||
seen["after_hide"] = _wait_state(driver, "closed")["state"]
|
||||
page.mouse.up()
|
||||
looks: List[Any] = observe(page, lambda: _state(driver), WATCH_S)
|
||||
seen["after_release"] = looks
|
||||
if not hide_between:
|
||||
# The release was answered by the parent alone; the page's mouseup and click come later, from the content process, so they are waited for in the page's own log
|
||||
# (never assumed to be there when the call returned).
|
||||
document = page.main_frame if name == "top" else next(f for f in page.frames if f.url == sites.url("B", "/select"))
|
||||
seen["page_events_arrived"] = wait_for(page, lambda: len(document.evaluate("window.__log")) >= 2, DEADLINE_S)
|
||||
seen["page_events"] = [tuple(row) for row in document.evaluate("window.__log")]
|
||||
if looks[-1] == "open":
|
||||
chrome.script(CLOSE_JS)
|
||||
seen["after_close"] = _wait_state(driver, "closed")["state"]
|
||||
return seen
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(SELECTS))
|
||||
def test_a_dropdown_opened_by_a_press_stays_open_after_the_release(firefox_binary, monkeypatch, name):
|
||||
seen = _flow(firefox_binary, monkeypatch, name, hide_between=False)
|
||||
assert seen["after_press"] == "open", "the press on the select of the %s document did not open the dropdown: %r" % (name, seen)
|
||||
assert seen["after_release"] == ["open"], (
|
||||
"the dropdown of the %s document did not stay open after the button went up (every look over %s s must read open, in the order seen): %r" % (name, WATCH_S, seen))
|
||||
assert seen["after_close"] == "closed", "the popup did not close when chrome hid it: %r" % seen
|
||||
assert seen["page_events_arrived"] and seen["page_events"] == [("mouseup", True), ("click", True)], (
|
||||
"the page of the %s document did not see a trusted mouseup and click on the select after the release (waited %s s for both): %r" % (name, DEADLINE_S, seen))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(SELECTS))
|
||||
def test_a_popup_hidden_between_the_press_and_the_release_reads_closed_after_it(firefox_binary, monkeypatch, name):
|
||||
"""The negative control: the reader sees a closed popup, so the first test's ``open`` is not what the reader says whatever happens."""
|
||||
seen = _flow(firefox_binary, monkeypatch, name, hide_between=True)
|
||||
assert seen["after_press"] == "open" and seen["after_hide"] == "closed", "the control did not reach its starting state (open, then hidden): %r" % seen
|
||||
assert seen["after_release"] == ["closed"], "a popup that chrome hid reads %r after the release, not closed: %r" % (seen["after_release"], seen)
|
||||
|
||||
|
||||
#: The chrome context menu of a page (the browser chrome's own element).
|
||||
CONTEXT_MENU_STATE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const menu = win.document.getElementById("contentAreaContextMenu");
|
||||
return JSON.stringify({state: menu ? menu.state : "no menu"});
|
||||
"""
|
||||
|
||||
#: Where the right click opens the menu, the moves across the page, the left click elsewhere and the last move: top-viewport CSS pixels, all on blank page.
|
||||
MENU_AT = (700, 300)
|
||||
MOVES = ((200, 500), (900, 500), (500, 600))
|
||||
CLICK_AT = (900, 200)
|
||||
LAST_MOVE = (500, 450)
|
||||
|
||||
|
||||
def test_a_context_menu_closes_on_the_next_press_and_no_input_call_hangs(firefox_binary, monkeypatch):
|
||||
calls: List[Tuple[str, float]] = []
|
||||
|
||||
def timed(label: str, call, *args, **kwargs):
|
||||
"""One input call: it must return (a hang or the client's ack timeout raises or stalls here); how long it took goes in the message of a failure, never in a bound."""
|
||||
began = time.monotonic()
|
||||
try:
|
||||
return call(*args, **kwargs)
|
||||
finally:
|
||||
calls.append((label, round(time.monotonic() - began, 3)))
|
||||
|
||||
with _page(firefox_binary, monkeypatch) as (page, chrome, _driver, _):
|
||||
menu = lambda: chrome.script(CONTEXT_MENU_STATE_JS)["state"] # noqa: E731
|
||||
timed("right click", page.mouse.click, *MENU_AT, button="right")
|
||||
opened = wait_for(page, lambda: menu() == "open", DEADLINE_S)
|
||||
assert opened, "the right click on the page did not open the chrome context menu (state %r); calls (s): %r" % (menu(), calls)
|
||||
for i, point in enumerate(MOVES):
|
||||
timed("move %d" % i, page.mouse.move, *point)
|
||||
timed("left click", page.mouse.click, *CLICK_AT)
|
||||
closed = wait_for(page, lambda: menu() == "closed", DEADLINE_S)
|
||||
timed("move after", page.mouse.move, *LAST_MOVE)
|
||||
assert closed, "the context menu was still %r after the press of a click elsewhere on the page; calls (s): %r" % (menu(), calls)
|
||||
assert [label for label, _ in calls] == ["right click", "move 0", "move 1", "move 2", "left click", "move after"], "an input call did not return: %r" % calls
|
||||
@@ -1,234 +0,0 @@
|
||||
"""The guard of tests/_no_network.py: a destination on this host passes, anything else is refused and recorded, and the record fails the test.
|
||||
|
||||
Each case installs its own guard on top of the one the conftest gives every test that is not e2e; the inner guard refuses first, so nothing
|
||||
reaches the outer one and nothing leaves the machine: a refused connect never sends a packet.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import socket
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
||||
import _no_network
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
OUTSIDE = ("1.1.1.1", 443) # never contacted: the guard refuses before the system call
|
||||
|
||||
|
||||
@pytest.mark.parametrize("host", ["127.0.0.1", "127.8.9.10", "::1", "0.0.0.0", "::", "localhost", "LocalHost", "a.localhost", None, "",
|
||||
"198.51.100.9", "192.0.2.1", "203.0.113.7", "2001:db8::1", "::ffff:127.0.0.1", "[::1]"])
|
||||
def test_this_host_is_this_host(host):
|
||||
assert _no_network.is_on_this_host(host)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("host", ["1.1.1.1", "8.8.8.8", "10.0.0.1", "192.168.1.1", "2606:4700::1111", "api.ipify.org", "example.com",
|
||||
b"icanhazip.com", "::ffff:8.8.8.8", "fe80::1%lo"])
|
||||
def test_outside_is_outside(host):
|
||||
assert not _no_network.is_on_this_host(host)
|
||||
|
||||
|
||||
def test_a_connect_outside_is_refused_named_and_fails_the_test(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "tests/test_x.py::test_y")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
with pytest.raises(ConnectionRefusedError) as refused:
|
||||
s.connect(OUTSIDE)
|
||||
message = str(refused.value)
|
||||
for part in ("WHERE: tests/test_x.py::test_y", "WHAT: connect to 1.1.1.1:443", "FIX:", "RULE:"):
|
||||
assert part in message, message
|
||||
assert guard.verdict() is not None and "connect to 1.1.1.1:443" in guard.verdict()
|
||||
|
||||
|
||||
def test_a_refusal_the_code_swallowed_still_fails_the_test(monkeypatch):
|
||||
"""The code under test may catch the refusal and carry on (an offline fallback): the record is what fails the test."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.connect_ex(OUTSIDE)
|
||||
except OSError:
|
||||
pass
|
||||
assert guard.verdict() is not None
|
||||
|
||||
|
||||
def test_a_datagram_and_a_name_lookup_outside_are_refused(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
s.sendto(b"x", ("8.8.8.8", 53))
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("api.ipify.org", 443)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.create_connection(("icanhazip.com", 443), timeout=1)
|
||||
assert guard.attempts == ["datagram to 8.8.8.8:53", "name lookup of api.ipify.org", "name lookup of icanhazip.com"]
|
||||
|
||||
|
||||
def test_a_client_thread_of_the_test_is_recorded(monkeypatch):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
def client():
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
try:
|
||||
s.connect(OUTSIDE)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
worker = threading.Thread(target=client)
|
||||
worker.start()
|
||||
worker.join(10)
|
||||
assert guard.attempts == ["connect to 1.1.1.1:443"]
|
||||
|
||||
|
||||
def test_this_host_passes_and_leaves_no_record(monkeypatch):
|
||||
"""The control: a server on loopback is reached through the same doors, by address and by name, and the test stays green."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
|
||||
server.bind(("127.0.0.1", 0))
|
||||
server.listen(1)
|
||||
port = server.getsockname()[1]
|
||||
with socket.create_connection(("localhost", port), timeout=5) as client:
|
||||
accepted, _ = server.accept()
|
||||
accepted.close()
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as other:
|
||||
assert other.connect_ex(("127.0.0.1", port)) == 0
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as receiver, socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sender:
|
||||
receiver.bind(("127.0.0.1", 0))
|
||||
sender.sendto(b"x", receiver.getsockname())
|
||||
assert guard.verdict() is None
|
||||
|
||||
|
||||
def test_the_address_this_host_sends_from_is_this_host(monkeypatch):
|
||||
"""A relay of the tests that leaves from the address of the host (tests/_host_address.py) is on this host: a datagram to it stays here."""
|
||||
own = _no_network.own_addresses()
|
||||
if not own:
|
||||
pytest.skip("this host has no default route, so no address of its own beside loopback")
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
with socket.socket(socket.AF_INET if ":" not in own[0] else socket.AF_INET6, socket.SOCK_DGRAM) as receiver:
|
||||
receiver.bind((own[0], 0))
|
||||
with socket.socket(receiver.family, socket.SOCK_DGRAM) as sender:
|
||||
sender.sendto(b"x", receiver.getsockname()[:2])
|
||||
assert guard.verdict() is None
|
||||
assert all(_no_network.is_on_this_host(a, own) for a in own)
|
||||
|
||||
|
||||
# The asyncio doors, for every loop kind this system has: the selector loop everywhere, and on Windows the Proactor loop too (the default
|
||||
# there), which connects with ConnectEx and sends with WSASendTo, never through socket.socket: the unit tier of the round runs on both systems.
|
||||
import asyncio # noqa: E402
|
||||
import sys # noqa: E402
|
||||
|
||||
LOOPS = ["selector"] + (["proactor"] if sys.platform == "win32" else [])
|
||||
|
||||
|
||||
def _run(kind, coroutine_function):
|
||||
loop = asyncio.SelectorEventLoop() if kind == "selector" else asyncio.ProactorEventLoop()
|
||||
try:
|
||||
return loop.run_until_complete(coroutine_function())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_an_asyncio_connection_to_a_numeric_address_outside_is_refused(monkeypatch, kind):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await asyncio.open_connection(*OUTSIDE)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.setblocking(False)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await asyncio.get_running_loop().sock_connect(s, OUTSIDE)
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.attempts == ["asyncio connect to 1.1.1.1:443"], guard.attempts
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_an_asyncio_datagram_outside_is_refused(monkeypatch, kind):
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
loop = asyncio.get_running_loop()
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await loop.create_datagram_endpoint(asyncio.DatagramProtocol, remote_addr=("8.8.8.8", 53))
|
||||
transport, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, local_addr=("127.0.0.1", 0))
|
||||
try:
|
||||
# the selector transport hands a refused send to its protocol (error_received) instead of raising it: the record is what counts
|
||||
try:
|
||||
transport.sendto(b"x", ("8.8.4.4", 53))
|
||||
except ConnectionRefusedError:
|
||||
pass
|
||||
finally:
|
||||
transport.close()
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.setblocking(False)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
await loop.sock_sendto(s, b"x", ("8.8.8.8", 5353))
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.attempts == ["asyncio datagram endpoint to 8.8.8.8:53", "asyncio datagram to 8.8.4.4:53", "asyncio datagram to 8.8.8.8:5353"] \
|
||||
or guard.attempts == ["asyncio datagram endpoint to 8.8.8.8:53", "datagram to 8.8.4.4:53", "asyncio datagram to 8.8.8.8:5353"], guard.attempts
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", LOOPS)
|
||||
def test_asyncio_on_this_host_passes(monkeypatch, kind):
|
||||
"""The control: a server on loopback, reached through asyncio by address and a datagram to a loopback receiver, leave no record."""
|
||||
guard = _no_network.install(monkeypatch, "t")
|
||||
|
||||
async def go():
|
||||
loop = asyncio.get_running_loop()
|
||||
server = await asyncio.start_server(lambda r, w: w.close(), "127.0.0.1", 0)
|
||||
port = server.sockets[0].getsockname()[1]
|
||||
reader, writer = await asyncio.open_connection("127.0.0.1", port)
|
||||
writer.close()
|
||||
server.close()
|
||||
await server.wait_closed()
|
||||
receiver, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, local_addr=("127.0.0.1", 0))
|
||||
sender, _ = await loop.create_datagram_endpoint(asyncio.DatagramProtocol, remote_addr=receiver.get_extra_info("sockname"))
|
||||
sender.sendto(b"x")
|
||||
sender.close()
|
||||
receiver.close()
|
||||
|
||||
_run(kind, go)
|
||||
assert guard.verdict() is None
|
||||
|
||||
|
||||
# The one declared third party: the version gate asks the index. Faked below the guard, so nothing leaves the machine here either.
|
||||
INDEX_ADDRESS = "8.8.4.4" # stands for the index: faked, never contacted
|
||||
|
||||
|
||||
def _fake_index(monkeypatch):
|
||||
"""The system lookup answers the index's address for pypi.org, and the system connect records instead of connecting."""
|
||||
reached = []
|
||||
monkeypatch.setattr(socket, "getaddrinfo", lambda host, port, *a, **k: [(socket.AF_INET, socket.SOCK_STREAM, 6, "", (INDEX_ADDRESS, port))])
|
||||
monkeypatch.setattr(socket.socket, "connect", lambda self, address: reached.append(address))
|
||||
return reached
|
||||
|
||||
|
||||
def test_the_version_gate_may_ask_the_index_and_only_the_index(monkeypatch):
|
||||
reached = _fake_index(monkeypatch)
|
||||
guard = _no_network.install(monkeypatch, "tests/test_version_is_not_taken.py::test_the_declared_version_is_not_already_published")
|
||||
(family, kind, proto, _name, address), = socket.getaddrinfo("pypi.org", 443)
|
||||
with socket.socket(family, kind) as s:
|
||||
s.connect(address)
|
||||
assert [a for a in reached if a[1] == 443] == [(INDEX_ADDRESS, 443)] # (the guard's own probe of this host's address is recorded too)
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("files.example.net", 443)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s, pytest.raises(ConnectionRefusedError):
|
||||
s.connect(OUTSIDE)
|
||||
assert guard.attempts == ["name lookup of files.example.net", "connect to 1.1.1.1:443"]
|
||||
|
||||
|
||||
def test_no_other_file_may_ask_the_index(monkeypatch):
|
||||
reached = _fake_index(monkeypatch)
|
||||
guard = _no_network.install(monkeypatch, "tests/test_x.py::test_y")
|
||||
with pytest.raises(ConnectionRefusedError):
|
||||
socket.getaddrinfo("pypi.org", 443)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s, pytest.raises(ConnectionRefusedError):
|
||||
s.connect((INDEX_ADDRESS, 443))
|
||||
assert [a for a in reached if a[1] == 443] == [] and guard.attempts == ["name lookup of pypi.org", "connect to %s:443" % INDEX_ADDRESS]
|
||||
|
||||
|
||||
def test_the_declared_third_parties_are_the_version_gate_alone():
|
||||
"""A new entry is a decision: this test changes with it, in the same diff, where a reviewer sees it."""
|
||||
assert _no_network.DECLARED_THIRD_PARTIES == {"tests/test_version_is_not_taken.py": ("pypi.org",)}
|
||||
@@ -1,166 +0,0 @@
|
||||
"""The tooltip of an element with a ``title`` opens at the pointer as it does on retail Firefox 159, in the top document and in a frame of another site.
|
||||
|
||||
THIS IS A PRODUCT MEASUREMENT, NOT A PAGE-VISIBLE ONE: a page cannot read where a tooltip opens. But the point the browser opens it at is the event's screen point
|
||||
(``ChromeTooltipListener::MouseMove`` keeps ``ScreenPointLayoutDevicePix`` of the mouse event, ``nsDocShellTreeOwner.cpp``, and ``XULBrowserWindow.showTooltip`` in the parent
|
||||
calls ``#remoteBrowserTooltip.openPopupAtScreen(x / devicePixelRatio, y / devicePixelRatio)``). The engine declares the window origin and the chrome offset to the content
|
||||
process, so that event point is a DECLARED screen point; opened as it is, the tooltip would sit away from the pointer by (declared - real) origin, and, in a frame of another
|
||||
process, by the declared chrome offset of its matrix as well. The engine maps the point back to the real one in the parent, before the popup opens (the tooltip map).
|
||||
|
||||
THE VERDICT IS "THE SAME OFFSET AS RETAIL". Retail Firefox 159 (the official build, driven by Marionette alone, no Playwright, headed on a display of its own: ``_retail_reference``) does the
|
||||
same steps, one browser at a time, on the same local pages, at the same display scale and in a window of the same outer size as ours (the retail window is set to it, and both inner sizes are compared first: a difference is BROKEN CONTROL); the tooltip's offset from the pointer on ours equals retail's within two device pixels. The rule Firefox computes
|
||||
(``tooltip_offset()``: ``LookAndFeel::kDefaultTooltipOffset`` = 21 CSS pixels, widget/LookAndFeel.h:349, ``nsMenuPopupFrame::GetMargin`` layout/xul/nsMenuPopupFrame.cpp:2249; on Windows
|
||||
``GetTooltipOffsetVertical``, widget/windows/nsLookAndFeel.cpp:43-51, makes it ceil(21 * cursor size / 32) when the system cursor size is not 32) is in each record as a cross-check
|
||||
(``rule_dy``) and is not the verdict: a record whose retail offset is not the rule is a finding about the rule, printed with both.
|
||||
|
||||
What it does, per display case (the four of the window tests), on each browser (launched with Marionette so that the test can read its chrome): a page of the top site has a 120x40 box with a
|
||||
``title`` at (40, 40), and a frame of another site, 420x200 at (30, 120), with the same box at (40, 40) of its document. For each of the two boxes:
|
||||
|
||||
* the pointer goes away from the box and then onto its centre (the client's own mouse on ours, mouse events through the window's widget from chrome scope on retail); the test waits for
|
||||
``#remoteBrowserTooltip`` of the browser window to be ``open`` (after ``ui.tooltip.delay_ms``); the chrome window is focused first, because ``showTooltip`` shows nothing in a window that
|
||||
has no focus;
|
||||
* from chrome, the popup's real screen rectangle (``getOuterScreenRect()``) and the REAL screen position of the pointer are read, in CSS pixels of the chrome: the content-area rectangle of the
|
||||
``<browser>`` plus the point in the page, converted with the chrome window's ``windowUtils.toScreenRectInCSSUnits`` (the widget as it really is);
|
||||
* ``dx`` and ``dy`` are the popup's left less the pointer's x and its top less the pointer's y, in DEVICE pixels of the chrome.
|
||||
|
||||
RED WITHOUT THE TOOLTIP MAP. With the declared point opened as it is, the popup is at the pointer plus (declared window origin - real window origin) (and, in the frame, plus the
|
||||
declared chrome offset less the real one): on Linux the window manager's frame and the host's chrome are not retail's, on Windows the real chrome has other heights, so at least one
|
||||
of the two offsets is more than two device pixels away from retail's at every case, and the assertion prints both records.
|
||||
|
||||
The engine that answers these values is not released yet: this test is red on an engine that declares the window origin without the map, on purpose.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import sys
|
||||
from typing import Any, Dict
|
||||
|
||||
import pytest
|
||||
from _fission_frames import Sites
|
||||
from _retail_reference import Driver, run_retail_twin
|
||||
from _stock_twin import both, differences
|
||||
from _window_origin import CASES, DEADLINE_S, wait_for
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
#: ``LookAndFeel::kDefaultTooltipOffset`` (widget/LookAndFeel.h:349): how far below the pointer an unanchored tooltip opens, CSS pixels, at the default cursor size.
|
||||
DEFAULT_TOOLTIP_OFFSET = 21
|
||||
#: ``kDefaultCursorSize`` of ``GetTooltipOffsetVertical`` (widget/windows/nsLookAndFeel.cpp:44).
|
||||
DEFAULT_CURSOR_SIZE = 32
|
||||
#: ``MOZ_SPI_CURSORSIZE`` (widget/windows/nsLookAndFeel.h:44).
|
||||
SPI_GETCURSORSIZE = 0x2028
|
||||
|
||||
|
||||
def tooltip_offset() -> int:
|
||||
"""The vertical tooltip offset Firefox computes on this host, by its own rule (widget/windows/nsLookAndFeel.cpp:43-51 on Windows; the default elsewhere)."""
|
||||
if sys.platform != "win32":
|
||||
return DEFAULT_TOOLTIP_OFFSET
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
size = wintypes.DWORD(DEFAULT_CURSOR_SIZE)
|
||||
if not ctypes.windll.user32.SystemParametersInfoW(SPI_GETCURSORSIZE, 0, ctypes.byref(size), 0):
|
||||
size = wintypes.DWORD(DEFAULT_CURSOR_SIZE)
|
||||
if size.value == DEFAULT_CURSOR_SIZE:
|
||||
return DEFAULT_TOOLTIP_OFFSET
|
||||
return math.ceil(DEFAULT_TOOLTIP_OFFSET * size.value / DEFAULT_CURSOR_SIZE)
|
||||
|
||||
|
||||
#: The box that has the title: 120x40 at (40, 40) of its document.
|
||||
BOX = (40, 40, 120, 40)
|
||||
#: Where the mouse waits before it comes onto the box, in the top document.
|
||||
AWAY = (700, 500)
|
||||
FRAME_AT = (30, 120)
|
||||
|
||||
BOX_CSS = ("#b{position:absolute;box-sizing:border-box;left:40px;top:40px;width:120px;height:40px;background:#9bd}"
|
||||
"html,body{margin:0;padding:0}")
|
||||
TOP = """<!doctype html><meta charset=utf-8><title>tooltip</title>
|
||||
<style>%s #f{position:absolute;left:30px;top:120px;width:420px;height:200px;border:0}</style>
|
||||
<body><div id=b title="the tooltip of the top document">box</div><iframe id=f src="%%s"></iframe>""" % BOX_CSS
|
||||
FRAME = """<!doctype html><meta charset=utf-8><title>tooltip in a frame</title>
|
||||
<style>%s</style><body><div id=b title="the tooltip of the frame">box</div>""" % BOX_CSS
|
||||
|
||||
FOCUS_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
win.focus();
|
||||
return JSON.stringify({focus: win.document.hasFocus()});
|
||||
"""
|
||||
STATE_JS = """
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
return JSON.stringify({state: win.document.getElementById("remoteBrowserTooltip").state});
|
||||
"""
|
||||
MEASURE_JS = """
|
||||
const [point] = arguments;
|
||||
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
const tip = win.document.getElementById("remoteBrowserTooltip");
|
||||
const b = win.gBrowser.selectedBrowser.getBoundingClientRect();
|
||||
const p = win.windowUtils.toScreenRectInCSSUnits(b.left + point.x, b.top + point.y, 0, 0);
|
||||
const r = tip.getOuterScreenRect();
|
||||
return JSON.stringify({state: tip.state, pointer: {x: p.left, y: p.top}, popup: {left: r.left, top: r.top, right: r.right, bottom: r.bottom}, dpr: win.devicePixelRatio});
|
||||
"""
|
||||
|
||||
|
||||
def _wait_state(driver: Driver, state: str) -> Dict[str, Any]:
|
||||
seen: Dict[str, Any] = {}
|
||||
|
||||
def look() -> bool:
|
||||
seen.update(driver.chrome.script(STATE_JS))
|
||||
return seen["state"] == state
|
||||
|
||||
wait_for(driver, look, DEADLINE_S)
|
||||
return seen
|
||||
|
||||
|
||||
def _measured(driver: Driver, point: Dict[str, float]) -> Dict[str, Any]:
|
||||
"""The popup and the pointer once two looks 100 ms apart agree."""
|
||||
read = driver.chrome.script(MEASURE_JS, (point,))
|
||||
for _ in range(int(DEADLINE_S * 10)):
|
||||
driver.wait_for_timeout(100)
|
||||
again = driver.chrome.script(MEASURE_JS, (point,))
|
||||
if again == read:
|
||||
return again
|
||||
read = again
|
||||
return read
|
||||
|
||||
|
||||
def _relation(read: Dict[str, Any], rule: int) -> Dict[str, Any]:
|
||||
"""The popup and the pointer, the offset between them in device pixels of the chrome, and the rule's offset as a cross-check."""
|
||||
dpr = read["dpr"]
|
||||
dx = (read["popup"]["left"] - read["pointer"]["x"]) * dpr
|
||||
dy = (read["popup"]["top"] - read["pointer"]["y"]) * dpr
|
||||
return {"popup": read["popup"], "pointer": read["pointer"], "dx": round(dx, 3), "dy": round(dy, 3), "rule_dy": round(rule * dpr, 3)}
|
||||
|
||||
|
||||
def _steps(sites, driver: Driver) -> Dict[str, Any]:
|
||||
"""What one browser does: the pointer onto each box, the tooltip against the pointer, the pointer away. {"scales": ..., "measured": {top, frame}}."""
|
||||
driver.goto(sites.url("A", "/page"))
|
||||
scales = driver.scales()
|
||||
wait_for(driver, lambda: driver.chrome.script(FOCUS_JS)["focus"], DEADLINE_S)
|
||||
focus = driver.chrome.script(FOCUS_JS)
|
||||
rule = tooltip_offset()
|
||||
measured: Dict[str, Any] = {}
|
||||
for name, origin in (("top", (0, 0)), ("frame", FRAME_AT)):
|
||||
point = {"x": origin[0] + BOX[0] + BOX[2] // 2, "y": origin[1] + BOX[1] + BOX[3] // 2}
|
||||
driver.move(*AWAY)
|
||||
driver.move(point["x"] - 20, point["y"] - 10)
|
||||
driver.move(point["x"], point["y"], steps=4)
|
||||
opened = _wait_state(driver, "open")
|
||||
assert opened["state"] == "open", "no tooltip opened over the box with a title of the %s document (popup state %r; the chrome window had focus: %r)" % (name, opened, focus)
|
||||
measured[name] = _relation(_measured(driver, point), rule)
|
||||
driver.move(*AWAY)
|
||||
closed = _wait_state(driver, "closed")
|
||||
assert closed["state"] == "closed", "the tooltip of the %s document did not close when the pointer left (popup state %r)" % (name, closed)
|
||||
return {"scales": scales, "measured": measured}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", sorted(CASES))
|
||||
def test_a_tooltip_opens_at_the_pointer_as_on_retail(firefox_binary, monkeypatch, case):
|
||||
monkeypatch.setenv("MOZ_REMOTE_ALLOW_SYSTEM_ACCESS", "1") # the chrome-scope reads
|
||||
with Sites() as sites:
|
||||
sites.route("A", "/page", lambda handler: TOP % sites.url("B", "/tip"))
|
||||
sites.route("B", "/tip", FRAME)
|
||||
retail, ours = run_retail_twin(case, firefox_binary, lambda driver: _steps(sites, driver))
|
||||
# two device pixels: the point is a device pixel and the popup's position is rounded once more
|
||||
relation = lambda record: {name: {key: value[key] for key in ("dx", "dy")} for name, value in record["measured"].items()} # noqa: E731
|
||||
differing = differences(relation(retail), relation(ours), {"dx": 2.0, "dy": 2.0}, "measured")
|
||||
assert not differing, (
|
||||
"%s: the tooltip of ours is not where retail's is against the pointer (dx, dy in device pixels of each chrome; rule_dy is the offset Firefox's own rule gives on this host):\n %s%s"
|
||||
% (case, "\n ".join(differing), both(case, retail, ours, "retail")))
|
||||
@@ -29,7 +29,6 @@ from http.server import BaseHTTPRequestHandler
|
||||
import pytest
|
||||
|
||||
from _bfcache_evidence import decide_outcome, read_after_go_back, wait_cacheable
|
||||
from _evidence_on_failure import FailureEvidence
|
||||
from _servers import LocalServer
|
||||
|
||||
STRATEGY_1 = {
|
||||
@@ -161,30 +160,13 @@ def _ask(page, where):
|
||||
return target.evaluate("window.__ask()")
|
||||
|
||||
|
||||
#: The engine's own log of the session history and the back-forward cache, kept with the evidence of a red run (one file per process): whether
|
||||
#: the restore happened, in which process, and what the parent did with the history entry. Run 45691494388 (job 139520127265) saw go_back
|
||||
#: end with "no new navigation on frame mainframe-11 in 30s" for top/other-site/goto and kept nothing to say whether the engine restored the
|
||||
#: page. A diagnostic no page reads.
|
||||
BFCACHE_LOG = "timestamp,SHIPBFCache:5,nsSHistory:5,SessionHistory:4,BCWebProgress:4,DocumentChannel:4,BrowsingContext:4"
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
@pytest.mark.parametrize("how", ["goto", "location"])
|
||||
@pytest.mark.parametrize("away", ["same-site", "other-site"])
|
||||
@pytest.mark.parametrize("where", ["top", "oop-frame"])
|
||||
def test_a_worker_leaves_with_its_page_for_the_cache_and_comes_back_the_same(firefox_binary, sites, events, where,
|
||||
away, how, engine_at_least):
|
||||
"""When it fails it saves, under ``invpw-evidence/worker-back-from-the-cache-<where>-<away>-<how>/``, the Juggler wire, the engine trace,
|
||||
the engine log BFCACHE_LOG and ``after-go-back.jsonl`` (what the page said when go_back raised, and 2 s later)."""
|
||||
engine_at_least("firefox-62")
|
||||
reads = _Reads()
|
||||
with FailureEvidence("worker-back-from-the-cache-%s-%s-%s" % (where, away, how)) as evidence:
|
||||
evidence.note_records("after-go-back", reads)
|
||||
evidence.arm(moz_log=BFCACHE_LOG)
|
||||
_the_case(firefox_binary, sites, events, where, away, how, reads)
|
||||
|
||||
|
||||
def _the_case(firefox_binary, sites, events, where, away, how, reads):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary, humanize=False,
|
||||
@@ -224,7 +206,7 @@ def _the_case(firefox_binary, sites, events, where, away, how, reads):
|
||||
|
||||
# 3. back from the cache: the same worker, told once, after the restored document's contexts are cleared
|
||||
back = len(events)
|
||||
_go_back_and_record(page, reads)
|
||||
page.go_back(wait_until="load")
|
||||
# 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
|
||||
@@ -294,34 +276,3 @@ def _assert_a_new_page_with_a_new_worker(page, events, where, old, back):
|
||||
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())
|
||||
|
||||
|
||||
class _Reads:
|
||||
"""What the page says right after a go_back that raised, and once more later (``FailureEvidence.note_records`` shape)."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.lock = threading.Lock()
|
||||
self.records = []
|
||||
|
||||
def read(self, page, when):
|
||||
record = {"when": when, "t": time.time(), "client_url": page.url}
|
||||
try:
|
||||
record.update(page.evaluate(
|
||||
"() => ({url: location.href, shown: window.__shown || null, history: history.length,"
|
||||
" type: (performance.getEntriesByType('navigation')[0] || {}).type || null, state: document.readyState})"))
|
||||
except Exception as problem: # the page may be gone or changing: that is what is being recorded
|
||||
record["read_error"] = "%s: %s" % (type(problem).__name__, problem)
|
||||
with self.lock:
|
||||
self.records.append(record)
|
||||
|
||||
|
||||
def _go_back_and_record(page, reads):
|
||||
"""``page.go_back(wait_until="load")``; when it raises, what the page says then and after a short pause is recorded first (the error is raised
|
||||
unchanged: the pause only dates a restore that lands after the wait, it decides nothing)."""
|
||||
try:
|
||||
page.go_back(wait_until="load")
|
||||
except Exception:
|
||||
reads.read(page, "right after the go_back raised")
|
||||
page.wait_for_timeout(2000)
|
||||
reads.read(page, "2 s later")
|
||||
raise
|
||||
+6
-81
@@ -15,7 +15,6 @@ import datetime
|
||||
import inspect
|
||||
import json
|
||||
import shutil
|
||||
import sysconfig
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -25,7 +24,6 @@ import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
import ci_ab_host as host # noqa: E402
|
||||
from _ab_host_declared import GFXTEST_ROW, gfxtest_rows # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
@@ -62,7 +60,7 @@ def judge(a, b, **kw):
|
||||
|
||||
|
||||
def expected():
|
||||
return gfxtest_rows()
|
||||
return host.load_expected()
|
||||
|
||||
|
||||
def fake_engine(root, package, payload=b"engine bytes"):
|
||||
@@ -241,9 +239,11 @@ def test_nothing_is_excused_there_is_no_list_of_noise():
|
||||
# -
|
||||
# The declared differences.
|
||||
|
||||
def test_the_file_declares_nothing_now_that_the_published_engine_no_longer_spawns_gfxtest_and_the_row_of_the_test_is_by_kind():
|
||||
assert host.load_expected() == [], "the published engine is the 70, which does not spawn gfxtest: its row would be stale in every run (the list may only shrink)"
|
||||
assert [(e["id"], e["os"], e["category"], e["name"]) for e in expected()] == [("gfxtest-69", "linux", "proc", "gfxtest")]
|
||||
def test_the_declared_difference_is_the_gfxtest_of_linux_by_kind_and_there_is_one_only():
|
||||
entries = expected()
|
||||
assert [(e["id"], e["os"], e["category"], e["name"]) for e in entries] == [("gfxtest-69", "linux", "proc", "gfxtest")]
|
||||
assert "0e896e4ee1" in entries[0]["reason"] and "GfxInfo.cpp:55" in entries[0]["reason"]
|
||||
assert len(entries) <= 1, "the list of declared differences may only shrink"
|
||||
|
||||
|
||||
def test_the_declared_gfxtest_difference_passes_in_an_a_b():
|
||||
@@ -3743,78 +3743,3 @@ def test_a_read_of_the_list_that_fails_after_stop_is_read_again_until_the_sessio
|
||||
with pytest.raises(host.TraceError, match="could not be read in 1 s after `logman stop`, the last error: logman query -ets failed with 0x80071068"):
|
||||
trace2._stop_session(clock.sleep, clock.now, 1.0)
|
||||
|
||||
|
||||
|
||||
# -
|
||||
# Each side's own install folder is that side's own package (engine final candidate, run 46227711139, Linux: the same read of the branding of the core, in the folder each side's core is installed in).
|
||||
|
||||
PUBLISHED_INSTALL = "/srv/ci/work/_temp/published-set/lib/python3.11/site-packages"
|
||||
CANDIDATE_INSTALL = "/opt/hostedtoolcache/Python/3.11.18/x64/lib/python3.11/site-packages"
|
||||
BRANDING = "invisible_core/branding/official/branding.zip"
|
||||
SIDES = {"published": PUBLISHED_INSTALL, "candidate": CANDIDATE_INSTALL}
|
||||
|
||||
|
||||
def a_side_context(monkeypatch, tmp_path, install):
|
||||
"""The Context `_context` makes in the python of a side whose packages are installed in `install` (sysconfig says so), launching /e/firefox."""
|
||||
monkeypatch.setattr(sysconfig, "get_paths", lambda *args, **kwargs: {"purelib": install, "platlib": install})
|
||||
return host._context("/e/firefox", False, tmp_path)
|
||||
|
||||
|
||||
def a_side_footprint(engine, ctx, touched):
|
||||
"""The footprint of a side that touched `touched` besides FILES: the host paths the classifier leaves, as the run records them."""
|
||||
fp = footprint(engine)
|
||||
found, ours = host.classify_paths(list(FILES) + list(touched), ctx)
|
||||
for seed in fp["seeds"]:
|
||||
seed["files"], seed["ours"] = found, ours
|
||||
return fp
|
||||
|
||||
|
||||
@pytest.mark.parametrize("side", ["published", "candidate"])
|
||||
def test_the_branding_of_the_core_each_side_reads_in_its_own_install_folder_is_its_own_package(monkeypatch, tmp_path, side):
|
||||
ctx = a_side_context(monkeypatch, tmp_path, SIDES[side])
|
||||
assert host.classify(SIDES[side] + "/" + BRANDING, ctx) == ("package", BRANDING)
|
||||
assert host.classify_paths([SIDES[side] + "/" + BRANDING], ctx) == ([], {"package": 1})
|
||||
|
||||
|
||||
def test_the_pair_of_the_run_is_no_difference_when_each_side_is_judged_in_its_own_install_folder(monkeypatch, tmp_path):
|
||||
a = a_side_footprint("firefox-70", a_side_context(monkeypatch, tmp_path, PUBLISHED_INSTALL), [PUBLISHED_INSTALL + "/" + BRANDING])
|
||||
b = a_side_footprint("candidate", a_side_context(monkeypatch, tmp_path, CANDIDATE_INSTALL), [CANDIDATE_INSTALL + "/" + BRANDING])
|
||||
report = judge(a, b, expected=[])
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert report["differences"] == [] and [s["ours"] for s in a["seeds"]] == [{"package": 1}, {"package": 1}] == [s["ours"] for s in b["seeds"]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("side,path", [
|
||||
("candidate", PUBLISHED_INSTALL + "/" + BRANDING), # the other side's install folder
|
||||
("published", CANDIDATE_INSTALL + "/" + BRANDING),
|
||||
("published", "/srv/ci/work/_temp/published-set/lib/python3.11/os.py"), # the python's own library, outside the folder packages are installed in
|
||||
("candidate", CANDIDATE_INSTALL + "-other/" + BRANDING), # a sibling folder that only starts with the same text
|
||||
("candidate", "/etc/machine-id"), # a path of the host, declared nowhere
|
||||
])
|
||||
def test_a_path_outside_the_side_s_own_install_folder_stays_a_host_path_and_a_difference(monkeypatch, tmp_path, side, path):
|
||||
a_ctx = a_side_context(monkeypatch, tmp_path, PUBLISHED_INSTALL)
|
||||
b_ctx = a_side_context(monkeypatch, tmp_path, CANDIDATE_INSTALL)
|
||||
own = {"published": PUBLISHED_INSTALL, "candidate": CANDIDATE_INSTALL}
|
||||
a = a_side_footprint("firefox-70", a_ctx, [own["published"] + "/" + BRANDING] + ([path] if side == "published" else []))
|
||||
b = a_side_footprint("candidate", b_ctx, [own["candidate"] + "/" + BRANDING] + ([path] if side == "candidate" else []))
|
||||
report = judge(a, b, expected=[])
|
||||
assert report["verdict"] == "red", "a read of %s by the %s side is nobody's package" % (path, side)
|
||||
assert {d["leaf"] for d in report["differences"]} == {"file." + path}
|
||||
|
||||
|
||||
def test_the_install_folders_of_a_process_are_where_its_python_installs_packages_with_the_real_folder_too(monkeypatch, tmp_path):
|
||||
real = tmp_path / "real"
|
||||
real.mkdir()
|
||||
monkeypatch.setattr(sysconfig, "get_paths", lambda *args, **kwargs: {"purelib": str(real), "platlib": str(real / ".." / "real")})
|
||||
assert str(real) in host.install_folders() and os.path.realpath(str(real / ".." / "real")) in host.install_folders()
|
||||
assert host.install_folders() <= {sysconfig.get_paths()["purelib"], os.path.realpath(sysconfig.get_paths()["purelib"]), sysconfig.get_paths()["platlib"],
|
||||
os.path.realpath(sysconfig.get_paths()["platlib"])}
|
||||
|
||||
|
||||
def test_the_row_of_the_graphics_probe_is_stale_when_the_published_engine_no_longer_spawns_it_and_the_file_declares_nothing():
|
||||
without = {k: n for k, n in KINDS.items() if k != "gfxtest"}
|
||||
a, b = footprint("firefox-70", kinds=without), a_candidate_without_gfxtest()
|
||||
report = judge(a, b, expected=expected())
|
||||
assert report["verdict"] == "red" and report["stale"] == ["gfxtest-69"] and report["declared"] == [] and report["differences"] == []
|
||||
assert report["problems"] == ["the declared difference 'gfxtest-69' (%s) does not show in this run: it is stale, remove it" % GFXTEST_ROW["reason"]]
|
||||
assert judge(a, b, expected=host.load_expected())["verdict"] == "green", "the file declares nothing: the same run is green"
|
||||
@@ -17,7 +17,6 @@ import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
import ci_ab_host as host # noqa: E402
|
||||
from _ab_host_declared import gfxtest_rows # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
@@ -67,7 +66,7 @@ def test_the_a_a_of_a_real_run_has_no_red_path(run, swap):
|
||||
@pytest.mark.parametrize("run", ("45077433049", "45088980743"))
|
||||
def test_the_a_b_of_a_real_run_whose_candidate_is_the_same_engine_has_no_red_path(run):
|
||||
first, again, candidate = real(run, "68"), real(run, "68-again"), real(run, "candidate")
|
||||
report = host.judge(first, candidate, expected=gfxtest_rows(), also_68=[again])
|
||||
report = host.judge(first, candidate, expected=host.load_expected(), also_68=[again])
|
||||
assert file_leaves(report) == set(), sorted(file_leaves(report))[:5]
|
||||
|
||||
|
||||
@@ -75,7 +74,7 @@ def test_the_install_folder_of_the_candidate_is_a_constant_difference_and_stays_
|
||||
"""Run 45060573559: the candidate was installed in another folder, so the hash of the folder in the names the updater makes (uninstall_ping_<hash>_..., updatelock-<hash>,
|
||||
updates\\<hash>) differs in EVERY launch of each side."""
|
||||
first, again, candidate = real("45060573559", "68"), real("45060573559", "68-again"), real("45060573559", "candidate")
|
||||
report = host.judge(first, candidate, expected=gfxtest_rows(), also_68=[again])
|
||||
report = host.judge(first, candidate, expected=host.load_expected(), also_68=[again])
|
||||
assert report["verdict"] == "red"
|
||||
hashed = {d["leaf"]: d for d in report["differences"] if d["category"] == "file" and any(
|
||||
h in d["leaf"] for h in ("uninstall_ping_", "updatelock-", BS + "updates" + BS, BS + "updates")) and "mozilla" in d["leaf"]}
|
||||
@@ -87,7 +86,7 @@ def test_the_install_folder_of_the_candidate_is_a_constant_difference_and_stays_
|
||||
|
||||
def test_the_declared_difference_of_a_real_linux_run_is_still_declared_and_not_red():
|
||||
first, again, candidate = real(LINUX_RUN, "68"), real(LINUX_RUN, "68-again"), real(LINUX_RUN, "candidate")
|
||||
report = host.judge(first, candidate, expected=gfxtest_rows(), also_68=[again])
|
||||
report = host.judge(first, candidate, expected=host.load_expected(), also_68=[again])
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert report["differences"] == [] and report["stale"] == []
|
||||
assert {d["leaf"] for d in report["declared"]} >= {"proc.gfxtest"} and {d["id"] for d in report["declared"]} == {"gfxtest-69"}
|
||||
@@ -226,7 +225,7 @@ GFX = "/var/lib/probe/gfxtest-only"
|
||||
def test_a_difference_the_list_declares_stays_declared_with_its_paths_and_is_not_lost_nor_red():
|
||||
kinds = dict(KINDS, gfxtest=1)
|
||||
a = built("firefox-68", only_in(MEASURED, (GFX,)), by={GFX: ["gfxtest"]}, kinds=kinds)
|
||||
report = judge(a, built("candidate"), expected=gfxtest_rows())
|
||||
report = judge(a, built("candidate"), expected=host.load_expected())
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert {d["leaf"] for d in report["declared"]} == {"proc.gfxtest"} | {"file." + GFX} and {d["id"] for d in report["declared"]} == {"gfxtest-69"}
|
||||
assert report["differences"] == []
|
||||
|
||||
@@ -18,8 +18,8 @@ Two modes, chosen by the environment as the gate chooses it:
|
||||
candidate set, or on all of them when the pull request changes a file of this oracle (AB_HOST_PR_SEEDS, exported by the step of e2e.yml that runs scripts/ci_ab_pr_seeds.py).
|
||||
This is the stability measurement: what the two traces do not agree on is a difference in diff-a-a.json, and red here says "what is compared is not stable". Nothing is
|
||||
excused: there is no list of noise.
|
||||
* a candidate (the gate's ab_oracle leg: INVPW_BINARY_PATH the candidate's binary, INVISIBLE_SEAL_FILE its seal): the A/A on the engine of the PUBLISHED SET (INVPW_PUBLISHED_PYTHON: its own core and wrapper in a venv, its engine fetched the way its core
|
||||
fetches one) on every seed of the set, then the published engine against the candidate, with the declared differences of ci/ab-host-expected.json.
|
||||
* a candidate (the gate's ab_oracle leg: INVPW_BINARY_PATH the candidate's binary, INVISIBLE_SEAL_FILE its seal): the A/A on the published firefox-68 (its seal and archive
|
||||
fetched the way the core fetches an engine) on every seed of the set, then the published engine against the candidate, with the declared differences of ci/ab-host-expected.json.
|
||||
|
||||
The launches run with a cache folder and a temp root of their own, so they leave nothing for the fontconfig test's cold launch and what the engine makes there is `ours`.
|
||||
|
||||
@@ -56,8 +56,7 @@ PR_SEEDS = 2
|
||||
def expected_footprints(candidate: bool, platform: str) -> list:
|
||||
"""The footprints a green run writes, sorted: the two runs of the published engine, the candidate's in the A/B, and on Windows the stock control's, which runs after a green
|
||||
A/A on every Windows run, a pull request included (run 45165805370: the control passed and the list without it was red)."""
|
||||
number = host.oracle.default_tag().rsplit("-", 1)[-1] # the engine of the published set (a pull request: the engine of the core in use)
|
||||
names = ["footprint-%s-again.json" % number, "footprint-%s.json" % number] + (["footprint-candidate.json"] if candidate else [])
|
||||
names = ["footprint-68-again.json", "footprint-68.json"] + (["footprint-candidate.json"] if candidate else [])
|
||||
return sorted(names + (["footprint-stock.json"] if platform == "win32" else []))
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def transcript(label="a", seeds=(11, 12)):
|
||||
"requests": {"GET A/": {"count": 1, "headers": [["Host", "journey-a.test:A"], ["Accept", "*/*"]], "name_orders": ["Host,Accept"],
|
||||
"body_length": 0}}}}},
|
||||
"https": {"h2": {"v1": {"connections": [{"alpn": "h2", "tls": wc.parse_client_hello(build_hello())}]}}},
|
||||
"webrtc": {"candidates": ["udp comp1 prio100 srflx <exit>"], "candidate_types": ["relay", "srflx"], "gathering": "complete"},
|
||||
"webrtc": {"candidates": ["udp comp1 prio100 srflx <exit>"], "gathering": "complete"},
|
||||
"idle": {"c1": {"destinations": {"connects": [], "dns": []}}},
|
||||
"lab": {"direct": {"witness_tcp": [], "witness_udp": [], "watcher": [], "doh_direct": [], "resolver_trap": [], "blind": []}},
|
||||
}
|
||||
@@ -1261,7 +1261,7 @@ def minimal_run():
|
||||
"end_stream": True}]}
|
||||
body = {"journey": {"steps": {"%02d" % i: step for i in range(17)}, "connects": ab.connect_summary(["127.0.0.1:7000"], norm),
|
||||
"dns": ab.dns_summary([("journey-a.test", 1, "lab")])}, "https": {"h2": {"v1": {"connections": [{"alpn": "h2", "tls": tls, "h2": h2}]}}},
|
||||
"webrtc": {"candidates": ["udp comp1 prio1 srflx <exit>"], "candidate_types": ["relay", "srflx"], "gathering": "complete"}, "idle": {"c1": {"destinations": {"connects": [], "dns": []}}},
|
||||
"webrtc": {"candidates": ["udp comp1 prio1 srflx <exit>"], "gathering": "complete"}, "idle": {"c1": {"destinations": {"connects": [], "dns": []}}},
|
||||
"lab": {"direct": {"witness_tcp": [], "witness_udp": [], "watcher": [], "doh_direct": [], "resolver_trap": [], "blind": []}}}
|
||||
leaves = ab.flatten({"11": body})
|
||||
by_category = {}
|
||||
@@ -1778,7 +1778,7 @@ def test_each_engine_run_of_the_network_oracle_has_a_cache_folder_of_its_own_tha
|
||||
def _ab_args(tmp_path, *extra):
|
||||
empty = tmp_path / "volatile.json"
|
||||
empty.write_text(json.dumps({"format": ab.VOLATILE_FORMAT, "entries": []}), encoding="utf-8")
|
||||
return ["ab", "--out", str(tmp_path / "out"), "--engine-tag", "firefox-68", "--published-binary", "published-ff", "--published-seal", "pub.seal.json", "--volatile", str(empty), "--seeds", "11,12", *extra]
|
||||
return ["ab", "--out", str(tmp_path / "out"), "--published-binary", "published-ff", "--published-seal", "pub.seal.json", "--volatile", str(empty), "--seeds", "11,12", *extra]
|
||||
|
||||
|
||||
def test_the_a_a_first_then_the_candidate_and_a_broken_control_stops_the_a_b(tmp_path, monkeypatch, capsys):
|
||||
@@ -2069,14 +2069,9 @@ time.sleep(60)
|
||||
|
||||
|
||||
def _alive(pid):
|
||||
"""Whether ``pid`` still runs. A process that exits between the two questions (it exists, then it is read) is gone, not an error: ``Process(pid)`` raises
|
||||
``NoSuchProcess`` for it (wrapper #603's round, pytest ubuntu py3.13: ``process PID not found`` from the grandchild the guard had just killed)."""
|
||||
import psutil
|
||||
|
||||
try:
|
||||
return psutil.pid_exists(pid) and psutil.Process(pid).status() != psutil.STATUS_ZOMBIE
|
||||
except psutil.NoSuchProcess:
|
||||
return False
|
||||
return psutil.pid_exists(pid) and psutil.Process(pid).status() != psutil.STATUS_ZOMBIE
|
||||
|
||||
|
||||
def _wait_gone(pid, seconds=10.0):
|
||||
@@ -2146,77 +2141,12 @@ def test_the_tree_guard_returns_at_the_timeout_kills_the_grandchild_and_names_th
|
||||
message = run.timeout_message("the network oracle", 3)
|
||||
assert message.startswith("the network oracle did not end within 3 s: the launch exit-pings of seed 11 (firefox-68-again) was alive for ")
|
||||
assert message.endswith(" s; its tree was killed")
|
||||
_assert_alive_since_its_line(run, spent)
|
||||
assert 2 <= run.launch["alive_s"] < 3 + 5
|
||||
finally:
|
||||
if pidfile.is_file():
|
||||
_kill_if_alive(int(pidfile.read_text()))
|
||||
|
||||
|
||||
def _assert_alive_since_its_line(run, spent):
|
||||
"""The time the message gives is measured from the launch line the oracle wrote to the moment the run was read, and it is what the message says.
|
||||
|
||||
⛔ NOT A WINDOW OF SECONDS. This used to assert ``2 <= alive_s < 8``: a child that a loaded machine starts late writes its launch line late, so the launch was alive for
|
||||
less than 2 s when the tree was killed, and the check failed although the guard had done everything right (the wrapper's pre-push under the load of the whole suite:
|
||||
``2 <= 1.75824``). What can be said whatever the load: the line cannot have been written before the run began nor after it was read, and its ``at`` is whole seconds
|
||||
(``launch_line``: ``timespec="seconds"``), so ``0 <= alive_s <= spent + 1``; and the message gives that number, not another."""
|
||||
alive = run.launch["alive_s"]
|
||||
assert alive is not None, "the launch line's time does not read: %r" % run.launch
|
||||
assert 0 <= alive <= spent + 1, "the launch was alive for %.2f s, outside what its line and the run allow (0 to %.2f s)" % (alive, spent + 1)
|
||||
assert ("was alive for %d s;" % alive) in run.timeout_message("the network oracle", 3)
|
||||
|
||||
|
||||
def test_a_process_that_exits_between_being_listed_and_being_read_is_gone(monkeypatch):
|
||||
"""The race at its source, made on purpose: the process is there when it is listed and gone when it is read. The old helper let ``NoSuchProcess`` out of
|
||||
``_alive`` and the test failed on a grandchild the guard had killed; now it is gone. A process that is really there is still alive (the control)."""
|
||||
import os
|
||||
|
||||
import psutil
|
||||
|
||||
def vanished(pid, *a, **k):
|
||||
raise psutil.NoSuchProcess(pid)
|
||||
|
||||
monkeypatch.setattr(psutil, "pid_exists", lambda pid: True)
|
||||
monkeypatch.setattr(psutil, "Process", vanished)
|
||||
assert _alive(424242) is False
|
||||
assert _wait_gone(424242, seconds=1.0) is True
|
||||
monkeypatch.undo()
|
||||
assert _alive(os.getpid()) is True
|
||||
|
||||
|
||||
def test_a_launch_that_began_late_is_named_with_the_time_since_its_own_line(tmp_path):
|
||||
"""The case the old check got wrong, made on purpose: a child slowed by a loaded machine writes its launch line one second before the tree is killed. The guard
|
||||
still names that launch and the time since ITS line (1 s); the old window ``2 <= alive_s < 8`` called that a failure, the check above accepts it."""
|
||||
import datetime
|
||||
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
killed = datetime.datetime(2026, 11, 26, 12, 0, 3, tzinfo=datetime.timezone.utc)
|
||||
began = killed - datetime.timedelta(seconds=1)
|
||||
text = crash.launch_line(11, "exit-pings", "firefox-68-again", at=began) + "\nthe grandchild is alive\n"
|
||||
run = crash.TreeRun(None, text, "", 3.0, True)
|
||||
run.launch = crash.last_launch(text, now=killed)
|
||||
assert run.launch["alive_s"] == 1.0
|
||||
assert not (2 <= run.launch["alive_s"] < 3 + 5), "the old window rejects this launch: that was the defect"
|
||||
_assert_alive_since_its_line(run, spent=3.0)
|
||||
assert run.timeout_message("the network oracle", 3).startswith(
|
||||
"the network oracle did not end within 3 s: the launch exit-pings of seed 11 (firefox-68-again) was alive for 1 s;")
|
||||
|
||||
|
||||
def test_the_check_refuses_a_time_its_line_cannot_give(tmp_path):
|
||||
"""The control: a launch line from before the run (or a clock that went back) gives a time the run could not have had, and the check says so."""
|
||||
import datetime
|
||||
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
killed = datetime.datetime(2026, 11, 26, 12, 0, 3, tzinfo=datetime.timezone.utc)
|
||||
for began, wrong in ((killed - datetime.timedelta(seconds=30), "30 s before a run of 3 s"), (killed + datetime.timedelta(seconds=5), "after the read")):
|
||||
text = crash.launch_line(11, "exit-pings", "firefox-68-again", at=began)
|
||||
run = crash.TreeRun(None, text, "", 3.0, True)
|
||||
run.launch = crash.last_launch(text, now=killed)
|
||||
with pytest.raises(AssertionError):
|
||||
_assert_alive_since_its_line(run, spent=3.0)
|
||||
|
||||
|
||||
def test_the_tree_guard_is_silent_when_the_run_ends_by_itself_and_keeps_stdout_stderr_and_the_code_apart(tmp_path):
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The network A/B oracle on a runner: the same journey on the local lab with the engine of the published set twice (the A/A, the control), and, with a candidate, against the candidate.
|
||||
"""The network A/B oracle on a runner: the same journey on the local lab with the published firefox-68 engine twice (the A/A, the control), and, with a candidate, against the candidate.
|
||||
|
||||
scripts/ci_ab_network.py walks the P4 journey (17 steps), one HTTPS site (HTTP/1.1 and HTTP/2), one HTTP/3 site, one WebRTC page and two idle launches through a SOCKS5 gateway in coherent mode, with the fake DoH,
|
||||
a witness and the watcher of direct connections, and writes what the lab saw as a transcript: the hosts contacted in order, the DNS questions, the TLS ClientHello, the HTTP/2 frames, every request head in
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
"""The probe of the WebRTC walk must hold the credential the lab's TURN server signs with, and the A/A must not count retransmissions (scripts/ci_ab_network.py, tests/_turn_chain.py), no browser.
|
||||
|
||||
Two defects of the oracle, each held here:
|
||||
|
||||
* The probe gave the TURN server ``lab``/``lab`` while the server signs its answers with the long-term key of its own password: the browser found the MESSAGE-INTEGRITY of every
|
||||
Allocate success invalid, dropped it, retransmitted up to the engine's maximum and ended in error 701, so no relay candidate was ever made. And the fake server never checked the
|
||||
request's own MESSAGE-INTEGRITY, so it "allocated" for a client with the wrong password. The probe now takes the credential as an argument (the walk passes the server's own
|
||||
constant) and the server refuses a request whose integrity is wrong, as a real one does.
|
||||
* The leaf ``seeds/<seed>/webrtc/udp/counts/<target>`` counted DATAGRAMS. A retransmission is network timing (the first RTO is 100 ms and doubles; a late 401 on a loaded host adds
|
||||
one), so 1+7 became 2+7 and the A/A of one engine read 8 against 9. The leaf now counts STUN TRANSACTIONS; a transaction with more transmits than the engine's maximum is a problem
|
||||
of the run, not a compared leaf.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import hmac
|
||||
import inspect
|
||||
import json
|
||||
import re
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import _turn_chain # noqa: E402
|
||||
import ci_ab_network as ab # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
COOKIE = 0x2112A442
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the count of transactions
|
||||
def walk_transcript(label, tids):
|
||||
"""A transcript of seed 4 whose WebRTC walk sent ``tids`` (one entry per datagram, in order) to the TURN server, summarised as ``run`` summarises them."""
|
||||
events = [{"target": ab.TURN_TARGET, "message": "stun-0x0003", "tid": tid, "opener": None} for tid in tids]
|
||||
return {"format": ab.FORMAT, "label": label, "platform": "linux",
|
||||
"seeds": {"4": {"webrtc": {"candidates": ["udp comp1 prio1 relay <exit>"], "candidate_types": ["relay"], "gathering": "complete", "udp": ab.udp_summary(events, ab.Normalizer({}))}}}}
|
||||
|
||||
|
||||
A, B = "aa" * 12, "bb" * 12
|
||||
#: The recorded shape: the first Allocate once and the second seven times, against the first twice (a late 401) and the second seven times.
|
||||
FIRST_RUN, SECOND_RUN = [A] + [B] * 7, [A] * 2 + [B] * 7
|
||||
|
||||
|
||||
def test_a_late_401_that_adds_a_retransmission_is_not_a_difference_of_the_engine():
|
||||
a, b = walk_transcript("a", FIRST_RUN), walk_transcript("b", SECOND_RUN)
|
||||
assert len(FIRST_RUN) == 8 and len(SECOND_RUN) == 9, "the recorded 8 against 9"
|
||||
counts = lambda t: t["seeds"]["4"]["webrtc"]["udp"]["counts"][ab.TURN_TARGET] # noqa: E731
|
||||
assert (counts(a), counts(b)) == (2, 2), "two transactions on both sides"
|
||||
report = ab.compare_transcripts(a, b, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and report["problems"] == [] and report["verdict"] == "green"
|
||||
|
||||
|
||||
def test_a_transaction_that_one_run_did_not_make_is_still_a_difference():
|
||||
a = walk_transcript("a", FIRST_RUN)
|
||||
c = walk_transcript("c", [A] + [B] * 7 + ["cc" * 12]) # a third transaction: the engine asked for something more
|
||||
report = ab.compare_transcripts(a, c, [], 0, "a", "c")
|
||||
assert [d["path"] for d in report["differences"]] == ["seeds/4/webrtc/udp/counts/%s" % ab.TURN_TARGET]
|
||||
assert (report["differences"][0]["a"], report["differences"][0]["b"]) == (2, 3) and report["verdict"] == "red"
|
||||
|
||||
|
||||
def test_a_datagram_that_is_not_stun_counts_one_each_and_the_messages_and_the_order_are_kept():
|
||||
events = [{"target": "127.0.0.1:5555", "message": "quic-long", "tid": None}] * 3 + [
|
||||
{"target": ab.TURN_TARGET, "message": "stun-0x0003", "tid": A}, {"target": ab.TURN_TARGET, "message": "stun-0x0113", "tid": A}]
|
||||
summary = ab.udp_summary(events, ab.Normalizer({}))
|
||||
assert summary == {"order": ["127.0.0.1:5555", ab.TURN_TARGET], "messages": {"127.0.0.1:5555": ["quic-long"], ab.TURN_TARGET: ["stun-0x0003", "stun-0x0113"]},
|
||||
"counts": {"127.0.0.1:5555": 3, ab.TURN_TARGET: 1}}
|
||||
|
||||
|
||||
def test_the_engines_maximum_is_the_pref_of_the_engine_and_a_transaction_over_it_is_a_problem_while_one_at_it_is_not():
|
||||
assert ab.STUN_MAX_TRANSMITS == 7
|
||||
source = (ROOT / "scripts" / "ci_ab_network.py").read_text(encoding="utf-8")
|
||||
assert "media.peerconnection.ice.stun_client_maximum_transmits" in source and "modules/libpref/init/all.js" in source
|
||||
|
||||
at_most = walk_transcript("a", [A] * 7)
|
||||
assert "over_limit" not in at_most["seeds"]["4"]["webrtc"]["udp"]
|
||||
assert ab.compare_transcripts(at_most, at_most, [], 0, "a", "a")["problems"] == []
|
||||
|
||||
over = walk_transcript("b", [A] * 8)
|
||||
assert over["seeds"]["4"]["webrtc"]["udp"]["over_limit"] == {ab.TURN_TARGET: [8]}
|
||||
report = ab.compare_transcripts(at_most, over, [], 0, "a", "b")
|
||||
assert report["verdict"] == "red" and len(report["problems"]) == 1 and "8 times" in report["problems"][0] and "maximum of 7" in report["problems"][0]
|
||||
assert report["problems"][0].startswith("b: ") and report["differences"] == [], "a problem of the run, not a compared leaf"
|
||||
both = ab.compare_transcripts(over, over, [], 0, "a", "b")
|
||||
assert len(both["problems"]) == 2 and both["differences"] == [], "each side that did it is named"
|
||||
|
||||
|
||||
def test_the_a_a_prints_a_transaction_over_the_maximum_as_a_fail_line_and_counts_it_among_the_problems(capsys):
|
||||
over = walk_transcript("a", [A] * 8)
|
||||
report = ab.compare_transcripts(over, walk_transcript("b", [A] * 7), [], 0, "a", "b")
|
||||
ab.print_report(report, True)
|
||||
out = capsys.readouterr().out
|
||||
assert re.search(r"^FAIL a: a STUN transaction to 198\.51\.100\.7:3478 was sent 8 times, more than the engine's maximum of 7 transmits", out, re.M), out
|
||||
assert "AB NETWORK A/A FAILED: 0 differences, 1 problems" in out and "\nDIFF " not in "\n" + out
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the credential of the probe
|
||||
def test_the_probe_has_no_credential_written_in_it_and_the_walk_passes_the_one_of_the_lab_server():
|
||||
js = ab.RTC_JS
|
||||
assert not re.search(r"""credential\s*:\s*['"]""", js) and not re.search(r"""username\s*:\s*['"]""", js), "no literal credential or user name in the page's script"
|
||||
assert "'lab'" not in js and _turn_chain.PASSWORD not in js
|
||||
assert "async (args) =>" in js and "const [stunUrl, turnUrl, username, credential] = args;" in js
|
||||
assert "{urls: [turnUrl], username, credential}" in js and "{urls: [stunUrl]}" in js, "the STUN entry has no credential, the TURN entry has the arguments"
|
||||
walk = inspect.getsource(ab.walk_webrtc)
|
||||
assert "from _turn_chain import PASSWORD" in walk and "[STUN_URL, TURN_URL, TURN_USERNAME, TURN_PASSWORD]" in walk
|
||||
assert _turn_chain.PASSWORD not in (ROOT / "scripts" / "ci_ab_network.py").read_text(encoding="utf-8"), "the password is written once, in tests/_turn_chain.py"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the TURN server refuses a wrong integrity
|
||||
def attribute(kind, value):
|
||||
return struct.pack("!HH", kind, len(value)) + value + b"\x00" * (-len(value) % 4)
|
||||
|
||||
|
||||
def signed(mtype, tid, user, password, extra=b""):
|
||||
"""A request as a client builds it (RFC 5389 section 15.4), written here and not taken from the server's module: USERNAME, REALM, NONCE, then MESSAGE-INTEGRITY, the
|
||||
HMAC-SHA1 under md5(user:realm:password) over the message with the length of the header counting the attribute itself."""
|
||||
body = attribute(0x0006, user.encode()) + attribute(0x0014, _turn_chain.REALM.encode()) + attribute(0x0015, _turn_chain.NONCE.encode()) + extra
|
||||
head = struct.pack("!HHI", mtype, len(body) + 24, COOKIE) + tid
|
||||
key = hashlib.md5(("%s:%s:%s" % (user, _turn_chain.REALM, password)).encode(), usedforsecurity=False).digest()
|
||||
return head + body + attribute(0x0008, hmac.new(key, head + body, hashlib.sha1).digest())
|
||||
|
||||
|
||||
def unsigned(mtype, tid):
|
||||
return struct.pack("!HHI", mtype, 0, COOKIE) + tid
|
||||
|
||||
|
||||
def ask(server, request):
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
client.settimeout(5)
|
||||
try:
|
||||
client.sendto(request, server.address)
|
||||
answer, _ = client.recvfrom(65536)
|
||||
finally:
|
||||
client.close()
|
||||
return struct.unpack("!H", answer[:2])[0], _turn_chain._attrs(answer)
|
||||
|
||||
|
||||
def error_code(attrs):
|
||||
return attrs[0x0009][2] * 100 + attrs[0x0009][3]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def turn():
|
||||
server = _turn_chain.TurnServer()
|
||||
try:
|
||||
yield server
|
||||
finally:
|
||||
server.close()
|
||||
|
||||
|
||||
def test_with_the_right_credential_an_allocate_is_answered_401_and_then_with_the_relay_and_nothing_is_refused(turn):
|
||||
kind, attrs = ask(turn, unsigned(0x0003, b"\x01" * 12))
|
||||
assert kind == 0x0113 and error_code(attrs) == 401 and attrs[0x0014] == _turn_chain.REALM.encode() and attrs[0x0015] == _turn_chain.NONCE.encode()
|
||||
kind, attrs = ask(turn, signed(0x0003, b"\x02" * 12, "lab", _turn_chain.PASSWORD))
|
||||
assert kind == 0x0103 and 0x0016 in attrs and 0x0008 in attrs, "the success carries XOR-RELAYED-ADDRESS and is signed"
|
||||
assert [a[2] for a in turn.allocations] == ["lab"] and turn.refused == []
|
||||
assert len(turn.seen) == 2 and [r[3] for r in turn.requests] == [False, True], "requests and seen keep their meaning"
|
||||
|
||||
|
||||
def test_with_a_wrong_credential_both_allocates_are_answered_401_and_nothing_is_allocated(turn):
|
||||
kind, attrs = ask(turn, unsigned(0x0003, b"\x01" * 12))
|
||||
assert kind == 0x0113 and error_code(attrs) == 401
|
||||
kind, attrs = ask(turn, signed(0x0003, b"\x02" * 12, "lab", "not-the-password"))
|
||||
assert kind == 0x0113 and error_code(attrs) == 401 and 0x0016 not in attrs, "no relay for a client with the wrong password"
|
||||
assert attrs[0x0014] == _turn_chain.REALM.encode() and attrs[0x0015] == _turn_chain.NONCE.encode(), "the 401 asks again, with the realm and the nonce"
|
||||
assert turn.allocations == []
|
||||
assert len(turn.refused) == 1 and turn.refused[0][2:4] == ("lab", b"\x02" * 12), turn.refused
|
||||
assert [r[3] for r in turn.requests] == [False, True], "the request still carried credentials: `requests` says what arrived, `refused` what was turned away"
|
||||
|
||||
|
||||
def test_a_request_with_a_user_name_and_no_integrity_or_a_changed_message_is_refused_too(turn):
|
||||
body = attribute(0x0006, b"lab")
|
||||
kind, _ = ask(turn, struct.pack("!HHI", 0x0003, len(body), COOKIE) + b"\x03" * 12 + body)
|
||||
assert kind == 0x0113 and turn.allocations == [] and len(turn.refused) == 1
|
||||
good = signed(0x0003, b"\x04" * 12, "lab", _turn_chain.PASSWORD)
|
||||
tampered = good[:20] + attribute(0x0006, b"lbb") + good[20 + len(attribute(0x0006, b"lab")):]
|
||||
assert len(tampered) == len(good) and ask(turn, tampered)[0] == 0x0113 and turn.allocations == [] and len(turn.refused) == 2
|
||||
assert ask(turn, good)[0] == 0x0103 and len(turn.allocations) == 1
|
||||
|
||||
|
||||
def test_a_refresh_with_a_wrong_integrity_is_refused_and_one_with_the_right_one_is_answered(turn):
|
||||
kind, attrs = ask(turn, signed(0x0004, b"\x05" * 12, "lab", "wrong"))
|
||||
assert kind == 0x0114 and error_code(attrs) == 401 and len(turn.refused) == 1
|
||||
kind, _ = ask(turn, signed(0x0004, b"\x06" * 12, "lab", _turn_chain.PASSWORD))
|
||||
assert kind == 0x0104 and len(turn.refused) == 1 and turn.allocations == []
|
||||
|
||||
|
||||
def test_the_integrity_check_is_the_one_of_rfc_5389_with_the_length_adjusted():
|
||||
good = signed(0x0003, b"\x07" * 12, "lab", _turn_chain.PASSWORD)
|
||||
assert _turn_chain.integrity_valid(good, "lab") and not _turn_chain.integrity_valid(good, "other")
|
||||
# an attribute after MESSAGE-INTEGRITY (a FINGERPRINT) does not change what is signed
|
||||
assert _turn_chain.integrity_valid(good + attribute(0x8028, b"\x00" * 4), "lab")
|
||||
assert not _turn_chain.integrity_valid(unsigned(0x0003, b"\x07" * 12), "lab") and not _turn_chain.integrity_valid(good[:-4], "lab")
|
||||
assert _turn_chain.long_term_key("lab") == hashlib.md5(("lab:%s:%s" % (_turn_chain.REALM, _turn_chain.PASSWORD)).encode(), usedforsecurity=False).digest()
|
||||
|
||||
|
||||
def test_the_server_of_the_lab_keeps_the_list_of_refusals_too():
|
||||
_gateway, turn_class, _page = ab.make_lab_classes()
|
||||
server = turn_class("127.0.0.1")
|
||||
try:
|
||||
assert server.refused == [] and isinstance(server, _turn_chain.TurnServer)
|
||||
kind, _ = ask(server, signed(0x0003, b"\x08" * 12, "lab", "wrong"))
|
||||
assert kind == 0x0113 and len(server.refused) == 1 and server.allocations == []
|
||||
kind, _ = ask(server, signed(0x0003, b"\x09" * 12, "lab", _turn_chain.PASSWORD))
|
||||
assert kind == 0x0103 and len(server.allocations) == 1
|
||||
json.dumps(server.exchanges)
|
||||
finally:
|
||||
server.close()
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the A/A proves the TURN path it compares
|
||||
def with_walk(transcript, **fields):
|
||||
"""The same transcript with fields of its seed-4 WebRTC walk replaced."""
|
||||
out = json.loads(json.dumps(transcript))
|
||||
out["seeds"]["4"]["webrtc"].update(fields)
|
||||
return out
|
||||
|
||||
|
||||
def turn_lines(report):
|
||||
"""The problems that say the TURN path did not work (a leaf that differs because of it is reported too, as a difference: that is not what is held here)."""
|
||||
return [p for p in report["problems"] if p.startswith("seeds/4/webrtc: ")]
|
||||
|
||||
|
||||
def test_a_transcript_whose_walk_made_no_relay_candidate_is_a_problem_on_both_sides_of_the_a_a():
|
||||
good = walk_transcript("a", FIRST_RUN)
|
||||
assert ab.compare_transcripts(good, walk_transcript("b", SECOND_RUN), [], 0, "a", "b")["problems"] == []
|
||||
no_relay = with_walk(walk_transcript("b", FIRST_RUN), candidate_types=["host", "srflx"])
|
||||
report = ab.compare_transcripts(good, no_relay, [], 0, "a", "b")
|
||||
assert report["verdict"] == "red" and len(turn_lines(report)) == 1
|
||||
assert report["problems"][0].startswith("seeds/4/webrtc: b made no relay candidate through the lab TURN (no error). Fix: the probe's credential must be the lab TURN's (tests/_turn_chain.py PASSWORD)")
|
||||
assert report["problems"][0].endswith("Rule: the A/A proves the TURN path it compares")
|
||||
both = ab.compare_transcripts(no_relay, with_walk(good, candidate_types=[]), [], 0, "a", "b")
|
||||
assert [p.split(" made")[0] for p in turn_lines(both)] == ["seeds/4/webrtc: a", "seeds/4/webrtc: b"], "each side that has none is named"
|
||||
|
||||
|
||||
def test_a_701_for_the_lab_turn_is_a_problem_even_when_a_relay_candidate_is_there_and_one_for_another_server_is_not(capsys):
|
||||
good = walk_transcript("a", FIRST_RUN)
|
||||
broken = with_walk(good, errors=["701 turn:%s?transport=udp" % ab.TURN_TARGET])
|
||||
report = ab.compare_transcripts(good, broken, [], 0, "a", "b")
|
||||
assert report["verdict"] == "red" and len(turn_lines(report)) == 1 and "701 turn:198.51.100.7:3478" in turn_lines(report)[0] and turn_lines(report)[0].startswith("seeds/4/webrtc: b ")
|
||||
ab.print_report(report, True)
|
||||
out = capsys.readouterr().out
|
||||
assert re.search(r"^FAIL seeds/4/webrtc: b made no relay candidate through the lab TURN \(701 turn:", out, re.M) and "AB NETWORK A/A FAILED:" in out and "2 problems" in out
|
||||
other = with_walk(good, errors=["701 stun:198.51.100.5:19302"])
|
||||
assert turn_lines(ab.compare_transcripts(good, other, [], 0, "a", "b")) == []
|
||||
|
||||
|
||||
def test_a_transcript_with_a_relay_candidate_and_no_error_is_not_a_problem_and_one_with_no_walk_says_nothing():
|
||||
good = walk_transcript("a", FIRST_RUN)
|
||||
assert ab.turn_path_problems(good, "a") == []
|
||||
assert ab.turn_path_problems({"seeds": {"4": {"journey": {}}}}, "a") == []
|
||||
assert ab.turn_path_problems({"seeds": {}}, "a") == []
|
||||
|
||||
|
||||
def test_a_request_the_lab_turn_refused_is_a_problem_and_the_count_is_not_a_compared_leaf():
|
||||
good = with_walk(walk_transcript("a", FIRST_RUN), turn={"messages": ["0x0003"], "allocated": True, "refused": 0})
|
||||
refused = with_walk(good, turn={"messages": ["0x0003"], "allocated": True, "refused": 2})
|
||||
report = ab.compare_transcripts(good, refused, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and len(report["problems"]) == 1 and len(turn_lines(report)) == 1 and "the lab TURN refused 2 request(s)" in report["problems"][0]
|
||||
assert ab.compare_transcripts(good, good, [], 0, "a", "b")["problems"] == []
|
||||
walk = inspect.getsource(ab.walk_webrtc)
|
||||
assert '"refused": len(lab.turn.refused)' in walk, "the walk writes what the lab TURN refused"
|
||||
@@ -1,263 +0,0 @@
|
||||
"""The TURN deallocation is evidence of the network oracle, never a compared leaf (scripts/ci_ab_network.py, tests/_turn_chain.py), no browser.
|
||||
|
||||
The engine ends an allocation with ONE Refresh whose LIFETIME is 0, best effort, while it shuts the TURN client down (nICEr ``nr_turn_client_deallocate``: "we are only sending a single
|
||||
request here because we are in the process of shutting everything down"). It reaches the lab in some walks and not in others for the same engine (the A/A of PR 611: two seeds whose
|
||||
``webrtc/turn/messages`` differed only by ``0x0004``). So it is recognised by what it MEANS (a Refresh, 0x0004, with LIFETIME, 0x000D, equal to 0), by the lab's TURN server, and the walk
|
||||
leaves it out of the messages and of the transactions the gateway counted for the TURN address; it goes to the evidence. More than one for one allocation, or one for an address that has
|
||||
no allocation, is a problem of the run. A Refresh that keeps the allocation alive (a lifetime above 0) is a message of the walk like any other.
|
||||
|
||||
The walks below are the real ``walk_webrtc`` on a real lab: a fake browser whose page sends the datagrams a TURN client sends to the lab's TURN server, over a socket on loopback, and
|
||||
whose gateway events are written as the gateway writes them.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import _turn_chain # noqa: E402
|
||||
import ci_ab_network as ab # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ALLOCATE, REFRESH_A, REFRESH_B, REFRESH_C = (bytes([n]) * 12 for n in (1, 2, 3, 4))
|
||||
RELAY_CANDIDATE = "candidate:1 1 udp 100 192.0.2.1 5000 typ relay"
|
||||
RULE = "Rule: the TURN deallocation is one best-effort send at teardown (nICEr nr_turn_client_deallocate)"
|
||||
|
||||
|
||||
def signed_refresh(tid, lifetime, user=b"lab"):
|
||||
"""A Refresh as a TURN client sends it after the 401: USERNAME and LIFETIME, signed with the long-term key."""
|
||||
body = _turn_chain._attr(0x0006, user) + _turn_chain._attr(0x000D, struct.pack("!I", lifetime))
|
||||
return _turn_chain._message(0x0004, tid, body, _turn_chain.long_term_key(user.decode()))
|
||||
|
||||
|
||||
def signed_allocate(tid, user=b"lab"):
|
||||
return _turn_chain._message(0x0003, tid, _turn_chain._attr(0x0006, user), _turn_chain.long_term_key(user.decode()))
|
||||
|
||||
|
||||
def wait_for(condition, what):
|
||||
for _ in range(200):
|
||||
if condition():
|
||||
return
|
||||
time.sleep(0.025)
|
||||
raise AssertionError("never happened: " + what)
|
||||
|
||||
|
||||
class Client:
|
||||
"""A TURN client's socket (one 5-tuple) that talks to the lab's TURN server and tells the recorder what the gateway would have written."""
|
||||
|
||||
def __init__(self, lab):
|
||||
self.lab = lab
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock.settimeout(5)
|
||||
self.sock.bind(("127.0.0.1", 0))
|
||||
|
||||
def send(self, datagram, message):
|
||||
before = len(self.lab.turn.requests)
|
||||
self.lab.gateway._route(_turn_chain.TURN_IP, _turn_chain.TURN_PORT, 1, datagram, 1, None) # the gateway writes the event, as it does for a browser's datagram
|
||||
self.sock.sendto(datagram, self.lab.turn.address)
|
||||
wait_for(lambda: len(self.lab.turn.requests) > before, "the lab TURN heard the datagram")
|
||||
self.sock.recvfrom(2048) # every request here is answered
|
||||
return self
|
||||
|
||||
def close(self):
|
||||
self.sock.close()
|
||||
|
||||
|
||||
def walk(label, script, times=None):
|
||||
"""The WebRTC walk of seed 4 on a lab, as ``run`` makes it, whose page does ``script(lab, clients)`` (the datagrams during the page, and at the close of the context, as the engine
|
||||
ends its allocations when the page closes), and the transcript of that seed."""
|
||||
clients = []
|
||||
|
||||
class Page:
|
||||
def goto(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def evaluate(self, js, arg):
|
||||
script(lab, clients, "page")
|
||||
result = {"candidates": [RELAY_CANDIDATE], "errors": [], "sdp": "v=0", "gathering": "complete"}
|
||||
return result if times is None else dict(result, times=times)
|
||||
|
||||
class Browser:
|
||||
def new_context(self, **kwargs):
|
||||
return types.SimpleNamespace(new_page=lambda: Page(), close=lambda: script(lab, clients, "close"))
|
||||
|
||||
try:
|
||||
with ab.Lab(host="127.0.0.1") as lab:
|
||||
out = ab.walk_webrtc(Browser(), lab)
|
||||
evidence = ab.webrtc_evidence(lab)
|
||||
finally:
|
||||
for client in clients:
|
||||
client.close()
|
||||
transcript = {"format": ab.FORMAT, "label": label, "platform": "linux", "seeds": {"4": {"webrtc": out}}}
|
||||
return transcript, evidence
|
||||
|
||||
|
||||
def allocation_then(*closing):
|
||||
"""A script: the allocation during the page, and ``closing`` (pairs of tid and lifetime sent from the allocation's own socket) when the context closes."""
|
||||
def script(lab, clients, stage):
|
||||
if stage == "page":
|
||||
clients.append(Client(lab).send(_turn_chain._message(0x0003, ALLOCATE, b""), "stun-0x0003"))
|
||||
clients[0].send(signed_allocate(ALLOCATE), "stun-0x0003")
|
||||
else:
|
||||
for tid, lifetime in closing:
|
||||
clients[0].send(signed_refresh(tid, lifetime), "stun-0x0004")
|
||||
return script
|
||||
|
||||
|
||||
def test_a_deallocation_seen_on_one_side_and_not_on_the_other_is_no_difference_of_the_walk():
|
||||
with_it, evidence_with = walk("a", allocation_then((REFRESH_A, 0)))
|
||||
without_it, evidence_without = walk("b", allocation_then())
|
||||
for transcript in (with_it, without_it):
|
||||
turn = transcript["seeds"]["4"]["webrtc"]["turn"]
|
||||
assert turn["messages"] == ["0x0003"], "the deallocation is not a message of the walk"
|
||||
assert transcript["seeds"]["4"]["webrtc"]["udp"]["counts"] == {ab.TURN_TARGET: 1}, "nor a transaction of the TURN address (the Allocate was one: its 401 and its retry share the id)"
|
||||
assert transcript["seeds"]["4"]["webrtc"]["udp"]["messages"] == {ab.TURN_TARGET: ["stun-0x0003"]}
|
||||
report = ab.compare_transcripts(with_it, without_it, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and report["problems"] == [] and report["verdict"] == "green", report["problems"]
|
||||
assert evidence_with["deallocation"]["seen"] is True and evidence_without["deallocation"] == {"seen": False, "records": []}
|
||||
|
||||
|
||||
def test_a_refresh_with_a_lifetime_above_zero_stays_in_the_messages_and_in_the_count():
|
||||
kept, evidence = walk("a", allocation_then((REFRESH_A, 600)))
|
||||
walk_of = kept["seeds"]["4"]["webrtc"]
|
||||
assert walk_of["turn"]["messages"] == ["0x0003", "0x0004"] and walk_of["udp"]["counts"] == {ab.TURN_TARGET: 2}
|
||||
assert walk_of["udp"]["messages"] == {ab.TURN_TARGET: ["stun-0x0003", "stun-0x0004"]}
|
||||
assert evidence["deallocation"] == {"seen": False, "records": []}
|
||||
assert walk_of["turn"]["deallocation"] == {"repeated": 0, "unallocated": 0, "early": 0}
|
||||
gone, _ = walk("b", allocation_then())
|
||||
differing = [d["path"] for d in ab.compare_transcripts(kept, gone, [], 0, "a", "b")["differences"]]
|
||||
assert "seeds/4/webrtc/turn/messages/1" in differing and "seeds/4/webrtc/udp/counts/%s" % ab.TURN_TARGET in differing, "a keep-alive IS the engine's doing, and is compared"
|
||||
|
||||
|
||||
def test_the_deallocation_goes_to_the_evidence_with_its_time_and_its_transaction_id():
|
||||
transcript, evidence = walk("a", allocation_then((REFRESH_A, 0)))
|
||||
json.dumps(evidence)
|
||||
(record,) = evidence["deallocation"]["records"]
|
||||
assert evidence["deallocation"]["seen"] is True
|
||||
assert record["tid"] == REFRESH_A.hex() and record["allocation"] == 0 and record["src"].startswith("127.0.0.1:")
|
||||
assert isinstance(record["t"], float) and record["t"] >= evidence["phase_t"]["webrtc"], "the time is the recorder's, the one of the other evidence"
|
||||
assert [d["tid"] for d in evidence["datagrams"]].count(REFRESH_A.hex()) == 1, "the datagram itself is still in the evidence, as every datagram is"
|
||||
assert transcript["seeds"]["4"]["webrtc"]["turn"]["deallocation"] == {"repeated": 0, "unallocated": 0, "early": 0}
|
||||
|
||||
|
||||
def test_two_deallocations_of_one_allocation_are_a_problem_and_no_leaf(capsys):
|
||||
twice, _ = walk("b", allocation_then((REFRESH_A, 0), (REFRESH_B, 0)))
|
||||
once, _ = walk("a", allocation_then((REFRESH_A, 0)))
|
||||
assert twice["seeds"]["4"]["webrtc"]["turn"]["deallocation"] == {"repeated": 1, "unallocated": 0, "early": 0}
|
||||
assert twice["seeds"]["4"]["webrtc"]["turn"]["messages"] == ["0x0003"]
|
||||
report = ab.compare_transcripts(once, twice, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and report["verdict"] == "red" and len(report["problems"]) == 1
|
||||
(line,) = report["problems"]
|
||||
assert line.startswith("seeds/4/webrtc: b: 1 allocation(s) of the lab TURN were ended by more than one deallocation") and ". Fix: " in line and line.endswith(RULE)
|
||||
ab.print_report(report, True)
|
||||
assert "FAIL " + line in capsys.readouterr().out
|
||||
assert ab.compare_transcripts(once, once, [], 0, "a", "a")["problems"] == []
|
||||
|
||||
|
||||
def test_a_deallocation_for_an_address_that_has_no_allocation_is_a_problem():
|
||||
def script(lab, clients, stage):
|
||||
if stage == "page":
|
||||
clients.append(Client(lab).send(signed_allocate(ALLOCATE), "stun-0x0003"))
|
||||
else:
|
||||
clients.append(Client(lab).send(signed_refresh(REFRESH_C, 0), "stun-0x0004")) # another socket: another address, which was never allocated
|
||||
|
||||
orphan, evidence = walk("b", script)
|
||||
assert orphan["seeds"]["4"]["webrtc"]["turn"]["deallocation"] == {"repeated": 0, "unallocated": 1, "early": 0}
|
||||
assert evidence["deallocation"]["records"][0]["allocation"] is None
|
||||
report = ab.compare_transcripts(orphan, orphan, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and len(report["problems"]) == 2, "each side that did it is named"
|
||||
assert all("from an address that has no allocation. Fix: " in p and p.endswith(RULE) for p in report["problems"])
|
||||
assert [p.split(": ")[1] for p in report["problems"]] == ["a", "b"]
|
||||
|
||||
|
||||
def serve_one(request_after_allocation):
|
||||
"""A TurnServer on loopback that heard an allocation and then ``request_after_allocation`` from the same socket; what it recorded."""
|
||||
server = _turn_chain.TurnServer()
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
client.settimeout(5)
|
||||
try:
|
||||
client.sendto(signed_allocate(ALLOCATE), server.address)
|
||||
assert struct.unpack("!H", client.recvfrom(2048)[0][:2])[0] == 0x0103
|
||||
client.sendto(request_after_allocation, server.address)
|
||||
answer, _ = client.recvfrom(2048)
|
||||
port = client.getsockname()[1]
|
||||
finally:
|
||||
client.close()
|
||||
server.close()
|
||||
return server, answer, port
|
||||
|
||||
|
||||
def test_the_turn_server_records_a_signed_refresh_with_lifetime_zero_as_a_deallocation_and_answers_it_as_it_always_did():
|
||||
server, answer, port = serve_one(signed_refresh(REFRESH_A, 0))
|
||||
assert struct.unpack("!H", answer[:2])[0] == 0x0104, "the answer to a Refresh is what it was"
|
||||
assert server.deallocations == [("127.0.0.1", port, REFRESH_A, server.deallocations[0][3], 0)]
|
||||
assert server.deallocation_tids() == {REFRESH_A} and [r[2] for r in server.deallocation_transactions()] == [REFRESH_A]
|
||||
assert len(server.allocations) == 1 and server.refused == []
|
||||
|
||||
|
||||
def test_the_turn_server_does_not_record_a_refresh_with_lifetime_600_or_any_other_message_as_a_deallocation():
|
||||
server, answer, _ = serve_one(signed_refresh(REFRESH_A, 600))
|
||||
assert struct.unpack("!H", answer[:2])[0] == 0x0104 and server.deallocations == [] and server.deallocation_tids() == set()
|
||||
server, _, _ = serve_one(_turn_chain._message(0x0008, REFRESH_B, _turn_chain._attr(0x0006, b"lab") + _turn_chain._attr(0x000D, struct.pack("!I", 0)),
|
||||
_turn_chain.long_term_key("lab")))
|
||||
assert server.deallocations == [], "a lifetime of 0 in another message type (CreatePermission) is not a deallocation: the type counts too"
|
||||
server, _, _ = serve_one(signed_refresh(REFRESH_C, 0)[:20] + _turn_chain._attr(0x0006, b"lab"))
|
||||
assert server.deallocations == [], "a Refresh with no LIFETIME is not one"
|
||||
|
||||
|
||||
def test_the_gateway_marks_a_deallocation_from_its_payload_and_the_mark_alone_takes_it_out_of_the_count():
|
||||
"""The datagram can be at the gateway before the lab's TURN server has recorded it: the count does not wait for the server."""
|
||||
def script(lab, clients, stage):
|
||||
if stage == "page":
|
||||
clients.append(Client(lab).send(signed_allocate(ALLOCATE), "stun-0x0003"))
|
||||
else:
|
||||
for tid, lifetime in ((REFRESH_A, 600), (REFRESH_B, 0)):
|
||||
lab.gateway._route(_turn_chain.TURN_IP, _turn_chain.TURN_PORT, 1, signed_refresh(tid, lifetime), 1, None) # never sent to the server
|
||||
|
||||
transcript, _ = walk("a", script)
|
||||
walk_of = transcript["seeds"]["4"]["webrtc"]
|
||||
assert walk_of["udp"]["counts"] == {ab.TURN_TARGET: 2} and walk_of["udp"]["messages"] == {ab.TURN_TARGET: ["stun-0x0003", "stun-0x0004"]}, "the 600 stays, the 0 goes, by the mark"
|
||||
with ab.Lab(host="127.0.0.1") as lab:
|
||||
lab.rec.set_phase("webrtc")
|
||||
for tid, lifetime in ((REFRESH_A, 600), (REFRESH_B, 0)):
|
||||
lab.gateway._route(_turn_chain.TURN_IP, _turn_chain.TURN_PORT, 1, signed_refresh(tid, lifetime), 1, None)
|
||||
lab.gateway._route("127.0.0.1", 5555, 1, signed_refresh(REFRESH_C, 0), 1, None)
|
||||
events = lab.rec.of("webrtc", "udp")
|
||||
assert [e["deallocation"] for e in events] == [False, True, True], "marked by meaning, whoever the datagram is for (the walk counts only the TURN address's)"
|
||||
|
||||
|
||||
def test_a_deallocation_before_the_page_began_closing_is_evidence_and_never_a_problem():
|
||||
"""The page's own times on the recorder's clock (the call of the page plus (closing - start) of its performance.now()) give ``early``. It stays in the facts as evidence, and is no problem:
|
||||
the page's clock is the engine's reduced-precision timer, and on Windows the published engine against itself came out "early" (wrapper #612's round), so it cannot order the two events."""
|
||||
def at_page(lab, clients, stage):
|
||||
if stage == "page":
|
||||
clients.append(Client(lab).send(signed_allocate(ALLOCATE), "stun-0x0003"))
|
||||
clients[0].send(signed_refresh(REFRESH_A, 0), "stun-0x0004") # the deallocation comes, by the page's clock, while the page is still open
|
||||
before, _ = walk("b", at_page, times={"start": 100.0, "closing": 100.0 + 600000.0}) # the page closes ten minutes after the call
|
||||
assert before["seeds"]["4"]["webrtc"]["turn"]["deallocation"] == {"repeated": 0, "unallocated": 0, "early": 1}
|
||||
report = ab.compare_transcripts(before, before, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and report["problems"] == []
|
||||
|
||||
after, _ = walk("b", allocation_then((REFRESH_A, 0)), times={"start": 100.0, "closing": 100.0})
|
||||
assert after["seeds"]["4"]["webrtc"]["turn"]["deallocation"] == {"repeated": 0, "unallocated": 0, "early": 0}
|
||||
assert ab.compare_transcripts(after, after, [], 0, "a", "b")["problems"] == []
|
||||
assert ab.closing_began(5.0, {"start": 250.0, "closing": 1750.0}) == 6.5 and ab.closing_began(5.0, None) is None and ab.closing_began(5.0, {"start": 1.0}) is None
|
||||
|
||||
|
||||
def test_the_recorded_windows_case_of_the_published_engine_against_itself_is_no_problem():
|
||||
"""Wrapper #612's round, e2e (network, windows): seeds 63 (firefox-68) and 6 (firefox-68-again) each had one deallocation "before the page began closing" by the page's clock."""
|
||||
def side(seed):
|
||||
return {"seeds": {seed: {"webrtc": {"turn": {"deallocation": {"repeated": 0, "unallocated": 0, "early": 1}}}}}}
|
||||
assert ab.turn_deallocation_problems(side("63"), "firefox-68") == []
|
||||
assert ab.turn_deallocation_problems(side("6"), "firefox-68-again") == []
|
||||
still = {"seeds": {"6": {"webrtc": {"turn": {"deallocation": {"repeated": 1, "unallocated": 1, "early": 1}}}}}}
|
||||
assert len(ab.turn_deallocation_problems(still, "firefox-68")) == 2
|
||||
@@ -1,594 +0,0 @@
|
||||
"""The WebRTC walk of the network oracle keeps its evidence OUTSIDE the leaves that are compared, and the hunt repeats that walk alone (scripts/ci_ab_network.py), no browser.
|
||||
|
||||
The A/A of the oracle found the published engine sending 8 or 9 TURN Allocate datagrams to 198.51.100.7:3478 in the WebRTC walk of one seed. The two readings are told apart by
|
||||
what each datagram carried and when: a STUN transaction id repeats on a retransmission, and the page's own ICE times and the moments of the stages say where the close fell. This file holds
|
||||
that evidence to its rules: it is in ``transcript["evidence"]`` (which ``compare_transcripts`` never reads), what the page returns for the compared fields is what it returned before, the
|
||||
transaction id comes from the header of the datagram, the gateway's summary is the one it was, and the hunt (``AB_NETWORK_HUNT=webrtc:<seed>:<n>``, wired into e2e-hunt.yml) writes one file
|
||||
per repetition and a summary and decides nothing.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
import ci_ab_network as ab # noqa: E402
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import _turn_chain # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
HUNT_WORKFLOW = ROOT / ".github" / "workflows" / "e2e-hunt.yml"
|
||||
|
||||
COOKIE = b"\x21\x12\xa4\x42"
|
||||
TID = bytes(range(1, 13))
|
||||
|
||||
|
||||
def stun(message_type: int, tid: bytes = TID) -> bytes:
|
||||
"""A STUN header (RFC 8489): type, length 0, the magic cookie and a 12-byte transaction id."""
|
||||
return message_type.to_bytes(2, "big") + b"\x00\x00" + COOKIE + tid
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the transaction id
|
||||
def test_the_transaction_id_is_bytes_8_to_20_of_a_stun_header():
|
||||
allocate = stun(0x0003)
|
||||
assert len(allocate) == 20
|
||||
assert ab.stun_tid(allocate) == TID.hex() == "0102030405060708090a0b0c"
|
||||
assert ab.stun_tid(allocate + b"\x00\x06\x00\x04lab\x00") == TID.hex(), "the attributes after the header change nothing"
|
||||
assert ab.stun_tid(stun(0x0113, b"\xff" * 12)) == "ff" * 12
|
||||
|
||||
|
||||
@pytest.mark.parametrize("payload", [b"", b"\xc3" + b"\x00" * 40, b"\x40" + b"\x01" * 30, b"\x00\x03\x00\x00" + b"\x00" * 16, stun(0x0003)[:19], b"hello world" * 3])
|
||||
def test_a_datagram_that_is_not_stun_has_no_transaction_id(payload):
|
||||
assert ab.stun_tid(payload) is None
|
||||
|
||||
|
||||
def test_the_gateway_writes_the_transaction_id_of_each_datagram_and_the_summary_of_the_phase_does_not_change():
|
||||
from _doh_servers import FakeDoh
|
||||
from _turn_chain import TURN_IP, TURN_PORT
|
||||
|
||||
assert "%s:%d" % (TURN_IP, TURN_PORT) == ab.TURN_TARGET, "the target the hunt counts is the TURN server of the lab"
|
||||
gateway_class, turn_class, _page = ab.make_lab_classes()
|
||||
rec = ab.Recorder()
|
||||
doh = FakeDoh({})
|
||||
turn = turn_class("127.0.0.1")
|
||||
gateway = gateway_class(rec, doh, turn, "127.0.0.1", "198.51.100.9")
|
||||
try:
|
||||
rec.set_phase("webrtc")
|
||||
gateway._route(TURN_IP, TURN_PORT, 1, stun(0x0003), 1, None)
|
||||
gateway._route(TURN_IP, TURN_PORT, 1, stun(0x0003), 1, None)
|
||||
gateway._route(TURN_IP, TURN_PORT, 1, stun(0x0003, b"\x09" * 12), 1, None)
|
||||
gateway._route("127.0.0.1", 5555, 1, b"\xc3" + b"\x00" * 20, 1, None)
|
||||
finally:
|
||||
gateway.close()
|
||||
turn.close()
|
||||
doh.close()
|
||||
events = rec.of("webrtc", "udp")
|
||||
assert [(e["target"], e["message"], e["tid"]) for e in events] == [
|
||||
(ab.TURN_TARGET, "stun-0x0003", TID.hex()), (ab.TURN_TARGET, "stun-0x0003", TID.hex()), (ab.TURN_TARGET, "stun-0x0003", "09" * 12), ("127.0.0.1:5555", "quic-long", None)]
|
||||
norm = ab.Normalizer({})
|
||||
# the count is of TRANSACTIONS: the first Allocate was sent twice (one transaction), the second once, and the QUIC datagram has no transaction id (one)
|
||||
assert ab.udp_summary(events, norm)["counts"] == {ab.TURN_TARGET: 2, "127.0.0.1:5555": 1}
|
||||
without = [{k: v for k, v in e.items() if k != "tid"} for e in events]
|
||||
assert ab.udp_summary(without, norm)["counts"] == {ab.TURN_TARGET: 3, "127.0.0.1:5555": 1}, "with no transaction id every datagram counts one"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the evidence key
|
||||
def lab_with(rec, **webrtc):
|
||||
return types.SimpleNamespace(rec=rec, webrtc=webrtc)
|
||||
|
||||
|
||||
def recorded_walk():
|
||||
"""A recorder that went through the stages of the walk, with the datagrams a TURN server's client sends: the first Allocate three times, the authenticated one twice, one late."""
|
||||
rec = ab.Recorder()
|
||||
rec.set_phase("webrtc")
|
||||
for target, message, tid in [(ab.TURN_TARGET, "stun-0x0003", "aa" * 12), (ab.TURN_TARGET, "stun-0x0003", "aa" * 12), ("198.51.100.5:19302", "stun-0x0001", "bb" * 12),
|
||||
(ab.TURN_TARGET, "stun-0x0003", "cc" * 12), ("127.0.0.1:5555", "quic-long", None)]:
|
||||
rec.event("udp", target=target, message=message, tid=tid, opener=None)
|
||||
counted = len(rec.of("webrtc", "udp"))
|
||||
rec.set_phase("webrtc.end")
|
||||
rec.event("udp", target=ab.TURN_TARGET, message="stun-0x0003", tid="cc" * 12, opener=None)
|
||||
return rec, counted
|
||||
|
||||
|
||||
def test_the_evidence_of_the_walk_lists_every_datagram_with_its_time_target_message_and_transaction_and_the_moments_of_the_stages():
|
||||
rec, counted = recorded_walk()
|
||||
page = {"start": 1.0, "offer": 2.0, "candidates": [{"t": 3.0, "type": "host"}], "errors": [{"t": 4.0, "code": 701, "url": "turn:x"}], "gathered": 5.0, "closing": 6.0, "closed": 6.5}
|
||||
evidence = ab.webrtc_evidence(lab_with(rec, counted=counted, evaluate={"called": 0.5, "returned": 7.0}, page=page))
|
||||
json.dumps(evidence)
|
||||
assert set(evidence) == {"phase_t", "evaluate", "page", "datagrams", "turn", "returned", "send_errors", "deallocation"}
|
||||
assert evidence["page"] == page and evidence["evaluate"] == {"called": 0.5, "returned": 7.0}
|
||||
assert set(evidence["phase_t"]) == {"webrtc", "webrtc.end"} and evidence["phase_t"]["webrtc"] <= evidence["phase_t"]["webrtc.end"]
|
||||
datagrams = evidence["datagrams"]
|
||||
assert [(d["target"], d["message"], d["tid"], d["phase"], d["counted"]) for d in datagrams] == [
|
||||
(ab.TURN_TARGET, "stun-0x0003", "aa" * 12, "webrtc", True), (ab.TURN_TARGET, "stun-0x0003", "aa" * 12, "webrtc", True), ("198.51.100.5:19302", "stun-0x0001", "bb" * 12, "webrtc", True),
|
||||
(ab.TURN_TARGET, "stun-0x0003", "cc" * 12, "webrtc", True), ("127.0.0.1:5555", "quic-long", None, "webrtc", True),
|
||||
(ab.TURN_TARGET, "stun-0x0003", "cc" * 12, "webrtc.end", False)]
|
||||
assert all(isinstance(d["t"], float) for d in datagrams) and [d["t"] for d in datagrams] == sorted(d["t"] for d in datagrams)
|
||||
|
||||
|
||||
def test_the_evidence_of_the_walk_leaves_out_the_datagrams_of_other_stages_and_says_nothing_when_the_walk_never_ran():
|
||||
rec = ab.Recorder()
|
||||
rec.set_phase("h3")
|
||||
rec.event("udp", target="127.0.0.1:1", message="quic-long", tid=None, opener=None)
|
||||
empty = ab.webrtc_evidence(lab_with(rec))
|
||||
assert empty == {"phase_t": {"webrtc": None, "webrtc.end": None}, "evaluate": None, "page": None, "datagrams": [], "turn": [], "returned": [], "send_errors": [], "deallocation": {"seen": False, "records": []}}
|
||||
|
||||
|
||||
def evidence_transcript(label, datagrams):
|
||||
"""A transcript as ``run`` writes it: ``seeds`` (compared) and ``evidence`` (not), with the webrtc evidence of a real recorder in it."""
|
||||
rec = ab.Recorder()
|
||||
rec.set_phase("webrtc")
|
||||
for tid in datagrams:
|
||||
rec.event("udp", target=ab.TURN_TARGET, message="stun-0x0003", tid=tid, opener=None)
|
||||
rec.set_phase("webrtc.end")
|
||||
evidence = ab.webrtc_evidence(lab_with(rec, counted=len(datagrams), page={"gathered": float(len(datagrams))}))
|
||||
return {"format": ab.FORMAT, "label": label, "platform": "linux",
|
||||
"seeds": {"4": {"webrtc": {"candidates": ["udp comp1 prio1 srflx <exit>"], "candidate_types": ["relay", "srflx"], "gathering": "complete", "udp": {"counts": {ab.TURN_TARGET: 8}}}}},
|
||||
"evidence": {"format": ab.EVIDENCE_FORMAT, "seeds": {"4": {"journey": [], "https": {}, "h3": [], "webrtc": evidence}}}}
|
||||
|
||||
|
||||
def test_two_transcripts_that_differ_only_in_the_evidence_of_the_walk_have_no_difference():
|
||||
a = evidence_transcript("a", ["aa" * 12] * 8)
|
||||
b = evidence_transcript("b", ["aa" * 12] * 7 + ["bb" * 12, "cc" * 12])
|
||||
assert a["evidence"] != b["evidence"] and a["seeds"] == b["seeds"]
|
||||
report = ab.compare_transcripts(a, b, [], 0, "a", "b")
|
||||
assert report["differences"] == [] and report["problems"] == [] and report["verdict"] == "green"
|
||||
assert report["leaves"] == ab.compare_transcripts(a, a, [], 0, "a", "a")["leaves"]
|
||||
assert ab.flatten(a["seeds"]).keys().isdisjoint({p for p in ab.flatten(a["evidence"]["seeds"], "evidence")}), "no leaf of the evidence is a leaf of the seeds"
|
||||
# and the same difference in the compared part IS one: the control of the test above
|
||||
c = json.loads(json.dumps(a))
|
||||
c["seeds"]["4"]["webrtc"]["udp"]["counts"][ab.TURN_TARGET] = 9
|
||||
assert [d["path"] for d in ab.compare_transcripts(a, c, [], 0, "a", "c")["differences"]] == ["seeds/4/webrtc/udp/counts/198.51.100.7:3478"]
|
||||
|
||||
|
||||
def test_a_run_writes_the_evidence_of_the_walk_under_the_evidence_of_its_seed(tmp_path, monkeypatch):
|
||||
import _lab_egress
|
||||
import ci_crash_evidence as crash
|
||||
|
||||
def walk_seed(binary, seed, with_idle, patch):
|
||||
ab.EVIDENCE[str(seed)] = evidence_transcript("x", ["aa" * 12] * 2)["evidence"]["seeds"]["4"]
|
||||
return {"webrtc": {}}
|
||||
|
||||
monkeypatch.setattr(ab, "walk_seed", walk_seed)
|
||||
monkeypatch.setattr(_lab_egress, "install", lambda patch, work: None)
|
||||
monkeypatch.setenv(crash.CRASH_DIR_ENV, str(tmp_path / "t.crash"))
|
||||
try:
|
||||
assert ab.run("/e/firefox", "firefox-68", (4,), tmp_path / "t.json") == 0
|
||||
finally:
|
||||
crash.stop_probe()
|
||||
document = json.loads((tmp_path / "t.json").read_text(encoding="utf-8"))
|
||||
assert [d["tid"] for d in document["evidence"]["seeds"]["4"]["webrtc"]["datagrams"]] == ["aa" * 12] * 2
|
||||
assert set(document) >= {"seeds", "evidence", "exits"} and "webrtc" not in document["evidence"], "the evidence is under the seed, not beside the seeds"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the page's probe
|
||||
def test_the_probe_returns_what_it_returned_and_its_times_beside_it():
|
||||
js = ab.RTC_JS
|
||||
assert "return {candidates: cands, errors, sdp, gathering, times: T};" in js, "the four fields that are compared come first and unchanged; `times` is the only addition"
|
||||
assert "cands.push(e.candidate.candidate)" in js and "errors.push({code: e.errorCode, url: e.url})" in js
|
||||
for what in ("T.offer = performance.now()", "T.gathered = performance.now()", "T.closing = performance.now()", "T.closed = performance.now()"):
|
||||
assert what in js, what
|
||||
assert re.search(r"T\.candidates\.push\(\{t: performance\.now\(\), type: ", js), "each icecandidate, with its type"
|
||||
assert re.search(r"T\.errors\.push\(\{t: performance\.now\(\), code: e\.errorCode, url: e\.url\}\)", js), "each icecandidateerror, with its code and url"
|
||||
assert js.index("T.closing = performance.now()") < js.index("pc.close()") < js.index("T.closed = performance.now()"), "the close is bracketed by its two times"
|
||||
|
||||
|
||||
def test_what_the_page_measures_of_itself_is_in_the_evidence_and_the_summary_of_the_walk_is_the_same_with_any_times():
|
||||
class Page:
|
||||
def __init__(self, result):
|
||||
self.result = result
|
||||
|
||||
def goto(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def evaluate(self, js, arg):
|
||||
assert js == ab.RTC_JS and arg == [ab.STUN_URL, ab.TURN_URL, ab.TURN_USERNAME, _turn_chain.PASSWORD]
|
||||
return json.loads(json.dumps(self.result))
|
||||
|
||||
class Browser:
|
||||
def __init__(self, result):
|
||||
self.page = Page(result)
|
||||
|
||||
def new_context(self, **kwargs):
|
||||
return types.SimpleNamespace(new_page=lambda: self.page, close=lambda: None)
|
||||
|
||||
base = {"candidates": ["candidate:1 1 udp 100 192.0.2.1 5000 typ host"], "errors": [{"code": 701, "url": "turn:198.51.100.7:3478"}], "sdp": "v=0\r\n", "gathering": "complete"}
|
||||
outs, labs = [], []
|
||||
for times in ({"start": 1.0, "gathered": 2.0}, {"start": 5.5, "gathered": 9.25, "closed": 11.0}, None):
|
||||
result = dict(base) if times is None else dict(base, times=times)
|
||||
with ab.Lab(host="127.0.0.1") as lab:
|
||||
outs.append(json.dumps(ab.walk_webrtc(Browser(result), lab), sort_keys=True))
|
||||
labs.append(lab.webrtc)
|
||||
assert outs[0] == outs[1] == outs[2], "the walk's summary does not depend on the page's times"
|
||||
assert '"times"' not in outs[0] and "gathered" not in outs[0]
|
||||
assert [x["page"] for x in labs] == [{"start": 1.0, "gathered": 2.0}, {"start": 5.5, "gathered": 9.25, "closed": 11.0}, None]
|
||||
assert all(x["evaluate"]["called"] <= x["evaluate"]["returned"] for x in labs) and all(isinstance(x["counted"], int) for x in labs)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the TURN server's answers and the relay's return path
|
||||
def signed_allocate(tid, user=b"lab"):
|
||||
"""An Allocate with USERNAME and the MESSAGE-INTEGRITY of the long-term key (the server of the lab checks it)."""
|
||||
from _turn_chain import _attr, _message, long_term_key
|
||||
|
||||
return _message(0x0003, tid, _attr(0x0006, user), long_term_key(user.decode()))
|
||||
|
||||
|
||||
def test_the_turn_server_of_the_lab_writes_every_request_with_what_it_carried_and_every_answer_with_where_it_went_and_answers_as_it_always_did():
|
||||
import socket
|
||||
|
||||
from _turn_chain import RELAYED, TurnServer
|
||||
|
||||
_gateway, turn_class, _page = ab.make_lab_classes()
|
||||
turn = turn_class("127.0.0.1")
|
||||
assert isinstance(turn, TurnServer) and isinstance(turn.sock, ab.ExchangeSocket)
|
||||
ticks = iter(x / 10 for x in range(1, 100))
|
||||
turn.clock = lambda: next(ticks)
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
client.settimeout(5)
|
||||
client.bind(("127.0.0.1", 0))
|
||||
first, second = b"\x01" * 12, b"\x02" * 12
|
||||
try:
|
||||
client.sendto(stun(0x0003, first), turn.address)
|
||||
unauthorized, _ = client.recvfrom(2048)
|
||||
client.sendto(signed_allocate(second), turn.address)
|
||||
success, _ = client.recvfrom(2048)
|
||||
client.sendto(b"not stun at all, twenty-odd bytes", turn.address)
|
||||
client.sendto(stun(0x0001, b"\x03" * 12), turn.address) # a Binding request: the server of the lab does not answer it
|
||||
port = client.getsockname()[1]
|
||||
for _ in range(100):
|
||||
if len(turn.exchanges) == 3:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
finally:
|
||||
client.close()
|
||||
turn.close()
|
||||
assert int.from_bytes(unauthorized[:2], "big") == 0x0113 and int.from_bytes(success[:2], "big") == 0x0103, "what the server answers is what it answered"
|
||||
assert len(turn.seen) == 3 and [a[2] for a in turn.allocations] == ["lab"] and turn.allocations[0][:2] == ("127.0.0.1", port)
|
||||
one, two, three = turn.exchanges
|
||||
json.dumps(turn.exchanges)
|
||||
assert (one["t"], one["src"], one["tid"], one["type"], one["username"], one["integrity"]) == (0.1, "127.0.0.1:%d" % port, first.hex(), "0x0003", False, False)
|
||||
assert one["responses"] == [{"t": 0.2, "tid": first.hex(), "type": "0x0113", "to": "127.0.0.1:%d" % port, "relayed": None, "mapped": None, "error": 401}]
|
||||
assert (two["tid"], two["type"], two["username"], two["integrity"]) == (second.hex(), "0x0003", True, True)
|
||||
(answer,) = two["responses"]
|
||||
assert answer["type"] == "0x0103" and answer["to"] == "127.0.0.1:%d" % port and answer["error"] is None
|
||||
assert answer["relayed"] == "%s:%d" % RELAYED and answer["mapped"] == "127.0.0.1:%d" % port, "the XOR-RELAYED-ADDRESS and XOR-MAPPED-ADDRESS the server put in, decoded"
|
||||
assert (three["type"], three["responses"]) == ("0x0001", []), "a request the server does not answer has no answer in its record"
|
||||
|
||||
|
||||
def test_a_failure_of_the_record_never_reaches_the_server():
|
||||
class Owner:
|
||||
exchanges = None # append on None: the record fails
|
||||
|
||||
def clock(self):
|
||||
raise RuntimeError("no clock")
|
||||
|
||||
class Raw:
|
||||
def __init__(self):
|
||||
self.sent = []
|
||||
|
||||
def recvfrom(self, size):
|
||||
return stun(0x0003), ("127.0.0.1", 9)
|
||||
|
||||
def sendto(self, data, address):
|
||||
self.sent.append((data, address))
|
||||
return len(data)
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
raw = Raw()
|
||||
sock = ab.ExchangeSocket(raw, Owner())
|
||||
assert sock.recvfrom(10) == (stun(0x0003), ("127.0.0.1", 9))
|
||||
assert sock.sendto(stun(0x0113), ("127.0.0.1", 9)) == 20 and raw.sent == [(stun(0x0113), ("127.0.0.1", 9))]
|
||||
sock.close()
|
||||
assert raw.closed is True
|
||||
|
||||
|
||||
def test_an_xor_address_is_decoded_and_an_answer_with_no_request_has_a_record_of_its_own():
|
||||
from _turn_chain import _attr, _xor_addr
|
||||
|
||||
assert ab.xor_address(_xor_addr("198.51.100.7", 50000)) == "198.51.100.7:50000"
|
||||
assert ab.xor_address(None) is None and ab.xor_address(b"\x00\x02" + b"\x00" * 18) is None
|
||||
assert ab.stun_attributes(stun(0x0003) + _attr(0x0006, b"lab") + _attr(0x0008, b"\x00" * 20)) == {0x0006: b"lab", 0x0008: b"\x00" * 20}
|
||||
assert ab.stun_attributes(stun(0x0003) + b"\x00\x06\x00\x40ab") == {}, "a truncated attribute says nothing"
|
||||
owner = types.SimpleNamespace(exchanges=[], clock=lambda: 1.5)
|
||||
ab.ExchangeSocket(types.SimpleNamespace(sendto=lambda data, address: 0), owner).sendto(stun(0x0113, b"\x07" * 12), ("127.0.0.1", 5))
|
||||
assert owner.exchanges == [{"t": 1.5, "src": None, "tid": "07" * 12, "type": None, "username": None, "integrity": None,
|
||||
"responses": [{"t": 1.5, "tid": "07" * 12, "type": "0x0113", "to": "127.0.0.1:5", "relayed": None, "mapped": None, "error": None}]}]
|
||||
|
||||
|
||||
def test_the_relay_writes_each_datagram_it_sends_back_with_the_address_it_claims_and_the_five_tuple_it_goes_to_and_still_sends_it():
|
||||
import socket
|
||||
import struct
|
||||
|
||||
from _doh_servers import FakeDoh
|
||||
|
||||
gateway_class, turn_class, _page = ab.make_lab_classes()
|
||||
rec = ab.Recorder()
|
||||
doh = FakeDoh({})
|
||||
turn = turn_class("127.0.0.1")
|
||||
gateway = gateway_class(rec, doh, turn, "127.0.0.1", "198.51.100.9")
|
||||
receiver = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
receiver.settimeout(5)
|
||||
receiver.bind(("127.0.0.1", 0))
|
||||
relay = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
relay.bind(("127.0.0.1", 0))
|
||||
try:
|
||||
rec.set_phase("webrtc")
|
||||
gateway._deliver(relay, receiver.getsockname(), "198.51.100.7", 3478, stun(0x0103, b"\x05" * 12))
|
||||
gateway._deliver(relay, receiver.getsockname(), "198.51.100.5", 19302, b"\xc3" + b"\x00" * 5)
|
||||
first, _ = receiver.recvfrom(2048)
|
||||
second, _ = receiver.recvfrom(2048)
|
||||
relay_address = relay.getsockname()
|
||||
client_address = receiver.getsockname()
|
||||
finally:
|
||||
receiver.close()
|
||||
relay.close()
|
||||
gateway.close()
|
||||
turn.close()
|
||||
doh.close()
|
||||
assert first == b"\x00\x00\x00\x01" + socket.inet_aton("198.51.100.7") + struct.pack("!H", 3478) + stun(0x0103, b"\x05" * 12), "the datagram is sent as it always was"
|
||||
assert second.endswith(b"\xc3" + b"\x00" * 5)
|
||||
back = rec.of("webrtc", "udp_back")
|
||||
assert [(e["claimed"], e["to"], e["relay"], e["message"], e["tid"]) for e in back] == [
|
||||
("198.51.100.7:3478", "%s:%d" % client_address, "%s:%d" % relay_address, "stun-0x0103", "05" * 12),
|
||||
("198.51.100.5:19302", "%s:%d" % client_address, "%s:%d" % relay_address, "quic-long", None)]
|
||||
assert rec.of("webrtc", "udp") == [], "a datagram back is not a datagram of the browser: the compared UDP summary does not see it"
|
||||
|
||||
|
||||
def test_the_evidence_keeps_the_turn_exchanges_of_the_walk_and_the_return_datagrams_and_the_gateways_send_errors():
|
||||
rec = ab.Recorder()
|
||||
rec.set_phase("webrtc")
|
||||
rec.event("udp_back", claimed="198.51.100.7:3478", to="127.0.0.1:40000", relay="127.0.0.1:41000", message="stun-0x0103", tid="aa" * 12)
|
||||
rec.set_phase("webrtc.end")
|
||||
rec.phase_t["webrtc"] = 5.0 # the stage began at 5 s on the recorder's clock
|
||||
before = {"t": 1.0, "src": "x:1", "tid": "00" * 12, "type": "0x0003", "username": False, "integrity": False, "responses": []}
|
||||
inside = {"t": 5.5, "src": "127.0.0.1:40000", "tid": "aa" * 12, "type": "0x0003", "username": True, "integrity": True, "responses": []}
|
||||
lab = types.SimpleNamespace(rec=rec, webrtc={}, turn=types.SimpleNamespace(exchanges=[before, inside]), gateway=types.SimpleNamespace(send_errors=["the answer to the client: OSError x"]))
|
||||
evidence = ab.webrtc_evidence(lab)
|
||||
json.dumps(evidence)
|
||||
assert evidence["turn"] == [inside], "the exchanges of the walk, not what the server heard before its stage"
|
||||
assert [(e["claimed"], e["to"], e["relay"], e["tid"], e["phase"]) for e in evidence["returned"]] == [("198.51.100.7:3478", "127.0.0.1:40000", "127.0.0.1:41000", "aa" * 12, "webrtc")]
|
||||
assert evidence["send_errors"] == ["the answer to the client: OSError x"]
|
||||
|
||||
|
||||
def test_a_lab_gives_its_turn_server_the_clock_of_its_recorder():
|
||||
with ab.Lab(host="127.0.0.1") as lab:
|
||||
assert lab.turn.clock == lab.rec.now and lab.turn.exchanges == []
|
||||
|
||||
|
||||
def test_a_hunt_repetition_launches_the_engine_with_its_own_log_and_the_variables_are_gone_after(tmp_path, monkeypatch):
|
||||
import os
|
||||
|
||||
seen = []
|
||||
|
||||
def launch(binary, seed, lab, patch):
|
||||
seen.append((os.environ.get("MOZ_LOG"), os.environ.get("MOZ_LOG_FILE")))
|
||||
raise RuntimeError("stop here")
|
||||
|
||||
monkeypatch.setattr(ab, "launch", launch)
|
||||
monkeypatch.setattr(ab, "begin_launch", lambda seed, name: None)
|
||||
monkeypatch.delenv("MOZ_LOG", raising=False)
|
||||
monkeypatch.delenv("MOZ_LOG_FILE", raising=False)
|
||||
patch = pytest.MonkeyPatch()
|
||||
try:
|
||||
record = ab.hunt_repetition("/e/firefox", "firefox-68-again", 7, 4, patch, tmp_path)
|
||||
assert "MOZ_LOG" not in os.environ and "MOZ_LOG_FILE" not in os.environ, "the variables are the launch's: a repetition leaves none"
|
||||
without = ab.hunt_repetition("/e/firefox", "firefox-68", 1, 4, patch)
|
||||
finally:
|
||||
patch.undo()
|
||||
assert seen == [("sync,timestamp,nicer:5,signaling:5", str(tmp_path / "firefox-68-again-7-mozlog")), (None, None)] and ab.HUNT_MOZ_LOG == "sync,timestamp,nicer:5,signaling:5"
|
||||
assert record["mozlog"] == "firefox-68-again-7-mozlog" and "mozlog" not in without
|
||||
|
||||
|
||||
def test_the_run_of_a_normal_a_a_does_not_log_the_engine():
|
||||
import inspect
|
||||
|
||||
for function in (ab.run_main, ab.run, ab.run_engine, ab.launch, ab.engine_env):
|
||||
assert "HUNT_MOZ_LOG" not in inspect.getsource(function) and "setenv" not in inspect.getsource(function), function.__name__
|
||||
assert "MOZ_LOG" in inspect.getsource(ab.engine_env), "an engine's own environment still has the log variables taken out: only the hunt's repetition sets them"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- the hunt
|
||||
def repetition(engine, i, tids, late=0, error=None):
|
||||
"""A repetition file as ``hunt_repetition`` writes it: ``tids`` are the transaction ids of the datagrams to the TURN server in order, the first ``late`` of the last ones after the close."""
|
||||
datagrams = [{"t": 0.1 * n, "phase": "webrtc.end" if n >= len(tids) - late else "webrtc", "target": ab.TURN_TARGET, "message": "stun-0x0003", "tid": tid, "counted": n < len(tids) - late}
|
||||
for n, tid in enumerate(tids)]
|
||||
datagrams.append({"t": 0.05, "phase": "webrtc", "target": "198.51.100.5:19302", "message": "stun-0x0001", "tid": "dd" * 12, "counted": True})
|
||||
record = {"format": ab.HUNT_FORMAT, "engine": engine, "i": i, "seed": 4, "error": error, "evidence": {"phase_t": {}, "evaluate": None, "page": None, "datagrams": datagrams}}
|
||||
record["counts"] = ab.hunt_counts(record["evidence"])
|
||||
return record
|
||||
|
||||
|
||||
def test_the_hunt_summary_counts_the_datagrams_to_the_turn_server_and_lists_the_transactions_of_each_target():
|
||||
a, b = "aa" * 12, "bb" * 12
|
||||
records = [repetition("firefox-68", 1, [a, a, a, b, b]), repetition("firefox-68", 2, [a, a, b, b, b, b], late=1), repetition("firefox-68-again", 1, [a] * 4 + [b] * 4),
|
||||
repetition("firefox-68-again", 2, [], error="Error: launch")]
|
||||
summary = ab.hunt_summary(records)
|
||||
json.dumps(summary)
|
||||
assert summary["format"] == ab.HUNT_SUMMARY_FORMAT and summary["target"] == "198.51.100.7:3478"
|
||||
first, second, third, failed = summary["repetitions"]
|
||||
assert (first["engine"], first["i"], first["count_3478"], first["count_3478_all"]) == ("firefox-68", 1, 5, 5)
|
||||
assert first["targets"] == {"198.51.100.5:19302": [["dd" * 12, 1]], ab.TURN_TARGET: [[a, 3], [b, 2]]}
|
||||
assert (second["count_3478"], second["count_3478_all"]) == (5, 6), "a datagram after the close is in `all` and not in the count the A/A makes"
|
||||
assert second["targets"][ab.TURN_TARGET] == [[a, 2], [b, 4]]
|
||||
assert (third["count_3478"], third["targets"][ab.TURN_TARGET]) == (8, [[a, 4], [b, 4]])
|
||||
assert failed["error"] == "Error: launch" and failed["count_3478"] == 0
|
||||
assert summary["count_3478_by_engine"] == {"firefox-68": {"5": 2}, "firefox-68-again": {"0": 1, "8": 1}}
|
||||
|
||||
|
||||
def test_the_hunt_summary_is_read_from_the_repetition_files_and_does_not_read_itself(tmp_path):
|
||||
for record in (repetition("firefox-68-again", 2, ["aa" * 12]), repetition("firefox-68", 10, ["aa" * 12]), repetition("firefox-68", 2, ["aa" * 12] * 2)):
|
||||
ab.write_json(tmp_path / ("%s-%d.json" % (record["engine"], record["i"])), record)
|
||||
ab.write_json(tmp_path / "summary.json", ab.hunt_summary(ab.read_hunt_records(tmp_path)))
|
||||
(tmp_path / "notes.txt").write_text("not json", encoding="utf-8")
|
||||
records = ab.read_hunt_records(tmp_path)
|
||||
assert [(r["engine"], r["i"]) for r in records] == [("firefox-68", 2), ("firefox-68", 10), ("firefox-68-again", 2)], "by engine, then by number (10 after 2)"
|
||||
assert len(ab.hunt_summary(records)["repetitions"]) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [("webrtc:4:20", ("webrtc", 4, 20)), (" webrtc:11:1 ", ("webrtc", 11, 1))])
|
||||
def test_the_hunt_spec_names_the_walk_the_seed_and_the_count(text, expected):
|
||||
assert ab.parse_hunt(text) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text", ["", "webrtc", "webrtc:4", "webrtc:four:3", "webrtc:4:0", "webrtc:4:-1", "h3:4:3", "webrtc:4:3:1", "4:3"])
|
||||
def test_a_hunt_spec_that_does_not_read_is_refused(text):
|
||||
with pytest.raises(ValueError, match=ab.HUNT_ENV):
|
||||
ab.parse_hunt(text)
|
||||
|
||||
|
||||
|
||||
def test_ab_with_the_hunt_variable_runs_only_the_walk_n_times_for_each_engine_of_the_a_a_and_exits_0(tmp_path, monkeypatch, capsys):
|
||||
calls = []
|
||||
|
||||
def hunt_engine(binary, seal, label, seed, n, out_dir):
|
||||
calls.append((binary, seal, label, seed, n))
|
||||
for i in range(1, n + 1):
|
||||
ab.write_json(out_dir / ("%s-%d.json" % (label, i)), repetition(label, i, ["aa" * 12] * (8 + i % 2)))
|
||||
return 0
|
||||
|
||||
def never(*a, **k):
|
||||
raise AssertionError("the A/A, the A/B and the volatile list are not part of a hunt")
|
||||
|
||||
monkeypatch.setattr(ab, "hunt_engine", hunt_engine)
|
||||
monkeypatch.setattr(ab, "run_engine", never)
|
||||
monkeypatch.setattr(ab, "compare_files", never)
|
||||
monkeypatch.setenv(ab.HUNT_ENV, "webrtc:4:3")
|
||||
assert ab.main(["ab", "--a-a", "--engine-tag", "firefox-68", "--out", str(tmp_path / "network"), "--published-binary", "/e/firefox"]) == 0
|
||||
binary = str(Path("/e/firefox"))
|
||||
assert calls == [(binary, None, "firefox-68", 4, 3), (binary, None, "firefox-68-again", 4, 3)]
|
||||
hunt = tmp_path / "network" / "hunt"
|
||||
assert sorted(p.name for p in hunt.iterdir()) == sorted(["summary.json"] + ["%s-%d.json" % (e, i) for e in ("firefox-68", "firefox-68-again") for i in (1, 2, 3)])
|
||||
summary = json.loads((hunt / "summary.json").read_text(encoding="utf-8"))
|
||||
assert [(r["engine"], r["i"], r["count_3478"]) for r in summary["repetitions"]] == [("firefox-68", 1, 9), ("firefox-68", 2, 8), ("firefox-68", 3, 9), ("firefox-68-again", 1, 9), ("firefox-68-again", 2, 8),
|
||||
("firefox-68-again", 3, 9)]
|
||||
assert summary["repetitions"][0]["targets"][ab.TURN_TARGET] == [["aa" * 12, 9]]
|
||||
assert not (tmp_path / "network" / "diff-a-a.json").exists()
|
||||
assert "hunt summary written" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_hunt_decides_nothing_even_when_an_engine_run_fails(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(ab, "hunt_engine", lambda *a, **k: 1)
|
||||
monkeypatch.setenv(ab.HUNT_ENV, "webrtc:4:2")
|
||||
assert ab.main(["ab", "--a-a", "--engine-tag", "firefox-68", "--out", str(tmp_path / "network"), "--published-binary", "/e/firefox"]) == 0
|
||||
assert json.loads((tmp_path / "network" / "hunt" / "summary.json").read_text(encoding="utf-8"))["repetitions"] == []
|
||||
|
||||
|
||||
def test_a_hunt_variable_that_does_not_read_is_refused_and_runs_nothing(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setattr(ab, "hunt_engine", lambda *a, **k: pytest.fail("a spec that does not read runs nothing"))
|
||||
monkeypatch.setenv(ab.HUNT_ENV, "webrtc:4")
|
||||
assert ab.main(["ab", "--a-a", "--engine-tag", "firefox-68", "--out", str(tmp_path / "network"), "--published-binary", "/e/firefox"]) == 2
|
||||
assert "FAIL AB_NETWORK_HUNT" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_without_the_hunt_variable_ab_is_the_a_a_it_was(tmp_path, monkeypatch):
|
||||
monkeypatch.delenv(ab.HUNT_ENV, raising=False)
|
||||
monkeypatch.setattr(ab, "hunt_engine", lambda *a, **k: pytest.fail("no hunt without the variable"))
|
||||
ran = []
|
||||
monkeypatch.setattr(ab, "run_engine", lambda binary, seal, label, seeds, out: ran.append(label) or 1)
|
||||
assert ab.main(["ab", "--a-a", "--engine-tag", "firefox-68", "--out", str(tmp_path / "network"), "--published-binary", "/e/firefox", "--seeds", "4"]) == 2
|
||||
assert ran == ["firefox-68", "firefox-68-again"], "the A/A runs the engine twice and says so when neither made a transcript: its own red, as before"
|
||||
|
||||
|
||||
def test_the_engine_of_a_hunt_runs_in_a_process_of_its_own_with_its_seal_and_its_own_cache(tmp_path, monkeypatch):
|
||||
seen = {}
|
||||
|
||||
class Done:
|
||||
returncode = 0
|
||||
|
||||
monkeypatch.setattr(ab.subprocess, "run", lambda cmd, env, timeout: seen.update(cmd=cmd, env=env, timeout=timeout) or Done())
|
||||
assert ab.hunt_engine("/e/firefox", "/e/seal.json", "firefox-68-again", 4, 20, tmp_path / "hunt") == 0
|
||||
cmd = seen["cmd"]
|
||||
assert cmd[3:] == ["hunt-run", "--binary", "/e/firefox", "--label", "firefox-68-again", "--seed", "4", "--n", "20", "--out", str(tmp_path / "hunt")]
|
||||
assert seen["env"]["INVISIBLE_SEAL_FILE"] == "/e/seal.json" and seen["env"]["INVISIBLE_CORE_AUTOFIX"] == "off"
|
||||
assert seen["timeout"] == ab.HUNT_BASE_S + 20 * ab.HUNT_PER_REPETITION_S
|
||||
|
||||
|
||||
def test_a_repetition_is_one_launch_the_walk_alone_and_the_evidence_read_after_the_close(monkeypatch):
|
||||
order = []
|
||||
|
||||
class Session:
|
||||
def __enter__(self):
|
||||
order.append("open")
|
||||
return types.SimpleNamespace(new_context=lambda **k: types.SimpleNamespace(new_page=lambda: order.append("page")))
|
||||
|
||||
def __exit__(self, *exc):
|
||||
order.append("closed")
|
||||
|
||||
monkeypatch.setattr(ab, "launch", lambda binary, seed, lab, patch: Session())
|
||||
monkeypatch.setattr(ab, "begin_launch", lambda seed, name: order.append("begin " + name))
|
||||
monkeypatch.setattr(ab, "glean_ready", lambda session, seed, name: order.append("glean") or {})
|
||||
monkeypatch.setattr(ab, "walk_webrtc", lambda browser, lab: order.append("walk") or {"udp": {}})
|
||||
for walker in ("walk_journey", "walk_h3", "walk_https"):
|
||||
monkeypatch.setattr(ab, walker, lambda *a, **k: pytest.fail("a hunt walks nothing but the WebRTC page"))
|
||||
monkeypatch.setattr(ab, "webrtc_evidence", lambda lab: order.append("evidence") or {"datagrams": [{"target": ab.TURN_TARGET, "counted": True}, {"target": ab.TURN_TARGET, "counted": False}]})
|
||||
record = ab.hunt_repetition("/e/firefox", "firefox-68", 3, 4, object())
|
||||
assert order == ["begin hunt", "open", "page", "glean", "walk", "closed", "evidence"]
|
||||
assert (record["engine"], record["i"], record["seed"], record["error"], record["counts"]) == ("firefox-68", 3, 4, None, {"counted": 1, "all": 2})
|
||||
|
||||
|
||||
def test_a_repetition_that_fails_is_a_record_with_its_error_and_the_hunt_goes_on(monkeypatch):
|
||||
def broken(binary, seed, lab, patch):
|
||||
raise RuntimeError("the engine did not start 17")
|
||||
|
||||
monkeypatch.setattr(ab, "launch", broken)
|
||||
monkeypatch.setattr(ab, "begin_launch", lambda seed, name: None)
|
||||
record = ab.hunt_repetition("/e/firefox", "firefox-68", 1, 4, object())
|
||||
assert record["error"] == "RuntimeError: the engine did not start N" and record["evidence"] is None and record["counts"] == {"counted": 0, "all": 0}
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------- e2e-hunt.yml
|
||||
def steps_of(text):
|
||||
"""The steps of the hunt job: ``{name: block}`` (the blocks of the lines that start with `` - ``)."""
|
||||
job = text[text.index("\n hunt:\n"):]
|
||||
blocks = re.split(r"\n(?= - )", job)
|
||||
return {b.split("name:", 1)[1].split("\n", 1)[0].strip(): b for b in blocks if b.startswith(" - name:")}
|
||||
|
||||
|
||||
def test_the_hunt_workflow_has_the_input_that_chooses_the_walk_and_stays_a_manual_one():
|
||||
text = HUNT_WORKFLOW.read_text(encoding="utf-8")
|
||||
on = text[text.index("\non:\n"):text.index("\npermissions:")]
|
||||
assert " workflow_dispatch:\n" in on and "push:" not in on and "pull_request" not in on and "schedule:" not in on
|
||||
inputs = on[on.index(" inputs:\n"):]
|
||||
block = inputs[inputs.index(" ab_network_webrtc_seed:\n"):]
|
||||
block = block[:block.index("\n os:")]
|
||||
assert 'default: ""' in block and "required: false" in block, "empty is today's behaviour"
|
||||
assert " runs:\n" in inputs and " os:\n" in inputs, "the inputs it had are still there"
|
||||
|
||||
|
||||
def test_the_step_of_the_walk_runs_the_hunt_mode_only_when_the_input_is_set_and_the_e2e_loop_only_when_it_is_not():
|
||||
steps = steps_of(HUNT_WORKFLOW.read_text(encoding="utf-8"))
|
||||
walk = next(b for n, b in steps.items() if n.startswith("The network oracle's WebRTC walk of one seed"))
|
||||
loop = steps["Loop until it catches one"]
|
||||
assert "if: inputs.ab_network_webrtc_seed != ''" in walk and "if: inputs.ab_network_webrtc_seed == ''" in loop
|
||||
assert "AB_NETWORK_HUNT: webrtc:${{ inputs.ab_network_webrtc_seed }}:${{ inputs.runs }}" in walk, "the seed and the number of repetitions come from the inputs, through the environment"
|
||||
assert "${{ inputs." not in walk.split("run: |")[1], "no input is written into the script text"
|
||||
assert "scripts/ci_ab_network.py ab --a-a --out network --published-binary \"$FF\"" in walk
|
||||
assert "xvfb-run -a" in walk and 'RUNNER_OS" = "Linux"' in walk
|
||||
assert "scripts/run_e2e.py" in loop and "run_e2e" not in walk
|
||||
for name in ("The security state (a fixed directory of the repository)", "The GeoIP database (made by the repository, same bytes every run)"):
|
||||
assert "if: inputs.ab_network_webrtc_seed != ''" in steps[name], "what only the hunt needs is made only for it"
|
||||
names = list(steps)
|
||||
assert names.index("The security state (a fixed directory of the repository)") < names.index("Fetch the published firefox binary") < names.index(next(n for n in names if n.startswith("The network oracle's WebRTC walk")))
|
||||
|
||||
|
||||
def test_the_hunt_uploads_network_hunt_as_an_artifact_and_every_action_it_uses_is_pinned_by_sha():
|
||||
text = HUNT_WORKFLOW.read_text(encoding="utf-8")
|
||||
steps = steps_of(text)
|
||||
upload = next(b for n, b in steps.items() if n.startswith("Upload the hunt of the network oracle's WebRTC walk"))
|
||||
assert "if: always() && inputs.ab_network_webrtc_seed != ''" in upload and "path: network/hunt" in upload
|
||||
assert re.search(r"uses: actions/upload-artifact@[0-9a-f]{40} # v4", upload)
|
||||
for line in text.splitlines():
|
||||
m = re.match(r"\s*- uses: (\S+)|\s+uses: (\S+)", line)
|
||||
if m and not (m.group(1) or m.group(2)).startswith("./"):
|
||||
assert re.search(r"@[0-9a-f]{40}\b", line), line
|
||||
+16
-27
@@ -25,15 +25,6 @@ VISITS = tuple((dpr, seed) for dpr in gate.DPRS for seed in gate.SEEDS)
|
||||
SMALL = {dpr: 6 for dpr in gate.DPRS}
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_declared_differences(tmp_path_factory, monkeypatch):
|
||||
"""The visits of these tests are fake pages: the real rows of ci/ab-oracle-expected.json (what the persona seeds 6 and 63 read) are not theirs. The rows are tested in
|
||||
tests/test_ab_oracle_declared_differences.py."""
|
||||
empty = tmp_path_factory.mktemp("declared") / "ab-oracle-expected.json"
|
||||
empty.write_text(json.dumps({"format": ab.EXPECTED_FORMAT, "differences": []}), encoding="utf-8")
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", empty)
|
||||
|
||||
|
||||
def items(seed=11):
|
||||
"""A visit of the page: nested objects, an image, a list, and a diag. value. The visit of seed 0 also has the second launch on a reused profile, under relaunch."""
|
||||
out = {
|
||||
@@ -203,9 +194,9 @@ def test_the_floor_is_what_the_host_gate_s_own_reference_holds_today():
|
||||
assert ab.MIN_LEAVES[dpr] == len(ref), "the reference holds %d leaves at dpr %s: move MIN_LEAVES with it" % (len(ref), dpr)
|
||||
|
||||
|
||||
def test_the_published_engine_is_named_by_the_set_never_by_the_harness_and_its_dump_is_named_for_it():
|
||||
assert not hasattr(ab, "ENGINE_TAG"), "a tag written in the harness is a baseline that goes stale at the next release (firefox-68 was held as the control when firefox-70 was published)"
|
||||
assert ab.dump_name("firefox-68") == "dump-68.json" and ab.dump_name("firefox-70") == "dump-70.json"
|
||||
def test_the_published_engine_is_firefox_68_and_its_dump_is_named_for_it():
|
||||
assert ab.ENGINE_TAG == "firefox-68" and ab.dump_name("firefox-68") == "dump-68.json"
|
||||
assert ab.dump_name("firefox-69") == "dump-69.json"
|
||||
|
||||
|
||||
# --- the files --------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -247,7 +238,7 @@ def test_compare_from_the_files_writes_the_diff_and_exits_by_the_verdict(tmp_pat
|
||||
|
||||
|
||||
def _compare(directory, capsys):
|
||||
rc = ab.main(["compare", "--engine-tag", "firefox-68", str(directory)])
|
||||
rc = ab.main(["compare", str(directory)])
|
||||
capsys.readouterr()
|
||||
return rc, (directory / "diff.json").read_text(encoding="utf-8")
|
||||
|
||||
@@ -289,7 +280,7 @@ def test_a_run_whose_engine_cannot_be_fetched_is_red_and_says_why(tmp_path, monk
|
||||
raise RuntimeError("the release index is down")
|
||||
|
||||
monkeypatch.setattr(ab, "fetch_published", broken)
|
||||
rc = ab.run("cand", tmp_path / "cand.seal.json", "linux-x86_64", tmp_path / "out", "firefox-68")
|
||||
rc = ab.run("cand", tmp_path / "cand.seal.json", "leg", tmp_path / "out", "firefox-68")
|
||||
out = capsys.readouterr().out
|
||||
assert rc == 1 and "FAIL RuntimeError: the release index is down" in out
|
||||
assert (tmp_path / "out" / "diff.json").is_file()
|
||||
@@ -531,9 +522,9 @@ def test_the_a_a_compares_again_from_the_files(tmp_path, monkeypatch, capsys):
|
||||
full = {key: items(key[1]) for key in asked}
|
||||
ab.write_json(tmp_path / "dump-68.json", ab.pack("firefox-68", full))
|
||||
ab.write_json(tmp_path / ab.again_name("firefox-68"), ab.pack("firefox-68-again", full))
|
||||
assert ab.main(["compare", "--engine-tag", "firefox-68", str(tmp_path), "--a-a", "--limit", "2"]) == 0
|
||||
assert ab.main(["compare", str(tmp_path), "--a-a", "--limit", "2"]) == 0
|
||||
ab.write_json(tmp_path / ab.again_name("firefox-68"), ab.pack("firefox-68-again", _changed(full)))
|
||||
assert ab.main(["compare", "--engine-tag", "firefox-68", str(tmp_path), "--a-a", "--limit", "2"]) == 2
|
||||
assert ab.main(["compare", str(tmp_path), "--a-a", "--limit", "2"]) == 2
|
||||
|
||||
|
||||
def test_the_limit_takes_the_first_seeds_and_the_command_line_needs_a_candidate_or_a_published_engine(tmp_path):
|
||||
@@ -572,11 +563,11 @@ def test_a_pull_request_that_touches_no_oracle_runs_the_default_seeds():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path,only", [
|
||||
("scripts/ci_host_gate.py", "AB_ORACLE_PR_SEEDS"), ("ci/ab-oracle-expected.json", "AB_ORACLE_PR_SEEDS"), ("scripts/host_gate/exceptions.json", "AB_ORACLE_PR_SEEDS"), ("scripts/host_gate/page/index.html", "AB_ORACLE_PR_SEEDS"),
|
||||
("scripts/ci_host_gate.py", "AB_ORACLE_PR_SEEDS"), ("scripts/host_gate/exceptions.json", "AB_ORACLE_PR_SEEDS"), ("scripts/host_gate/page/index.html", "AB_ORACLE_PR_SEEDS"),
|
||||
("tests/test_ab_oracle.py", "AB_ORACLE_PR_SEEDS"), ("tests/test_ab_oracle_e2e.py", "AB_ORACLE_PR_SEEDS"),
|
||||
("scripts/ci_ab_network.py", "AB_NETWORK_PR_SEEDS"), ("ci/ab-network-volatile.json", "AB_NETWORK_PR_SEEDS"), ("tests/test_ab_network_e2e.py", "AB_NETWORK_PR_SEEDS"),
|
||||
("scripts/ci_ab_host.py", "AB_HOST_PR_SEEDS"), ("ci/ab-host-expected.json", "AB_HOST_PR_SEEDS"), ("tests/test_ab_host.py", "AB_HOST_PR_SEEDS"),
|
||||
("tests/_strace_stand_in.py", "AB_HOST_PR_SEEDS"), ("tests/_ab_host_declared.py", "AB_HOST_PR_SEEDS"),
|
||||
("tests/_strace_stand_in.py", "AB_HOST_PR_SEEDS"),
|
||||
])
|
||||
def test_a_pull_request_that_touches_the_files_of_one_oracle_runs_every_seed_of_that_oracle_only(path, only):
|
||||
got = pr.pr_seed_counts(["README.md", path], every=5)
|
||||
@@ -638,7 +629,7 @@ def _job(text, name):
|
||||
def _needs_core_on_index(body, linux):
|
||||
"""A Linux job of e2e.yml waits for the core on the index and for the run's linux-deps-e2e job (its Ubuntu packages, from the archive once, never by the job);
|
||||
a Windows job waits for the core only."""
|
||||
return ("needs: [core-on-index, linux-deps-e2e]" in body) if linux else ("needs: core-on-index\n" in body)
|
||||
return ("needs: [changes, core-on-index, linux-deps-e2e]" in body) if linux else ("needs: [changes, core-on-index]\n" in body)
|
||||
|
||||
|
||||
def _linux_deps_e2e_packages(text):
|
||||
@@ -647,12 +638,12 @@ def _linux_deps_e2e_packages(text):
|
||||
return job[job.index("packages:"):].split("\n", 1)[0]
|
||||
|
||||
|
||||
def test_the_e2e_workflow_runs_the_step_on_a_pull_request_in_the_jobs_that_run_the_oracles_and_the_e2e_tests_read_its_variables():
|
||||
def test_the_e2e_workflow_runs_the_step_in_the_merge_queue_run_in_the_jobs_that_run_the_oracles_and_the_e2e_tests_read_its_variables():
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
text = (root / ".github" / "workflows" / "e2e.yml").read_text(encoding="utf-8")
|
||||
legs = {name: _job(text, name) for name in ("e2e-linux", "e2e-windows-control-a", "e2e-windows", "e2e-network", "e2e-network-windows", "e2e-host", "e2e-host-windows", "e2e-page", "e2e-page-windows")}
|
||||
step = (' - name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)\n'
|
||||
" if: github.event_name == 'pull_request'\n shell: bash\n env:\n BASE_SHA: ${{ github.event.pull_request.base.sha }}\n"
|
||||
" if: github.event_name == 'merge_group'\n shell: bash\n env:\n BASE_SHA: ${{ github.event.merge_group.base_sha }}\n"
|
||||
' run: python scripts/ci_ab_pr_seeds.py "$BASE_SHA" >> "$GITHUB_ENV"\n')
|
||||
assert [name for name, body in legs.items() if step in body] == ["e2e-linux", "e2e-windows", "e2e-network", "e2e-network-windows", "e2e-host", "e2e-host-windows", "e2e-page", "e2e-page-windows"], "the jobs that run the oracles' tests, and only those"
|
||||
for name in ("e2e-linux", "e2e-windows", "e2e-network", "e2e-network-windows", "e2e-host", "e2e-host-windows", "e2e-page", "e2e-page-windows"):
|
||||
@@ -715,9 +706,7 @@ def test_the_host_e2e_expects_the_stock_footprint_on_windows_in_both_modes_and_n
|
||||
control that had passed. The four cases, so that the gate (the candidate mode) does not find a fifth."""
|
||||
import test_ab_host_e2e as host_e2e
|
||||
|
||||
number = ab.default_tag().rsplit("-", 1)[-1] # the tag of the published set: the files are named for it, whichever release it is
|
||||
a_a = ["footprint-%s-again.json" % number, "footprint-%s.json" % number]
|
||||
a_b = a_a + ["footprint-candidate.json"]
|
||||
a_a, a_b = ["footprint-68-again.json", "footprint-68.json"], ["footprint-68-again.json", "footprint-68.json", "footprint-candidate.json"]
|
||||
assert host_e2e.expected_footprints(False, "linux") == a_a
|
||||
assert host_e2e.expected_footprints(True, "linux") == a_b
|
||||
assert host_e2e.expected_footprints(False, "win32") == sorted(a_a + ["footprint-stock.json"])
|
||||
@@ -909,7 +898,7 @@ def test_a_candidate_set_visit_list_with_seed_0_expects_the_second_launch_of_it_
|
||||
assert ab.judge(full, lacking, [], expected=tuple(asked))["verdict"] == "red"
|
||||
ab.write_json(tmp_path / "dump-68.json", ab.pack("firefox-68", full))
|
||||
ab.write_json(tmp_path / "dump-candidate.json", ab.pack("candidate", lacking))
|
||||
assert ab.main(["compare", "--engine-tag", "firefox-68", str(tmp_path), "--limit", "2"]) == 1
|
||||
assert ab.main(["compare", str(tmp_path), "--limit", "2"]) == 1
|
||||
assert "second launch of dpr" in capsys.readouterr().out
|
||||
|
||||
|
||||
@@ -1100,10 +1089,10 @@ def test_the_final_set_has_jobs_of_its_own_in_four_shards_on_each_system_and_the
|
||||
for body in (linux, windows):
|
||||
assert "shard: [1, 2, 3, 4]" in body and "AB_ORACLE_SEED_SET: final" in body and "AB_ORACLE_SHARD: ${{ matrix.shard }}/4" in body
|
||||
assert body.count(page) == 1 and "scripts/run_e2e.py" not in body and "timeout-minutes: 40" in body and "fail-fast: false" in body
|
||||
assert ("needs: [core-on-index, e2e-page-final-touched, linux-deps-e2e]" if body is linux else "needs: [core-on-index, e2e-page-final-touched]") in body and "needs.e2e-page-final-touched.outputs.touched == 'true'" in body
|
||||
assert ("needs: [changes, core-on-index, e2e-page-final-touched, linux-deps-e2e]" if body is linux else "needs: [changes, core-on-index, e2e-page-final-touched]") in body and "needs.e2e-page-final-touched.outputs.touched == 'true'" in body
|
||||
assert "skipped\": 0" in body and '{"tests": 1, "failures": 0, "errors": 0, "skipped": 0}' in body, "one test, passed: a skipped one is red"
|
||||
assert "matrix.shard" in body.split("name: invpw-evidence-page-final", 1)[1].split("path:", 1)[0], "four shards, four artifact names"
|
||||
assert "scripts/ci_ab_oracle.py touched" in touched and "pull_request" in touched and "outputs:" in touched
|
||||
assert "scripts/ci_ab_oracle.py touched" in touched and "github.event_name == 'merge_group'" in touched and "github.event.merge_group.base_sha" in touched and "outputs:" in touched
|
||||
shared_linux, shared_windows = _job(text, "e2e-linux"), _job(text, "e2e-windows")
|
||||
assert "AB_ORACLE_SEED_SET" not in shared_linux + shared_windows + _job(text, "e2e-windows-control-a"), "the shared jobs run the candidate set and do not grow"
|
||||
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
"""The page oracle's declared differences (ci/ab-oracle-expected.json), judged against the run of the engine's final candidate (run 46227711139, Linux and Windows).
|
||||
|
||||
That run's A/B was red on 24 differences per system, all of them the bar of the main window above the content: seed 6 at 1.25 (106 device px as retail Firefox 159 measures it,
|
||||
the published engine's core said 107) and seed 63 at 1.5 (the compact density that retail picks by itself under 720 CSS px, 73 CSS px instead of the normal 85). The DIFF lines
|
||||
of that run are the data below, the same on both systems. The judge allows a difference only when a row of the file matches it exactly, is red on any other, red on a row that
|
||||
does not show (stale), and never applies the rows to the A/A.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
import ci_ab_oracle as ab # noqa: E402
|
||||
import ci_host_gate as gate # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
FILE = Path(__file__).resolve().parents[1] / "ci" / "ab-oracle-expected.json"
|
||||
SMALL = {1.0: 3, 1.25: 3, 1.5: 3}
|
||||
CANDIDATE_SET = tuple(ab.select_visits()) # what a run visits by default: seeds 0, 2, 4, 6 and 63, each at its own DPR
|
||||
|
||||
#: The 24 DIFF lines of the A/B of both systems in run 46227711139 (identical on Linux and Windows).
|
||||
TODAY = """\
|
||||
DIFF seed 6 dpr 1.25 leaf state.after_fullscreen.events.mousemove: firefox-70 [[0, 86], [0, 85]] | candidate [[0, 85], [0, 84]]
|
||||
DIFF seed 6 dpr 1.25 leaf state.after_fullscreen.innerHeight: firefox-70 730 | candidate 731
|
||||
DIFF seed 6 dpr 1.25 leaf state.after_fullscreen.mozInnerScreenY: firefox-70 85.5999984741211 | candidate 84.80000305175781
|
||||
DIFF seed 6 dpr 1.25 leaf state.normal.events.mousemove: firefox-70 [[0, 86], [0, 85]] | candidate [[0, 85], [0, 84]]
|
||||
DIFF seed 6 dpr 1.25 leaf state.normal.innerHeight: firefox-70 730 | candidate 731
|
||||
DIFF seed 6 dpr 1.25 leaf state.normal.mozInnerScreenY: firefox-70 85.5999984741211 | candidate 84.80000305175781
|
||||
DIFF seed 6 dpr 1.25 leaf surface.visualViewport.height: firefox-70 730.4000244140625 | candidate 731.2000122070312
|
||||
DIFF seed 6 dpr 1.25 leaf surface.window.innerHeight: firefox-70 730 | candidate 731
|
||||
DIFF seed 6 dpr 1.25 leaf surface.window.mozInnerScreenY: firefox-70 85.5999984741211 | candidate 84.80000305175781
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.events.click: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.events.mousedown: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.events.mousemove: firefox-70 [[0, 85], [0, 84]] | candidate [[0, 73], [0, 72]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.events.mouseup: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.innerHeight: firefox-70 587 | candidate 599
|
||||
DIFF seed 63 dpr 1.5 leaf state.after_fullscreen.mozInnerScreenY: firefox-70 84.66666412353516 | candidate 72.66666412353516
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.events.click: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.events.mousedown: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.events.mousemove: firefox-70 [[0, 85], [0, 84]] | candidate [[0, 72], [0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.events.mouseup: firefox-70 [[0, 85]] | candidate [[0, 73]]
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.innerHeight: firefox-70 587 | candidate 599
|
||||
DIFF seed 63 dpr 1.5 leaf state.normal.mozInnerScreenY: firefox-70 84.66666412353516 | candidate 72.66666412353516
|
||||
DIFF seed 63 dpr 1.5 leaf surface.visualViewport.height: firefox-70 587.3333129882812 | candidate 599.3333129882812
|
||||
DIFF seed 63 dpr 1.5 leaf surface.window.innerHeight: firefox-70 587 | candidate 599
|
||||
DIFF seed 63 dpr 1.5 leaf surface.window.mozInnerScreenY: firefox-70 84.66666412353516 | candidate 72.66666412353516
|
||||
"""
|
||||
_LINE = re.compile(r"^DIFF seed (\d+) dpr ([\d.]+) leaf (\S+): firefox-70 (.*) \| candidate (.*)$")
|
||||
DIFFS = [(int(m[1]), float(m[2]), m[3], json.loads(m[4]), json.loads(m[5])) for m in map(_LINE.match, TODAY.splitlines())]
|
||||
|
||||
|
||||
def _put(items: dict, leaf: str, value) -> None:
|
||||
node = items
|
||||
*path, last = leaf.split(".")
|
||||
for name in path:
|
||||
node = node.setdefault(name, {})
|
||||
node[last] = value
|
||||
|
||||
|
||||
def _visit(seed: int, side: int | None) -> dict:
|
||||
"""What the page dumped in one visit: leaves that do not move, and, for the two seeds of the run, the leaves of today's differences with the value of one side (0 the published
|
||||
engine, 1 the candidate)."""
|
||||
items = {"surface": {"navigator": {"hardwareConcurrency": 8, "language": "en-US"}, "screen": {"width": 1920, "height": 1080}}, "text": {"fonts": ["Arial", "Segoe UI"]}}
|
||||
for s, dpr, leaf, published, candidate in DIFFS:
|
||||
if s == seed:
|
||||
_put(items, leaf, (published, candidate)[side])
|
||||
if seed == ab.RELAUNCH_SEED:
|
||||
items.update(copy.deepcopy(gate.relaunch_items(items)))
|
||||
return items
|
||||
|
||||
|
||||
def dumps(side: int) -> dict:
|
||||
return {(dpr, seed): _visit(seed, side) for dpr, seed in CANDIDATE_SET}
|
||||
|
||||
|
||||
def rows(os_name: str) -> list:
|
||||
return [r for r in ab.load_expected(FILE) if r["os"] == os_name]
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def small_floor(monkeypatch):
|
||||
monkeypatch.setattr(ab, "MIN_LEAVES", SMALL)
|
||||
|
||||
|
||||
def judge(published, candidate, os_name="linux", declared=None, expected=CANDIDATE_SET):
|
||||
return ab.judge(published, candidate, [], expected=expected, declared=declared, os_name=os_name)
|
||||
|
||||
|
||||
# -
|
||||
# Today's run, as data.
|
||||
|
||||
@pytest.mark.parametrize("os_name", ["linux", "windows"])
|
||||
def test_the_old_judge_is_red_on_the_24_differences_of_the_run_and_the_new_one_is_green_with_the_rows(os_name):
|
||||
without = judge(dumps(0), dumps(1))
|
||||
assert without["verdict"] == "red" and len(without["differences"]) == 24
|
||||
assert {(d["seed"], d["dpr"], d["leaf"], json.dumps(d["a"]), json.dumps(d["b"])) for d in without["differences"]} == {(s, d, leaf, json.dumps(p), json.dumps(c)) for s, d, leaf, p, c in DIFFS}
|
||||
report = judge(dumps(0), dumps(1), os_name, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert len(report["declared"]) == 24 and report["differences"] == [] and report["stale"] == []
|
||||
|
||||
|
||||
def test_the_file_has_a_row_per_os_seed_and_leaf_of_the_run_with_its_two_values_and_exactly_the_keys():
|
||||
document = json.loads(FILE.read_text(encoding="utf-8"))
|
||||
assert document["format"] == "ab-oracle-expected/1"
|
||||
got = document["differences"]
|
||||
assert len(got) == 48
|
||||
for row in got:
|
||||
assert sorted(row) == sorted(["id", "os", "seed", "dpr", "leaf", "published", "candidate", "reason"]), "no field that says who decided, nothing else"
|
||||
for os_name in ("linux", "windows"):
|
||||
assert sorted((r["seed"], r["dpr"], r["leaf"], json.dumps(r["published"]), json.dumps(r["candidate"])) for r in got if r["os"] == os_name) == \
|
||||
sorted((s, d, leaf, json.dumps(p), json.dumps(c)) for s, d, leaf, p, c in DIFFS)
|
||||
assert len({r["id"] for r in got}) == 48
|
||||
|
||||
|
||||
def test_every_row_says_the_retail_source_the_core_function_and_the_leaf():
|
||||
for row in ab.load_expected(FILE):
|
||||
reason = row["reason"]
|
||||
assert "45672953042" in reason and "45679625406" in reason and "retail window-geometry capture workflow" in reason, row["id"]
|
||||
assert "window_frame.chrome_height_device" in reason and "This leaf: " in reason, row["id"]
|
||||
assert ("106 device px" in reason) if row["seed"] == 6 else ("720 CSS px" in reason and "gUIDensity" in reason and "compact" in reason), row["id"]
|
||||
assert not any(name in FILE.read_text(encoding="utf-8").lower() for name in ("decided_by", "c:\\", "/home/"))
|
||||
|
||||
|
||||
def test_the_rows_are_for_visits_that_a_run_makes():
|
||||
from persona_cover import load_visits
|
||||
|
||||
visits = {(dpr, seed) for kind in ("candidate", "final") for seed, dpr in load_visits(kind)}
|
||||
for row in ab.load_expected(FILE):
|
||||
assert (row["dpr"], row["seed"]) in visits, "%s names a visit that no seed set makes: it could never show, and never be stale" % row["id"]
|
||||
|
||||
|
||||
# -
|
||||
# What stays red.
|
||||
|
||||
def test_a_difference_that_no_row_covers_is_red_and_the_rows_stay_applied():
|
||||
candidate = dumps(1)
|
||||
candidate[(1.0, 2)]["surface"]["navigator"]["language"] = "it-IT"
|
||||
report = judge(dumps(0), candidate, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["declared"]) == 24
|
||||
assert [(d["seed"], d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [(2, "surface.navigator.language", "en-US", "it-IT")]
|
||||
assert report["problems"] == ["seed 2 dpr 1.0 surface.navigator.language: \"en-US\" vs \"it-IT\""]
|
||||
|
||||
|
||||
def test_a_leaf_of_a_row_with_another_value_than_the_row_says_is_red_and_its_row_is_stale():
|
||||
candidate = dumps(1)
|
||||
candidate[(1.25, 6)]["surface"]["window"]["innerHeight"] = 732 # a row says 731
|
||||
report = judge(dumps(0), candidate, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red"
|
||||
assert [(d["seed"], d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [(6, "surface.window.innerHeight", 730, 732)]
|
||||
assert report["stale"] == ["linux-seed6-surface.window.innerHeight"]
|
||||
|
||||
|
||||
def test_a_row_of_another_seed_dpr_or_os_does_not_cover_the_same_leaf():
|
||||
rows_linux = [r for r in ab.load_expected(FILE) if r["os"] == "linux"]
|
||||
assert judge(dumps(0), dumps(1), "windows", declared=rows_linux)["verdict"] == "red", "the rows of another os do not apply"
|
||||
report = judge(dumps(0), dumps(1), declared=[dict(r, dpr=1.0) if r["seed"] == 6 else r for r in rows_linux])
|
||||
assert report["verdict"] == "red" and {d["seed"] for d in report["differences"]} == {6}, "a row of another dpr does not cover seed 6"
|
||||
|
||||
|
||||
def test_a_row_that_does_not_show_is_red_and_says_it_is_stale_and_to_remove_it():
|
||||
candidate = dumps(1)
|
||||
candidate[(1.5, 63)] = _visit(63, 0) # the candidate reads what the published engine reads at seed 63: its 24 - 15 rows are gone from the run
|
||||
report = judge(dumps(0), candidate, declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 15 and report["differences"] == []
|
||||
assert any("the declared difference 'linux-seed63-state.normal.innerHeight'" in p and "does not show in this run: it is stale, remove it" in p for p in report["problems"])
|
||||
|
||||
|
||||
def test_when_the_published_engine_is_the_candidate_s_own_work_every_row_is_stale():
|
||||
report = judge(dumps(1), dumps(1), declared=ab.load_expected(FILE))
|
||||
assert report["verdict"] == "red" and len(report["stale"]) == 24 and report["declared"] == [] and report["differences"] == []
|
||||
|
||||
|
||||
def test_a_row_of_a_visit_this_run_did_not_make_is_not_judged_here():
|
||||
only = ((1.0, 0),)
|
||||
report = judge({k: v for k, v in dumps(0).items() if k in only}, {k: v for k, v in dumps(1).items() if k in only}, declared=ab.load_expected(FILE), expected=only)
|
||||
assert report["verdict"] == "green", report["problems"]
|
||||
assert report["declared"] == [] and report["stale"] == []
|
||||
|
||||
|
||||
# -
|
||||
# The A/A, the files and the command line.
|
||||
|
||||
def _write(directory: Path, name: str, engine: str, visits: dict) -> None:
|
||||
ab.write_json(directory / name, ab.pack(engine, visits))
|
||||
|
||||
|
||||
def _run(directory: Path, capsys, *argv) -> tuple:
|
||||
rc = ab.main(["compare", "--engine-tag", "firefox-70", str(directory), *argv])
|
||||
return rc, capsys.readouterr().out
|
||||
|
||||
|
||||
def test_the_rows_are_applied_to_the_a_b_from_the_files_and_never_to_the_a_a(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", FILE)
|
||||
_write(tmp_path, "dump-70.json", "firefox-70", dumps(0))
|
||||
_write(tmp_path, "dump-candidate.json", "candidate", dumps(1))
|
||||
_write(tmp_path, ab.again_name("firefox-70"), "firefox-70-again", dumps(1))
|
||||
for leg in ("linux-x86_64", "win-x86_64"):
|
||||
rc, out = _run(tmp_path, capsys, "--leg", leg)
|
||||
assert rc == 0 and "AB ORACLE OK: 0 differences, 0 problems" in out
|
||||
assert out.count("DECLARED ") == 24 and "DIFF seed" not in out and "24 differences declared in ci/ab-oracle-expected.json" in out
|
||||
rc, out = _run(tmp_path, capsys, "--a-a", "--leg", "linux-x86_64")
|
||||
report = json.loads((tmp_path / "diff-a-a.json").read_text(encoding="utf-8"))
|
||||
assert rc == 2 and report["declared"] == [] and report["stale"] == [] and len(report["differences"]) == 24, "the A/A is held to equality, whatever the file says"
|
||||
assert out.count("DIFF seed") == 24 and "DECLARED" not in out
|
||||
|
||||
|
||||
def test_the_a_b_from_the_files_is_red_on_the_old_command_line_data_without_the_rows_and_names_the_stale_one_with_them(tmp_path, monkeypatch, capsys):
|
||||
empty = tmp_path / "none.json"
|
||||
empty.write_text(json.dumps({"format": ab.EXPECTED_FORMAT, "differences": []}), encoding="utf-8")
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", empty)
|
||||
_write(tmp_path, "dump-70.json", "firefox-70", dumps(0))
|
||||
_write(tmp_path, "dump-candidate.json", "candidate", dumps(1))
|
||||
rc, out = _run(tmp_path, capsys, "--leg", "linux-x86_64")
|
||||
assert rc == 1 and out.count("DIFF seed") == 24 and "AB ORACLE FAILED: 24 differences, 24 problems" in out
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", FILE)
|
||||
_write(tmp_path, "dump-candidate.json", "candidate", dumps(0))
|
||||
rc, out = _run(tmp_path, capsys, "--leg", "win-x86_64")
|
||||
assert rc == 1 and out.count("is stale, remove it") == 24 and "FAIL the declared difference 'windows-seed6-state.normal.innerHeight'" in out
|
||||
|
||||
|
||||
# -
|
||||
# The file itself.
|
||||
|
||||
def _document(tmp_path, **change):
|
||||
row = {"id": "a", "os": "linux", "seed": 6, "dpr": 1.25, "leaf": "surface.window.innerHeight", "published": 730, "candidate": 731, "reason": "why"}
|
||||
document = {"format": ab.EXPECTED_FORMAT, "differences": [row]}
|
||||
document.update(change)
|
||||
path = tmp_path / "expected.json"
|
||||
path.write_text(json.dumps(document), encoding="utf-8")
|
||||
return path
|
||||
|
||||
|
||||
def test_a_row_must_have_exactly_its_keys_one_place_and_one_id_and_a_reason(tmp_path):
|
||||
assert len(ab.load_expected(_document(tmp_path))) == 1
|
||||
good = json.loads(_document(tmp_path).read_text(encoding="utf-8"))["differences"][0]
|
||||
for bad in (dict(good, decided_by="x"), {k: v for k, v in good.items() if k != "candidate"}, dict(good, os="macos"), dict(good, reason=" ")):
|
||||
path = _document(tmp_path, differences=[bad])
|
||||
with pytest.raises(SystemExit):
|
||||
ab.load_expected(path)
|
||||
with pytest.raises(SystemExit):
|
||||
ab.load_expected(_document(tmp_path, differences=[good, dict(good, id="b")])) # one place twice
|
||||
with pytest.raises(SystemExit):
|
||||
ab.load_expected(_document(tmp_path, differences=[good, dict(good, leaf="x")])) # one id twice
|
||||
with pytest.raises(SystemExit):
|
||||
ab.load_expected(_document(tmp_path, format="ab-host-expected/1"))
|
||||
|
||||
|
||||
def test_the_os_of_a_leg_is_the_one_of_the_two_the_gate_runs_and_any_other_is_refused():
|
||||
assert (ab.os_of_leg("linux-x86_64"), ab.os_of_leg("win-x86_64")) == ("linux", "windows")
|
||||
with pytest.raises(SystemExit):
|
||||
ab.os_of_leg("leg")
|
||||
with pytest.raises(ValueError):
|
||||
ab.compare_visits({}, {}, [], declared=[{"os": "linux"}])
|
||||
|
||||
|
||||
def test_a_run_applies_the_rows_of_its_leg_to_the_a_b_only_and_a_published_engine_that_differs_from_itself_is_a_broken_control_whatever_the_rows_say(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.setattr(ab, "EXPECTED_FILE", FILE)
|
||||
|
||||
def fake(sequence):
|
||||
queue = iter(sequence)
|
||||
return lambda *args, **kwargs: (next(queue), [])
|
||||
|
||||
monkeypatch.setattr(ab, "_dump_visits", fake([dumps(0), dumps(0), dumps(1)]))
|
||||
assert ab.run_ab("win-x86_64", tmp_path / "out", "firefox-70", ("pub", None), "cand", tmp_path / "s.json", list(CANDIDATE_SET)) == 0
|
||||
assert len(json.loads((tmp_path / "out" / "diff.json").read_text(encoding="utf-8"))["declared"]) == 24
|
||||
assert json.loads((tmp_path / "out" / "diff-a-a.json").read_text(encoding="utf-8"))["declared"] == []
|
||||
monkeypatch.setattr(ab, "_dump_visits", fake([dumps(0), dumps(1)])) # the published engine against itself reads what the candidate reads
|
||||
assert ab.run_ab("linux-x86_64", tmp_path / "out2", "firefox-70", ("pub", None), "cand", tmp_path / "s.json", list(CANDIDATE_SET)) == 2
|
||||
assert "BROKEN CONTROL" in capsys.readouterr().out
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Same seed, same bytes: the published engine (the one of the published set) against itself (the control) and, with a candidate, against the candidate, on this machine.
|
||||
"""Same seed, same bytes: the published firefox-68 engine against itself (the control) and, with a candidate, against the candidate, on this machine.
|
||||
|
||||
scripts/ci_ab_oracle.py runs the host gate's dump (the page of scripts/host_gate, every API a page reads) over the persona seeds of ci/persona-seeds.json, each at its own
|
||||
DPR. Like the network and host oracles, it has two modes, told by whether there is a candidate:
|
||||
@@ -11,8 +11,8 @@ DPR. Like the network and host oracles, it has two modes, told by whether there
|
||||
(fetched the way the core fetches an engine: the release's seal.json and the archive checked against it) against the candidate. If the A/A is broken the A/B is not run. AB_ORACLE_SEED_SET=final and
|
||||
AB_ORACLE_SHARD=i/n run the 20 seeds that reach every value of every dimension, split over n jobs.
|
||||
|
||||
The only differences either comparison lets through are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys. The verdict is the pytest result; the files (dump-<N>.json for the tag of the published set,
|
||||
dump-<N>-again.json, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) and the log are the evidence.
|
||||
The only differences either comparison lets through are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys. The verdict is the pytest result; the files (dump-68.json,
|
||||
dump-68-again.json, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) and the log are the evidence.
|
||||
|
||||
Two more things the comparison cannot say are held here (`_check_ab_visit_and_poison`). The oracle's dumps carry the ab. leaves (scripts/ci_host_gate.py): the poison probe of the page on every
|
||||
seed and, on seeds 0 and 63, the extra visit of every realm and window a page can make; seed 63 must differ from seed 0 on at least AB_CONTROL_MIN of them (the count is in ab-control.json and the log).
|
||||
@@ -91,7 +91,7 @@ def _check_ab_visit_and_poison(out: Path, candidate: bool) -> None:
|
||||
any A/B), and seed 63 reads other values than seed 0 (the control of the ab leaves; the measured count goes to ab-control.json and the log).
|
||||
On a poisoned host (the gate's leg: AB_ORACLE_POISON=1) the poison is in force, the negative control of stock Firefox read it, and neither
|
||||
engine read any of it: its dumps hold the identity the core declares."""
|
||||
published = out / ab.dump_name(ab.default_tag())
|
||||
published = out / "dump-68.json"
|
||||
dumps = [("the published engine", published)] + ([("the candidate", out / "dump-candidate.json")] if candidate else [])
|
||||
problems = []
|
||||
for name, path in dumps:
|
||||
@@ -171,12 +171,11 @@ def test_the_published_engine_repeats_itself_and_the_candidate_gives_the_same_by
|
||||
assert sorted(control["relaunch"]) == sorted(ab.visit_name(*key) for key in ab.relaunch_visits(visits)), "seed 0 is launched twice on one profile, whichever shard has it"
|
||||
_check_what_every_launch_left(out, candidate)
|
||||
_check_ab_visit_and_poison(out, candidate)
|
||||
tag = ab.default_tag()
|
||||
names = sorted(p.name for p in out.glob("*.json") if not p.name.startswith("poison-"))
|
||||
if candidate:
|
||||
diff = json.loads((out / "diff.json").read_text(encoding="utf-8"))
|
||||
assert diff["verdict"] == "green" and diff["differences"] == [] and diff["problems"] == []
|
||||
assert len(diff["visits"]) >= 1 and len(diff["compared"]) == len(diff["visits"]), "every visit asked for is compared: %s" % diff["visits"]
|
||||
assert names == sorted(["ab-control.json", "diff-a-a.json", "diff.json", ab.again_name(tag), ab.dump_name(tag), "dump-candidate.json"])
|
||||
assert names == ["ab-control.json", "diff-a-a.json", "diff.json", "dump-68-again.json", "dump-68.json", "dump-candidate.json"]
|
||||
else:
|
||||
assert names == sorted(["ab-control.json", "diff-a-a.json", ab.again_name(tag), ab.dump_name(tag)])
|
||||
assert names == ["ab-control.json", "diff-a-a.json", "dump-68-again.json", "dump-68.json"]
|
||||
@@ -85,7 +85,7 @@ def test_async_default_context_kwargs_match_sync():
|
||||
|
||||
# ── parity with the sync launcher, driven rather than declared ───────────────
|
||||
|
||||
def test_the_async_api_stamps_the_session_token_into_the_browser_env(declared_engine):
|
||||
def test_the_async_api_stamps_the_session_token_into_the_browser_env():
|
||||
"""The gap that shipped a "fixed" leak to half the users.
|
||||
|
||||
The Windows process-leak fix went into 0.4.0 and was described as fixed. It
|
||||
|
||||
@@ -7,20 +7,17 @@ CreatePattern`` used to read its source canvas through the pattern's own context
|
||||
projected ones: a page compared the two and read the difference. On firefox-68 two lines of ``CreatePattern`` (the HTMLCanvasElement and the
|
||||
OffscreenCanvas overloads; folder ``fingerprint/canvas/text-metrics`` of the series, ``dom/canvas/CanvasRenderingContext2D.cpp``) read the snapshot
|
||||
from the element, so the pattern carries the projection. A 2D canvas is not projected at all (a 2D canvas reads back exactly as drawn,
|
||||
``tests/test_canvas_reads_as_drawn.py``), so a pattern of a 2D canvas is the same pixels with the noise on and off.
|
||||
``tests/test_canvas_reads_as_drawn.py``), so a pattern of a 2D canvas is the same pixels with the engine on and off.
|
||||
|
||||
What the test reads. One page builds a source (a WebGL canvas, a WebGL OffscreenCanvas, or a 2D canvas), fills a 2D canvas with
|
||||
``createPattern(source, 'no-repeat')`` and reads it back with ``getImageData``, then clears it and draws the source with ``drawImage`` and reads that.
|
||||
The WebGL render is a triangle with per-vertex colours and antialiased edges on a white clear (what a fingerprinting page draws, and where the
|
||||
projection acts: ``tests/test_webgl_noise_active.py``); the 2D source is a gradient, an antialiased arc and a rotated rectangle.
|
||||
|
||||
The negative control, in the same module. The same page runs with the canvas noise declared off and the engine still on (``zoom.stealth.canvas.
|
||||
substitute_pixels`` false, the same declared GPU, the engine's own GL: no projection, because the noise is off, not because the engine is):
|
||||
the WebGL pattern pixels with the noise on must DIFFER from those (the projection is what changed them), and the 2D pattern pixels must be the
|
||||
SAME bytes with the noise on and off. A control with the engine off (``zoom.stealth.fpp.hw_seed`` 0) would draw the WebGL source on the host's
|
||||
GL, which a runner may not serve (no context, once in 3083 launches), so no launch of this file has the engine off. On Linux, in both launches,
|
||||
the maps of the engine's processes hold the engine's own GL and no libEGL of the host's. A render that is not drawn (a blank source) fails the
|
||||
test: the pixels are checked to hold more than one colour. WebGL being unavailable on the runner is a failure, not a skip.
|
||||
The negative control, in the same module. The same page runs with the engine not declared (``zoom.stealth.fpp.hw_seed`` = 0: no projection): the
|
||||
WebGL pattern pixels with the engine declared must DIFFER from those (the projection is what changed them), and the 2D pattern pixels must be the
|
||||
SAME bytes with the engine on and off. A render that is not drawn (a blank source) fails the test: the pixels are checked to hold more than one
|
||||
colour. WebGL being unavailable on the runner is a failure, not a skip.
|
||||
|
||||
Run: pytest tests/test_canvas_create_pattern_projection_e2e.py -m e2e -v
|
||||
"""
|
||||
@@ -28,9 +25,6 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from engine_process_tree import assert_the_gl_is_the_engines_own, gl_maps_of_this_test
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
SIZE = 64
|
||||
@@ -84,73 +78,58 @@ READ = """(args) => {
|
||||
KINDS = ["webgl", "offscreen-webgl", "2d"]
|
||||
|
||||
|
||||
#: A hw_seed no runner has by accident (the engine is on when it is positive), the one both launches of this file declare: the same GPU, so
|
||||
#: the engine's own GL in both. The control declares only the canvas noise off.
|
||||
_HW_SEED = 12345
|
||||
def _read(firefox_binary, engine_declared):
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
|
||||
def _launch_prefs(noise_on: bool) -> dict:
|
||||
"""The prefs of one launch of this file: the engine always on (the same declared GPU, the engine's own GL), with the canvas noise on, or
|
||||
with only the canvas noise declared off (``zoom.stealth.canvas.substitute_pixels`` false: no projection, the bytes as that GPU drew them)."""
|
||||
prefs = {"zoom.stealth.fpp.hw_seed": _HW_SEED}
|
||||
if not noise_on:
|
||||
prefs["zoom.stealth.canvas.substitute_pixels"] = False
|
||||
return prefs
|
||||
|
||||
|
||||
def _read(firefox_binary, noise_on):
|
||||
prefs = {} if engine_declared else {"zoom.stealth.fpp.hw_seed": 0}
|
||||
out = {}
|
||||
with InvisiblePlaywright(seed=21, binary_path=firefox_binary, headless=True,
|
||||
extra_prefs=_launch_prefs(noise_on)) as browser:
|
||||
with InvisiblePlaywright(seed=21, binary_path=firefox_binary, headless=True, extra_prefs=prefs) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
page.goto("about:blank", timeout=30_000)
|
||||
for kind in KINDS:
|
||||
got = page.evaluate(READ, [kind, SIZE])
|
||||
assert "error" not in got, got["error"]
|
||||
out[kind] = {name: bytes(values) for name, values in got.items()}
|
||||
gl_maps = gl_maps_of_this_test(firefox_binary)
|
||||
assert_the_gl_is_the_engines_own(firefox_binary, gl_maps)
|
||||
return out
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def readings(firefox_binary):
|
||||
"""kind -> {viaPattern, viaDraw} bytes, with the canvas noise on and off (the engine on in both). The browsers are closed before the tests run."""
|
||||
noised = _read(firefox_binary, True)
|
||||
control = _read(firefox_binary, False)
|
||||
for mode, rows in (("noise on", noised), ("noise off", control)):
|
||||
"""kind -> {viaPattern, viaDraw} bytes, with the engine declared and not declared. The browsers are closed before the tests run."""
|
||||
declared = _read(firefox_binary, True)
|
||||
stock = _read(firefox_binary, False)
|
||||
for mode, rows in (("engine declared", declared), ("engine not declared", stock)):
|
||||
for kind, row in rows.items():
|
||||
assert len(row["viaPattern"]) == SIZE * SIZE * 4 and len(set(row["viaPattern"])) > 1, (
|
||||
"%s: the %s pattern read back is blank or has the wrong size: the source was not drawn" % (mode, kind))
|
||||
return {"noised": noised, "control": control}
|
||||
return {"declared": declared, "stock": stock}
|
||||
|
||||
|
||||
def test_create_pattern_from_a_webgl_canvas_carries_the_projection(readings):
|
||||
noised, control = readings["noised"]["webgl"], readings["control"]["webgl"]
|
||||
assert noised["viaPattern"] != control["viaPattern"], (
|
||||
"createPattern(webglCanvas) reads the same pixels with the noise on and off: the pattern is the clean render, the "
|
||||
declared, stock = readings["declared"]["webgl"], readings["stock"]["webgl"]
|
||||
assert declared["viaPattern"] != stock["viaPattern"], (
|
||||
"createPattern(webglCanvas) reads the same pixels with the engine declared and not declared: the pattern is the clean render, the "
|
||||
"projection does not reach it")
|
||||
|
||||
|
||||
def test_create_pattern_from_an_offscreen_webgl_canvas_carries_the_projection(readings):
|
||||
noised, control = readings["noised"]["offscreen-webgl"], readings["control"]["offscreen-webgl"]
|
||||
assert noised["viaPattern"] != control["viaPattern"], (
|
||||
"createPattern(offscreenWebglCanvas) reads the same pixels with the noise on and off: the pattern is the clean render, "
|
||||
declared, stock = readings["declared"]["offscreen-webgl"], readings["stock"]["offscreen-webgl"]
|
||||
assert declared["viaPattern"] != stock["viaPattern"], (
|
||||
"createPattern(offscreenWebglCanvas) reads the same pixels with the engine declared and not declared: the pattern is the clean render, "
|
||||
"the projection does not reach it")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["webgl", "offscreen-webgl"])
|
||||
def test_a_pattern_of_a_webgl_canvas_reads_what_drawimage_of_it_reads(readings, kind):
|
||||
noised = readings["noised"][kind]
|
||||
assert noised["viaPattern"] == noised["viaDraw"], (
|
||||
"%s: the pixels of createPattern + fill and of drawImage differ with the noise on: the two reads of one canvas carry "
|
||||
declared = readings["declared"][kind]
|
||||
assert declared["viaPattern"] == declared["viaDraw"], (
|
||||
"%s: the pixels of createPattern + fill and of drawImage differ with the engine declared: the two reads of one canvas carry "
|
||||
"different projections" % kind)
|
||||
|
||||
|
||||
def test_create_pattern_from_a_2d_canvas_reads_the_same_with_the_engine_on_and_off(readings):
|
||||
"""A 2D source is untouched whether the canvas noise is on or off (the engine is on in both launches): it is read as drawn."""
|
||||
noised, control = readings["noised"]["2d"], readings["control"]["2d"]
|
||||
assert noised["viaPattern"] == control["viaPattern"], (
|
||||
"createPattern(2dCanvas) differs between the noise on and off: a 2D source must be read as drawn")
|
||||
assert noised["viaDraw"] == control["viaDraw"], "drawImage(2dCanvas) differs between the noise on and off"
|
||||
assert noised["viaPattern"] == noised["viaDraw"], "a pattern of a 2D canvas is not the pixels drawImage reads"
|
||||
declared, stock = readings["declared"]["2d"], readings["stock"]["2d"]
|
||||
assert declared["viaPattern"] == stock["viaPattern"], (
|
||||
"createPattern(2dCanvas) differs between the engine declared and not declared: a 2D source must be read as drawn")
|
||||
assert declared["viaDraw"] == stock["viaDraw"], "drawImage(2dCanvas) differs between the engine declared and not declared"
|
||||
assert declared["viaPattern"] == declared["viaDraw"], "a pattern of a 2D canvas is not the pixels drawImage reads"
|
||||
@@ -16,12 +16,8 @@ known-bad:
|
||||
per-seed change at readback.
|
||||
* A toDataURL PNG carries the deBG chunk retail 151 writes.
|
||||
* A WebGL canvas that is not premultiplied (premultipliedAlpha:false, half
|
||||
transparent) reads the same pixels through toDataURL and toBlob, noised (the
|
||||
engine on, hw_seed > 0); the control is the same engine, the same declared GPU
|
||||
and the same GL, the engine's own, with only the canvas noise declared off
|
||||
(zoom.stealth.canvas.substitute_pixels false), so a defect of our hook that
|
||||
changed the bytes with the noise off shows in the control. In both launches, on
|
||||
Linux, the engine's processes map the engine's own GL and no libEGL of the host's.
|
||||
transparent) reads the same pixels through toDataURL and toBlob, noised with the
|
||||
engine on (hw_seed > 0); the control is the engine off (hw_seed 0: as drawn).
|
||||
|
||||
Runs against about:blank and a local http page, no network/proxy. Part of the
|
||||
e2e release gate.
|
||||
@@ -30,14 +26,9 @@ Run: pytest tests/test_canvas_reads_as_drawn.py -m e2e -v
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import threading
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
from _evidence_on_failure import FailureEvidence
|
||||
from engine_process_tree import assert_the_gl_is_the_engines_own, gl_maps_of_this_test
|
||||
from _webgl_unavailable import SECOND_ATTEMPT_AFTER_MS, split_probe, unavailable_message
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
_GRID_JS = """(offscreen) => {
|
||||
@@ -170,12 +161,9 @@ def test_two_seeds_on_the_same_machine_draw_the_same_text(firefox_binary):
|
||||
|
||||
_NON_PREMULTIPLIED_JS = """async () => {
|
||||
const c = document.createElement('canvas'); c.width = 128; c.height = 128;
|
||||
const statusMessages = [];
|
||||
c.addEventListener('webglcontextcreationerror', e => statusMessages.push(e.statusMessage));
|
||||
const gl = c.getContext('webgl', {premultipliedAlpha: false, alpha: true,
|
||||
preserveDrawingBuffer: true, antialias: true});
|
||||
if (!gl) return {unavailable: true, statusMessages,
|
||||
webglInterface: typeof WebGLRenderingContext, webgl2Interface: typeof WebGL2RenderingContext};
|
||||
if (!gl) return null;
|
||||
const alpha = 128 / 255;
|
||||
const vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
gl.shaderSource(vs, 'attribute vec2 p; attribute vec3 c; varying vec3 v;'
|
||||
@@ -204,79 +192,22 @@ _NON_PREMULTIPLIED_JS = """async () => {
|
||||
}"""
|
||||
|
||||
|
||||
#: A second attempt at a context, on a fresh canvas, made 2 s after a first one that gave none: it only records (what the page heard, and the
|
||||
#: renderer if a context exists); the verdict stays the first attempt's.
|
||||
_SECOND_ATTEMPT_JS = """() => {
|
||||
const out = {};
|
||||
try {
|
||||
const c = document.createElement('canvas'); c.width = 128; c.height = 128;
|
||||
const statusMessages = [];
|
||||
c.addEventListener('webglcontextcreationerror', e => statusMessages.push(e.statusMessage));
|
||||
const gl = c.getContext('webgl', {premultipliedAlpha: false, alpha: true,
|
||||
preserveDrawingBuffer: true, antialias: true});
|
||||
out.statusMessages = statusMessages;
|
||||
out.created = !!gl;
|
||||
if (gl) {
|
||||
out.renderer = gl.getParameter(gl.RENDERER);
|
||||
out.vendor = gl.getParameter(gl.VENDOR);
|
||||
const info = gl.getExtension('WEBGL_debug_renderer_info');
|
||||
if (info) {
|
||||
out.unmaskedRenderer = gl.getParameter(info.UNMASKED_RENDERER_WEBGL);
|
||||
out.unmaskedVendor = gl.getParameter(info.UNMASKED_VENDOR_WEBGL);
|
||||
}
|
||||
}
|
||||
} catch (e) { out.error = String(e); }
|
||||
return out;
|
||||
}"""
|
||||
|
||||
|
||||
#: A hw_seed no runner has by accident (the engine is on when it is positive). Both launches of the test below keep the engine ON with the
|
||||
#: same declared GPU, so on the engine's own GL: a launch with hw_seed 0 would run WebGL on the host's Mesa, which a runner may not serve.
|
||||
_HW_SEED = 12345
|
||||
|
||||
|
||||
def _launch_prefs(noise_on: bool) -> dict:
|
||||
"""The prefs of one launch of the test below: the engine always on (the same declared GPU, the engine's own GL), with the canvas noise
|
||||
on, or with only the canvas noise declared off (``zoom.stealth.canvas.substitute_pixels`` false: the bytes as that GPU drew them)."""
|
||||
prefs = {"zoom.stealth.fpp.hw_seed": _HW_SEED}
|
||||
if not noise_on:
|
||||
prefs["zoom.stealth.canvas.substitute_pixels"] = False
|
||||
return prefs
|
||||
|
||||
|
||||
def _non_premultiplied(firefox_binary, noise_on, attempts=None):
|
||||
def _non_premultiplied(firefox_binary, hw_seed):
|
||||
"""(the pixels of toDataURL, the pixels of toBlob) of one half-transparent, non-premultiplied WebGL canvas,
|
||||
as 128x128 RGBA bytes, with the canvas noise on or off (``_launch_prefs``): the engine is on in both.
|
||||
|
||||
When the page gets no context the first time, the assertion carries why: what the page heard on
|
||||
`webglcontextcreationerror` and, after a pause of 2 s, what a second attempt on a fresh canvas heard (and its
|
||||
renderer if it got one). The second attempt changes no verdict. `attempts`, a record the evidence keeps, gets both.
|
||||
On Linux, once the page has its context, the maps of the engine's processes say the GL is the engine's own."""
|
||||
as 128x128 RGBA bytes, with the engine on (hw_seed > 0) or off (0)."""
|
||||
import base64
|
||||
|
||||
from _page_bytes import unfiltered
|
||||
|
||||
with InvisiblePlaywright(
|
||||
seed=7, binary_path=firefox_binary, headless=True,
|
||||
extra_prefs=_launch_prefs(noise_on),
|
||||
extra_prefs={"zoom.stealth.fpp.hw_seed": hw_seed},
|
||||
) as b:
|
||||
p = b.new_context().new_page()
|
||||
p.goto("about:blank", timeout=30_000)
|
||||
got, first = split_probe(p.evaluate(_NON_PREMULTIPLIED_JS))
|
||||
second = None
|
||||
if got is None:
|
||||
p.wait_for_timeout(SECOND_ATTEMPT_AFTER_MS)
|
||||
try:
|
||||
second = p.evaluate(_SECOND_ATTEMPT_JS)
|
||||
except Exception as problem: # only a note: the first attempt is the verdict
|
||||
second = {"error": repr(problem)}
|
||||
gl_maps = gl_maps_of_this_test(firefox_binary)
|
||||
if attempts is not None:
|
||||
with attempts.lock:
|
||||
attempts.records.append({"noise_on": noise_on, "context": got is not None, "first": first, "second": second})
|
||||
assert got is not None, unavailable_message(first, second)
|
||||
got = p.evaluate(_NON_PREMULTIPLIED_JS)
|
||||
assert got is not None, "webgl is unavailable: a WebGL canvas cannot be read"
|
||||
assert got["premultipliedAlpha"] is False, "the context is premultiplied: %r" % got["premultipliedAlpha"]
|
||||
assert_the_gl_is_the_engines_own(firefox_binary, gl_maps)
|
||||
images = [unfiltered(base64.b64decode(got["url"].split(",", 1)[1])), unfiltered(base64.b64decode(got["blob"]))]
|
||||
for png in images:
|
||||
assert (png["w"], png["h"], png["channels"]) == (128, 128, 4), png
|
||||
@@ -285,40 +216,25 @@ def _non_premultiplied(firefox_binary, noise_on, attempts=None):
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_a_non_premultiplied_webgl_canvas_reads_the_same_through_todataurl_and_toblob(firefox_binary):
|
||||
"""toDataURL and toBlob of a premultipliedAlpha:false WebGL canvas give the same pixels, noised.
|
||||
"""toDataURL and toBlob of a premultipliedAlpha:false WebGL canvas give the same pixels, noised with the engine on.
|
||||
|
||||
The canvas noise is applied to the snapshot with its alpha type: a context that is not premultiplied stores
|
||||
the colours as drawn, and a reader that took it for premultiplied would noise (or convert) them wrongly.
|
||||
Both PNG readers go through the same hook (GetImageBuffer, GetInputStream in ClientWebGLContext.cpp). The
|
||||
canvas is half transparent (alpha 128/255, colours as drawn), so a premultiplied reading changes the bytes.
|
||||
Negative control, in the same test: the same engine, the same declared GPU and the engine's own GL, with only
|
||||
the canvas noise declared off (``zoom.stealth.canvas.substitute_pixels`` false): the two readers are the bytes
|
||||
as drawn, their alpha is the 128 drawn, and the noised PNG differs from them. So a defect of our hook that
|
||||
changed the bytes with the noise off shows in the control, and no runner's Mesa is in either launch (on Linux
|
||||
the maps of both launches hold the engine's own GL and no libEGL of the host's)."""
|
||||
with FailureEvidence("canvas-webgl-non-premultiplied") as evidence:
|
||||
attempts = types.SimpleNamespace(lock=threading.Lock(), records=[])
|
||||
evidence.note_records("webgl-attempts", attempts)
|
||||
# One arming before both launches (noise on, then off): the variables it sets stay for the second launch, and the
|
||||
# engine writes one log file per process (MOZ_LOG_FILE has %PID), so both are covered; a second arm() would lose
|
||||
# the first one's patch. gfx2d is the module of gfxCriticalNote (gfx/2d/Factory.cpp, LazyLogModule "gfx2d"); the
|
||||
# engine has no log module named GfxInfo or WebGL (none in widget/ or dom/canvas), so none is asked for.
|
||||
evidence.arm(moz_log="timestamp,gfx2d:5")
|
||||
on_url, on_blob = _non_premultiplied(firefox_binary, True, attempts)
|
||||
off_url, off_blob = _non_premultiplied(firefox_binary, False, attempts)
|
||||
_the_noise_off_and_on_readings_agree(on_url, on_blob, off_url, off_blob)
|
||||
|
||||
|
||||
def _the_noise_off_and_on_readings_agree(on_url, on_blob, off_url, off_blob):
|
||||
Negative control, in the same test: with the engine off the two readers are the bytes as drawn, their alpha is
|
||||
the 128 drawn, and the engine-on PNG differs from them."""
|
||||
on_url, on_blob = _non_premultiplied(firefox_binary, 12345)
|
||||
off_url, off_blob = _non_premultiplied(firefox_binary, 0)
|
||||
alphas = {off_url[i] for i in range(3, len(off_url), 4)}
|
||||
assert alphas <= set(range(126, 131)), (
|
||||
"noise off: the alpha of the PNG is %s, not the 128 that was drawn" % sorted(alphas))
|
||||
"engine off: the alpha of the PNG is %s, not the 128 that was drawn" % sorted(alphas))
|
||||
differing = lambda a, b: sum(1 for x, y in zip(a, b) if x != y)
|
||||
assert off_blob == off_url, (
|
||||
"noise off: %d of %d bytes of toBlob differ from toDataURL" % (differing(off_blob, off_url), len(off_url)))
|
||||
"engine off: %d of %d bytes of toBlob differ from toDataURL" % (differing(off_blob, off_url), len(off_url)))
|
||||
assert differing(on_url, off_url), (
|
||||
"toDataURL of a non-premultiplied WebGL canvas is the same with the noise on and off: no noise reaches "
|
||||
"toDataURL of a non-premultiplied WebGL canvas is the same with the engine on and off: no noise reaches "
|
||||
"the page, so comparing the two readers says nothing")
|
||||
assert on_blob == on_url, (
|
||||
"noise on: %d of %d bytes of toBlob differ from toDataURL of the same non-premultiplied WebGL canvas"
|
||||
"engine on: %d of %d bytes of toBlob differ from toDataURL of the same non-premultiplied WebGL canvas"
|
||||
% (differing(on_blob, on_url), len(on_url)))
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Canvas / WebGL render-stealth regression test (binary-level, 2026-06-18).
|
||||
|
||||
Guards a patched-binary behaviour that must never regress, needed for the
|
||||
fingerprint to look like a real Windows browser to FOSS detectors (a headless
|
||||
detector, a fingerprint library, a public leak-test page) and fixed-hash reference checks:
|
||||
fingerprint to look like a real Windows browser to FOSS detectors (CreepJS,
|
||||
FingerprintJS, BrowserLeaks) and fixed-hash reference checks:
|
||||
|
||||
Solid WebGL readback purity under render-noise - a fixed solid-colour WebGL
|
||||
readback (which reference checks hash against a universal constant) must stay
|
||||
|
||||
@@ -516,27 +516,26 @@ def test_the_summary_groups_by_family_and_is_a_finding_not_a_failure():
|
||||
def test_without_a_clean_dump_the_summary_says_it_and_no_file_is_written(tmp_path):
|
||||
(tmp_path / "dump-68.json").write_text(json.dumps(packed((1.0, 0, {"a": 1}))), encoding="utf-8")
|
||||
summary = tmp_path / "summary.md"
|
||||
assert poison.write_dependence(tmp_path, summary, "firefox-68") is None
|
||||
assert poison.write_dependence(tmp_path, summary) is None
|
||||
assert "No dump of the published engine on the clean runner" in summary.read_text(encoding="utf-8")
|
||||
assert not (tmp_path / poison.dependence_file("firefox-68")).exists()
|
||||
assert not (tmp_path / poison.DEPENDENCE_FILE).exists()
|
||||
|
||||
|
||||
def test_the_dependence_is_written_to_its_own_file_and_to_the_summary(tmp_path):
|
||||
(tmp_path / poison.clean_file("firefox-68")).write_text(json.dumps(packed((1.0, 0, {"a": 1}))), encoding="utf-8")
|
||||
(tmp_path / poison.CLEAN_FILE).write_text(json.dumps(packed((1.0, 0, {"a": 1}))), encoding="utf-8")
|
||||
(tmp_path / "dump-68.json").write_text(json.dumps(packed((1.0, 0, {"a": 2}))), encoding="utf-8")
|
||||
summary = tmp_path / "summary.md"
|
||||
report = poison.write_dependence(tmp_path, summary, "firefox-68")
|
||||
assert json.loads((tmp_path / poison.dependence_file("firefox-68")).read_text(encoding="utf-8")) == report
|
||||
report = poison.write_dependence(tmp_path, summary)
|
||||
assert json.loads((tmp_path / poison.DEPENDENCE_FILE).read_text(encoding="utf-8")) == report
|
||||
assert report["differences"] == [{"seed": 0, "dpr": 1.0, "leaf": "a", "clean": 1, "poisoned": 2}]
|
||||
assert "1 of 1 leaves differ" in summary.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_the_files_of_the_by_product_are_poison_files_which_the_oracle_s_listing_ignores():
|
||||
assert poison.clean_file("firefox-70").startswith("poison-") and poison.dependence_file("firefox-70").startswith("poison-")
|
||||
assert poison.CLEAN_FILE.startswith("poison-") and poison.DEPENDENCE_FILE.startswith("poison-")
|
||||
import ci_ab_oracle as oracle
|
||||
|
||||
for tag in ("firefox-68", "firefox-70"):
|
||||
assert oracle.clean_name(tag) == poison.clean_file(tag), "the clean dump of the oracle and the file the dependence reads are named by one tag"
|
||||
assert oracle.clean_name("firefox-68") == poison.CLEAN_FILE
|
||||
|
||||
|
||||
def test_the_clean_dump_is_the_published_engine_dumped_on_this_machine_and_judges_nothing(tmp_path, monkeypatch):
|
||||
|
||||
@@ -1,673 +0,0 @@
|
||||
"""The control side of every A/B oracle is the PUBLISHED SET, as a user installs it (scripts/ci_published_set.py, ci/py-lock/published.txt).
|
||||
|
||||
Engine candidate 5 (run 46208549074) had every A/B red on a BROKEN CONTROL: the published engine (labelled firefox-68 in the logs, a tag written in the harness, when
|
||||
firefox-70 was the last published) was launched by the CANDIDATE'S core, which no longer declares `zoom.stealth.screen.popup_position`, and an engine refuses a launch
|
||||
whose declarations its core does not emit (rule 7). The pairing the oracle held the candidate to was one no user ever has. A control is the set a user gets:
|
||||
|
||||
* the last `invisible-playwright` on the index, the `invisible-core` it pins exactly, and the engine that core's seal pins, in a venv of their own;
|
||||
* nothing is chosen by hand: no tag, no version, no commit is written in a harness file or a workflow;
|
||||
* installed by hash (ci-03), from the wheelhouse of the run, offline; the lock is one file that .github/workflows/published-set.yml keeps equal to the index;
|
||||
* the candidate's side is what it was: core_ref, wrapper_ref and the candidate engine.
|
||||
|
||||
Without a browser: the first test below is the defect itself on a fake engine that refuses as rule 7 does, with two fake cores (the candidate's lacks a declaration the
|
||||
published engine requires) and the harness's real command line; it is red on the harness that launched the control with the candidate's core. The others hold the lock
|
||||
(known-bad inputs first), the resolver on synthetic index documents, the install commands, and that no tag is written in a harness file.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
import ci_ab_host as host # noqa: E402
|
||||
import ci_ab_network as net # noqa: E402
|
||||
import ci_ab_oracle as ab # noqa: E402
|
||||
import ci_crash_evidence as crash # noqa: E402
|
||||
import ci_host_gate as gate # noqa: E402
|
||||
import ci_published_set as ps # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
#: The variable that names the python of the published set's venv. Spelled here, so that the defect test below runs on a harness that has no notion of it.
|
||||
PUBLISHED_PYTHON_ENV = "INVPW_PUBLISHED_PYTHON"
|
||||
REQUIRED = "zoom.stealth.screen.popup_position"
|
||||
RULE_7 = "stealth: %s is not declared" % REQUIRED
|
||||
|
||||
|
||||
# -
|
||||
# The defect: the control launched by the candidate's core
|
||||
|
||||
#: What `ci_host_gate.py dump` is for this test: the engine at argv[2] says what it requires its core to declare (`requires.txt` beside it) and refuses, as the engine's
|
||||
#: declaration gate does, when the core it is launched by (the `invisible_core` this python imports) does not declare it; else it writes the visit the page would.
|
||||
FAKE_DUMP = '''\
|
||||
import json, os, sys
|
||||
from pathlib import Path
|
||||
import invisible_core
|
||||
|
||||
binary = Path(sys.argv[2])
|
||||
out = Path(sys.argv[sys.argv.index("--out") + 1])
|
||||
required = binary.with_name("requires.txt").read_text(encoding="utf-8").split()
|
||||
missing = [name for name in required if name not in invisible_core.DECLARED]
|
||||
if missing:
|
||||
print("stealth: %s is not declared by the core %s (rule 7)" % (missing[0], invisible_core.NAME), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
visits = [a.split(":") for i, a in enumerate(sys.argv) if i and sys.argv[i - 1] == "--visit"]
|
||||
for seed, dpr in visits:
|
||||
items = json.loads(ITEMS)
|
||||
(out / ("leg_dpr%s_seed%s.json" % (dpr, seed))).write_text(json.dumps({"leg": "leg", "dpr": float(dpr), "seed": int(seed), "result": {"format": FORMAT, "items": items}}), encoding="utf-8")
|
||||
where = os.environ.get(CRASH_DIR_ENV)
|
||||
if where:
|
||||
Path(where).mkdir(parents=True, exist_ok=True)
|
||||
(Path(where) / "exits.json").write_text(json.dumps({"format": CRASH_FORMAT, "launches": [{"n": 1, "label": {"seed": 0, "dpr": 1.0, "launch": "visit"}, "pid": 1, "returncode": 0}]}), encoding="utf-8")
|
||||
'''
|
||||
|
||||
FAKE_CORE = '''\
|
||||
NAME = %(name)r
|
||||
DECLARED = %(declared)r
|
||||
'''
|
||||
FAKE_SEAL = '''\
|
||||
class _Seal:
|
||||
tag = %(tag)r
|
||||
is_local = False
|
||||
|
||||
def describe(self):
|
||||
return "the seal of the fake core %(name)s: " + self.tag
|
||||
|
||||
|
||||
def active_seal():
|
||||
return _Seal()
|
||||
'''
|
||||
FAKE_DOWNLOAD = '''\
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
ENGINE_DIR_ENV = "INVISIBLE_PLAYWRIGHT_ENGINE_DIR"
|
||||
|
||||
|
||||
def ensure_binary(*args, **kwargs):
|
||||
folder = Path(os.environ[ENGINE_DIR_ENV]) / %(tag)r
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
(folder / "firefox").write_text("the published engine", encoding="utf-8")
|
||||
(folder / "requires.txt").write_text(%(requires)r, encoding="utf-8")
|
||||
return folder / "firefox"
|
||||
'''
|
||||
|
||||
|
||||
def write_core(site: Path, name: str, declared: list, tag: str = "firefox-70", requires: str = "") -> None:
|
||||
package = site / "invisible_core"
|
||||
package.mkdir(parents=True, exist_ok=True)
|
||||
(package / "__init__.py").write_text(FAKE_CORE % {"name": name, "declared": declared}, encoding="utf-8")
|
||||
(package / "seal.py").write_text(FAKE_SEAL % {"name": name, "tag": tag}, encoding="utf-8")
|
||||
(package / "download.py").write_text(FAKE_DOWNLOAD % {"tag": tag, "requires": requires}, encoding="utf-8")
|
||||
|
||||
|
||||
def make_venv(folder: Path, core_name: str, declared: list, requires: str) -> Path:
|
||||
"""A real venv (no pip: it installs nothing) whose site-packages holds a fake `invisible_core` that declares `declared`: the published set's venv."""
|
||||
subprocess.run([sys.executable, "-m", "venv", "--without-pip", str(folder)], check=True, capture_output=True)
|
||||
python = ps.venv_python(folder)
|
||||
purelib = subprocess.run([str(python), "-c", "import sysconfig; print(sysconfig.get_paths()['purelib'])"], check=True, capture_output=True, text=True).stdout.strip()
|
||||
write_core(Path(purelib), core_name, declared, requires=requires)
|
||||
return python
|
||||
|
||||
|
||||
class _GateWithAFakeDump:
|
||||
"""The host gate module, but `ci_host_gate.py dump` is the fake dump script: the command line the harness builds is the real one."""
|
||||
|
||||
def __init__(self, script: Path):
|
||||
self.__file__ = str(script)
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(gate, name)
|
||||
|
||||
|
||||
def _items(seed: int) -> dict:
|
||||
return {"surface": {"navigator": {"hardwareConcurrency": 8 + seed % 3, "language": "en-US"}, "screen": {"width": 1920, "height": 1080}},
|
||||
"text": {"fonts": ["Arial", "Segoe UI"]}, "blend": {"data": "AAEC", "enc": "png", "w": 1, "h": 1}}
|
||||
|
||||
|
||||
def test_the_control_is_launched_by_the_core_it_was_built_for_never_by_the_candidates(tmp_path, monkeypatch, capfd):
|
||||
"""Candidate core: declares only `a`. Candidate engine: needs only `a`. Published core (in the set's venv): declares `a` and the popup position the published engine
|
||||
needs. The job's python imports the candidate core (as the gate's python does); the published engine run by it is refused as rule 7. A harness that launches the control
|
||||
with the job's python (and the job's PYTHONPATH, seal and pin switches) is red here with that refusal; one that launches it in the set's venv is green."""
|
||||
candidate_site = tmp_path / "candidate-site"
|
||||
write_core(candidate_site, "candidate-core", ["a"])
|
||||
published_python = make_venv(tmp_path / "set-venv", "published-core", ["a", REQUIRED], requires="a %s" % REQUIRED)
|
||||
script = tmp_path / "fake_dump.py"
|
||||
script.write_text("ITEMS = %r\nFORMAT = %r\nCRASH_DIR_ENV = %r\nCRASH_FORMAT = %r\n" % (json.dumps(_items(11)), gate.FORMAT, crash.CRASH_DIR_ENV, crash.FORMAT) + FAKE_DUMP, encoding="utf-8")
|
||||
candidate = tmp_path / "candidate-engine" / "firefox"
|
||||
candidate.parent.mkdir()
|
||||
candidate.write_text("the candidate", encoding="utf-8")
|
||||
(candidate.parent / "requires.txt").write_text("a", encoding="utf-8")
|
||||
|
||||
monkeypatch.setattr(ab, "gate", _GateWithAFakeDump(script))
|
||||
monkeypatch.setattr(ab, "MIN_LEAVES", {1.0: 6})
|
||||
monkeypatch.setenv("PYTHONPATH", str(candidate_site)) # the job's python imports the candidate's core, as the gate's does
|
||||
monkeypatch.setenv(PUBLISHED_PYTHON_ENV, str(published_python))
|
||||
monkeypatch.setenv("INVISIBLE_CORE_PIN", "allow")
|
||||
|
||||
# What the OLD harness fetched the control with, in this process: the candidate's core downloads the published engine under the published seal. The new harness asks the set.
|
||||
in_process = []
|
||||
import invisible_core.download as download
|
||||
import invisible_core.seal as seal_module
|
||||
|
||||
def old_fetch(*args, **kwargs):
|
||||
in_process.append("download")
|
||||
return [str(tmp_path / "seal-source")]
|
||||
|
||||
def old_download_file(url, dst, *a, **k):
|
||||
in_process.append("download")
|
||||
Path(dst).write_text("{}", encoding="utf-8")
|
||||
|
||||
def old_ensure(*a, **k):
|
||||
in_process.append("download")
|
||||
folder = Path(os.environ[download.ENGINE_DIR_ENV]) / "firefox-70"
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
(folder / "firefox").write_text("the published engine", encoding="utf-8")
|
||||
(folder / "requires.txt").write_text("a %s" % REQUIRED, encoding="utf-8")
|
||||
return folder / "firefox"
|
||||
|
||||
monkeypatch.setattr(download, "release_asset_urls", old_fetch)
|
||||
monkeypatch.setattr(download, "_download_file", old_download_file)
|
||||
monkeypatch.setattr(download, "ensure_binary", old_ensure)
|
||||
monkeypatch.setattr(seal_module, "load_seal", lambda path: types.SimpleNamespace(tag="firefox-70", is_local=False, describe=lambda: "the published seal"))
|
||||
|
||||
out = tmp_path / "out"
|
||||
rc = ab.run(str(candidate), tmp_path / "candidate.seal.json", "linux-x86_64", out, "firefox-70", visits=[(1.0, 11)])
|
||||
seen = capfd.readouterr()
|
||||
said = seen.out + seen.err
|
||||
assert RULE_7 not in said, ("the published engine was launched by the candidate's core and refused it (BROKEN CONTROL, engine candidate 5): the control is the published set, "
|
||||
"launched in its own venv:\n" + said[-1500:])
|
||||
assert rc == 0 and json.loads((out / "diff.json").read_text(encoding="utf-8"))["verdict"] == "green", said[-1500:]
|
||||
assert not in_process, "the control's engine is fetched by the published set's own core, never in this process by the candidate's: %s" % in_process
|
||||
assert (out / "dump-70.json").is_file() and (out / "dump-candidate.json").is_file()
|
||||
|
||||
|
||||
# -
|
||||
# The seams of the three oracles: the control side runs in the set's python, with nothing of the candidate's job
|
||||
|
||||
JOB_ENV = {"PYTHONPATH": "/candidate/site", "VIRTUAL_ENV": "/candidate/venv", "INVISIBLE_SEAL_FILE": "/candidate/gate.seal.json", "INVISIBLE_CORE_PIN": "allow",
|
||||
"INVISIBLE_CORE_AUTOFIX": "off", "PYTHONHOME": "/candidate/home", "MOZ_LOG": "sync", "STEALTHFOX_GEOIP_MMDB": "/lab/geoip.mmdb"}
|
||||
|
||||
|
||||
class _Done:
|
||||
returncode = 0
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def job(monkeypatch):
|
||||
for name in ps.SET_LEAKS:
|
||||
monkeypatch.delenv(name, raising=False)
|
||||
for name, value in JOB_ENV.items():
|
||||
monkeypatch.setenv(name, value)
|
||||
|
||||
|
||||
def _recorded(monkeypatch, module):
|
||||
calls = []
|
||||
monkeypatch.setattr(module.subprocess, "run", lambda cmd, env=None, timeout=None, **k: calls.append((cmd, env)) or _Done())
|
||||
return calls
|
||||
|
||||
|
||||
def _own_cache(monkeypatch):
|
||||
monkeypatch.setattr(ab, "own_cache_env", lambda env, folder, platform=None: dict(env))
|
||||
|
||||
|
||||
def _check_set_side(cmd, env, python, seal):
|
||||
assert cmd[0] == python, "the control runs in the venv of the published set, not in the python of the job"
|
||||
for name in ("PYTHONPATH", "PYTHONHOME", "VIRTUAL_ENV", "MOZ_LOG"):
|
||||
assert name not in env, "%s of the candidate's job reaches the published set's process and can make it import another core" % name
|
||||
assert env["INVISIBLE_CORE_AUTOFIX"] == "off" and "INVISIBLE_CORE_PIN" not in env, "the pin of the set's wrapper on its core stays checked, as on a user's machine"
|
||||
assert env.get("INVISIBLE_SEAL_FILE") == seal and env["STEALTHFOX_GEOIP_MMDB"] == "/lab/geoip.mmdb", "the lab's files still reach it"
|
||||
|
||||
|
||||
def test_the_page_oracle_runs_the_control_dump_in_the_set_s_python(tmp_path, monkeypatch, job):
|
||||
calls = _recorded(monkeypatch, ab)
|
||||
_own_cache(monkeypatch)
|
||||
assert ab.run_dump("pub", None, "linux-x86_64", tmp_path / "o", [(1.0, 11)], python="/set/bin/python") == 0
|
||||
_check_set_side(*calls[0], "/set/bin/python", None)
|
||||
assert calls[0][0][1] == str(Path(gate.__file__))
|
||||
assert ab.run_dump("cand", tmp_path / "s.json", "linux-x86_64", tmp_path / "o", [(1.0, 11)]) == 0
|
||||
cmd, env = calls[1]
|
||||
assert cmd[0] == sys.executable and env["INVISIBLE_SEAL_FILE"] == str(tmp_path / "s.json") and env["PYTHONPATH"] == "/candidate/site", "the candidate's side is as it was"
|
||||
assert env["INVISIBLE_CORE_PIN"] == "allow" and env["INVISIBLE_CORE_AUTOFIX"] == "off"
|
||||
|
||||
|
||||
def test_the_host_oracle_runs_the_control_in_the_set_s_python(tmp_path, monkeypatch, job):
|
||||
calls = _recorded(monkeypatch, host)
|
||||
_own_cache(monkeypatch)
|
||||
monkeypatch.setattr(host.oracle, "own_cache_env", lambda env, folder, platform=None: dict(env))
|
||||
assert host.run_subprocess("pub", None, "linux-x86_64", tmp_path / "f.json", "firefox-70", [11], python="/set/bin/python") == 0
|
||||
_check_set_side(*calls[0], "/set/bin/python", None)
|
||||
assert host.run_subprocess("cand", tmp_path / "s.json", "linux-x86_64", tmp_path / "f.json", "candidate", [11]) == 0
|
||||
assert calls[1][0][0] == sys.executable and calls[1][1]["PYTHONPATH"] == "/candidate/site"
|
||||
|
||||
|
||||
def test_the_network_oracle_runs_the_control_in_the_set_s_python(tmp_path, monkeypatch, job):
|
||||
calls = _recorded(monkeypatch, net)
|
||||
monkeypatch.setattr(ab, "own_cache_env", lambda env, folder, platform=None: dict(env))
|
||||
assert net.run_engine("pub", None, "firefox-70", (11,), tmp_path / "t.json", python="/set/bin/python") == 0
|
||||
_check_set_side(*calls[0], "/set/bin/python", None)
|
||||
assert net.run_engine("cand", str(tmp_path / "s.json"), "candidate", (11,), tmp_path / "t.json") == 0
|
||||
assert calls[1][0][0] == sys.executable and calls[1][1]["INVISIBLE_CORE_PIN"] == "allow"
|
||||
|
||||
|
||||
def test_the_published_engine_of_each_oracle_comes_from_the_set_and_its_python_goes_with_it(tmp_path, monkeypatch):
|
||||
package = tmp_path / "engines" / "firefox-70"
|
||||
package.mkdir(parents=True)
|
||||
(package / "firefox").write_bytes(b"the published engine")
|
||||
monkeypatch.setattr(ab, "fetch_published", lambda tag, work: (str(package / "firefox"), None, "/set/bin/python"))
|
||||
monkeypatch.setattr(host, "stage_dir", lambda base=None: tmp_path / "stage" / "firefox")
|
||||
seen = {}
|
||||
monkeypatch.setattr(host, "run_subprocess", lambda exe, seal, leg, out, label, seeds, crash_with=None, python=None: seen.setdefault(label, python) and 1)
|
||||
host.ab(None, None, "linux-x86_64", tmp_path / "h", "firefox-70", [11])
|
||||
assert seen == {"firefox-70": "/set/bin/python", "firefox-70 again": "/set/bin/python"}, "both runs of the A/A"
|
||||
args = types.SimpleNamespace(published_binary=None, published_seal=None, engine_tag="firefox-70")
|
||||
assert net.published_engine(args, tmp_path) == (str(package / "firefox"), None, "/set/bin/python")
|
||||
given = types.SimpleNamespace(published_binary="/given/firefox", published_seal=None, engine_tag="firefox-70")
|
||||
assert net.published_engine(given, tmp_path) == ("/given/firefox", None, None), "a binary the caller gives (a pull request's A/A) runs as this process does"
|
||||
|
||||
|
||||
def test_the_variable_is_the_one_the_harness_reads():
|
||||
assert ab.PUBLISHED_PYTHON_ENV == PUBLISHED_PYTHON_ENV
|
||||
|
||||
|
||||
def test_a_candidate_with_no_published_set_is_refused_never_held_to_its_own_core(tmp_path, monkeypatch):
|
||||
monkeypatch.delenv(ab.PUBLISHED_PYTHON_ENV, raising=False)
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
ab.fetch_published("firefox-70", tmp_path)
|
||||
assert ab.PUBLISHED_PYTHON_ENV in str(e.value) and "ci_published_set.py install" in str(e.value) and "never the core and the wrapper of the candidate" in str(e.value)
|
||||
monkeypatch.setenv(ab.PUBLISHED_PYTHON_ENV, str(tmp_path / "no-python"))
|
||||
with pytest.raises(RuntimeError):
|
||||
ab.fetch_published(None, tmp_path)
|
||||
|
||||
|
||||
def test_a_label_that_is_not_the_engine_of_the_set_is_refused(tmp_path, monkeypatch):
|
||||
python = make_venv(tmp_path / "set-venv", "published-core", ["a"], requires="a")
|
||||
monkeypatch.setenv(ab.PUBLISHED_PYTHON_ENV, str(python))
|
||||
binary, seal, set_python = ab.fetch_published("firefox-70", tmp_path / "work")
|
||||
assert Path(binary).is_file() and seal is None and set_python == str(python)
|
||||
assert ab.default_tag() == "firefox-70", "the tag of the control is what the set's seal says"
|
||||
with pytest.raises(RuntimeError, match="labelled firefox-68 but the published set carries firefox-70"):
|
||||
ab.fetch_published("firefox-68", tmp_path / "work2")
|
||||
|
||||
|
||||
def _written_tags(path: Path) -> list:
|
||||
"""The `firefox-<N>` string constants of the CODE of a script (docstrings and comments are prose, and may name a release)."""
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
docstrings = {id(n.body[0].value) for n in ast.walk(tree) if isinstance(n, (ast.Module, ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))
|
||||
and n.body and isinstance(n.body[0], ast.Expr) and isinstance(getattr(n.body[0], "value", None), ast.Constant)}
|
||||
import re
|
||||
|
||||
return [(n.lineno, n.value) for n in ast.walk(tree) if isinstance(n, ast.Constant) and isinstance(n.value, str) and id(n) not in docstrings
|
||||
and re.fullmatch(r"firefox-\d+(-candidate)?", n.value)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("script", ["ci_ab_oracle.py", "ci_ab_host.py", "ci_ab_network.py", "ci_poison_host.py", "ci_published_set.py"])
|
||||
def test_no_oracle_writes_the_tag_of_the_engine_it_holds_the_candidate_to(script):
|
||||
"""firefox-68 stayed written in the oracles as the control after firefox-69 and firefox-70 were published: the baseline is the published set, so a new release is the new baseline."""
|
||||
assert _written_tags(ROOT / "scripts" / script) == []
|
||||
|
||||
|
||||
def test_the_checker_of_a_written_tag_sees_one(tmp_path):
|
||||
bad = tmp_path / "x.py"
|
||||
bad.write_text('"""docs may say firefox-68."""\nENGINE_TAG = "firefox-68"\n', encoding="utf-8")
|
||||
assert _written_tags(bad) == [(2, "firefox-68")]
|
||||
|
||||
|
||||
# -
|
||||
# The lock
|
||||
|
||||
LOCK = ROOT / "ci" / "py-lock" / "published.txt"
|
||||
GATE_LOCK = ROOT / "ci" / "py-lock" / "gate.txt"
|
||||
H1, H2, H3 = "a" * 64, "b" * 64, "c" * 64
|
||||
|
||||
|
||||
def _lock(**kw) -> str:
|
||||
text = "\n".join([
|
||||
"# header", "# wrapper-requires: greenlet<4.0.0,>=3.1.1 | psutil>=5.9", "# core-requires: platformdirs>=4",
|
||||
"invisible-core==70.83.0 \\", " --hash=sha256:%s \\" % H1, " --hash=sha256:%s" % H2,
|
||||
"invisible-playwright==0.60.0 \\", " --hash=sha256:%s" % H3, ""])
|
||||
for old, new in kw.items():
|
||||
assert old in text, old
|
||||
text = text.replace(old, new)
|
||||
return text
|
||||
|
||||
|
||||
def test_the_committed_lock_reads_and_every_entry_has_hashes_and_an_exact_version():
|
||||
parsed = ps.parse_lock(LOCK.read_text(encoding="utf-8"))
|
||||
assert parsed["wrapper"][0] and parsed["core"][0] and parsed["wrapper"][1] and parsed["core"][1]
|
||||
assert LOCK.read_bytes().count(b"\r") == 0, "LF only"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("what,text,says", [
|
||||
("a range", _lock(**{"invisible-core==70.83.0": "invisible-core>=70.83.0"}), "not `name==version"),
|
||||
("an entry with no hash", _lock(**{"invisible-playwright==0.60.0 \\\n --hash=sha256:" + H3: "invisible-playwright==0.60.0"}), "has no hash"),
|
||||
("a hash that is not a sha256", _lock(**{H3: "zz"}), "not a --hash=sha256"),
|
||||
("the wrapper missing", _lock().split("invisible-playwright")[0], "must hold exactly"),
|
||||
("a duplicated entry", _lock() + "invisible-core==70.83.0 --hash=sha256:%s\n" % H1, "listed twice"),
|
||||
("the requirements of the wrapper unsaid", _lock().replace("# wrapper-requires: greenlet<4.0.0,>=3.1.1 | psutil>=5.9\n", ""), "wrapper-requires"),
|
||||
("a URL", _lock(**{"invisible-core==70.83.0": "invisible-core @ https://x/y.whl"}), "not `name==version"),
|
||||
])
|
||||
def test_a_lock_that_is_not_a_hash_pinned_set_is_refused(what, text, says):
|
||||
with pytest.raises(ValueError, match=says):
|
||||
ps.parse_lock(text)
|
||||
|
||||
|
||||
def test_the_committed_set_installs_over_the_gate_s_own_lock_offline():
|
||||
"""The venv of the set is the gate's third-party lock plus the two wheels, `--no-deps`: every requirement of either must be met by a package that lock holds."""
|
||||
parsed = ps.parse_lock(LOCK.read_text(encoding="utf-8"))
|
||||
assert ps.problems_of_lock(parsed, GATE_LOCK.read_text(encoding="utf-8")) == []
|
||||
|
||||
|
||||
def test_a_requirement_the_gate_lock_does_not_meet_is_named():
|
||||
parsed = ps.parse_lock(_lock())
|
||||
gate_text = "greenlet==3.5.6 \\\n --hash=sha256:%s\npsutil==7.2.2 \\\n --hash=sha256:%s\n" % (H1, H1)
|
||||
found = ps.problems_of_lock(parsed, gate_text)
|
||||
assert any("platformdirs>=4" in p and "does not hold it" in p for p in found), found
|
||||
old = "greenlet==2.0.0 \\\n --hash=sha256:%s\npsutil==7.2.2 \\\n --hash=sha256:%s\nplatformdirs==4.1 \\\n --hash=sha256:%s\n" % (H1, H1, H1)
|
||||
assert any("greenlet<4.0.0,>=3.1.1" in p and "holds greenlet==2.0.0" in p for p in ps.problems_of_lock(parsed, old))
|
||||
|
||||
|
||||
def test_the_wrapper_pins_the_core_of_the_lock_exactly_and_the_ledger_knows_the_version():
|
||||
"""Offline: the lock says what the ledger (PUBLISHED.json, written at each release) says of that version of the wrapper. A lock that names a version nobody published, or
|
||||
a core the wrapper of that version did not pin, is wrong; whether it is the LAST release is the index's to say (published-set.yml)."""
|
||||
parsed = ps.parse_lock(LOCK.read_text(encoding="utf-8"))
|
||||
ledger = json.loads((ROOT / "PUBLISHED.json").read_text(encoding="utf-8"))["released"]
|
||||
rows = [r for r in ledger if r["version"] == parsed["wrapper"][0]]
|
||||
assert len(rows) == 1, "the lock names invisible-playwright %s, which the ledger does not list as published" % parsed["wrapper"][0]
|
||||
requires = [r for r in rows[0]["requires_dist"] if "extra ==" not in r]
|
||||
assert ps.core_pin_of(requires) == parsed["core"][0]
|
||||
others = sorted(r.replace(" ", "") for r in requires if not r.startswith("invisible-core"))
|
||||
assert sorted(r.replace(" ", "") for r in parsed["wrapper_requires"]) == others
|
||||
|
||||
|
||||
# -
|
||||
# The resolver, on documents made here (the index is read by `check` in published-set.yml, never by a unit test)
|
||||
|
||||
def _doc(name: str, version: str, requires: list, files: list) -> dict:
|
||||
return {"info": {"name": name, "version": version, "requires_dist": requires},
|
||||
"urls": [{"filename": f, "packagetype": "bdist_wheel" if f.endswith(".whl") else "sdist", "digests": {"sha256": h}, "yanked": y} for f, h, y in files]}
|
||||
|
||||
|
||||
def _index(wrapper_pin="70.83.0", extra=()):
|
||||
docs = {
|
||||
"invisible-playwright/json": _doc("invisible-playwright", "0.60.0", [], []),
|
||||
"invisible-playwright/0.60.0/json": _doc("invisible-playwright", "0.60.0", ["greenlet<4.0.0,>=3.1.1", "invisible-core==%s" % wrapper_pin, "psutil>=5.9", "pytest>=7; extra == 'dev'"],
|
||||
[("w.whl", H3, False), ("w.tar.gz", H1, False), ("yanked.whl", H2, True)]),
|
||||
"invisible-core/70.83.0/json": _doc("invisible-core", "70.83.0", ["platformdirs>=4", "ruff>=0.6; extra == 'dev'"], [("c.whl", H2, False), ("c.tar.gz", H1, False)]),
|
||||
}
|
||||
docs.update(dict(extra))
|
||||
return lambda url: docs[url.split("/pypi/", 1)[1]]
|
||||
|
||||
|
||||
def test_the_lock_is_made_from_the_last_release_and_the_core_it_pins():
|
||||
text = ps.resolve(_index())
|
||||
parsed = ps.parse_lock(text)
|
||||
assert parsed["wrapper"] == ("0.60.0", sorted([H1, H3])), "every file of the version that is on the index and not yanked, by its sha256"
|
||||
assert parsed["core"] == ("70.83.0", sorted([H1, H2]))
|
||||
assert parsed["wrapper_requires"] == ["greenlet<4.0.0,>=3.1.1", "psutil>=5.9"] and parsed["core_requires"] == ["platformdirs>=4"], "no extra"
|
||||
assert ps.resolve(_index()) == text, "the same index, the same bytes"
|
||||
|
||||
|
||||
def test_a_wrapper_that_does_not_pin_its_core_exactly_is_no_set():
|
||||
with pytest.raises(ValueError, match="does not pin invisible-core exactly once"):
|
||||
ps.core_pin_of(["invisible-core>=70", "psutil>=5.9"])
|
||||
with pytest.raises(ValueError, match="pins invisible-core==70.83.0 but the core document is of 70.84.0"):
|
||||
ps.lock_text(_index()("https://x/pypi/invisible-playwright/0.60.0/json"), _doc("invisible-core", "70.84.0", [], [("c.whl", H2, False)]))
|
||||
|
||||
|
||||
def test_the_check_is_red_when_the_index_has_a_newer_release_and_says_the_command(tmp_path):
|
||||
stale = tmp_path / "published.txt"
|
||||
stale.write_text(ps.resolve(_index()), encoding="utf-8")
|
||||
assert ps.check(_index(), stale) == []
|
||||
newer = {"invisible-playwright/json": _doc("invisible-playwright", "0.61.0", [], []),
|
||||
"invisible-playwright/0.61.0/json": _doc("invisible-playwright", "0.61.0", ["invisible-core==71.84.0", "psutil>=5.9"], [("w2.whl", H1, False)]),
|
||||
"invisible-core/71.84.0/json": _doc("invisible-core", "71.84.0", ["platformdirs>=4"], [("c2.whl", H3, False)])}
|
||||
found = ps.check(_index(extra=newer), stale)
|
||||
assert len(found) == 1 and "invisible-playwright 0.60.0 + invisible-core 70.83.0" in found[0] and "invisible-playwright 0.61.0 + invisible-core 71.84.0" in found[0]
|
||||
assert "resolve --write" in found[0]
|
||||
assert ps.check(_index(), tmp_path / "missing.txt")[0].startswith("missing.txt holds nothing")
|
||||
|
||||
|
||||
def test_an_index_that_cannot_be_read_is_red_not_green():
|
||||
def down(url):
|
||||
raise OSError("the index is down")
|
||||
|
||||
assert "the index is down" in ps.check(down)[0]
|
||||
|
||||
|
||||
# -
|
||||
# The install (offline, by hash) and what is verified of it
|
||||
|
||||
def _wheel(folder: Path, name: str, who: str, requires: str = "") -> str:
|
||||
"""A real, tiny wheel `<name>-70.83.0-py3-none-any.whl` whose package says in WHO whose it is (it declares `requires`, a Requires-Dist line, when given); returns its sha256."""
|
||||
import hashlib
|
||||
import zipfile
|
||||
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
version = "70.83.0"
|
||||
dist = "%s-%s.dist-info" % (name, version)
|
||||
files = {"%s/__init__.py" % name: "WHO = %r\n" % who,
|
||||
dist + "/METADATA": "Metadata-Version: 2.1\nName: %s\nVersion: %s\n%s" % (name.replace("_", "-"), version, ("Requires-Dist: %s\n" % requires) if requires else ""),
|
||||
dist + "/WHEEL": "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: true\nTag: py3-none-any\n"}
|
||||
path = folder / ("%s-%s-py3-none-any.whl" % (name, version))
|
||||
with zipfile.ZipFile(path, "w") as z:
|
||||
for n, text in files.items():
|
||||
z.writestr(n, text)
|
||||
z.writestr(dist + "/RECORD", "".join("%s,,\n" % n for n in files) + dist + "/RECORD,,\n")
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
NAMES = ("invisible_core", "invisible_playwright")
|
||||
|
||||
|
||||
def _tiny_house(tmp_path: Path):
|
||||
"""A wheelhouse as the run's has it: the published set's two wheels in `published/`, and in its own folder the CANDIDATE's wheels of the same two packages, built from the
|
||||
refs: the same file names, other bytes. The lock names the published ones. Returns (house, lock, published sha256 by name, candidate sha256 by name)."""
|
||||
house = tmp_path / "house"
|
||||
house.mkdir()
|
||||
(house / "lock.txt").write_text("", encoding="utf-8")
|
||||
published = {name: _wheel(house / "published", name, "published") for name in NAMES}
|
||||
candidate = {name: _wheel(house, name, "candidate") for name in NAMES}
|
||||
for name in NAMES:
|
||||
assert candidate[name] != published[name], "same file name, other bytes: the candidate's"
|
||||
lock = tmp_path / "published.txt"
|
||||
lock.write_text("# wrapper-requires: \n# core-requires: \ninvisible-core==70.83.0 --hash=sha256:%s\ninvisible-playwright==70.83.0 --hash=sha256:%s\n"
|
||||
% (published["invisible_core"], published["invisible_playwright"]), encoding="utf-8")
|
||||
return house, lock, published, candidate
|
||||
|
||||
|
||||
def test_the_install_is_offline_hash_checked_and_in_a_venv_of_its_own(tmp_path, monkeypatch):
|
||||
house, lock, _published, _candidate = _tiny_house(tmp_path)
|
||||
ran = []
|
||||
monkeypatch.setenv("PYTHONPATH", "/candidate/site")
|
||||
ps.install(house, tmp_path / "venv", lock, run=lambda cmd, **kw: ran.append((cmd, kw)) or types.SimpleNamespace(returncode=0, stdout="", stderr=""))
|
||||
venv_cmd, first, second, check = ran
|
||||
assert check[0][1:] == ["-m", "pip", "check"] and "PYTHONPATH" not in check[1]["env"], "then pip check over the whole venv, with the set's python"
|
||||
assert venv_cmd[0][1:] == ["-m", "venv", str(tmp_path / "venv")]
|
||||
for cmd, kw in (first, second):
|
||||
assert cmd[0] == str(ps.venv_python(tmp_path / "venv")) and cmd[1:5] == ["-m", "pip", "install", "--quiet"]
|
||||
assert "--no-index" in cmd and "--require-hashes" in cmd and cmd.count("--find-links") == 1
|
||||
assert "PYTHONPATH" not in kw["env"], "nothing of the candidate's job"
|
||||
assert first[0][first[0].index("--find-links") + 1] == str(house), "the third-party lock comes from the wheelhouse"
|
||||
assert second[0][second[0].index("--find-links") + 1] == str(house / "published"), "the two wheels of the set come from published/ and from nowhere else: the wheelhouse's own folder holds the candidate's"
|
||||
assert first[0][-2:] == ["-r", str(house / "lock.txt")] and "--no-deps" not in first[0]
|
||||
assert "--no-deps" in second[0] and second[0][-2:] == ["-r", str(lock)], "the two wheels, by the hashes of the lock, over the third-party lock"
|
||||
|
||||
|
||||
def test_an_install_without_the_gate_s_lock_in_the_wheelhouse_is_refused(tmp_path):
|
||||
with pytest.raises(FileNotFoundError, match="not a py-deps wheelhouse"):
|
||||
ps.install(tmp_path, tmp_path / "venv", LOCK, run=lambda *a, **k: None)
|
||||
|
||||
|
||||
def test_an_install_without_the_published_folder_is_refused_not_served_by_the_candidates_wheels(tmp_path):
|
||||
(tmp_path / "lock.txt").write_text("", encoding="utf-8")
|
||||
with pytest.raises(FileNotFoundError, match="has no published/ folder"):
|
||||
ps.install(tmp_path, tmp_path / "venv", LOCK, run=lambda *a, **k: None)
|
||||
|
||||
|
||||
def test_an_install_whose_published_folder_holds_another_file_than_the_lock_s_is_refused_naming_both(tmp_path):
|
||||
"""The published folder has a wheel of the right name and version whose sha256 is not the lock's (a candidate build put there): refused before anything is installed."""
|
||||
house, lock, published, candidate = _tiny_house(tmp_path)
|
||||
_wheel(house / "published", "invisible_core", "candidate") # overwrites the published one with the candidate's bytes, the same name
|
||||
ran = []
|
||||
with pytest.raises(FileNotFoundError) as e:
|
||||
ps.install(house, tmp_path / "venv", lock, run=lambda cmd, **kw: ran.append(cmd))
|
||||
assert published["invisible_core"] in str(e.value) and candidate["invisible_core"] in str(e.value) and ran == []
|
||||
|
||||
|
||||
def test_the_set_is_installed_from_published_never_from_the_candidates_wheels_of_the_same_names(tmp_path):
|
||||
"""The wheelhouse's own folder holds the candidate's invisible_core and invisible_playwright, built from the refs, with the file names of the published ones (the versions
|
||||
are equal). The old install looked in the wheelhouse for the two wheels of the set: it refused the candidate's file by its hash (and with no hash check it would have put
|
||||
the candidate's core in the control's venv). A real pip, offline, on wheels made here; what was installed is read back from the disk, not from the version."""
|
||||
house, lock, published, _candidate = _tiny_house(tmp_path)
|
||||
python = ps.install(house, tmp_path / "venv", lock)
|
||||
done = subprocess.run([str(python), "-I", "-c", "import invisible_core, invisible_playwright; print(invisible_core.WHO, invisible_playwright.WHO)"],
|
||||
capture_output=True, text=True, check=True)
|
||||
assert done.stdout.split() == ["published", "published"]
|
||||
record = json.loads((tmp_path / "venv" / ps.RECORD_FILE).read_text(encoding="utf-8"))["packages"]
|
||||
assert {n: record[n.replace("_", "-")]["sha256"] for n in NAMES} == published
|
||||
assert record["invisible-core"]["wheel"] == "invisible_core-70.83.0-py3-none-any.whl"
|
||||
assert ps.verify(str(python), lock, run=_real_identity(tmp_path / "venv", python)) == []
|
||||
|
||||
|
||||
def _real_identity(venv: Path, python: Path):
|
||||
"""The identity of a real venv made here (its tiny wheels have no seal): what the set's python would print, from the venv's own folders."""
|
||||
purelib = subprocess.run([str(python), "-c", "import sysconfig; print(sysconfig.get_paths()['purelib'])"], capture_output=True, text=True, check=True).stdout.strip()
|
||||
return _identity(prefix=str(venv), core_file=str(Path(purelib) / "invisible_core" / "__init__.py"), wrapper_file=str(Path(purelib) / "invisible_playwright" / "__init__.py"),
|
||||
core="70.83.0", core_version="70.83.0", wrapper="70.83.0")
|
||||
|
||||
|
||||
def test_pip_check_is_red_when_a_published_wheel_requires_what_the_wheelhouse_does_not_hold_and_green_on_the_normal_house(tmp_path):
|
||||
"""`--no-deps` installs a wheel without reading what it declares. A published wheel that requires a package the house's dependencies do not satisfy is red at pip check,
|
||||
with what pip says; the normal house (the same two wheels declaring nothing unmet) is green. Real pip."""
|
||||
normal = tmp_path / "normal"
|
||||
normal.mkdir()
|
||||
house, lock, _published, _candidate = _tiny_house(normal)
|
||||
assert ps.install(house, normal / "venv", lock).is_file()
|
||||
bad = tmp_path / "bad"
|
||||
bad.mkdir()
|
||||
house = bad / "house"
|
||||
house.mkdir()
|
||||
(house / "lock.txt").write_text("", encoding="utf-8")
|
||||
hashes = {"invisible_core": _wheel(house / "published", "invisible_core", "published", requires="a-package-no-house-holds>=1"),
|
||||
"invisible_playwright": _wheel(house / "published", "invisible_playwright", "published")}
|
||||
lock = bad / "published.txt"
|
||||
lock.write_text("# wrapper-requires: \n# core-requires: \ninvisible-core==70.83.0 --hash=sha256:%s\ninvisible-playwright==70.83.0 --hash=sha256:%s\n"
|
||||
% (hashes["invisible_core"], hashes["invisible_playwright"]), encoding="utf-8")
|
||||
with pytest.raises(RuntimeError, match="pip check .* is red") as e:
|
||||
ps.install(house, bad / "venv", lock)
|
||||
assert "a-package-no-house-holds" in str(e.value) and "invisible-core" in str(e.value), "it names what pip reports"
|
||||
assert not (bad / "venv" / ps.RECORD_FILE).exists(), "a venv that failed its check records nothing"
|
||||
|
||||
|
||||
def test_a_published_lock_that_names_neither_wheel_is_red_with_real_pip_files_in_both_folders(tmp_path):
|
||||
"""The negative control of the same-name case: two real wheels of one name and version (the candidate's in the wheelhouse's folder, the published one in published/), and a lock
|
||||
that names the hash of neither. It is red, and names the sha256 of what published/ holds."""
|
||||
house, _lock, published, candidate = _tiny_house(tmp_path)
|
||||
other = tmp_path / "other.txt"
|
||||
other.write_text("# wrapper-requires: \n# core-requires: \ninvisible-core==70.83.0 --hash=sha256:%s\ninvisible-playwright==70.83.0 --hash=sha256:%s\n" % ("e" * 64, "f" * 64), encoding="utf-8")
|
||||
with pytest.raises(FileNotFoundError) as e:
|
||||
ps.install(house, tmp_path / "venv", other)
|
||||
assert published["invisible_core"] in str(e.value) and "e" * 64 in str(e.value) and candidate["invisible_core"] not in str(e.value)
|
||||
assert not (tmp_path / "venv").exists(), "nothing was installed"
|
||||
|
||||
|
||||
def test_verify_names_the_file_installed_and_is_green_only_when_it_is_the_published_lock_s(tmp_path):
|
||||
"""The candidate's lock and the published one can name the same package at the same version, so the version proves nothing. A venv that holds the CANDIDATE's wheels of the
|
||||
same names (installed wrongly, from the wheelhouse's own folder) says so: the file, its sha256 and the sha256 the lock holds. The old verify compared versions only and
|
||||
was green on it."""
|
||||
import subprocess as sp
|
||||
|
||||
house, lock, published, candidate = _tiny_house(tmp_path)
|
||||
venv = tmp_path / "wrong-venv"
|
||||
sp.run([sys.executable, "-m", "venv", str(venv)], check=True, capture_output=True)
|
||||
python = ps.venv_python(venv)
|
||||
env = {k: v for k, v in os.environ.items() if k != "PYTHONPATH"}
|
||||
sp.run([str(python), "-m", "pip", "install", "--quiet", "--no-index", "--no-deps", str(house / "invisible_core-70.83.0-py3-none-any.whl"),
|
||||
str(house / "invisible_playwright-70.83.0-py3-none-any.whl")], check=True, env=env)
|
||||
ps.write_record(venv, {n.replace("_", "-"): (house / ("%s-70.83.0-py3-none-any.whl" % n), candidate[n]) for n in NAMES})
|
||||
problems = ps.verify(str(python), lock, run=_real_identity(venv, python))
|
||||
assert len(problems) == 2, problems
|
||||
for name, n in (("invisible-core", "invisible_core"), ("invisible-playwright", "invisible_playwright")):
|
||||
text = next(p for p in problems if p.startswith(name + ":"))
|
||||
assert "%s-70.83.0-py3-none-any.whl" % n in text and candidate[n] in text and published[n] in text, "it names the file installed, its sha256 and the lock's: " + text
|
||||
# the record says the published wheel but the disk holds the candidate's bytes: a record is not believed over the files
|
||||
ps.write_record(venv, {n.replace("_", "-"): (house / "published" / ("%s-70.83.0-py3-none-any.whl" % n), published[n]) for n in NAMES})
|
||||
again = ps.verify(str(python), lock, run=_real_identity(venv, python))
|
||||
assert len(again) == 2 and all("on disk is" in p and "__init__.py" in p for p in again), again
|
||||
# and without any record nothing says which file it is
|
||||
(venv / ps.RECORD_FILE).unlink()
|
||||
assert "has no %s" % ps.RECORD_FILE in ps.verify(str(python), lock, run=_real_identity(venv, python))[0]
|
||||
|
||||
|
||||
def _identity(**kw):
|
||||
parsed = ps.parse_lock(LOCK.read_text(encoding="utf-8"))
|
||||
prefix = "/set"
|
||||
base = {"prefix": prefix, "core": parsed["core"][0], "core_version": parsed["core"][0], "core_file": prefix + "/lib/invisible_core/__init__.py",
|
||||
"wrapper": parsed["wrapper"][0], "wrapper_file": prefix + "/lib/invisible_playwright/__init__.py", "seal_tag": "firefox-70", "seal_local": False}
|
||||
base.update(kw)
|
||||
return lambda cmd, **k: types.SimpleNamespace(returncode=0, stdout=json.dumps(base), stderr="")
|
||||
|
||||
|
||||
def _installed_set(tmp_path: Path):
|
||||
"""The state `install` leaves, made here: the published wheels' package files in a site folder, and the record naming the wheels. Returns (lock, identity kwargs)."""
|
||||
import zipfile
|
||||
|
||||
house, lock, published, _candidate = _tiny_house(tmp_path)
|
||||
prefix, site = tmp_path / "set", tmp_path / "set" / "lib"
|
||||
site.mkdir(parents=True)
|
||||
chosen = {}
|
||||
for n in NAMES:
|
||||
wheel = house / "published" / ("%s-70.83.0-py3-none-any.whl" % n)
|
||||
with zipfile.ZipFile(wheel) as z:
|
||||
z.extract("%s/__init__.py" % n, site)
|
||||
chosen[n.replace("_", "-")] = (wheel, published[n])
|
||||
ps.write_record(prefix, chosen)
|
||||
return lock, dict(prefix=str(prefix), core_file=str(site / "invisible_core" / "__init__.py"), wrapper_file=str(site / "invisible_playwright" / "__init__.py"),
|
||||
core="70.83.0", core_version="70.83.0", wrapper="70.83.0")
|
||||
|
||||
|
||||
def test_what_the_set_s_python_imports_is_the_lock_from_its_own_venv(tmp_path):
|
||||
lock, kw = _installed_set(tmp_path)
|
||||
assert ps.verify("py", lock, run=_identity(**kw)) == []
|
||||
assert any("core it runs" in p for p in ps.verify("py", lock, run=_identity(**dict(kw, core="71.1.0"))))
|
||||
assert any("core it runs" in p for p in ps.verify("py", lock, run=_identity(**dict(kw, core_file="/candidate/src/invisible_core/__init__.py")))), "a core from another place is the candidate's"
|
||||
assert any("wrapper it runs" in p for p in ps.verify("py", lock, run=_identity(**dict(kw, wrapper_file="/candidate/src/invisible_playwright/__init__.py"))))
|
||||
assert any("local seal" in p for p in ps.verify("py", lock, run=_identity(**dict(kw, seal_local=True))))
|
||||
|
||||
|
||||
def test_a_set_that_cannot_import_is_an_error_not_a_pass():
|
||||
with pytest.raises(RuntimeError, match="could not import the published set"):
|
||||
ps.identity("py", run=lambda cmd, **k: types.SimpleNamespace(returncode=1, stdout="", stderr="ModuleNotFoundError: invisible_core"))
|
||||
|
||||
|
||||
# -
|
||||
# The wiring: the lock is kept equal to the index, and these tests are run by the rounds
|
||||
|
||||
def test_a_workflow_keeps_the_lock_equal_to_the_index_every_day_and_on_a_pull_request_that_touches_it():
|
||||
text = (ROOT / ".github" / "workflows" / "published-set.yml").read_text(encoding="utf-8")
|
||||
assert 'cron: "' in text and "pull_request:" in text and "ci/py-lock/published.txt" in text and "scripts/ci_published_set.py" in text
|
||||
assert "python scripts/ci_published_set.py check" in text and "pip install" not in text, "it reads the index and installs nothing"
|
||||
|
||||
|
||||
def test_this_file_is_run_by_the_whole_unit_suite_of_both_systems():
|
||||
rows = {r["id"]: r for r in json.loads((ROOT / "ci" / "required-suites.json").read_text(encoding="utf-8"))}
|
||||
for suite in ("wrapper.unit.all.linux", "wrapper.unit.all.windows"):
|
||||
assert "tests/test_ci_published_set.py" in rows[suite]["tests"], suite
|
||||
|
||||
|
||||
def test_the_required_suites_of_the_oracles_say_the_control_is_the_set():
|
||||
rows = {r["id"]: r for r in json.loads((ROOT / "ci" / "required-suites.json").read_text(encoding="utf-8"))}
|
||||
for suite in ("wrapper.e2e.ab_oracle", "wrapper.e2e.ab_network", "wrapper.e2e.ab_host"):
|
||||
assert "published set" in rows[suite]["note"].lower(), suite
|
||||
assert "firefox-68" not in rows[suite]["note"], suite
|
||||
@@ -25,17 +25,19 @@ the files themselves:
|
||||
a job of its own that waits for them. A job that `needs` another is
|
||||
SKIPPED when that one fails unless its `if:` says `always()`, and a
|
||||
skipped check is not red. So: the job `e2e` needs the parts and
|
||||
`core-on-index`; its `if:` is `always()` and the gate of the parts (the
|
||||
core on the index, not the Windows-only dispatch) joined by `&&`, so that
|
||||
it is skipped exactly when the parts are skipped for the core, as the
|
||||
Linux job was before the split, and runs in every other case; its one
|
||||
`core-on-index`; its `if:` is `always()` and the gate of the parts (not the
|
||||
Windows-only dispatch) joined by `&&`, so that it is skipped exactly when
|
||||
the parts are skipped by that dispatch, and runs in every other case (a
|
||||
core that is not on the index fails `core-on-index`, the parts are then
|
||||
skipped and this job runs and is red: no output of `core-on-index` is
|
||||
read by any `if:`, ci-13); its one
|
||||
step binds `needs.e2e-linux.result` (`success` only when every part
|
||||
succeeded) and fails unless it is `success`, in exactly the form
|
||||
`if [ "$PARTS" != "success" ]; then ... exit 1 ... fi`, with no other
|
||||
result named in its code (a cancelled part measured nothing, a skipped
|
||||
one ran nothing); no `continue-on-error`; no other job has its name.
|
||||
Known-bad: without `always()`, accepting `skipped`, not needing the
|
||||
parts, exiting 0, reading another job, dropping the gate of the core,
|
||||
parts, exiting 0, reading another job, dropping the gate of the dispatch,
|
||||
`success() || failure()`, the single job before the split.
|
||||
|
||||
The checkers are tested on known-bad inputs first, because a check that has
|
||||
@@ -205,8 +207,8 @@ def problems_concurrency(name: str, spec: dict) -> list[str]:
|
||||
if "github.run_id" not in group:
|
||||
out.append(f"{name}: outside a pull request the group is not unique to the run, "
|
||||
f"so a newer pending run of main replaces an older one")
|
||||
if "github.ref" in group or "head_ref" in group:
|
||||
out.append(f"{name}: the group is keyed on the ref, which is main for every push to main")
|
||||
if ("github.ref" in group and "merge_group" not in group) or "head_ref" in group:
|
||||
out.append(f"{name}: the group is keyed on the ref, which is main for every push to main (only a merge queue run may key on it: its ref is its own)")
|
||||
return out
|
||||
|
||||
|
||||
@@ -317,9 +319,9 @@ def test_the_push_triggers_the_release_reads_are_still_there():
|
||||
e2e = triggers(_load(WORKFLOWS / "e2e.yml"))
|
||||
assert e2e["push"]["branches"] == ["main"], \
|
||||
"scripts/e2e_is_green.py needs the e2e of the push to main on the tagged commit"
|
||||
assert "pull_request" in e2e
|
||||
assert "merge_group" in e2e and "pull_request" not in e2e, "e2e runs in the merge queue run, not on the pull request"
|
||||
tests = triggers(_load(WORKFLOWS / "tests.yml"))
|
||||
assert tests["push"]["branches"] == ["main"] and "pull_request" in tests
|
||||
assert tests["push"]["branches"] == ["main"] and "pull_request" in tests and "merge_group" in tests
|
||||
publish = triggers(_load(WORKFLOWS / "publish.yml"))
|
||||
assert publish["push"]["tags"] == ["v*"], "publish must start on a release tag"
|
||||
|
||||
@@ -387,7 +389,7 @@ def problems_linux_check(text: str) -> list:
|
||||
if PARTS_JOB not in needs:
|
||||
out.append("the check does not need the parts (%s): it would not wait for them, nor read their result" % PARTS_JOB)
|
||||
if INDEX_GATE not in needs:
|
||||
out.append("the check does not need %s: its `if:` cannot read whether the core is on the index" % INDEX_GATE)
|
||||
out.append("the check does not need %s: it would run before the index was asked" % INDEX_GATE)
|
||||
if "||" in str(check.get("if", "")):
|
||||
out.append("the `if:` of the check has a `||`: it must be `always()` and the gate of the parts")
|
||||
cond = _conjuncts(check.get("if"))
|
||||
@@ -442,7 +444,7 @@ def test_a_linux_check_that_accepts_skipped_is_refused():
|
||||
|
||||
|
||||
def test_a_linux_check_that_does_not_need_the_parts_is_refused():
|
||||
body = _check_body().replace("needs: [core-on-index, e2e-linux]", "needs: [core-on-index]", 1)
|
||||
body = _check_body().replace("needs: [changes, core-on-index, e2e-linux]", "needs: [changes, core-on-index]", 1)
|
||||
assert body != _check_body()
|
||||
assert any("does not need the parts" in p for p in problems_linux_check(_e2e_with_check(body)))
|
||||
|
||||
@@ -457,8 +459,8 @@ def test_a_linux_check_that_reads_another_job_is_refused():
|
||||
assert any("does not bind PARTS" in p for p in problems_linux_check(_e2e_with_check(body)))
|
||||
|
||||
|
||||
def test_a_linux_check_that_drops_the_gate_of_the_core_is_refused():
|
||||
body = _check_body().replace(" && needs.core-on-index.outputs.available == 'true'", "", 1)
|
||||
def test_a_linux_check_that_drops_the_gate_of_the_dispatch_is_refused():
|
||||
body = _check_body().replace(" && inputs.only != 'windows-control-a'", "", 1)
|
||||
assert body != _check_body()
|
||||
assert any("not `always()` and the gate of the parts" in p for p in problems_linux_check(_e2e_with_check(body)))
|
||||
|
||||
|
||||
+1
-174
@@ -345,153 +345,6 @@ def test_a_retired_file_does_not_excuse_another_loss_in_the_same_row(tmp_path, m
|
||||
assert code == 1 and "tests/test_e.py" in capsys.readouterr().out
|
||||
|
||||
|
||||
# --- retired tests: a single test of a file that stays, declared by nodeid ----------------------------------------
|
||||
GONE_NODE = FILE_A + "::test_gone"
|
||||
|
||||
|
||||
def _retired_test(nodeid=GONE_NODE, suite="s.one", count=1, from_min_tests=5, **over):
|
||||
entry = {"nodeid": nodeid, "suite": suite, "count": count, "from_min_tests": from_min_tests, "reason": "removed with its bundle", "decided_by": "pm", "date": "2026-11-27"}
|
||||
entry.update(over)
|
||||
return entry
|
||||
|
||||
|
||||
def _main_that_had_the_test(tmp_path, retired, min_tests=5):
|
||||
"""main's row of FILE_A, FILE_B, NODE with one more test (the one that is retired) in the floor."""
|
||||
return _main_with(tmp_path, [_suite(min_tests=min_tests)], retired)
|
||||
|
||||
|
||||
def test_a_declared_test_lets_the_floor_drop_by_exactly_its_count_is_green(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test()])
|
||||
assert _judge(tmp_path, GREEN, extra=["--main-required", str(main)])[0] == 0 # 5 on main, 4 here, 1 declared
|
||||
|
||||
|
||||
def test_the_counts_of_the_entries_of_a_suite_are_summed(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
other = FILE_B + "::test_also_gone"
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test(from_min_tests=7), _retired_test(other, from_min_tests=7),
|
||||
_retired_test(nodeid=FILE_A + "::t3", from_min_tests=7)], min_tests=7)
|
||||
assert _judge(tmp_path, GREEN, extra=["--main-required", str(main)])[0] == 0 # 7 -> 4: three declared
|
||||
|
||||
|
||||
def test_a_floor_that_drops_by_more_than_the_declared_count_is_red(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test(count=1, from_min_tests=6)], min_tests=6) # 6 -> 4 here: one declared, two lost
|
||||
code, _r = _judge(tmp_path, GREEN, extra=["--main-required", str(main)])
|
||||
assert code == 1 and "went down" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_a_test_that_goes_with_no_entry_is_red(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, None)
|
||||
code, _r = _judge(tmp_path, GREEN, extra=["--main-required", str(main)])
|
||||
assert code == 1 and "went down" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_an_entry_of_another_suite_or_of_a_file_the_row_does_not_run_excuses_nothing(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
for i, entry in enumerate([_retired_test(suite="s.another"), _retired_test(nodeid="tests/test_unlisted.py::test_gone")]):
|
||||
folder = tmp_path / ("case%d" % i)
|
||||
folder.mkdir()
|
||||
main = _main_that_had_the_test(folder, [entry])
|
||||
sub = tmp_path / ("run%d" % i)
|
||||
sub.mkdir()
|
||||
code, _r = _judge(sub, GREEN, extra=["--main-required", str(main)])
|
||||
assert code == 1 and "went down" in capsys.readouterr().out, entry
|
||||
|
||||
|
||||
def test_a_declared_test_that_the_suite_still_collects_is_red(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test()])
|
||||
still = GREEN + [_case(FILE_A, "test_gone")]
|
||||
code, _r = _judge(tmp_path, still, rows=[_suite(min_tests=5)], extra=["--main-required", str(main)])
|
||||
out = capsys.readouterr().out
|
||||
assert code == 1 and GONE_NODE in out and "still collects it" in out
|
||||
|
||||
|
||||
def test_a_declared_test_still_collected_with_a_parameter_is_red_and_excuses_nothing(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test()])
|
||||
still = GREEN[:3] + [_case(FILE_A, "test_gone[p1]")] # 4 tests, the floor of 4 lowered by the entry
|
||||
code, _r = _judge(tmp_path, still, extra=["--main-required", str(main)])
|
||||
out = capsys.readouterr().out
|
||||
assert code == 1 and "still collects it" in out and "went down" in out
|
||||
|
||||
|
||||
def test_the_retired_tests_of_the_branch_excuse_nothing(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, None)
|
||||
(tmp_path / verdict.RETIRED_NAME).write_text(json.dumps([_retired_test()]), encoding="utf-8")
|
||||
code, _r = _judge(tmp_path, GREEN, extra=["--main-required", str(main)])
|
||||
assert code == 1 and "went down" in capsys.readouterr().out
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad, why", [
|
||||
({"nodeid": FILE_A}, "nodeid must be"),
|
||||
({"nodeid": FILE_A + "::"}, "nodeid must be"),
|
||||
({"nodeid": "::test_gone"}, "nodeid must be"),
|
||||
({"nodeid": 3}, "nodeid must be"),
|
||||
({"suite": "s.unknown"}, "not a row of main"),
|
||||
({"suite": ""}, "suite must be"),
|
||||
({"count": 0}, "count must be"),
|
||||
({"from_min_tests": 0}, "from_min_tests must be"),
|
||||
({"count": 3, "from_min_tests": 2}, "from_min_tests must be"),
|
||||
({"from_min_tests": "5"}, "from_min_tests must be"),
|
||||
({"from_min_tests": None}, "from_min_tests must be"),
|
||||
({"count": True}, "count must be"),
|
||||
({"count": "1"}, "count must be"),
|
||||
({"reason": ""}, "reason must be"),
|
||||
({"decided_by": ""}, "decided_by must be"),
|
||||
({"decided_by": None}, "decided_by must be"),
|
||||
({"date": ""}, "date must be"),
|
||||
({"file": GONE, "tests": {"s.one": 1}}, "not both"),
|
||||
])
|
||||
def test_a_malformed_retired_test_of_main_is_red(tmp_path, monkeypatch, capsys, bad, why):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test(**bad)])
|
||||
code, _r = _judge(tmp_path, GREEN, extra=["--main-required", str(main)])
|
||||
out = capsys.readouterr().out
|
||||
assert code == 1 and "retired list of main" in out and why in out, out
|
||||
assert why in " ".join(verdict.validate_retired([_retired_test(**bad)], {"s.one"}))
|
||||
|
||||
|
||||
def test_the_same_test_declared_twice_for_a_suite_is_red():
|
||||
assert any("more than once" in p for p in verdict.validate_retired([_retired_test(), _retired_test()], {"s.one"}))
|
||||
assert verdict.validate_retired([_retired_test(), _retired_test(suite="s.two")], {"s.one", "s.two"}) == []
|
||||
|
||||
|
||||
def test_files_and_tests_may_share_the_list():
|
||||
assert verdict.validate_retired([_retired(), _retired_test()], {"s.one"}) == []
|
||||
|
||||
|
||||
def test_an_entry_allows_the_drop_only_while_main_still_has_the_floor_it_was_written_at(tmp_path, monkeypatch, capsys):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test(from_min_tests=5)], min_tests=5)
|
||||
assert _judge(tmp_path, GREEN, extra=["--main-required", str(main)])[0] == 0
|
||||
capsys.readouterr()
|
||||
# the removal is on main: its floor is 4, the entry was written at 5 and is inert, so a further drop is red
|
||||
sub = tmp_path / "later"
|
||||
sub.mkdir()
|
||||
main = _main_that_had_the_test(sub, [_retired_test(from_min_tests=5)], min_tests=4)
|
||||
code, _r = _judge(sub, GREEN, rows=[_suite(min_tests=3)], extra=["--main-required", str(main)])
|
||||
assert code == 1 and "went down" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_an_inert_entry_asks_nothing_of_a_suite_that_collects_the_test_again(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
main = _main_that_had_the_test(tmp_path, [_retired_test(from_min_tests=5)], min_tests=4)
|
||||
again = GREEN + [_case(FILE_A, "test_gone")]
|
||||
assert _judge(tmp_path, again, rows=[_suite(min_tests=5)], extra=["--main-required", str(main)])[0] == 0
|
||||
|
||||
|
||||
def test_the_entries_of_one_suite_must_share_one_from_min_tests():
|
||||
both = [_retired_test(from_min_tests=5), _retired_test(FILE_B + "::t", from_min_tests=6)]
|
||||
assert any("disagree on from_min_tests" in p for p in verdict.validate_retired(both, {"s.one"}))
|
||||
assert verdict.validate_retired([_retired_test(from_min_tests=5), _retired_test(FILE_B + "::t", from_min_tests=5)], {"s.one"}) == []
|
||||
other = [_retired_test(from_min_tests=5), _retired_test(FILE_B + "::t", suite="s.two", from_min_tests=9)]
|
||||
assert verdict.validate_retired(other, {"s.one", "s.two"}) == []
|
||||
|
||||
|
||||
# --- args --------------------------------------------------------------------------------------------------------
|
||||
def test_args_prints_the_files_and_node_ids_one_per_line(tmp_path, capsys):
|
||||
required = _write_required(tmp_path / "required.json", [_suite()])
|
||||
@@ -836,10 +689,7 @@ def test_the_real_retired_list_is_well_formed_and_names_rows_that_exist():
|
||||
assert verdict.validate_retired(data) == []
|
||||
ids = {r["id"] for r in _real()}
|
||||
for entry in data:
|
||||
if "nodeid" in entry:
|
||||
assert entry["suite"] in ids, entry["nodeid"]
|
||||
else:
|
||||
assert set(entry["tests"]) <= ids, entry["file"]
|
||||
assert set(entry["tests"]) <= ids, entry["file"]
|
||||
|
||||
|
||||
def test_the_tests_a_retired_file_had_are_what_the_collection_counts_while_it_exists():
|
||||
@@ -849,8 +699,6 @@ def test_the_tests_a_retired_file_had_are_what_the_collection_counts_while_it_ex
|
||||
import sys
|
||||
markers = {r["id"]: r["marker"] for r in _real()}
|
||||
for entry in json.loads(RETIRED.read_text(encoding="utf-8")):
|
||||
if "nodeid" in entry:
|
||||
continue # a retired test is counted by the next test
|
||||
if not (ROOT / entry["file"]).is_file():
|
||||
continue
|
||||
for row, declared in entry["tests"].items():
|
||||
@@ -860,27 +708,6 @@ def test_the_tests_a_retired_file_had_are_what_the_collection_counts_while_it_ex
|
||||
assert counted == declared, "%s in %s: declared %d, collected %d" % (entry["file"], row, declared, counted)
|
||||
|
||||
|
||||
def test_every_retired_test_names_a_file_its_row_runs_and_counts_what_the_collection_counts_while_it_exists():
|
||||
"""A retired test leaves a file that stays, in a row that lists that file or that very node id; while the test is still defined in the tree
|
||||
(the PR that removes it deletes it) its count is the number of tests the row's marker collects under that node id."""
|
||||
import subprocess
|
||||
import sys
|
||||
rows = {r["id"]: r for r in _real()}
|
||||
for entry in json.loads(RETIRED.read_text(encoding="utf-8")):
|
||||
if "nodeid" not in entry:
|
||||
continue
|
||||
nid, row = entry["nodeid"], rows[entry["suite"]]
|
||||
path, _sep, name = nid.partition("::")
|
||||
assert nid in row["tests"] or path in row["tests"], "%s is not run by %s" % (nid, row["id"])
|
||||
assert (ROOT / path).is_file(), "%s: the file of a retired test stays" % nid
|
||||
if _node_problems(row["id"], path, name, ROOT):
|
||||
continue # already out of the tree
|
||||
done = subprocess.run([sys.executable, "-m", "pytest", "--collect-only", "-q", "-p", "no:cacheprovider", "-o", "addopts=",
|
||||
"-m", row["marker"], nid], cwd=str(ROOT), capture_output=True, text=True)
|
||||
counted = sum(1 for line in done.stdout.splitlines() if "::" in line)
|
||||
assert counted == entry["count"], "%s in %s: declared %d, collected %d" % (nid, row["id"], entry["count"], counted)
|
||||
|
||||
|
||||
WHOLE_SUITE_MARKER = "not slow and not e2e" # the exact expression of the unit job of tests.yml (pyproject addopts)
|
||||
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
r"""Every Windows job that launches a browser has TEMP and TMP on D:, set on the job.
|
||||
|
||||
The profile of every Firefox the tests launch is made in TEMP. On the Windows runners of GitHub the default TEMP is on C:, and four browsers at
|
||||
once saturate that disk (a queue up to 144, latencies up to 4 s): the parent's main thread stays still 40-60 s and the e2e fail at random
|
||||
(a `goto` that hangs, a start that never answers). Measured on 20/11 with two hunts: the profiles on C: took 5 of 4 shards, TEMP and TMP on
|
||||
`D:\a\_temp` took none. A test cannot fail for a reason that is not its own, so the fix is at the source: the job's `env` names D:.
|
||||
|
||||
`runner.temp` is not readable in a job's `env` (only `github`, `needs`, `strategy`, `matrix`, `inputs`, `secrets` and `vars` are), so the job
|
||||
names the runner's temp folder itself: `D:\a\_temp`, which the runner makes before the first step. A job that runs on both systems says
|
||||
`startsWith(<where it runs>, 'windows') && 'D:\a\_temp' || '/tmp'` (`/tmp` is what Linux uses anyway).
|
||||
|
||||
PyYAML is not a dependency of this package, so the workflows are read line by line: a job is the block under ` <id>:` below `jobs:`, its
|
||||
fields are the ones at four spaces, its `env` the keys at six, where it runs the values of the matrix key (or workflow input) its `runs-on` names.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
WORKFLOWS = Path(__file__).resolve().parents[1] / ".github" / "workflows"
|
||||
BS = chr(92)
|
||||
D_TEMP = "D:" + BS + "a" + BS + "_temp"
|
||||
|
||||
#: A Windows job that is left alone, and why. Nothing else is. (Empty: every Windows job of this repository launches a browser.)
|
||||
EXEMPT: dict[tuple[str, str], str] = {}
|
||||
|
||||
CONDITIONAL = re.compile(
|
||||
r"^\$\{\{\s*startsWith\((?P<ctx>(?:matrix|inputs)\.\w+),\s*'windows'\)\s*&&\s*'(?P<win>[^']*)'\s*\|\|\s*'(?P<other>[^']*)'\s*\}\}$")
|
||||
CONTEXT = re.compile(r"^\$\{\{\s*(?:matrix|inputs)\.(\w+)\s*\}\}$")
|
||||
JOB = re.compile(r"^ ([\w-]+):\s*$")
|
||||
|
||||
|
||||
def _jobs(text: str) -> dict[str, list[str]]:
|
||||
lines = text.split("\n")
|
||||
start = next(i for i, line in enumerate(lines) if line == "jobs:")
|
||||
jobs, current = {}, None
|
||||
for line in lines[start + 1:]:
|
||||
m = JOB.match(line)
|
||||
if m:
|
||||
current = jobs.setdefault(m.group(1), [])
|
||||
elif current is not None:
|
||||
current.append(line)
|
||||
return jobs
|
||||
|
||||
|
||||
def _field(block: list[str], key: str):
|
||||
for line in block:
|
||||
m = re.match(r"^ %s:\s*(.*?)\s*$" % re.escape(key), line)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def _env(block: list[str]) -> dict[str, str]:
|
||||
out, inside = {}, False
|
||||
for line in block:
|
||||
if re.match(r"^ env:\s*$", line):
|
||||
inside = True
|
||||
elif inside:
|
||||
m = re.match(r"^ ([\w.-]+):\s*(.*?)\s*$", line)
|
||||
if m:
|
||||
out[m.group(1)] = m.group(2)
|
||||
elif line.strip() and not line.strip().startswith("#"):
|
||||
inside = False
|
||||
return out
|
||||
|
||||
|
||||
def _strip(value: str) -> str:
|
||||
return value[1:-1] if len(value) >= 2 and value[0] == value[-1] and value[0] in "'\"" else value
|
||||
|
||||
|
||||
def _values_of(text: str, block: list[str], context: str, key: str) -> list[str]:
|
||||
"""The values `key` takes: in the job's matrix (`key: [a, b]` or `{ key: a, ... }` rows), or the options of the workflow input of that name."""
|
||||
if context == "inputs":
|
||||
options = re.search(r"^ %s:\n(?: .*\n)*? options:\n((?: - .*\n)+)" % re.escape(key), text, re.M)
|
||||
return [_strip(x.strip()) for x in re.findall(r"- (.*)", options.group(1))] if options else []
|
||||
out = []
|
||||
for line in block:
|
||||
m = re.match(r"^\s+%s:\s*\[(.*)\]\s*$" % re.escape(key), line)
|
||||
if m:
|
||||
out += [_strip(x.strip()) for x in m.group(1).split(",") if x.strip()]
|
||||
out += [_strip(x) for x in re.findall(r"[{,]\s*%s:\s*([^,}\s]+)" % re.escape(key), line)]
|
||||
return out
|
||||
|
||||
|
||||
def windows_jobs_without_temp_on_d(name: str, text: str) -> list[str]:
|
||||
"""One line per Windows leg of the workflow whose TEMP or TMP is not on D:."""
|
||||
problems = []
|
||||
for job_id, block in _jobs(text).items():
|
||||
runs_on = _field(block, "runs-on")
|
||||
if runs_on is None or (name, job_id) in EXEMPT:
|
||||
continue
|
||||
m = CONTEXT.match(runs_on)
|
||||
if m:
|
||||
context = re.search(r"(matrix|inputs)", runs_on).group(1)
|
||||
legs = [(v, {context + "." + m.group(1): v}) for v in _values_of(text, block, context, m.group(1))]
|
||||
else:
|
||||
legs = [(runs_on, {})]
|
||||
env = _env(block)
|
||||
for runner, leg in legs:
|
||||
if "windows" not in runner:
|
||||
continue
|
||||
for var in ("TEMP", "TMP"):
|
||||
value = None
|
||||
if var in env:
|
||||
raw = env[var]
|
||||
c = CONDITIONAL.match(_strip(raw)) or CONDITIONAL.match(raw)
|
||||
if c:
|
||||
value = _strip(c.group("win")) if leg.get(c.group("ctx"), "").startswith("windows") else c.group("other")
|
||||
else:
|
||||
value = _strip(raw)
|
||||
if value is None or not value.upper().startswith("D:" + BS):
|
||||
problems.append("%s: job `%s` on %s has %s=%r, not a folder on D:" % (name, job_id, runner, var, value))
|
||||
return problems
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", sorted(WORKFLOWS.glob("*.yml")), ids=lambda p: p.name)
|
||||
def test_every_windows_job_keeps_the_profiles_on_d(path):
|
||||
assert windows_jobs_without_temp_on_d(path.name, path.read_text(encoding="utf-8")) == []
|
||||
|
||||
|
||||
def test_the_windows_jobs_that_launch_a_browser_are_all_seen():
|
||||
"""The check must find the legs it is meant to judge: a parser that sees none says fine to everything."""
|
||||
seen = {}
|
||||
for path in WORKFLOWS.glob("*.yml"):
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for job_id, block in _jobs(text).items():
|
||||
runs_on = _field(block, "runs-on") or ""
|
||||
m = CONTEXT.match(runs_on)
|
||||
values = _values_of(text, block, re.search(r"(matrix|inputs)", runs_on).group(1), m.group(1)) if m else [runs_on]
|
||||
if any("windows" in v for v in values):
|
||||
seen[(path.name, job_id)] = True
|
||||
expected = {("e2e.yml", "e2e-windows"), ("e2e.yml", "e2e-windows-control-a"), ("fakeweb.yml", "walk"), ("tests.yml", "unit"),
|
||||
("firefox-launch-matrix.yml", "smoke"), ("real-sites.yml", "round"), ("real-sites.yml", "admit"),
|
||||
("user-install.yml", "install"), ("e2e-hunt.yml", "hunt")}
|
||||
assert expected <= set(seen), "the check does not see %s" % sorted(expected - set(seen))
|
||||
|
||||
|
||||
def _wf(runs_on, env="", matrix=""):
|
||||
text = "jobs:\n a:\n runs-on: %s\n" % runs_on
|
||||
if env:
|
||||
text += " env:\n" + "".join(" %s: %s\n" % kv for kv in env)
|
||||
return text + matrix + " steps:\n - run: x\n"
|
||||
|
||||
|
||||
def test_the_check_sees_what_it_is_meant_to_see():
|
||||
"""A check that has only ever said fine is not known to say anything else."""
|
||||
check = windows_jobs_without_temp_on_d
|
||||
assert check("x.yml", _wf("windows-2022")), "a Windows job with no TEMP passed"
|
||||
assert len(check("x.yml", _wf("windows-2022", [("TEMP", "C:" + BS + "t"), ("TMP", "'" + D_TEMP + "'")]))) == 1, "TEMP on C: passed"
|
||||
assert len(check("x.yml", _wf("windows-2022", [("TEMP", "'" + D_TEMP + "'")]))) == 1, "a job with TEMP and no TMP passed"
|
||||
assert check("x.yml", _wf("windows-2022", [("TEMP", "'" + D_TEMP + "'"), ("TMP", "'" + D_TEMP + "'")])) == []
|
||||
cond = "${{ startsWith(matrix.os, 'windows') && '" + D_TEMP + "' || '/tmp' }}"
|
||||
matrix = " strategy:\n matrix:\n os: [ubuntu-24.04, windows-latest]\n"
|
||||
assert check("x.yml", _wf("${{ matrix.os }}", [("TEMP", cond), ("TMP", cond)], matrix)) == []
|
||||
wrong_way = cond.replace("'" + D_TEMP + "' || '/tmp'", "'/tmp' || '" + D_TEMP + "'")
|
||||
assert len(check("x.yml", _wf("${{ matrix.os }}", [("TEMP", wrong_way), ("TMP", wrong_way)], matrix))) == 2, "a matrix job on C: on Windows passed"
|
||||
assert len(check("x.yml", _wf("${{ matrix.os }}", None, matrix))) == 2, "a matrix job with no TEMP passed"
|
||||
include = " strategy:\n matrix:\n include:\n - { os: linux, runner: ubuntu-24.04 }\n - { os: windows, runner: windows-2022 }\n"
|
||||
assert len(check("x.yml", _wf("${{ matrix.runner }}", None, include))) == 2, "a Windows leg of an `include` matrix was not seen"
|
||||
assert check("x.yml", _wf("ubuntu-24.04")) == [], "a Linux job was judged"
|
||||
inputs = "on:\n workflow_dispatch:\n inputs:\n os:\n type: choice\n options:\n - ubuntu-24.04\n - windows-latest\n"
|
||||
assert len(check("x.yml", inputs + _wf("${{ inputs.os }}"))) == 2, "a Windows option of a workflow input was not seen"
|
||||
@@ -1020,7 +1020,7 @@ def test_neither_entry_point_decides_the_cursor_default(cls):
|
||||
What the value IS gets asserted where it lives, in the core's own suite,
|
||||
and end to end by `test_the_show_cursor_kwarg_reaches_the_prefs`.
|
||||
|
||||
(Owner decision 2026-08-28: on. The studied system ships it on too. The argument for
|
||||
(Owner decision 2026-08-28: on. Camoufox ships it on too. The argument for
|
||||
off has not gone away and is recorded next to the constant: a pointer
|
||||
gliding across a window with nobody touching the mouse reads as "this is a
|
||||
bot" to any person glancing at the monitor.)
|
||||
|
||||
+136
-53
@@ -1,27 +1,36 @@
|
||||
"""E2E: run the REAL open-source detector libraries against the patched binary, on CI.
|
||||
"""E2E: run the REAL open-source detectors against the patched binary, on CI.
|
||||
|
||||
Instead of our own hand-rolled signal checks, this loads the actual detection
|
||||
libraries and uses their FULL API surface:
|
||||
|
||||
* The client-side bot detector (MIT) - the one a commercial fingerprinting
|
||||
service itself uses. We assert the aggregate verdict
|
||||
* BotD (@fingerprintjs/botd, MIT) - the client-side bot detector that
|
||||
FingerprintJS Pro itself uses. We assert the aggregate verdict
|
||||
(``detect().bot == False``) AND every one of its ~18 individual detectors
|
||||
(``getDetections()``) returns ``bot == False``.
|
||||
* The open-source fingerprint library (MIT) - ``get()`` must return a ``visitorId``
|
||||
* FingerprintJS open-source (MIT) - ``get()`` must return a ``visitorId``
|
||||
that is STABLE across two fresh launches with the same seed, and a RICH
|
||||
component set (the fingerprint surface is real, not a stub).
|
||||
* The automation-rules scanner (version 1.0.6, MIT) - ``collectFingerprint()``
|
||||
* fpscanner (antoinevastel/fpscanner 1.0.6, MIT) - ``collectFingerprint()``
|
||||
runs ~21 bot-detection rules in the browser. We assert the **engine-agnostic**
|
||||
subset (webdriver / selenium / bot-UA / platform / timezone / language) is
|
||||
clean. We deliberately do NOT assert the Chrome/GPU-only rules (hasCDP,
|
||||
hasPlaywright, hasSwiftshaderRenderer, hasMissingChromeObject, …): they're
|
||||
trivially clean on Firefox, and the GPU ones can legitimately fire on a
|
||||
software-WebGL CI host (Xvfb/llvmpipe) - asserting them would false-red.
|
||||
* CreepJS (abrahamjuliot/creepjs, MIT, pinned) - the gold-standard Firefox-aware
|
||||
headless/stealth/lie detector. It exposes its result on ``window.Fingerprint``.
|
||||
We assert ``headlessRating == 0`` (webdriver + headless-UA tells) and the
|
||||
JS-proxy stealth tells are absent. ``stealthRating`` / ``totalLies`` /
|
||||
``likeHeadlessRating`` are LOGGED, not hard-asserted, because some of their
|
||||
sub-signals (hasBadWebGL, prefers-light-color) are GPU/theme-sensitive and
|
||||
differ on a GPU-less CI host.
|
||||
|
||||
Everything is hermetic: the libraries are vendored (tests/vendor/) and served
|
||||
from a localhost HTTP server - no external CDN call. Runs identically on a dev box and a GH runner.
|
||||
from a localhost HTTP server - no external CDN call. For CreepJS, every non-local
|
||||
request is aborted, so its optional crowd-comparison POST never runs and the
|
||||
verdict is computed purely locally. Runs identically on a dev box and a GH runner.
|
||||
|
||||
NOT covered: the commercial, server-side service built on the fingerprint library - stays the local
|
||||
NOT covered: FingerprintJS *Pro* (commercial, server-side) - stays the local
|
||||
realness gate.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -37,16 +46,17 @@ from invisible_playwright import InvisiblePlaywright
|
||||
from _servers import LocalServer
|
||||
|
||||
_VENDOR = Path(__file__).parent / "vendor"
|
||||
_BOT_DETECTOR = "bot-detector-2.0.0.esm.js"
|
||||
_FINGERPRINT_LIB = "fingerprint-library-5.2.0.umd.min.js"
|
||||
_RULES_SCANNER = "rules-scanner-1.0.6.es.js"
|
||||
_BOTD = "botd-2.0.0.esm.js"
|
||||
_FPJS = "fingerprintjs-5.2.0.umd.min.js"
|
||||
_FPSCANNER = "fpscanner-1.0.6.es.js"
|
||||
_CREEPJS = "creepjs-10aa672.js" # pinned abrahamjuliot/creepjs@10aa6724
|
||||
|
||||
# rules-scanner rules that are MEANINGFUL on Firefox and GPU-independent - these must
|
||||
# fpscanner rules that are MEANINGFUL on Firefox and GPU-independent - these must
|
||||
# stay clean. The omitted rules are Chrome-only (hasCDP/hasPlaywright/
|
||||
# hasMissingChromeObject/hasHighCPUCount/hasImpossibleDeviceMemory/
|
||||
# headlessChromeScreenResolution) or GPU-sensitive on a software-WebGL CI host
|
||||
# (hasSwiftshaderRenderer/hasGPUMismatch/hasMismatchWebGLInWorker).
|
||||
_RULES_SCANNER_AGNOSTIC = [
|
||||
_FPSCANNER_AGNOSTIC = [
|
||||
"hasWebdriver", "hasWebdriverIframe", "hasWebdriverWorker", "hasWebdriverWritable",
|
||||
"hasSeleniumProperty", "hasBotUserAgent", "hasPlatformMismatch",
|
||||
"hasMismatchLanguages", "hasUTCTimezone", "hasMismatchPlatformIframe",
|
||||
@@ -55,31 +65,29 @@ _RULES_SCANNER_AGNOSTIC = [
|
||||
|
||||
_PAGE = f"""<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>detectors</title>
|
||||
<script>const knownGlobals = new Set(Object.getOwnPropertyNames(window));</script>
|
||||
<script src="/{_FINGERPRINT_LIB}"></script>
|
||||
<script>window.__fpLib = window[Object.getOwnPropertyNames(window).find(n => !knownGlobals.has(n))];</script>
|
||||
<script src="/{_FPJS}"></script>
|
||||
</head><body><h1 id="state">loading</h1>
|
||||
<script type="module">
|
||||
window.__bot_det = null; window.__fp = null; window.__fps = null; window.__err = "";
|
||||
window.__botd = null; window.__fp = null; window.__fps = null; window.__err = "";
|
||||
(async () => {{
|
||||
try {{
|
||||
const Detector = await import("/{_BOT_DETECTOR}");
|
||||
const bot_det = await Detector.load();
|
||||
const verdict = bot_det.detect();
|
||||
const raw = bot_det.getDetections() || {{}};
|
||||
const Botd = await import("/{_BOTD}");
|
||||
const botd = await Botd.load();
|
||||
const verdict = botd.detect();
|
||||
const raw = botd.getDetections() || {{}};
|
||||
const detections = {{}};
|
||||
for (const k in raw) detections[k] = {{ bot: raw[k].bot, botKind: raw[k].botKind || null }};
|
||||
window.__bot_det = {{ bot: verdict.bot, botKind: verdict.botKind || null, detections }};
|
||||
}} catch (e) {{ window.__err += " bot_det:" + e; }}
|
||||
window.__botd = {{ bot: verdict.bot, botKind: verdict.botKind || null, detections }};
|
||||
}} catch (e) {{ window.__err += " botd:" + e; }}
|
||||
try {{
|
||||
const fp = await window.__fpLib.load();
|
||||
const fp = await FingerprintJS.load();
|
||||
const r = await fp.get();
|
||||
const keys = Object.keys(r.components || {{}});
|
||||
const errored = keys.filter(k => r.components[k] && "error" in r.components[k]);
|
||||
window.__fp = {{ visitorId: r.visitorId, componentKeys: keys, erroredComponents: errored }};
|
||||
}} catch (e) {{ window.__err += " fp:" + e; }}
|
||||
try {{
|
||||
const M = await import("/{_RULES_SCANNER}");
|
||||
const M = await import("/{_FPSCANNER}");
|
||||
const scanner = new M.default();
|
||||
const fp = await scanner.collectFingerprint({{ encrypt: false }});
|
||||
window.__fps = {{ fastBotDetection: fp.fastBotDetection, details: fp.fastBotDetectionDetails }};
|
||||
@@ -88,12 +96,20 @@ window.__bot_det = null; window.__fp = null; window.__fps = null; window.__err =
|
||||
}})();
|
||||
</script></body></html>"""
|
||||
|
||||
# CreepJS gets its own page: creep.js is a plain `defer` script that runs on load
|
||||
# and populates window.Fingerprint. A minimal DOM is enough (the rich report DOM
|
||||
# is only for the visual page, not the computation).
|
||||
_CREEP_PAGE = f"""<!doctype html><html><head><meta charset="utf-8"><title>creep</title></head>
|
||||
<body><div id="fingerprint-data"></div><script src="/{_CREEPJS}" defer></script></body></html>"""
|
||||
|
||||
|
||||
class _DetectorSite:
|
||||
"""Localhost server: `/` → bot detector + fingerprint library + rules scanner page,
|
||||
"""Localhost server: `/` → BotD+FPJS+fpscanner page, `/creepjs` → CreepJS page,
|
||||
`/<file>` → the vendored bundle."""
|
||||
|
||||
def __init__(self):
|
||||
page = _PAGE.encode()
|
||||
creep_page = _CREEP_PAGE.encode()
|
||||
# Preload the vendored bundle by exact filename. Serving from this map
|
||||
# means a request never builds a filesystem path from its own input, so
|
||||
# there is no path a crafted request could traverse.
|
||||
@@ -104,6 +120,8 @@ class _DetectorSite:
|
||||
p = self.path.split("?")[0]
|
||||
if p == "/":
|
||||
body, ctype = page, "text/html; charset=utf-8"
|
||||
elif p == "/creepjs":
|
||||
body, ctype = creep_page, "text/html; charset=utf-8"
|
||||
else:
|
||||
body = files.get(Path(p.lstrip("/")).name)
|
||||
if body is None:
|
||||
@@ -126,6 +144,10 @@ class _DetectorSite:
|
||||
def url(self):
|
||||
return f"http://127.0.0.1:{self.port}/"
|
||||
|
||||
@property
|
||||
def creep_url(self):
|
||||
return f"http://127.0.0.1:{self.port}/creepjs"
|
||||
|
||||
def close(self):
|
||||
self._srv.shutdown()
|
||||
|
||||
@@ -138,7 +160,7 @@ def detector_site():
|
||||
|
||||
|
||||
def _run_detectors(firefox_binary, url):
|
||||
"""Launch the binary, load the page, return (bot_det, fp, fps, err)."""
|
||||
"""Launch the binary, load the page, return (botd, fp, fps, err)."""
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto(url, wait_until="load", timeout=45000)
|
||||
@@ -146,31 +168,64 @@ def _run_detectors(firefox_binary, url):
|
||||
"() => document.getElementById('state').textContent === 'done'",
|
||||
timeout=45000,
|
||||
)
|
||||
bot_det = page.evaluate("() => window.__bot_det")
|
||||
botd = page.evaluate("() => window.__botd")
|
||||
fp = page.evaluate("() => window.__fp")
|
||||
fps = page.evaluate("() => window.__fps")
|
||||
err = page.evaluate("() => window.__err")
|
||||
return bot_det, fp, fps, err
|
||||
return botd, fp, fps, err
|
||||
|
||||
|
||||
def _run_creepjs(firefox_binary, creep_url):
|
||||
"""Launch the binary, run CreepJS fully offline, return its headless result."""
|
||||
_EV = """() => {
|
||||
const f = window.Fingerprint;
|
||||
if (!f || !f.headless) return { ready: false };
|
||||
const h = f.headless;
|
||||
return {
|
||||
ready: true,
|
||||
headlessRating: h.headlessRating,
|
||||
stealthRating: h.stealthRating,
|
||||
likeHeadlessRating: h.likeHeadlessRating,
|
||||
headless: h.headless || {},
|
||||
stealth: h.stealth || {},
|
||||
totalLies: (f.lies && f.lies.totalLies) || 0,
|
||||
};
|
||||
}"""
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary) as browser:
|
||||
page = browser.new_page()
|
||||
# NetworkObserver was stripped to the bone on 2026-08-24: page.route()
|
||||
# no longer exists (Network.setRequestInterception refuses), so
|
||||
# blocking CreepJS's optional POST to arh.antoinevastel.com can no
|
||||
# longer be done this way. Verified: without the block the test still
|
||||
# passes, with the same outcome on headlessRating/stealth - that POST
|
||||
# was test-hygiene isolation (speed, no dependency on a third-party
|
||||
# site), not a precondition of the assertions.
|
||||
page.goto(creep_url, wait_until="domcontentloaded", timeout=45000)
|
||||
page.wait_for_function(
|
||||
"() => !!(window.Fingerprint && window.Fingerprint.headless)",
|
||||
timeout=60000,
|
||||
)
|
||||
return page.evaluate(_EV)
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_bot_detector_flags_no_automation(firefox_binary, detector_site):
|
||||
"""The real bot detector must not flag the build - aggregate AND every one of its
|
||||
def test_botd_no_detector_flags_automation(firefox_binary, detector_site):
|
||||
"""The real BotD must not flag the build - aggregate AND every one of its
|
||||
individual detectors (webDriver/userAgent/appVersion/plugins/process/...)."""
|
||||
bot_det, _fp, _fps, err = _run_detectors(firefox_binary, detector_site.url)
|
||||
assert bot_det is not None, f"the bot detector produced no result (err:{err!r})"
|
||||
assert bot_det.get("bot") is False, (
|
||||
f"the bot detector aggregate flagged a bot: botKind={bot_det.get('botKind')!r}"
|
||||
botd, _fp, _fps, err = _run_detectors(firefox_binary, detector_site.url)
|
||||
assert botd is not None, f"BotD produced no result (err:{err!r})"
|
||||
assert botd.get("bot") is False, (
|
||||
f"BotD aggregate flagged a bot: botKind={botd.get('botKind')!r}"
|
||||
)
|
||||
detections = bot_det.get("detections") or {}
|
||||
assert detections, f"the bot detector getDetections() returned nothing (err:{err!r})"
|
||||
detections = botd.get("detections") or {}
|
||||
assert detections, f"BotD getDetections() returned nothing (err:{err!r})"
|
||||
flagged = {k: v.get("botKind") for k, v in detections.items() if v.get("bot")}
|
||||
assert not flagged, f"the bot detector individual detectors flagged automation: {flagged}"
|
||||
assert not flagged, f"BotD individual detectors flagged automation: {flagged}"
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_fingerprint_library_visitorid_is_stable_across_launches(firefox_binary, detector_site):
|
||||
"""The fingerprint library visitorId must be present and identical across two fresh
|
||||
def test_fingerprintjs_visitorid_stable_across_launches(firefox_binary, detector_site):
|
||||
"""FingerprintJS visitorId must be present and identical across two fresh
|
||||
launches with the same seed - a real browser is stable; an over-randomized
|
||||
spoof drifts (and a drifting fingerprint is itself a bot tell)."""
|
||||
_b1, fp1, _f1, err1 = _run_detectors(firefox_binary, detector_site.url)
|
||||
@@ -178,43 +233,71 @@ def test_the_fingerprint_library_visitorid_is_stable_across_launches(firefox_bin
|
||||
assert fp1 and fp1.get("visitorId"), f"no visitorId on run 1 (err:{err1!r})"
|
||||
assert fp2 and fp2.get("visitorId"), f"no visitorId on run 2 (err:{err2!r})"
|
||||
assert fp1["visitorId"] == fp2["visitorId"], (
|
||||
f"the fingerprint library visitorId drifted across launches: "
|
||||
f"FingerprintJS visitorId drifted across launches: "
|
||||
f"{fp1['visitorId']!r} != {fp2['visitorId']!r} (per-session entropy = bot tell)"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_fingerprint_library_collects_a_rich_fingerprint(firefox_binary, detector_site):
|
||||
"""The fingerprint library must collect a RICH component surface (a real browser
|
||||
def test_fingerprintjs_collects_rich_fingerprint(firefox_binary, detector_site):
|
||||
"""FingerprintJS must collect a RICH component surface (a real browser
|
||||
exposes many signals; a stripped/blocked surface is itself suspicious)."""
|
||||
_b, fp, _f, err = _run_detectors(firefox_binary, detector_site.url)
|
||||
assert fp and fp.get("visitorId"), f"the fingerprint library produced no id (err:{err!r})"
|
||||
assert fp and fp.get("visitorId"), f"FingerprintJS produced no id (err:{err!r})"
|
||||
keys = fp.get("componentKeys") or []
|
||||
assert len(keys) >= 15, (
|
||||
f"the fingerprint library collected only {len(keys)} components - surface too thin "
|
||||
f"FingerprintJS collected only {len(keys)} components - surface too thin "
|
||||
f"(suppressed signals are themselves a tell): {keys}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_rules_scanner_flags_no_automation_rule(firefox_binary, detector_site):
|
||||
"""The rules scanner's engine-agnostic bot rules (webdriver/selenium/bot-UA/platform/
|
||||
def test_fpscanner_no_automation_rules(firefox_binary, detector_site):
|
||||
"""fpscanner's engine-agnostic bot rules (webdriver/selenium/bot-UA/platform/
|
||||
timezone/language) must all be clean. The Chrome/GPU-only rules are ignored
|
||||
on purpose (see module docstring) - they false-red on a software-WebGL host."""
|
||||
_b, _fp, fps, err = _run_detectors(firefox_binary, detector_site.url)
|
||||
assert fps is not None, f"the rules scanner produced no result (err:{err!r})"
|
||||
assert fps is not None, f"fpscanner produced no result (err:{err!r})"
|
||||
details = fps.get("details") or {}
|
||||
assert details, f"the rules scanner returned no detection details (err:{err!r})"
|
||||
assert details, f"fpscanner returned no detection details (err:{err!r})"
|
||||
flagged = [
|
||||
k for k in _RULES_SCANNER_AGNOSTIC
|
||||
k for k in _FPSCANNER_AGNOSTIC
|
||||
if details.get(k) and details[k].get("detected")
|
||||
]
|
||||
assert not flagged, (
|
||||
f"the rules scanner flagged automation on engine-agnostic rules: {flagged} "
|
||||
f"fpscanner flagged automation on engine-agnostic rules: {flagged} "
|
||||
f"(full details: { {k: v for k, v in details.items() if v.get('detected')} })"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_creepjs_headless_and_proxy_clean(firefox_binary, detector_site):
|
||||
"""CreepJS (Firefox-aware) must see no headless tell and no JS-proxy stealth
|
||||
tell. ``headlessRating`` aggregates webDriverIsOn + headless-UA checks (all
|
||||
GPU-independent). The proxy/runtime stealth sub-signals (hasIframeProxy,
|
||||
hasToStringProxy, hasBadChromeRuntime) must be false - a spoof implemented
|
||||
with a JS Proxy is exactly what CreepJS catches. stealthRating/totalLies/
|
||||
likeHeadlessRating are GPU/theme-sensitive, so we log them, not assert."""
|
||||
r = _run_creepjs(firefox_binary, detector_site.creep_url)
|
||||
assert r and r.get("ready"), f"CreepJS never populated window.Fingerprint: {r!r}"
|
||||
print(
|
||||
f"[creepjs] headlessRating={r['headlessRating']} stealthRating={r['stealthRating']} "
|
||||
f"likeHeadlessRating={r['likeHeadlessRating']} totalLies={r['totalLies']} "
|
||||
f"headless={r['headless']} stealth={r['stealth']}"
|
||||
)
|
||||
assert r["headlessRating"] == 0, (
|
||||
f"CreepJS headless tells fired: headless={r['headless']} "
|
||||
f"(headlessRating={r['headlessRating']})"
|
||||
)
|
||||
stealth = r.get("stealth") or {}
|
||||
proxy_tells = {
|
||||
k: stealth.get(k)
|
||||
for k in ("hasIframeProxy", "hasToStringProxy", "hasBadChromeRuntime")
|
||||
if stealth.get(k)
|
||||
}
|
||||
assert not proxy_tells, f"CreepJS JS-proxy stealth tells fired: {proxy_tells}"
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_enumerate_devices_resolves_promptly(firefox_binary, detector_site):
|
||||
"""navigator.mediaDevices.enumerateDevices() must RESOLVE, and quickly.
|
||||
@@ -223,11 +306,11 @@ def test_enumerate_devices_resolves_promptly(firefox_binary, detector_site):
|
||||
it even though it was the cause of four different failures.
|
||||
|
||||
The symptom that was visible was
|
||||
`test_the_fingerprint_library_visitorid_is_stable_across_launches` going red roughly one
|
||||
`test_fingerprintjs_visitorid_stable_across_launches` going red roughly one
|
||||
time in three - a name that sends you the wrong way, because it had nothing
|
||||
to do with either the identifier or its stability. The detectors page stayed
|
||||
at `state='loading'`: the bot detector finished, the fingerprint library finished, the rules scanner did
|
||||
not. Inside the rules scanner:
|
||||
at `state='loading'`: BotD finished, FingerprintJS finished, fpscanner did
|
||||
not. Inside fpscanner:
|
||||
|
||||
return new Promise(async function(t) {
|
||||
const a = await navigator.mediaDevices.enumerateDevices();
|
||||
|
||||
@@ -422,7 +422,6 @@ def test_a_real_page_sees_a_drag_that_travelled(firefox_binary):
|
||||
"""
|
||||
import urllib.parse
|
||||
|
||||
import _os_cursor
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
html = (
|
||||
@@ -446,11 +445,6 @@ def test_a_real_page_sees_a_drag_that_travelled(firefox_binary):
|
||||
with InvisiblePlaywright(seed=42, binary_path=firefox_binary) as browser:
|
||||
page = browser.new_page()
|
||||
page.goto("data:text/html," + urllib.parse.quote(html))
|
||||
# ⛔ THE OS CURSOR IS NOT IN THE WINDOW. A window under the real cursor gets a native move for it, the first native move of a process passes Gecko's
|
||||
# filter, and the page saw `mousemove 512,299 buttons=0` after the press (the runner's cursor is at 512,384, the window covers it). The cursor is
|
||||
# parked before the browser starts (`tests/_os_cursor.py`, the autouse fixture of conftest); here the test says it is still outside, so a gesture
|
||||
# judged by the events it records is never judged with the system's own move among them.
|
||||
_os_cursor.require_outside()
|
||||
page.mouse.move(300, 300)
|
||||
page.evaluate("() => { window.__e = []; }")
|
||||
page.drag_and_drop("#a", "#b")
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
"""Every page or frame that an e2e test asks the fake sites for is a route that the same file registers.
|
||||
|
||||
``Sites`` (``tests/_fission_frames.py``) answers a path that nobody routed with a 404 and an EMPTY body, in no error. A page that is loaded from such a path is an empty document: the test
|
||||
goes on and fails later, in a place that does not say why. The intersection twin did that: the frame's source was ``sites.url("B", "/io")``, the route of that path was dropped in one commit
|
||||
and ``_register`` did not get it back, so ``document.getElementById('t')`` was null and ``IntersectionObserver.observe`` threw, in a frame whose request was answered 404.
|
||||
|
||||
The rule (a red closes by a written rule that a test imposes on every file): in each test module that runs ``Sites()``, every ``X.url(site, path)`` call, and every
|
||||
``wait_frame``/``frame_of`` call that names a site and a path (``X.url(site)`` or ``X.origin[site]``, and the path), has a ``X.route(site, path, ...)`` call in the same module.
|
||||
|
||||
HOW THE PATHS ARE READ (``ast``, no browser). A path is its text where it is a string. A part that is computed (``"/io-" + tag``, ``"/h%d" % n``, an f-string) is a wildcard, so ``"/io-" + tag`` asked
|
||||
and ``"/io-" + tag`` routed are the same page. A site that is a name (a loop variable) is any site. A path that is only a name (``sites.url(site, path)``) is any route of that site: it is
|
||||
resolved at run time, and the module must at least route something for it. The scope is the module: a registration is in a helper that the tests of the module call, and the module is the unit
|
||||
that holds both ends, so the check does not follow calls.
|
||||
|
||||
THE EXEMPTIONS are listed in ``EXEMPT`` with the reason; an entry that no call uses any more is itself red, so the list cannot outlive its case.
|
||||
|
||||
Known-bad input: the intersection file as it was (``sites.url("B", "/io")`` asked, ``B /io`` never routed), and a snippet of the same shape. Green: the file with the route back, a snippet that routes it,
|
||||
and the paths with a computed part. The scan must find calls: a scan that reads no ``url`` and no ``route`` of a file that has both is red, so a change of the call shapes cannot turn the check into a pass.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, NamedTuple, Optional, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
|
||||
#: (file name, site, path as the scan reads it) -> why this asked path is no page that a browser loads. A path that is asked and compared, never requested.
|
||||
EXEMPT: Dict[Tuple[str, str, str], str] = {
|
||||
("test_fission_frames_workers_storage_and_special_frames_e2e.py", "B", "/"):
|
||||
"the expected scope of a service worker (the folder of its script) is compared with the scope the page reads; no request is made for it",
|
||||
}
|
||||
|
||||
#: A frame lookup: ``wait_frame(page, origin, path)`` and ``frame_of(page, origin, path)``, ``origin`` being ``X.url(site)`` or ``X.origin[site]``.
|
||||
FRAME_LOOKUPS = ("wait_frame", "frame_of")
|
||||
|
||||
_SPEC = re.compile(r"%[-#0 +]*\d*(?:\.\d+)?[sdrifx]")
|
||||
_FORMAT_FIELD = re.compile(r"\{[^{}]*\}")
|
||||
|
||||
|
||||
class Use(NamedTuple):
|
||||
kind: str # "url" or "route"
|
||||
site: str # "A", "B", "C" or "*" (not a literal)
|
||||
path: str # the text, a computed part as "*"
|
||||
line: int
|
||||
|
||||
|
||||
def _shape(node: ast.AST) -> str:
|
||||
"""The text of a path expression, a computed part as ``*``."""
|
||||
if isinstance(node, ast.Constant) and isinstance(node.value, str):
|
||||
return node.value
|
||||
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add):
|
||||
return _shape(node.left) + _shape(node.right)
|
||||
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Mod) and isinstance(node.left, ast.Constant) and isinstance(node.left.value, str):
|
||||
return _SPEC.sub("*", node.left.value)
|
||||
if isinstance(node, ast.JoinedStr):
|
||||
return "".join(_shape(part.value) if isinstance(part, ast.Constant) or not isinstance(part, ast.FormattedValue) else "*" for part in node.values)
|
||||
if (isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and node.func.attr == "format"
|
||||
and isinstance(node.func.value, ast.Constant) and isinstance(node.func.value.value, str)):
|
||||
return _FORMAT_FIELD.sub("*", node.func.value.value)
|
||||
return "*"
|
||||
|
||||
|
||||
def _site(node: ast.AST) -> str:
|
||||
if isinstance(node, ast.Constant) and node.value in ("A", "B", "C"):
|
||||
return node.value
|
||||
return "*"
|
||||
|
||||
|
||||
def _is_url_call(node: ast.AST, args: int) -> bool:
|
||||
return isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and node.func.attr == "url" and len(node.args) == args and not node.keywords
|
||||
|
||||
|
||||
def _origin_site(node: ast.AST) -> Optional[str]:
|
||||
"""The site of an origin expression: ``X.url("B")`` or ``X.origin["B"]``; None for anything else."""
|
||||
if _is_url_call(node, 1):
|
||||
return _site(node.args[0])
|
||||
if isinstance(node, ast.Subscript) and isinstance(node.value, ast.Attribute) and node.value.attr == "origin":
|
||||
return _site(node.slice)
|
||||
return None
|
||||
|
||||
|
||||
def uses_in(source: str) -> List[Use]:
|
||||
"""Every path a module asks the fake sites for (``url``) and every one it registers (``route``), in source order."""
|
||||
out: List[Use] = []
|
||||
for node in ast.walk(ast.parse(source)):
|
||||
if not isinstance(node, ast.Call):
|
||||
continue
|
||||
if _is_url_call(node, 2):
|
||||
out.append(Use("url", _site(node.args[0]), _shape(node.args[1]), node.lineno))
|
||||
elif isinstance(node.func, ast.Attribute) and node.func.attr == "route" and len(node.args) >= 3 and isinstance(node.args[0], (ast.Constant, ast.Name)):
|
||||
out.append(Use("route", _site(node.args[0]), _shape(node.args[1]), node.lineno))
|
||||
elif isinstance(node.func, ast.Name) and node.func.id in FRAME_LOOKUPS and len(node.args) >= 3:
|
||||
site = _origin_site(node.args[1])
|
||||
if site is not None:
|
||||
out.append(Use("url", site, _shape(node.args[2]), node.lineno))
|
||||
return out
|
||||
|
||||
|
||||
def runs_sites(source: str) -> bool:
|
||||
"""Whether the module builds a ``Sites()`` (a call, not a name in text)."""
|
||||
return any(isinstance(n, ast.Call) and isinstance(n.func, ast.Name) and n.func.id == "Sites" for n in ast.walk(ast.parse(source)))
|
||||
|
||||
|
||||
def _same_page(asked: Use, routed: Use) -> bool:
|
||||
if "*" not in (asked.site, routed.site) and asked.site != routed.site:
|
||||
return False
|
||||
if asked.path == "*" or routed.path == "*":
|
||||
return True
|
||||
pattern = lambda text: re.compile(".*".join(re.escape(part) for part in text.split("*"))) # noqa: E731
|
||||
return bool(pattern(asked.path).fullmatch(routed.path) or pattern(routed.path).fullmatch(asked.path))
|
||||
|
||||
|
||||
def unrouted(source: str, name: str = "<module>") -> List[str]:
|
||||
"""What the module asks for that it does not route, one line each: where, what, how to correct, which rule. ``[]`` when each is routed or exempt."""
|
||||
uses = uses_in(source)
|
||||
routes = [u for u in uses if u.kind == "route"]
|
||||
problems: List[str] = []
|
||||
for asked in (u for u in uses if u.kind == "url"):
|
||||
if (name, asked.site, asked.path) in EXEMPT:
|
||||
continue
|
||||
if not any(_same_page(asked, routed) for routed in routes):
|
||||
problems.append(
|
||||
"%s:%d asks the fake sites for %s %s and nothing in the module routes it: an unrouted path is a 404 with an empty body (tests/_fission_frames.py), so the page that loads it is "
|
||||
"an empty document. Add sites.route(%r, %r, <page>) where the module registers its pages (the rule: every page a test asks the fake sites for is a route of the same module)"
|
||||
% (name, asked.line, "site " + asked.site, repr(asked.path), asked.site, asked.path))
|
||||
return problems
|
||||
|
||||
|
||||
def _modules() -> Dict[str, str]:
|
||||
return {path.name: path.read_text(encoding="utf-8") for path in sorted(TESTS.glob("*.py")) if path.name != Path(__file__).name
|
||||
and "Sites(" in path.read_text(encoding="utf-8") and runs_sites(path.read_text(encoding="utf-8"))}
|
||||
|
||||
|
||||
# ---- the rule, on every module of the tests ------------------------------------------------------------------------------------------
|
||||
|
||||
def test_every_page_an_e2e_test_asks_the_fake_sites_for_is_routed_by_its_module():
|
||||
problems: List[str] = []
|
||||
for name, source in _modules().items():
|
||||
problems += unrouted(source, name)
|
||||
assert not problems, "\n" + "\n".join(problems)
|
||||
|
||||
|
||||
def test_an_exemption_that_no_call_uses_is_red():
|
||||
used = set()
|
||||
for name, source in _modules().items():
|
||||
used |= {(name, u.site, u.path) for u in uses_in(source) if u.kind == "url"}
|
||||
stale = sorted(set(EXEMPT) - used)
|
||||
assert not stale, "EXEMPT lists a path that no module asks for any more (remove it, with its reason): %r" % (stale,)
|
||||
|
||||
|
||||
def test_the_scan_reads_the_calls_of_the_modules_it_judges():
|
||||
"""A scan that finds no ``url`` or no ``route`` in a module that has them judges nothing; the modules are checked one by one for that."""
|
||||
modules = _modules()
|
||||
assert len(modules) >= 17, "the scan found %d modules that run Sites(); the tests of the fission frames and the twins are at least that: %s" % (len(modules), sorted(modules))
|
||||
for name, source in modules.items():
|
||||
uses = uses_in(source)
|
||||
kinds = {u.kind for u in uses}
|
||||
assert kinds == {"url", "route"}, "%s runs Sites() and the scan read %s of it (calls read: %d)" % (name, sorted(kinds) or "nothing", len(uses))
|
||||
intersection = uses_in(modules["test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"])
|
||||
assert {("url", "B", "/io"), ("route", "B", "/io")} <= {(u.kind, u.site, u.path) for u in intersection}, "the intersection file is read without its frame page"
|
||||
|
||||
|
||||
# ---- known bad and known good ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
#: The shape of the intersection file when it was red: the frame's source is B /io and only A is routed.
|
||||
OLD_REGISTER = '''
|
||||
def _intersection(sites, page, chrome, tag):
|
||||
page.goto(sites.url("A", "/io-" + tag))
|
||||
frame = wait_frame(page, sites.origin["B"], "/io", seconds=30)
|
||||
|
||||
def _register(sites, tag):
|
||||
sites.route("A", "/io-" + tag, lambda handler: TOP_IO % sites.url("B", "/io"))
|
||||
sites.route("B", "/leaf-top-" + tag, LEAF)
|
||||
sites.route("C", "/leaf-nested-" + tag, LEAF)
|
||||
'''
|
||||
|
||||
NEW_REGISTER = OLD_REGISTER.replace(' sites.route("B", "/leaf-top-"', ' sites.route("B", "/io", FRAME_IO)\n sites.route("B", "/leaf-top-"')
|
||||
|
||||
|
||||
def test_the_old_intersection_register_is_red_and_says_where_what_and_how_to_correct():
|
||||
problems = unrouted(OLD_REGISTER, "old.py")
|
||||
assert len(problems) == 2, problems # the url in the page of A and the frame lookup
|
||||
assert all("old.py:" in p and "site B" in p and "'/io'" in p and "sites.route('B', '/io'" in p for p in problems), problems
|
||||
|
||||
|
||||
def test_the_register_with_the_route_back_is_green():
|
||||
assert unrouted(NEW_REGISTER, "new.py") == []
|
||||
|
||||
|
||||
def test_a_route_of_another_site_does_not_answer_for_the_asked_site():
|
||||
source = 'def f(s):\n s.url("B", "/x")\n s.route("A", "/x", "page")\n'
|
||||
assert len(unrouted(source, "snippet.py")) == 1
|
||||
|
||||
|
||||
def test_a_computed_part_of_a_path_is_the_same_page_on_both_sides():
|
||||
green = 'def f(s, tag):\n s.url("A", "/page-" + tag)\n s.url("B", "/h%d" % 1)\n s.route("A", "/page-" + tag, "p")\n s.route("B", "/h%d" % 2, "p")\n'
|
||||
assert unrouted(green, "snippet.py") == []
|
||||
red = 'def f(s, tag):\n s.url("A", "/page-" + tag)\n s.route("A", "/other-" + tag, "p")\n'
|
||||
assert len(unrouted(red, "snippet.py")) == 1
|
||||
|
||||
|
||||
def test_a_loop_over_the_sites_routes_every_site():
|
||||
source = 'def f(s):\n s.url("C", "/file.bin")\n for site in ("A", "B", "C"):\n s.route(site, "/file.bin", "x")\n'
|
||||
assert unrouted(source, "snippet.py") == []
|
||||
|
||||
|
||||
def test_the_files_of_the_tests_read_the_old_intersection_file_as_red():
|
||||
"""The file as it was when the route was gone (the register without ``B /io``), cut from the real file: the real shape, not only a snippet."""
|
||||
source = (TESTS / "test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py").read_text(encoding="utf-8")
|
||||
old = source.replace(' sites.route("B", "/io", FRAME_IO)\n', "")
|
||||
assert old != source, "the intersection file does not route B /io in the form this check removes"
|
||||
assert unrouted(old, "test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"), "the file without the route of B /io is not red"
|
||||
assert unrouted(source, "test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py") == []
|
||||
@@ -1,99 +0,0 @@
|
||||
"""On Windows, a pytest process of a job that keeps WER dumps clears SEM_NOGPFAULTERRORBOX of its error mode and keeps its other bits (tests/_wer_error_mode.py).
|
||||
|
||||
The runner starts the pytest controllers with the error mode 0x0003 (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX), every child inherits the mode of its parent,
|
||||
and a process with the bit 0x0002 never invokes Windows Error Reporting: the LocalDumps key of python.exe of the job (e2e.yml) never saw a crashing xdist worker.
|
||||
|
||||
The behaviour, in a real child python (the mode is a property of the process, and a child inherits it from the parent's ``SetErrorMode`` at its start):
|
||||
|
||||
* born with 0x0003 and ``INVPW_WER_DUMPS`` naming an existing folder: the child's mode afterwards is 0x0001, and ``error-mode.log`` next to the dumps' folder holds the
|
||||
line of that process, with the mode it was born with and the mode it has now; other bits of the mode stay (0x8003 gives 0x8001, 0x0000 stays 0x0000);
|
||||
* without the variable, or with a folder that does not exist: the mode is unchanged and no log is written.
|
||||
|
||||
A file of its own, and only the row of Windows names it: the kernel's error mode is a Windows mechanism and the test skips on every other system, where a skip is red
|
||||
in the row (tests/test_reaper_on_windows.py is the same case). What runs on both systems (nothing happens off Windows) is in
|
||||
tests/test_every_windows_job_keeps_a_dump_of_a_crashing_python.py.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = [pytest.mark.unit, pytest.mark.skipif(os.name != "nt", reason="the error mode of a process is a Windows mechanism")]
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
#: What the child does: runs the entry point of tests/_wer_error_mode.py as conftest's pytest_configure does, and says its pid and its mode before and after.
|
||||
CHILD = (
|
||||
"import ctypes, json, os, sys\n"
|
||||
"sys.path.insert(0, sys.argv[1])\n"
|
||||
"k = ctypes.WinDLL('kernel32')\n"
|
||||
"k.GetErrorMode.restype = ctypes.c_uint\n"
|
||||
"born = k.GetErrorMode()\n"
|
||||
"import _wer_error_mode\n"
|
||||
"_wer_error_mode.clear_for_wer_dumps()\n"
|
||||
"print(json.dumps({'pid': os.getpid(), 'born': born, 'now': k.GetErrorMode()}))\n"
|
||||
)
|
||||
|
||||
|
||||
def _run_child(born_mode: int, variable: str | None) -> tuple[dict, subprocess.CompletedProcess]:
|
||||
"""A child python started with the error mode ``born_mode`` (set in this process just before the spawn, put back after), and ``INVPW_WER_DUMPS`` = ``variable``."""
|
||||
kernel32 = ctypes.WinDLL("kernel32")
|
||||
kernel32.GetErrorMode.restype = ctypes.c_uint
|
||||
kernel32.SetErrorMode.argtypes = [ctypes.c_uint]
|
||||
kernel32.SetErrorMode.restype = ctypes.c_uint
|
||||
env = {k: v for k, v in os.environ.items() if k != "INVPW_WER_DUMPS"}
|
||||
if variable is not None:
|
||||
env["INVPW_WER_DUMPS"] = variable
|
||||
mine = kernel32.GetErrorMode()
|
||||
kernel32.SetErrorMode(born_mode)
|
||||
try:
|
||||
done = subprocess.run([sys.executable, "-c", CHILD, str(TESTS)], env=env, capture_output=True, text=True, timeout=120)
|
||||
finally:
|
||||
kernel32.SetErrorMode(mine)
|
||||
assert done.returncode == 0, "the child failed: " + done.stderr[-1500:]
|
||||
return json.loads(done.stdout.strip().splitlines()[-1]), done
|
||||
|
||||
|
||||
def _evidence(tmp_path: Path) -> tuple[Path, Path]:
|
||||
"""The shape of the job's evidence: <evidence>/dumps/python is the folder of the dumps, the log goes to <evidence>/dumps."""
|
||||
dumps = tmp_path / "invpw-evidence" / "dumps" / "python"
|
||||
dumps.mkdir(parents=True)
|
||||
return dumps, dumps.parent / "error-mode.log"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("born, expected", [(0x0003, 0x0001), (0x0002, 0x0000), (0x8003, 0x8001), (0x0001, 0x0001), (0x0000, 0x0000)])
|
||||
def test_the_child_loses_the_gp_fault_bit_and_keeps_the_other_bits(tmp_path, born, expected):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, done = _run_child(born, str(dumps))
|
||||
assert seen["born"] == born, "the child was not born with 0x%04x but 0x%04x (the mode is not inherited here): %r" % (born, seen["born"], seen)
|
||||
assert seen["now"] == expected, "born 0x%04x, expected 0x%04x after the entry point, got 0x%04x" % (born, expected, seen["now"])
|
||||
assert seen["now"] == born & ~0x0002
|
||||
assert done.stderr == "" and done.stdout.strip() == json.dumps(seen), "the entry point wrote to stdout or stderr: %r %r" % (done.stdout, done.stderr)
|
||||
line = "pid %d error mode born 0x%04x, now 0x%04x" % (seen["pid"], born, expected)
|
||||
assert line in log.read_text(encoding="utf-8").splitlines(), "no evidence line %r in %s: %r" % (line, log, log.read_text(encoding="utf-8") if log.exists() else None)
|
||||
|
||||
|
||||
def test_the_runner_mode_0x0003_gives_0x0001_and_the_evidence_says_so(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, str(dumps))
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0001)
|
||||
assert log.read_text(encoding="utf-8") == "pid %d error mode born 0x0003, now 0x0001\n" % seen["pid"]
|
||||
|
||||
|
||||
def test_without_the_variable_the_mode_is_unchanged_and_nothing_is_written(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, None)
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0003), seen
|
||||
assert not log.exists() and list(tmp_path.rglob("*.log")) == []
|
||||
|
||||
|
||||
def test_a_variable_that_names_no_folder_leaves_the_mode_unchanged(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, str(tmp_path / "no-such-folder"))
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0003), seen
|
||||
assert not log.exists()
|
||||
@@ -137,46 +137,3 @@ def test_every_declared_refusal_is_still_refused():
|
||||
+ "\n ".join(stale)
|
||||
+ "\n\nRemove them: an inventory that describes a gap which has been "
|
||||
"closed is as wrong as one that misses a gap.")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# Refusals of a PARAMETER of a served operation
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The operations above are refused whole. A served operation can also refuse one parameter (or one value of it): `screenshot` refuses `mask`, `style`,
|
||||
# `animations="disabled"`, `caret="initial"` and `omitBackground` with png, because Playwright honours them by modifying the page. Those are keyed by
|
||||
# (operation, parameter) in `perimeter.REFUSED_PARAMETERS`, which holds the sentence the caller reads, and raised in `server.py` through
|
||||
# `_refuse_parameter(operation, parameter)`, the one function that reads that table. The wire-method budget is about operations and does not see them.
|
||||
def _parameter_refusals_in_the_server():
|
||||
tree = ast.parse(SERVER.read_text(encoding="utf-8"))
|
||||
found = set()
|
||||
for node in ast.walk(tree):
|
||||
if (isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == "_refuse_parameter"
|
||||
and len(node.args) == 2 and all(isinstance(a, ast.Constant) for a in node.args)):
|
||||
found.add((node.args[0].value, node.args[1].value))
|
||||
return found
|
||||
|
||||
|
||||
def test_the_parameter_refusals_are_readable():
|
||||
"""The safety net: an empty derivation would make the two assertions below compare nothing with nothing."""
|
||||
assert len(_parameter_refusals_in_the_server()) >= 5, "no `_refuse_parameter(operation, parameter)` call found in server.py: the reader is broken"
|
||||
assert len(perimeter.REFUSED_PARAMETERS) >= 5
|
||||
|
||||
|
||||
def test_every_parameter_refusal_is_declared_in_the_perimeter():
|
||||
undeclared = sorted(_parameter_refusals_in_the_server() - set(perimeter.REFUSED_PARAMETERS))
|
||||
assert not undeclared, (
|
||||
"server.py refuses these parameters and perimeter.REFUSED_PARAMETERS does not name them:\n " + "\n ".join("%s.%s" % k for k in undeclared)
|
||||
+ "\nAdd each as (operation, parameter): the sentence a caller reads.")
|
||||
|
||||
|
||||
def test_every_declared_parameter_refusal_is_still_raised():
|
||||
stale = sorted(set(perimeter.REFUSED_PARAMETERS) - _parameter_refusals_in_the_server())
|
||||
assert not stale, (
|
||||
"these are declared in perimeter.REFUSED_PARAMETERS and server.py no longer raises them:\n " + "\n ".join("%s.%s" % k for k in stale)
|
||||
+ "\nRemove them: an inventory that describes a refusal that is gone is as wrong as one that misses one.")
|
||||
|
||||
|
||||
def test_a_parameter_refusal_is_a_sentence_a_person_can_act_on():
|
||||
for key, sentence in perimeter.REFUSED_PARAMETERS.items():
|
||||
assert isinstance(sentence, str) and len(sentence) >= len("Not implemented"), key
|
||||
assert perimeter.parameter_refusal(*key) == sentence
|
||||
@@ -1,180 +0,0 @@
|
||||
"""Every Windows job of e2e.yml that runs pytest keeps a full dump of a python.exe that crashes, inside the evidence it uploads.
|
||||
|
||||
The pytest-xdist worker (python.exe) died on the Windows e2e jobs with ``node down: Not properly terminated`` and ``Windows fatal exception: access violation``
|
||||
(jobs 138402013609 and 138966622085), in a thread Python has no state for, so faulthandler named no native frame. Windows Error Reporting writes a full user-mode
|
||||
dump of a process that dies from an unhandled exception when ``HKLM\\SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps\\python.exe`` says so
|
||||
(DumpFolder, DumpType 2 = full, DumpCount; https://learn.microsoft.com/windows/win32/wer/collecting-user-mode-dumps). faulthandler's handler on Windows is a vectored
|
||||
one that returns EXCEPTION_CONTINUE_SEARCH, so the exception goes on and WER still sees it.
|
||||
|
||||
For each Windows job that runs pytest (found by ``runs-on: windows-*``, so a new one is covered by itself):
|
||||
|
||||
* before its first pytest step a PowerShell step turns WER on (``Disabled`` 0, ``DontShowUI`` 1) and sets LocalDumps of python.exe: ``DumpType`` 2, ``DumpCount`` 3,
|
||||
``DumpFolder`` an expandable string, ``$RUNNER_TEMP/invpw-evidence/dumps/python``: inside the folder the job's evidence upload takes;
|
||||
* the same step exports ``INVPW_WER_DUMPS=$dumps`` (the DumpFolder) to ``$GITHUB_ENV``, so that every later step has it: tests/conftest.py then makes every pytest
|
||||
process (the controller and each xdist worker) clear SEM_NOGPFAULTERRORBOX (0x0002) of its error mode (tests/_wer_error_mode.py). The runner gives its pytest
|
||||
processes the mode 0x0003, every child inherits it, and a process with that bit never invokes Windows Error Reporting: with LocalDumps set and the bit kept, a
|
||||
crashing worker still left no dump. Nothing else sets the variable;
|
||||
* after the tests a step with ``if: always()`` runs ``scripts/ci_wer_dumps.py`` on that folder (sizes, faulting module), before the upload;
|
||||
* the upload of ``$RUNNER_TEMP/invpw-evidence`` is ``if: always()``, after the tests.
|
||||
|
||||
Known-bad inputs: a job whose step does not export the variable, one that exports another folder, a job that sets the variable elsewhere, a job without the step, the step after the first pytest step, a mini dump (DumpType 1), a key of another executable, a folder outside the evidence, a
|
||||
summary missing or not ``always()``, an upload that is not ``always()``. The green case is the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
E2E = Path(__file__).resolve().parents[1] / ".github" / "workflows" / "e2e.yml"
|
||||
EXPECTED_WINDOWS_JOBS = {
|
||||
"e2e-windows-control-a", "e2e-windows", "e2e-network-windows", "e2e-host-windows", "e2e-page-windows", "e2e-page-final-windows",
|
||||
}
|
||||
SUMMARY_STEP = " - name: What Windows Error Reporting kept of a crashing python.exe (size, faulting module, in the evidence)\n"
|
||||
WER_STEP = " - name: Windows Error Reporting keeps a full dump of a python.exe that crashes (into the evidence)\n"
|
||||
ALWAYS = " if: always()\n"
|
||||
|
||||
|
||||
def _jobs(text: str) -> dict[str, str]:
|
||||
"""job id -> its text, for the jobs of the file (a job starts at two spaces of indent)."""
|
||||
body = "\n" + text.split("\njobs:\n", 1)[1]
|
||||
starts = [(m.group(1), m.start()) for m in re.finditer(r"\n ([A-Za-z0-9_-]+):[ ]*(?=\n)", body)]
|
||||
out = {}
|
||||
for i, (name, at) in enumerate(starts):
|
||||
out[name] = body[at:starts[i + 1][1] if i + 1 < len(starts) else len(body)]
|
||||
return out
|
||||
|
||||
|
||||
def _windows_jobs(text: str) -> dict[str, str]:
|
||||
return {k: v for k, v in _jobs(text).items() if re.search(r"^ runs-on: windows-", v, re.M)}
|
||||
|
||||
|
||||
def _steps(job: str) -> list[str]:
|
||||
"""The steps of a job, each without its comment lines."""
|
||||
body = job.split("\n steps:\n", 1)[1]
|
||||
chunks = re.split(r"\n(?= - )", "\n" + body)
|
||||
steps = []
|
||||
for c in chunks:
|
||||
lines = [ln for ln in c.split("\n") if not ln.strip().startswith("#")]
|
||||
if any(ln.startswith(" - ") for ln in lines):
|
||||
steps.append("\n".join(lines))
|
||||
return steps
|
||||
|
||||
|
||||
def _problems(name: str, job: str) -> list[str]:
|
||||
steps = _steps(job)
|
||||
runs_pytest = [i for i, s in enumerate(steps) if re.search(r"pytest|run_e2e\.py", s)]
|
||||
if not runs_pytest:
|
||||
return ["%s: no step runs pytest (this test finds them by name: update it with the job)" % name]
|
||||
first, last = runs_pytest[0], runs_pytest[-1]
|
||||
dumps = [i for i, s in enumerate(steps) if "LocalDumps" in s]
|
||||
if len(dumps) != 1:
|
||||
return ["%s: %d steps set LocalDumps, expected 1" % (name, len(dumps))]
|
||||
step = steps[dumps[0]]
|
||||
bad = []
|
||||
if dumps[0] > first:
|
||||
bad.append("%s: LocalDumps is set after the first pytest step" % name)
|
||||
if "shell: pwsh" not in step:
|
||||
bad.append("%s: the LocalDumps step is not PowerShell" % name)
|
||||
if not re.search(r'LocalDumps\\python\.exe"', step):
|
||||
bad.append("%s: LocalDumps is not the key of python.exe" % name)
|
||||
if not re.search(r"-Name DumpType -PropertyType DWord -Value 2\b", step):
|
||||
bad.append("%s: DumpType is not 2 (a full dump)" % name)
|
||||
if not re.search(r"-Name DumpCount -PropertyType DWord -Value 3\b", step):
|
||||
bad.append("%s: DumpCount is not 3" % name)
|
||||
if not re.search(r"-Name DumpFolder -PropertyType ExpandString -Value \$dumps\b", step):
|
||||
bad.append("%s: DumpFolder is not an expandable string" % name)
|
||||
if not re.search(r"\$dumps = Join-Path \$env:RUNNER_TEMP 'invpw-evidence\\dumps\\python'", step):
|
||||
bad.append("%s: the dump folder is not RUNNER_TEMP/invpw-evidence/dumps/python (the folder the evidence upload takes)" % name)
|
||||
if not re.search(r"-Name Disabled -PropertyType DWord -Value 0\b", step):
|
||||
bad.append("%s: WER is not made enabled (Disabled 0)" % name)
|
||||
if not re.search(r"-Name DontShowUI -PropertyType DWord -Value 1\b", step):
|
||||
bad.append("%s: WER may show a dialog (DontShowUI 1 missing)" % name)
|
||||
if not re.search(r'^\s*"INVPW_WER_DUMPS=\$dumps"\s*\|\s*Out-File -FilePath \$env:GITHUB_ENV -Append', step, re.M):
|
||||
bad.append("%s: the LocalDumps step does not export INVPW_WER_DUMPS=$dumps (the DumpFolder) to $GITHUB_ENV: without it tests/conftest.py leaves the error mode of "
|
||||
"every pytest process as the runner gave it (0x0003, SEM_NOGPFAULTERRORBOX set) and a crashing xdist worker never reaches the LocalDumps above" % name)
|
||||
in_job = [ln for ln in job.split("\n") if "INVPW_WER_DUMPS" in ln and not ln.strip().startswith("#")]
|
||||
in_step = [ln for ln in step.split("\n") if "INVPW_WER_DUMPS" in ln]
|
||||
if len(in_job) != len(in_step):
|
||||
bad.append("%s: INVPW_WER_DUMPS is set outside the LocalDumps step (%d lines in the job, %d in the step): the one step that sets the dump folder exports it"
|
||||
% (name, len(in_job), len(in_step)))
|
||||
uploads = [i for i, s in enumerate(steps) if "actions/upload-artifact" in s and re.search(r"^\s+(path: )?\$\{\{ runner\.temp \}\}/invpw-evidence$", s, re.M)]
|
||||
if len(uploads) != 1:
|
||||
return bad + ["%s: %d steps upload the evidence folder, expected 1" % (name, len(uploads))]
|
||||
up = steps[uploads[0]]
|
||||
if uploads[0] < last:
|
||||
bad.append("%s: the evidence is uploaded before the last pytest step" % name)
|
||||
if not re.search(r"^ if: always\(\)$", up, re.M):
|
||||
bad.append("%s: the upload of the evidence is not if: always()" % name)
|
||||
summaries = [i for i, s in enumerate(steps) if "scripts/ci_wer_dumps.py" in s]
|
||||
if len(summaries) != 1:
|
||||
return bad + ["%s: %d steps run scripts/ci_wer_dumps.py, expected 1" % (name, len(summaries))]
|
||||
s = steps[summaries[0]]
|
||||
if not (last < summaries[0] < uploads[0]):
|
||||
bad.append("%s: the dump summary is not between the last pytest step and the upload" % name)
|
||||
if not re.search(r"^ if: always\(\)$", s, re.M):
|
||||
bad.append("%s: the dump summary is not if: always()" % name)
|
||||
if 'invpw-evidence/dumps/python"' not in s:
|
||||
bad.append("%s: the dump summary does not read the dump folder" % name)
|
||||
return bad
|
||||
|
||||
|
||||
def _job() -> str:
|
||||
return _windows_jobs(E2E.read_text(encoding="utf-8"))["e2e-host-windows"]
|
||||
|
||||
|
||||
def test_the_windows_jobs_are_the_ones_this_test_knows():
|
||||
assert set(_windows_jobs(E2E.read_text(encoding="utf-8"))) == EXPECTED_WINDOWS_JOBS
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", sorted(EXPECTED_WINDOWS_JOBS))
|
||||
def test_the_job_keeps_a_full_dump_of_a_crashing_python_in_its_evidence(name):
|
||||
job = _windows_jobs(E2E.read_text(encoding="utf-8"))[name]
|
||||
assert _problems(name, job) == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mutate, expected",
|
||||
[
|
||||
(lambda t: t.replace("-Name DumpType -PropertyType DWord -Value 2", "-Name DumpType -PropertyType DWord -Value 1"), "DumpType is not 2"),
|
||||
(lambda t: t.replace("LocalDumps\\python.exe", "LocalDumps\\firefox.exe"), "not the key of python.exe"),
|
||||
(lambda t: t.replace("-Name Disabled -PropertyType DWord -Value 0", "-Name Disabled -PropertyType DWord -Value 1"), "Disabled 0"),
|
||||
(lambda t: t.replace("-PropertyType ExpandString", "-PropertyType String"), "not an expandable string"),
|
||||
(lambda t: t.replace("'invpw-evidence\\dumps\\python'", "'crash-dumps'"), "not RUNNER_TEMP/invpw-evidence/dumps/python"),
|
||||
(lambda t: t.replace('"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8\n', ""), "does not export INVPW_WER_DUMPS=$dumps"),
|
||||
(lambda t: t.replace('"INVPW_WER_DUMPS=$dumps"', '"INVPW_WER_DUMPS=C:\\elsewhere"'), "does not export INVPW_WER_DUMPS=$dumps"),
|
||||
(lambda t: t.replace(" - name: Upload what the test saved\n", " - name: Upload what the test saved\n env:\n INVPW_WER_DUMPS: x\n"), "set outside the LocalDumps step"),
|
||||
(lambda t: t.replace("scripts/ci_wer_dumps.py", "scripts/nothing.py"), "0 steps run scripts/ci_wer_dumps.py"),
|
||||
(lambda t: t.replace(SUMMARY_STEP + ALWAYS, SUMMARY_STEP), "dump summary is not if: always()"),
|
||||
(lambda t: t.replace(" - name: Upload what the test saved\n" + ALWAYS, " - name: Upload what the test saved\n"), "upload of the evidence is not if: always()"),
|
||||
],
|
||||
)
|
||||
def test_known_bad_jobs_are_refused(mutate, expected):
|
||||
job = _job()
|
||||
bad = mutate(job)
|
||||
assert bad != job, "the mutation did not apply: this test is stale"
|
||||
assert any(expected in p for p in _problems("e2e-host-windows", bad)), _problems("e2e-host-windows", bad)
|
||||
|
||||
|
||||
def test_the_step_after_the_tests_and_the_missing_step_are_refused():
|
||||
job = _job()
|
||||
start = job.index(WER_STEP)
|
||||
end = job.index("\n - ", start + 1)
|
||||
gone = job[:start] + job[end + 1:]
|
||||
assert not any("LocalDumps" in s for s in _steps(gone))
|
||||
assert any("0 steps set LocalDumps" in p for p in _problems("x", gone))
|
||||
moved = job[:start] + job[end + 1:] + "\n" + job[start:end]
|
||||
assert any("after the first pytest step" in p for p in _problems("x", moved)), _problems("x", moved)
|
||||
|
||||
|
||||
def test_the_entry_point_does_nothing_off_windows(tmp_path, monkeypatch):
|
||||
"""Linux (and any system but Windows) is left alone, whatever the variable says: no log, no error, nothing written."""
|
||||
import _wer_error_mode
|
||||
dumps = tmp_path / "invpw-evidence" / "dumps" / "python"
|
||||
dumps.mkdir(parents=True)
|
||||
monkeypatch.setattr(_wer_error_mode.sys, "platform", "linux")
|
||||
_wer_error_mode.clear_for_wer_dumps({"INVPW_WER_DUMPS": str(dumps)})
|
||||
assert list(tmp_path.rglob("*.log")) == []
|
||||
@@ -593,12 +593,14 @@ WORKFLOW = (ROOT / ".github" / "workflows" / "fakeweb.yml").read_text(encoding="
|
||||
|
||||
|
||||
def test_the_workflow_has_four_legs_and_one_verdict_job():
|
||||
assert len(re.findall(r"^ [a-z0-9_-]+:\n (?:name|uses):", WORKFLOW, re.MULTILINE)) == 4 # core-on-index, linux-deps-fakeweb, walk, verdict
|
||||
assert len(re.findall(r"^ [a-z0-9_-]+:\n (?:name|uses|needs):", WORKFLOW, re.MULTILINE)) == 5 # changes, core-on-index, linux-deps-fakeweb, walk, verdict
|
||||
assert WORKFLOW.count("{ profile: ") == 4
|
||||
for leg in ("p2, os: linux", "p2, os: windows", "p4, os: linux", "p4, os: windows"):
|
||||
assert "profile: " + leg in WORKFLOW
|
||||
assert "name: fakeweb verdict" in WORKFLOW and "if: always()" in WORKFLOW.split("name: fakeweb verdict", 1)[1]
|
||||
assert '"${{ needs.walk.result }}" != "success"' in WORKFLOW # a leg that did not run is not green
|
||||
verdict = WORKFLOW.split("name: fakeweb verdict", 1)[1]
|
||||
assert "needs: [changes, core-on-index, linux-deps-fakeweb, walk]" in verdict and "WORKFLOW: fakeweb" in verdict and "NEEDS: ${{ toJSON(needs) }}" in verdict
|
||||
# a leg that did not run is not green: scripts/ci_gate.py (read from main) expects `success` of `walk`, see tests/test_the_workflows_are_ready_for_the_merge_queue.py
|
||||
|
||||
|
||||
def test_every_action_is_pinned_to_a_commit():
|
||||
@@ -616,7 +618,8 @@ def test_the_workflow_runs_stock_and_ours_and_never_reruns_or_forgives():
|
||||
assert WORKFLOW.index("scripts/ci_lab_geoip.py build") < first_run and WORKFLOW.index("scripts/ci_lab_security_state.py set") < WORKFLOW.index("fetch | tail -1")
|
||||
|
||||
|
||||
def test_the_workflow_starts_on_the_fake_web_files_of_a_pull_request_and_of_main_and_by_hand():
|
||||
def test_the_workflow_starts_in_the_merge_queue_run_and_on_the_fake_web_files_of_main_and_by_hand():
|
||||
on = WORKFLOW.split("\npermissions:", 1)[0]
|
||||
assert " push:\n branches: [main]\n paths:" in on and " pull_request:\n paths:" in on and " workflow_dispatch:" in on
|
||||
assert on.count("'tests/fakeweb/**'") == 2 and on.count("'.github/workflows/fakeweb.yml'") == 2
|
||||
assert " push:\n branches: [main]\n paths:" in on and " merge_group:\n types: [checks_requested]\n" in on and " workflow_dispatch:" in on
|
||||
assert "pull_request" not in on.split("\non:\n", 1)[1], "a pull request runs the fast set; this workflow runs in the queue run"
|
||||
assert on.count("'tests/fakeweb/**'") == 1 and on.count("'.github/workflows/fakeweb.yml'") == 1
|
||||
@@ -11,11 +11,11 @@ WebGL renderer in the main thread but not in a Web Worker, the
|
||||
inconsistency proves the spoof is fake.
|
||||
|
||||
Sources studied (all FOSS, MIT-licensed):
|
||||
- the headless detector, lies module - the canonical lie detector
|
||||
- the headless detector, worker module - main-vs-worker scope cross-check
|
||||
- the headless detector, math module - Math.x(p) deterministic equality
|
||||
- the headless detector, navigator module - UA/platform/oscpu invariants
|
||||
- a public fingerprinting-notes README - worker hwConcurrency,
|
||||
- creepjs/src/lies/index.ts - the canonical lie detector
|
||||
- creepjs/src/worker/index.ts - main-vs-worker scope cross-check
|
||||
- creepjs/src/math/index.ts - Math.x(p) deterministic equality
|
||||
- creepjs/src/navigator/index.ts - UA/platform/oscpu invariants
|
||||
- niespodd/browser-fingerprinting README - worker hwConcurrency,
|
||||
plugin chain, perf.timeOrigin
|
||||
|
||||
Everything runs against `about:blank` with NO network and NO proxy.
|
||||
@@ -66,7 +66,7 @@ def _ev(page, expr):
|
||||
|
||||
# ===========================================================================
|
||||
# 1. Math determinism - same input MUST yield same output
|
||||
# Source: the headless detector, math module
|
||||
# Source: creepjs/src/math/index.ts
|
||||
# A wrapper that adds noise to Math.* (canvas-spoofing prefs) exposes
|
||||
# itself here: two consecutive calls with the same input must be
|
||||
# byte-identical.
|
||||
@@ -119,7 +119,7 @@ def test_math_pow_two_arg_determinism(page):
|
||||
|
||||
# ===========================================================================
|
||||
# 2. Worker scope vs main thread - navigator properties MUST agree
|
||||
# Source: the headless detector, worker module
|
||||
# Source: creepjs/src/worker/index.ts
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ def test_worker_platform_matches_main(page):
|
||||
|
||||
# ===========================================================================
|
||||
# 3. Iframe scope vs window scope
|
||||
# Source: the headless detector, lies module (getBehemothIframe pattern)
|
||||
# Source: creepjs/src/lies/index.ts (getBehemothIframe pattern)
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ def test_iframe_screen_matches_window(page):
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# 4. UA self-consistency (the headless detector, navigator module)
|
||||
# 4. UA self-consistency (creepjs/src/navigator/index.ts)
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@@ -285,12 +285,12 @@ def test_navigator_oscpu_matches_userAgent(page):
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# 5. Native function self-toString (the headless detector, lies module, hasKnownToString)
|
||||
# 5. Native function self-toString (creepjs/src/lies/index.ts hasKnownToString)
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
def _is_native_toString(text, fn_name):
|
||||
"""Mirror of the headless detector hasKnownToString - accept the engine-specific
|
||||
"""Mirror of CreepJS hasKnownToString - accept the engine-specific
|
||||
native patterns (single-line on V8, multi-line on SpiderMonkey)."""
|
||||
import re as _re
|
||||
name = _re.escape(fn_name)
|
||||
@@ -449,7 +449,7 @@ _DESCRIPTOR_NATIVE_PROPS = [
|
||||
def test_navigator_property_descriptor_is_getter_not_value(page, prop):
|
||||
"""Each spoofable navigator.* property must be defined via a native
|
||||
getter - NOT Object.defineProperty(..., {value: x}). The value-field
|
||||
descriptor is the lazy spoof leak the headless detector catches."""
|
||||
descriptor is the lazy spoof leak CreepJS catches."""
|
||||
has_lie = _ev(page, f"""() => {{
|
||||
let proto = navigator;
|
||||
let descriptor = null;
|
||||
|
||||
@@ -6,16 +6,16 @@ here means our patched build appears human to that detector; a fail
|
||||
means a real stealth hole that anti-bot kits would exploit in production.
|
||||
|
||||
Detector libraries studied (all FOSS, MIT-licensed):
|
||||
- a client-side bot detector - 19 detectors, the most
|
||||
- github.com/fingerprintjs/BotD - 19 detectors, the most
|
||||
widely deployed client-side
|
||||
bot detector
|
||||
- a headless / stealth / lies detector - headless, stealth and lies
|
||||
- github.com/abrahamjuliot/creepjs - headless / stealth / lies
|
||||
modules
|
||||
- an open-source fingerprint library - canvas / audio / color /
|
||||
- github.com/fingerprintjs/fingerprintjs - canvas / audio / color /
|
||||
touch consistency
|
||||
- an automation-rules scanner - UA / platform / oscpu
|
||||
- github.com/antoinevastel/fpscanner - UA / platform / oscpu
|
||||
cross-checks
|
||||
- a public classic-harness test page - the classic Puppeteer harness
|
||||
- bot.sannysoft.com - classic Puppeteer harness
|
||||
|
||||
Everything runs against `about:blank` with NO network and NO proxy. The
|
||||
suite is intended to be part of the release-gate: pre-push hook runs
|
||||
@@ -77,19 +77,19 @@ def _ev(page, expr):
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# The public classic Puppeteer detection harness
|
||||
# sannysoft.com - classic Puppeteer detection harness
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_chrome_object_is_consistent(page):
|
||||
def test_sannysoft_chrome_object_consistency(page):
|
||||
"""Firefox UA + window.chrome present = bot-framework leak."""
|
||||
if "Firefox" in _ev(page, "navigator.userAgent"):
|
||||
assert not _ev(page, "typeof window.chrome !== 'undefined'")
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_permissions_query_works(page):
|
||||
def test_sannysoft_permissions_query_works(page):
|
||||
"""navigator.permissions.query() must return a proper PermissionStatus."""
|
||||
ok = _ev(page, """async () => {
|
||||
if (!navigator.permissions || !navigator.permissions.query) return false;
|
||||
@@ -102,7 +102,7 @@ def test_the_permissions_query_works(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_iframe_does_not_leak_the_chrome_object(page):
|
||||
def test_sannysoft_iframe_chrome_not_leaked(page):
|
||||
"""iframe.contentWindow.chrome must not leak on Firefox UA."""
|
||||
if "Firefox" not in _ev(page, "navigator.userAgent"):
|
||||
pytest.skip("Firefox-only invariant")
|
||||
@@ -118,7 +118,7 @@ def test_the_iframe_does_not_leak_the_chrome_object(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_iframe_languages_are_not_empty(page):
|
||||
def test_sannysoft_iframe_languages_not_empty(page):
|
||||
"""Iframe-scope navigator.languages must have ≥1 entry."""
|
||||
n = _ev(page, """() => {
|
||||
const f = document.createElement('iframe');
|
||||
@@ -132,12 +132,12 @@ def test_the_iframe_languages_are_not_empty(page):
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# The open-source fingerprint library - fingerprint surface coherence
|
||||
# FingerprintJS - fingerprint surface coherence
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_canvas_2d_context_returns_a_valid_one(page):
|
||||
def test_fpjs_canvas_2d_context_returns_valid(page):
|
||||
ok = _ev(page, """() => {
|
||||
const c = document.createElement('canvas');
|
||||
c.width = 100; c.height = 100;
|
||||
@@ -151,7 +151,7 @@ def test_the_canvas_2d_context_returns_a_valid_one(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_audio_context_works(page):
|
||||
def test_fpjs_audio_context_works(page):
|
||||
ok = _ev(page, """async () => {
|
||||
try {
|
||||
const ctx = new (window.OfflineAudioContext ||
|
||||
@@ -167,7 +167,7 @@ def test_the_audio_context_works(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_color_gamut_query_works(page):
|
||||
def test_fpjs_color_gamut_query_works(page):
|
||||
"""matchMedia('(color-gamut: ...)') must match at least srgb."""
|
||||
ok = _ev(page, """matchMedia('(color-gamut: srgb)').matches ||
|
||||
matchMedia('(color-gamut: p3)').matches ||
|
||||
@@ -176,7 +176,7 @@ def test_the_color_gamut_query_works(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_screen_color_depth_is_realistic(page):
|
||||
def test_fpjs_screen_color_depth_realistic(page):
|
||||
"""Atypical color depths are headless-distinctive."""
|
||||
cd = _ev(page, "screen.colorDepth")
|
||||
assert cd in (24, 30, 32)
|
||||
@@ -219,12 +219,12 @@ def test_pin_audio_max_channels_lands_in_destination(page):
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# Rules-scanner-style cross-checks
|
||||
# fpscanner-style cross-checks
|
||||
# ===========================================================================
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_the_ua_and_the_platform_agree(page):
|
||||
def test_fpscanner_ua_vs_platform_consistent(page):
|
||||
"""UA OS substring must agree with navigator.platform OS substring."""
|
||||
ua = _ev(page, "navigator.userAgent")
|
||||
platform = _ev(page, "navigator.platform")
|
||||
@@ -237,21 +237,21 @@ def test_the_ua_and_the_platform_agree(page):
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
def test_firefox_has_no_userAgentData(page):
|
||||
def test_fpscanner_no_userAgentData_on_firefox(page):
|
||||
"""navigator.userAgentData is Chromium-only. Presence on Firefox UA = bot."""
|
||||
if "Firefox" in _ev(page, "navigator.userAgent"):
|
||||
assert not _ev(page, "'userAgentData' in navigator")
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# WebGL masking-detector guard (a public fingerprint page, fixed red box / webgl hash)
|
||||
# WebGL masking-detector guard (pixelscan getFixedRedBox / webglHash)
|
||||
#
|
||||
# A public fingerprint page flags "fingerprint masking" on the WebGL readPixels output. We
|
||||
# reproduce ITS probe locally (the gradient triangle of the fingerprint library) and check
|
||||
# pixelscan flags "fingerprint masking" on the WebGL readPixels output. We
|
||||
# reproduce ITS probe locally (the fingerprintjs gradient triangle) and check
|
||||
# the structural signature it keys on: our stealth readPixels noise MUST be a
|
||||
# coherent, monotonic gamma remap (smooth, ~0 spikes), NOT isolated +-1 flips
|
||||
# (which read as unnatural high-frequency noise and were flagged as masking).
|
||||
# This is the CI-safe local stand-in for the server-side check of that page; it
|
||||
# This is the CI-safe local stand-in for pixelscan's server-side check; it
|
||||
# guards the gamma fix from ever silently regressing to the +-1 algorithm.
|
||||
# ===========================================================================
|
||||
|
||||
@@ -298,7 +298,7 @@ _WEBGL_MASKING_PROBE = """() => {
|
||||
def test_webgl_readpixels_no_masking_signature(page):
|
||||
"""Stealth WebGL readPixels noise must be a coherent gamma remap (smooth),
|
||||
not isolated +-1 flips. +-1 noise on the smooth gradient triangle produced
|
||||
~300+ 'spikes' and that page flagged it as masking; the gamma remap leaves
|
||||
~300+ 'spikes' and pixelscan flagged it as masking; the gamma remap leaves
|
||||
the gradient smooth (~0 spikes). Regression guard for the gamma fix."""
|
||||
res = _ev(page, _WEBGL_MASKING_PROBE)
|
||||
if res.get("error") == "no-webgl" and sys.platform == "darwin":
|
||||
@@ -311,7 +311,7 @@ def test_webgl_readpixels_no_masking_signature(page):
|
||||
# genuine / gamma -> ~0; the rejected +-1 algorithm produced ~320.
|
||||
assert res["spikes"] < 30, (
|
||||
f"WebGL readPixels shows {res['spikes']} high-frequency noise spikes "
|
||||
f"(flagged as masking by a public page); the stealth noise must be a smooth gamma remap."
|
||||
f"(pixelscan-maskable); the stealth noise must be a smooth gamma remap."
|
||||
)
|
||||
|
||||
|
||||
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user