Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
694486d3cd | ||
|
|
e07b6cd9ca | ||
|
|
a24063f846 | ||
|
|
ef40bdea98 | ||
|
|
2634d58325 | ||
|
|
737d8b57b1 | ||
|
|
9d04623ee6 |
No files matched your search
@@ -0,0 +1,96 @@
|
||||
name: fakeweb-p2 (engine of a series run, reduced: the hard pages and the quiet one)
|
||||
|
||||
# The fake web, profile P2, on the engine a RUN of the series repository built (its `asset-win-x86_64` artifact), in the same job as
|
||||
# Playwright's own Firefox: the verdict is "the same outcome as stock", per page, with the numbers. The series repository is public, so
|
||||
# `gh run download` needs no secret. To run it on another engine, change ENGINE_RUN_ID and push: this workflow starts on a push that
|
||||
# touches this file (a hunt, not a gate). REDUCED: the run on every page took more than its 60 minutes (cancelled at the ceiling, run 43178594622),
|
||||
# so this one runs the three hard pages (HARD in scripts/run_fakeweb.py) and the quiet one, 10 repetitions, in 45 minutes.
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/fakeweb-p2.yml'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
engine_run_id:
|
||||
description: 'run of feder-cr/firefox_antidetect_patch whose asset-win-x86_64 artifact is the engine'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
ENGINE_RUN_ID: ${{ inputs.engine_run_id || '43164943499' }}
|
||||
ENGINE_REPO: feder-cr/firefox_antidetect_patch
|
||||
|
||||
jobs:
|
||||
p2:
|
||||
name: fakeweb P2 (windows, engine of run ${{ inputs.engine_run_id || '43164943499' }})
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 45
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: Install the wrapper + test deps, and Playwright's own Firefox as the control
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)" psutil
|
||||
python -m playwright install firefox
|
||||
- name: The engine of the run
|
||||
run: |
|
||||
mkdir -p engine
|
||||
gh run download "$ENGINE_RUN_ID" --repo "$ENGINE_REPO" --name asset-win-x86_64 --dir engine/archive
|
||||
ls -la engine/archive
|
||||
python - <<'PY'
|
||||
import glob, zipfile
|
||||
z = glob.glob("engine/archive/*.zip")[0]
|
||||
zipfile.ZipFile(z).extractall("engine/x")
|
||||
print("extracted", z)
|
||||
PY
|
||||
python -m invisible_core seal --binary engine/x/firefox.exe --tag firefox-63-candidate -o "$PWD/engine/seal.json"
|
||||
echo "INVPW_BINARY_PATH=$PWD/engine/x/firefox.exe" >> "$GITHUB_ENV"
|
||||
echo "INVISIBLE_SEAL_FILE=$PWD/engine/seal.json" >> "$GITHUB_ENV"
|
||||
echo "INVISIBLE_CORE_PIN=allow" >> "$GITHUB_ENV"
|
||||
- name: The fake web beside stock, per page
|
||||
run: |
|
||||
python scripts/run_fakeweb.py --binary "$INVPW_BINARY_PATH" --repetitions 10 --patterns leaving_beacons_subframe,leaving_beacons,cancel_among_beacons,quiet --out fakeweb-p2.json || echo "RUN_FAKEWEB_EXIT=$?" >> "$GITHUB_ENV"
|
||||
python - <<'PY'
|
||||
import collections, json
|
||||
r = json.load(open("fakeweb-p2.json"))
|
||||
rows = collections.defaultdict(lambda: [0, 0, 0, 0])
|
||||
for who, idx in (("candidate", 0), ("stock", 2)):
|
||||
for c in r[who]:
|
||||
rows[c["pattern"]][idx + (0 if c["idle"] else 1)] += 1
|
||||
print("%-30s %12s %12s" % ("page", "engine idle/not", "stock idle/not"))
|
||||
for p, v in sorted(rows.items()):
|
||||
print("%-30s %6d/%-5d %6d/%-5d" % (p, v[0], v[1], v[2], v[3]))
|
||||
print("fails (engine not idle where stock idles):", len(r["fails"]), "broken controls:", len(r["broken_control"]))
|
||||
PY
|
||||
- name: The mandatory case under a load of other browsers (three loaders of ours)
|
||||
if: always()
|
||||
run: python -m pytest tests/test_fakeweb_p2_e2e.py -m e2e -q -p no:cacheprovider -rA
|
||||
- name: Upload the numbers
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: fakeweb-p2-${{ github.run_id }}
|
||||
path: fakeweb-p2.json
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
- name: Verdict of the fake web run
|
||||
if: always()
|
||||
run: |
|
||||
if [ -n "${RUN_FAKEWEB_EXIT:-}" ]; then echo "run_fakeweb.py exited ${RUN_FAKEWEB_EXIT}: red"; exit 1; fi
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The single entry of the fake web (ci-release-18): our engine and Playwright's own Firefox on the same offline pages,
|
||||
same client, same job. Red when our engine does not idle where stock does, and red as a broken control when stock does not
|
||||
do what tests/fakeweb/pages.json declares.
|
||||
|
||||
python scripts/run_fakeweb.py --binary PATH [--profile p2] [--patterns a,b] [--repetitions N] [--out FILE]
|
||||
|
||||
The pages are served by tests/fakeweb/sites.py (two origins on 127.0.0.1, every response finite). Only profile P2 (one reused
|
||||
page, the stock client over the served browser) exists so far.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
|
||||
from fakeweb import profile_p2, sites # noqa: E402
|
||||
|
||||
# The patterns that took a routed, reused page to `networkidle` never: a request whose end the page never gets.
|
||||
HARD = ["leaving_beacons_subframe", "leaving_beacons", "cancel_among_beacons"]
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--binary", required=True)
|
||||
ap.add_argument("--profile", default="p2", choices=["p2"])
|
||||
ap.add_argument("--patterns", default=",".join(HARD), help="comma separated; 'all' for every page")
|
||||
ap.add_argument("--repetitions", type=int, default=10)
|
||||
ap.add_argument("--idle-timeout-ms", type=int, default=10000)
|
||||
ap.add_argument("--no-stock", action="store_true", help="candidate only (the verdict then reads pages.json alone)")
|
||||
ap.add_argument("--out", default=None)
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
import importlib
|
||||
|
||||
sync_playwright = importlib.import_module("playwright.sync_api").sync_playwright # the stock client, by name
|
||||
|
||||
declared = json.loads((ROOT / "tests" / "fakeweb" / "pages.json").read_text(encoding="utf-8"))["stock_firefox"]
|
||||
patterns = [p for p in sites.PATTERNS if p != "quiet"] if args.patterns == "all" else args.patterns.split(",")
|
||||
unknown = [p for p in patterns if p not in sites.PATTERNS]
|
||||
if unknown:
|
||||
ap.error("unknown patterns: %s" % unknown)
|
||||
|
||||
origin_a, _origin_o, stop = sites.start((0, 0))
|
||||
try:
|
||||
kw = {"idle_timeout_ms": args.idle_timeout_ms}
|
||||
candidate = profile_p2.run_on_candidate(sync_playwright, args.binary, origin_a, patterns, args.repetitions, **kw)
|
||||
stock = [] if args.no_stock else profile_p2.run_on_stock(sync_playwright, origin_a, patterns, args.repetitions, **kw)
|
||||
finally:
|
||||
stop()
|
||||
|
||||
if args.no_stock: # stock is what pages.json says it is
|
||||
stock = [dict(c, idle=declared.get(c["pattern"], "idle") == "idle") for c in candidate]
|
||||
fails, broken = profile_p2.verdict(candidate, stock, declared)
|
||||
report = {"profile": args.profile, "patterns": patterns, "repetitions": args.repetitions,
|
||||
"candidate": candidate, "stock": stock, "fails": fails, "broken_control": broken}
|
||||
if args.out:
|
||||
pathlib.Path(args.out).write_text(json.dumps(report, indent=1), encoding="utf-8")
|
||||
for key, err in fails:
|
||||
print("FAIL round %d %s%s: %s" % (key[0], key[1], " (canary after %s)" % key[3] if key[2] else "", err))
|
||||
for key, err in broken:
|
||||
print("BROKEN CONTROL stock did not idle on %s round %d: %s" % (key[1], key[0], err))
|
||||
print("cells: %d, fails: %d, broken controls: %d" % (len(candidate), len(fails), len(broken)))
|
||||
return 1 if (fails or broken) else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Whitespace-only changes.
@@ -0,0 +1,23 @@
|
||||
"""One background load for the fake web: its own copy of the sites and a browser of ours that reloads an ad-heavy page every two
|
||||
seconds until the process is stopped. `python loader.py BINARY` (run by tests/test_fakeweb_p2_e2e.py, three at a time)."""
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from fakeweb import sites # noqa: E402
|
||||
|
||||
from invisible_playwright import InvisiblePlaywright # noqa: E402
|
||||
|
||||
origin, _other, stop = sites.start((0, 0))
|
||||
try:
|
||||
with InvisiblePlaywright(binary_path=sys.argv[1], headless=True, seed=7) as browser:
|
||||
page = browser.new_context().new_page()
|
||||
while True:
|
||||
try:
|
||||
page.goto(origin + "/p/ad_iframes", wait_until="load", timeout=15000)
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(2)
|
||||
finally:
|
||||
stop()
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"comment": "The outcome of Playwright's own Firefox (stock.lock) on each page: 'idle' means page.wait_for_load_state('networkidle') arrives. A page enters this list after 20 green runs of stock in a row; if stock deviates, the suite is red as a broken control. newsfront is not listed: stock Firefox stalls on it 1 or 2 times in 10 (a pending list that is empty), so it cannot be a gate until a minimal pattern replaces it.",
|
||||
"stock_firefox": {
|
||||
"quiet": "idle",
|
||||
"beacon_pair": "idle",
|
||||
"keepalive_fetch": "idle",
|
||||
"tracking_pixel": "idle",
|
||||
"dup_font": "idle",
|
||||
"removed_iframe": "idle",
|
||||
"cancelled_requests": "idle",
|
||||
"cancel_burst": "idle",
|
||||
"redirect_chain": "idle",
|
||||
"late_requests": "idle",
|
||||
"long_poll": "idle",
|
||||
"ad_iframes": "idle",
|
||||
"late_dom_resources": "idle",
|
||||
"unload_beacon": "idle",
|
||||
"leaving_beacons": "idle",
|
||||
"leaving_beacons_subframe": "idle",
|
||||
"cancel_among_beacons": "idle"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
"""Profile P2 of ci-release-18: ONE context and ONE page, reused for every address, driven by the stock Playwright client.
|
||||
|
||||
The shape of a production client (tf-fetch): a stock Playwright client connected to our served browser, a context route
|
||||
(plain synchronous function: abort image and media, continue the rest), `goto(wait_until="commit")` and then the client-side
|
||||
wait for `networkidle`. After every difficult page the `quiet` canary is loaded on the same page: a state that survives a
|
||||
navigation makes the canary fail. The same driver runs against the stock Firefox, launched by the same client, so the
|
||||
verdict is "same outcome as stock".
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
BLOCKED = ("image", "media")
|
||||
|
||||
|
||||
def install_route(context):
|
||||
context.route("**/*", lambda route: route.abort() if route.request.resource_type in BLOCKED else route.continue_())
|
||||
|
||||
|
||||
def navigate(page, url, *, idle_timeout_ms):
|
||||
rec = {"idle": False, "err": None, "seconds": None}
|
||||
# The requests the client has heard of and not yet heard the end of: a navigation that does not idle says who is still in flight
|
||||
# (type, method, url, frame). The process that hosts a request is not readable by a client.
|
||||
open_requests = {}
|
||||
|
||||
def started(request):
|
||||
try:
|
||||
frame = request.frame.url[:100]
|
||||
except Exception:
|
||||
frame = None
|
||||
open_requests[id(request)] = {"type": request.resource_type, "method": request.method, "url": request.url[:160],
|
||||
"frame": frame, "t": round(time.monotonic() - t0, 2)}
|
||||
|
||||
def ended(request):
|
||||
open_requests.pop(id(request), None)
|
||||
|
||||
t0 = time.monotonic()
|
||||
page.on("request", started)
|
||||
page.on("requestfinished", ended)
|
||||
page.on("requestfailed", ended)
|
||||
try:
|
||||
page.goto(url, wait_until="commit", timeout=15000)
|
||||
page.wait_for_load_state("networkidle", timeout=idle_timeout_ms)
|
||||
rec["idle"] = True
|
||||
except Exception as exc: # recorded, the run goes on: the verdict compares outcomes
|
||||
text = str(exc).strip()
|
||||
rec["err"] = (text.splitlines()[0] if text else repr(exc))[:200]
|
||||
rec["in_flight"] = list(open_requests.values())[:30]
|
||||
finally:
|
||||
for event, handler in (("request", started), ("requestfinished", ended), ("requestfailed", ended)):
|
||||
try:
|
||||
page.remove_listener(event, handler)
|
||||
except Exception:
|
||||
pass
|
||||
rec["seconds"] = round(time.monotonic() - t0, 2)
|
||||
return rec
|
||||
|
||||
|
||||
def drive(browser, origin, patterns, repetitions, idle_timeout_ms=10000):
|
||||
"""Every pattern `repetitions` times, each followed by the canary. Returns a list of cells."""
|
||||
cells = []
|
||||
context = browser.new_context()
|
||||
try:
|
||||
install_route(context)
|
||||
page = context.new_page()
|
||||
for rep in range(1, repetitions + 1):
|
||||
for name in patterns:
|
||||
for pattern, canary in ((name, False), ("quiet", True)):
|
||||
cell = navigate(page, "%s/p/%s" % (origin, pattern), idle_timeout_ms=idle_timeout_ms)
|
||||
cell.update(round=rep, pattern=pattern, canary=canary, after=name if canary else None)
|
||||
cells.append(cell)
|
||||
finally:
|
||||
try:
|
||||
context.close()
|
||||
except Exception:
|
||||
pass
|
||||
return cells
|
||||
|
||||
|
||||
def run_on_candidate(sync_playwright, binary, origin, patterns, repetitions, **kw):
|
||||
"""Our engine, served over the Playwright WebSocket and driven by the stock client."""
|
||||
from invisible_playwright._juggler.remote import launch_server
|
||||
|
||||
server = launch_server(headless=True, binary_path=binary, locale="en-US", timezone="Europe/Rome")
|
||||
try:
|
||||
with sync_playwright() as p:
|
||||
browser = p.firefox.connect(server.ws_endpoint)
|
||||
try:
|
||||
return drive(browser, origin, patterns, repetitions, **kw)
|
||||
finally:
|
||||
browser.close()
|
||||
finally:
|
||||
server.close()
|
||||
|
||||
|
||||
def run_on_stock(sync_playwright, origin, patterns, repetitions, **kw):
|
||||
with sync_playwright() as p:
|
||||
browser = p.firefox.launch()
|
||||
try:
|
||||
return drive(browser, origin, patterns, repetitions, **kw)
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
|
||||
def verdict(candidate, stock, declared):
|
||||
"""The cells where the candidate fails and stock idles, and the cells where stock is not what pages.json declares."""
|
||||
key = lambda c: (c["round"], c["pattern"], c["canary"], c["after"]) # noqa: E731
|
||||
stock_by = {key(c): c for c in stock}
|
||||
fails, broken = [], []
|
||||
for c in candidate:
|
||||
s = stock_by.get(key(c))
|
||||
if s is None:
|
||||
continue
|
||||
if s["idle"] and not c["idle"]:
|
||||
fails.append((key(c), c["err"]))
|
||||
for s in stock:
|
||||
if declared.get(s["pattern"]) == "idle" and not s["idle"]:
|
||||
broken.append((key(s), s["err"]))
|
||||
return fails, broken
|
||||
@@ -0,0 +1,471 @@
|
||||
"""Offline test sites that recreate what ad-heavy pages do to the network.
|
||||
|
||||
One process serves two origins on 127.0.0.1 (page origin "A" and "the other
|
||||
origin" O). Every response is finite (about 3 s at most), so a correct browser
|
||||
must reach networkidle on every page.
|
||||
|
||||
Usage:
|
||||
python sites.py --ports 8311 8312
|
||||
from sites import start; origin_a, origin_b, stop = start((8311, 8312))
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from urllib.parse import parse_qs, urlencode, urlsplit
|
||||
|
||||
MAX_DELAY_MS = 3000
|
||||
# Operations per burst in cancel_among_beacons (env FAKEWEB_BURST overrides).
|
||||
BURST_OPS = int(os.environ.get("FAKEWEB_BURST", "40"))
|
||||
|
||||
PNG_1X1 = base64.b64decode(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
|
||||
)
|
||||
SVG = b'<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><rect width="8" height="8" fill="#888"/></svg>'
|
||||
WOFF2 = b"wOF2" + b"\x00" * 60 # not a real font; the point is the request, not the glyphs
|
||||
|
||||
# Shared prelude for every page: A and O, plus a helper to run code after load.
|
||||
PRELUDE = """
|
||||
const afterLoad = (ms, f) => {
|
||||
const go = () => setTimeout(f, ms);
|
||||
if (document.readyState === 'complete') go(); else addEventListener('load', go);
|
||||
};
|
||||
const noop = () => {};
|
||||
// Read the body so Chromium also finishes the request (an unread body can keep it pending).
|
||||
const get = (u, o) => fetch(u, o).then((r) => r.text()).catch(noop);
|
||||
"""
|
||||
|
||||
# name -> (description, js). The js runs with A (page origin) and O (other origin).
|
||||
PATTERNS = {
|
||||
"quiet": ("nothing at all (the canary)", ""),
|
||||
"beacon_pair": (
|
||||
"two sendBeacon calls to O about 1 ms apart, 700 ms after load",
|
||||
"""
|
||||
afterLoad(700, () => {
|
||||
navigator.sendBeacon(O + '/beacon', 'a=1');
|
||||
setTimeout(() => navigator.sendBeacon(O + '/beacon', 'b=2'), 1);
|
||||
});
|
||||
""",
|
||||
),
|
||||
"keepalive_fetch": (
|
||||
"fetch with keepalive and no-cors to O",
|
||||
"""
|
||||
fetch(O + '/r?kind=json&id=ka1', {keepalive: true, mode: 'no-cors'}).catch(noop);
|
||||
afterLoad(200, () => fetch(O + '/r?kind=json&id=ka2', {keepalive: true, mode: 'no-cors'}).catch(noop));
|
||||
""",
|
||||
),
|
||||
"tracking_pixel": (
|
||||
"four new Image() pixels to O",
|
||||
"""
|
||||
for (let i = 0; i < 4; i++) { const im = new Image(); im.src = O + '/r?kind=png&id=px' + i; }
|
||||
""",
|
||||
),
|
||||
"dup_font": (
|
||||
"fontcss with 5 @font-face rules sharing one woff2 URL, injected 250 ms after load",
|
||||
"""
|
||||
afterLoad(250, () => {
|
||||
const l = document.createElement('link');
|
||||
l.rel = 'stylesheet'; l.href = O + '/r?kind=fontcss&id=fc';
|
||||
document.head.appendChild(l);
|
||||
for (const w of [400, 500, 600, 700, 800]) {
|
||||
const s = document.createElement('span');
|
||||
s.textContent = 'weight ' + w + ' ';
|
||||
s.style.cssText = 'font-family: FakeFont, serif; font-weight: ' + w;
|
||||
document.body.appendChild(s);
|
||||
}
|
||||
});
|
||||
""",
|
||||
),
|
||||
"removed_iframe": (
|
||||
"iframe from O that starts 6 slow fetches and 6 slow images, removed after 150 ms",
|
||||
"""
|
||||
const f = document.createElement('iframe');
|
||||
f.src = O + '/f/slow';
|
||||
document.body.appendChild(f);
|
||||
setTimeout(() => f.remove(), 150);
|
||||
""",
|
||||
),
|
||||
"cancelled_requests": (
|
||||
"aborted fetch, replaced img src, removed script element, all at 100 ms",
|
||||
"""
|
||||
const ac = new AbortController();
|
||||
get(A + '/r?kind=json&delay=2000&id=c1', {signal: ac.signal});
|
||||
setTimeout(() => ac.abort(), 100);
|
||||
const im = new Image();
|
||||
im.src = O + '/r?kind=png&delay=2000&id=c2';
|
||||
document.body.appendChild(im);
|
||||
setTimeout(() => { im.src = A + '/r?kind=png&id=c3'; }, 100);
|
||||
const sc = document.createElement('script');
|
||||
sc.src = O + '/r?kind=js&delay=2000&id=c4';
|
||||
document.head.appendChild(sc);
|
||||
setTimeout(() => sc.remove(), 100);
|
||||
""",
|
||||
),
|
||||
"cancel_burst": (
|
||||
"20 slow fetches aborted after 0-30 ms, 5 iframes added and removed at once",
|
||||
"""
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const c = new AbortController();
|
||||
const base = i % 2 ? O : A;
|
||||
get(base + '/r?kind=json&delay=2000&id=cb' + i, {signal: c.signal});
|
||||
setTimeout(() => c.abort(), Math.round(i * 1.5));
|
||||
}
|
||||
const frames = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const f = document.createElement('iframe');
|
||||
f.src = O + '/f/slow?n=' + i;
|
||||
document.body.appendChild(f);
|
||||
frames.push(f);
|
||||
}
|
||||
setTimeout(() => frames.forEach((f) => f.remove()), 0);
|
||||
""",
|
||||
),
|
||||
"redirect_chain": (
|
||||
"script and fetch behind 2-3 cross-origin 302 hops",
|
||||
"""
|
||||
const rs = document.createElement('script');
|
||||
rs.src = A + '/r?kind=js&redirect=3&id=rc1';
|
||||
document.head.appendChild(rs);
|
||||
get(O + '/r?kind=json&redirect=2&id=rc2');
|
||||
""",
|
||||
),
|
||||
"late_requests": (
|
||||
"a fetch every 300 ms, 7 times",
|
||||
"""
|
||||
for (let i = 1; i <= 7; i++) {
|
||||
setTimeout(() => get(A + '/r?kind=json&id=late' + i), 300 * i);
|
||||
}
|
||||
""",
|
||||
),
|
||||
"long_poll": (
|
||||
"one fetch that takes 2.5 s",
|
||||
"""
|
||||
get(A + '/r?kind=json&delay=2500&id=lp');
|
||||
""",
|
||||
),
|
||||
"ad_iframes": (
|
||||
"3 iframes from O, each with a beacon, a pixel, a delayed script and a nested iframe",
|
||||
"""
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const f = document.createElement('iframe');
|
||||
f.src = O + '/f/ad?n=' + i + '&a=' + encodeURIComponent(A);
|
||||
document.body.appendChild(f);
|
||||
}
|
||||
""",
|
||||
),
|
||||
"late_dom_resources": (
|
||||
"img, svg image and stylesheet inserted 600 ms after load",
|
||||
"""
|
||||
afterLoad(600, () => {
|
||||
const im = document.createElement('img');
|
||||
im.src = O + '/r?kind=svg&id=ld1';
|
||||
document.body.appendChild(im);
|
||||
const ns = 'http://www.w3.org/2000/svg';
|
||||
const svg = document.createElementNS(ns, 'svg');
|
||||
const image = document.createElementNS(ns, 'image');
|
||||
image.setAttribute('href', O + '/r?kind=png&id=ld2');
|
||||
svg.appendChild(image);
|
||||
document.body.appendChild(svg);
|
||||
const l = document.createElement('link');
|
||||
l.rel = 'stylesheet'; l.href = A + '/r?kind=css&delay=300&id=ld3';
|
||||
document.head.appendChild(l);
|
||||
});
|
||||
""",
|
||||
),
|
||||
"unload_beacon": (
|
||||
"sendBeacon in a pagehide listener",
|
||||
"""
|
||||
addEventListener('pagehide', () => navigator.sendBeacon(O + '/beacon', 'bye'));
|
||||
""",
|
||||
),
|
||||
"leaving_beacons": (
|
||||
"beacons and keepalive POSTs fired from pagehide, visibilitychange(hidden), beforeunload and unload",
|
||||
"""
|
||||
const leave = (tag) => {
|
||||
const q = '?t=' + tag;
|
||||
navigator.sendBeacon(O + '/beacon' + q + '&n=1', 'a=1');
|
||||
navigator.sendBeacon(O + '/beacon' + q + '&n=2', 'b=2');
|
||||
navigator.sendBeacon(A + '/beacon' + q + '&n=3', new Blob(['{"leaving":true}'], {type: 'application/json'}));
|
||||
for (let i = 4; i <= 5; i++) {
|
||||
fetch(O + '/beacon' + q + '&n=' + i, {method: 'POST', keepalive: true, mode: 'no-cors', body: 'x'}).catch(noop);
|
||||
}
|
||||
};
|
||||
addEventListener('pagehide', () => leave('pagehide'));
|
||||
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') leave('hidden'); });
|
||||
addEventListener('beforeunload', () => leave('beforeunload'));
|
||||
addEventListener('unload', () => leave('unload'));
|
||||
""",
|
||||
),
|
||||
"leaving_beacons_subframe": (
|
||||
"3 frames (2 from O, 1 from A) that beacon while leaving: one removed at 300 ms, one sent to about:blank at 500 ms, one left in place",
|
||||
"""
|
||||
const mkFrame = (base) => {
|
||||
const f = document.createElement('iframe');
|
||||
f.src = base + '/f/frame_leaver';
|
||||
document.body.appendChild(f);
|
||||
return f;
|
||||
};
|
||||
const fr1 = mkFrame(O), fr2 = mkFrame(O), fr3 = mkFrame(A);
|
||||
afterLoad(300, () => fr1.remove());
|
||||
afterLoad(500, () => { fr2.src = 'about:blank'; });
|
||||
""",
|
||||
),
|
||||
"cancel_among_beacons": (
|
||||
"bursts of aborted slow fetches interleaved with sendBeacon and keepalive fetches, 3 bursts 200 ms apart",
|
||||
"""
|
||||
const burst = (n) => {
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (i % 2 === 0) {
|
||||
// slow fetch that is aborted at once (some at 1-5 ms)
|
||||
const c = new AbortController();
|
||||
get((i % 4 ? A : O) + '/r?kind=json&delay=2000&id=cab' + i, {signal: c.signal});
|
||||
if (i % 6 === 0) setTimeout(() => c.abort(), 1 + (i % 5)); else c.abort();
|
||||
} else if (i % 8 === 1) {
|
||||
fetch(O + '/r?kind=json&id=cak' + i, {keepalive: true, mode: 'no-cors'}).catch(noop);
|
||||
} else {
|
||||
navigator.sendBeacon(O + '/beacon?n=' + i, 'x');
|
||||
}
|
||||
}
|
||||
};
|
||||
for (let k = 0; k < 3; k++) setTimeout(() => burst(BURST_OPS), 200 * k);
|
||||
""".replace("BURST_OPS", str(BURST_OPS)),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def _newsfront():
|
||||
parts = []
|
||||
for name, (_, js) in PATTERNS.items():
|
||||
if name != "quiet":
|
||||
parts.append("(() => {\n" + js + "\n})();")
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
PATTERNS["newsfront"] = ("all of the above JS on one page", _newsfront())
|
||||
|
||||
|
||||
def page_html(name, a, o):
|
||||
desc, js = PATTERNS[name]
|
||||
return (
|
||||
"<!doctype html><html><head><meta charset=utf-8><title>%s</title></head><body>"
|
||||
"<h1>%s</h1><p>%s</p>"
|
||||
"<script>const A=%s, O=%s;\n%s\n%s</script>"
|
||||
"<p id=tail>end of %s</p></body></html>"
|
||||
) % (name, name, desc, json.dumps(a), json.dumps(o), PRELUDE, js, name)
|
||||
|
||||
|
||||
def frame_html(kind, own, other, params):
|
||||
"""Inner pages used by iframes. own = origin serving this frame, other = the opposite origin."""
|
||||
if kind == "slow":
|
||||
body = (
|
||||
"for (let i = 0; i < 6; i++) {"
|
||||
" fetch('/r?kind=json&delay=2000&id=sf' + i).then((r) => r.text()).catch(() => {});"
|
||||
" const im = new Image(); im.src = '/r?kind=png&delay=2000&id=si' + i;"
|
||||
" }"
|
||||
)
|
||||
elif kind == "ad":
|
||||
n = params.get("n", ["0"])[0]
|
||||
body = (
|
||||
"navigator.sendBeacon('/beacon', 'ad=%s');"
|
||||
" const im = new Image(); im.src = '/r?kind=png&id=adpx%s';"
|
||||
" const s = document.createElement('script'); s.src = '/r?kind=js&delay=800&id=ads%s';"
|
||||
" document.head.appendChild(s);"
|
||||
" const f = document.createElement('iframe'); f.src = %s + '/f/nested?n=%s';"
|
||||
" document.body.appendChild(f);"
|
||||
) % (n, n, n, json.dumps(other), n)
|
||||
elif kind == "frame_leaver":
|
||||
# Beacons and a keepalive POST fired while this frame is being left or detached.
|
||||
body = (
|
||||
"const own = %s, other = %s;"
|
||||
" const leave = (tag) => {"
|
||||
" navigator.sendBeacon(other + '/beacon?t=' + tag + '&n=1', 'a=1');"
|
||||
" navigator.sendBeacon(own + '/beacon?t=' + tag + '&n=2', 'b=2');"
|
||||
" fetch(other + '/beacon?t=' + tag + '&n=3', {method: 'POST', keepalive: true, mode: 'no-cors', body: 'x'}).catch(() => {});"
|
||||
" };"
|
||||
" addEventListener('pagehide', () => leave('pagehide'));"
|
||||
" document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') leave('hidden'); });"
|
||||
" addEventListener('beforeunload', () => leave('beforeunload'));"
|
||||
" addEventListener('unload', () => leave('unload'));"
|
||||
) % (json.dumps(own), json.dumps(other))
|
||||
else: # nested
|
||||
n = params.get("n", ["0"])[0]
|
||||
body = (
|
||||
"const s = document.createElement('script'); s.src = '/r?kind=js&delay=500&id=nest%s';"
|
||||
" document.head.appendChild(s);"
|
||||
) % n
|
||||
return (
|
||||
"<!doctype html><html><head><meta charset=utf-8><title>frame %s</title></head>"
|
||||
"<body><p>frame %s</p><script>%s</script></body></html>"
|
||||
) % (kind, kind, body)
|
||||
|
||||
|
||||
class State:
|
||||
def __init__(self):
|
||||
self.origins = ["", ""]
|
||||
self.hits = {}
|
||||
self.lock = threading.Lock()
|
||||
|
||||
def hit(self, path):
|
||||
with self.lock:
|
||||
self.hits[path] = self.hits.get(path, 0) + 1
|
||||
|
||||
|
||||
class Site(ThreadingHTTPServer):
|
||||
daemon_threads = True
|
||||
allow_reuse_address = True
|
||||
request_queue_size = 128
|
||||
|
||||
def __init__(self, addr, handler, idx, state):
|
||||
super().__init__(addr, handler)
|
||||
self.idx = idx
|
||||
self.state = state
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def _send(self, code, ctype, body=b"", extra=None):
|
||||
self.send_response(code)
|
||||
if ctype:
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
for k, v in (extra or {}).items():
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
if body and self.command != "HEAD":
|
||||
self.wfile.write(body)
|
||||
|
||||
def _guard(self, fn):
|
||||
# Browsers abort requests on purpose; a dropped socket is not an error here.
|
||||
try:
|
||||
fn()
|
||||
except (BrokenPipeError, ConnectionResetError, ConnectionAbortedError, TimeoutError):
|
||||
self.close_connection = True
|
||||
|
||||
def do_GET(self):
|
||||
self._guard(self._get)
|
||||
|
||||
def do_POST(self):
|
||||
self._guard(self._post)
|
||||
|
||||
def do_OPTIONS(self):
|
||||
self._guard(lambda: self._send(204, None, b"", {
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "*",
|
||||
}))
|
||||
|
||||
def _post(self):
|
||||
u = urlsplit(self.path)
|
||||
n = int(self.headers.get("Content-Length") or 0)
|
||||
if n:
|
||||
self.rfile.read(n)
|
||||
self.server.state.hit(u.path)
|
||||
self._send(204, None, b"")
|
||||
|
||||
def _get(self):
|
||||
st = self.server.state
|
||||
idx = self.server.idx
|
||||
own, other = st.origins[idx], st.origins[1 - idx]
|
||||
u = urlsplit(self.path)
|
||||
q = parse_qs(u.query, keep_blank_values=True)
|
||||
st.hit(u.path)
|
||||
if u.path == "/_patterns":
|
||||
body = json.dumps({k: v[0] for k, v in PATTERNS.items()}, indent=1).encode()
|
||||
return self._send(200, "application/json", body)
|
||||
if u.path == "/_hits":
|
||||
with st.lock:
|
||||
body = json.dumps(st.hits, indent=1, sort_keys=True).encode()
|
||||
return self._send(200, "application/json", body)
|
||||
if u.path.startswith("/p/"):
|
||||
name = u.path[3:]
|
||||
if name not in PATTERNS:
|
||||
return self._send(404, "text/plain", b"unknown pattern")
|
||||
html = page_html(name, st.origins[0], st.origins[1])
|
||||
return self._send(200, "text/html; charset=utf-8", html.encode())
|
||||
if u.path.startswith("/f/"):
|
||||
kind = u.path[3:]
|
||||
if kind not in ("slow", "ad", "nested", "frame_leaver"):
|
||||
return self._send(404, "text/plain", b"unknown frame")
|
||||
html = frame_html(kind, own, other, q)
|
||||
return self._send(200, "text/html; charset=utf-8", html.encode())
|
||||
if u.path == "/r":
|
||||
return self._resource(q, own, other)
|
||||
return self._send(404, "text/plain", b"not found")
|
||||
|
||||
def _resource(self, q, own, other):
|
||||
hops = int(q.get("redirect", ["0"])[0] or 0)
|
||||
if hops > 0:
|
||||
nq = {k: v[0] for k, v in q.items()}
|
||||
nq["redirect"] = str(hops - 1)
|
||||
return self._send(302, None, b"", {"Location": other + "/r?" + urlencode(nq)})
|
||||
delay = min(int(q.get("delay", ["0"])[0] or 0), MAX_DELAY_MS)
|
||||
if delay > 0:
|
||||
time.sleep(delay / 1000.0)
|
||||
kind = q.get("kind", ["json"])[0]
|
||||
rid = q.get("id", [""])[0]
|
||||
if kind == "js":
|
||||
return self._send(200, "application/javascript", ("/* %s */\n" % rid).encode())
|
||||
if kind == "css":
|
||||
return self._send(200, "text/css", b".fw-x{color:#222}\n")
|
||||
if kind == "png":
|
||||
return self._send(200, "image/png", PNG_1X1)
|
||||
if kind == "svg":
|
||||
return self._send(200, "image/svg+xml", SVG)
|
||||
if kind == "woff2":
|
||||
return self._send(200, "font/woff2", WOFF2)
|
||||
if kind == "fontcss":
|
||||
font_url = self.server.state.origins[1] + "/r?kind=woff2&id=font"
|
||||
rules = "".join(
|
||||
"@font-face{font-family:FakeFont;font-weight:%d;src:url(%s) format('woff2');}\n" % (w, font_url)
|
||||
for w in (400, 500, 600, 700, 800)
|
||||
)
|
||||
return self._send(200, "text/css", rules.encode())
|
||||
if kind == "json":
|
||||
return self._send(200, "application/json", json.dumps({"ok": True, "id": rid}).encode())
|
||||
return self._send(400, "text/plain", b"bad kind")
|
||||
|
||||
|
||||
def start(ports=(8311, 8312), bind="127.0.0.1", public_host=("127.0.0.1", "localhost")):
|
||||
"""Start both origins on daemon threads. Returns (origin_a, origin_b, stop).
|
||||
|
||||
bind: address to listen on (0.0.0.0 = all interfaces, e.g. to reach it from a container).
|
||||
public_host: host name written into the pages for A and O, one string for both or a pair (A, O). The default pair makes
|
||||
A `127.0.0.1` and O `localhost`: two different SITES for Fission (two ports of one host are one site, and a frame of the
|
||||
"other origin" would never leave the page's process).
|
||||
"""
|
||||
hosts = (public_host, public_host) if isinstance(public_host, str) else tuple(public_host)
|
||||
state = State()
|
||||
servers = [Site((bind, p), Handler, i, state) for i, p in enumerate(ports)]
|
||||
state.origins = ["http://%s:%d" % (hosts[i], s.server_address[1]) for i, s in enumerate(servers)]
|
||||
for s in servers:
|
||||
threading.Thread(target=s.serve_forever, daemon=True).start()
|
||||
|
||||
def stop():
|
||||
for s in servers:
|
||||
s.shutdown()
|
||||
s.server_close()
|
||||
|
||||
return state.origins[0], state.origins[1], stop
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--ports", nargs=2, type=int, default=[8311, 8312])
|
||||
ap.add_argument("--bind", default="127.0.0.1", help="address to listen on (0.0.0.0 = all interfaces)")
|
||||
ap.add_argument("--public-host", default="127.0.0.1", help="host name written into the pages for A and O")
|
||||
args = ap.parse_args()
|
||||
a, b, stop = start(tuple(args.ports), args.bind, args.public_host)
|
||||
print("A =", a, " O =", b, flush=True)
|
||||
try:
|
||||
while True:
|
||||
time.sleep(3600)
|
||||
except KeyboardInterrupt:
|
||||
stop()
|
||||
@@ -0,0 +1,2 @@
|
||||
playwright=1.61.0
|
||||
# sha256 of the stock browser archives is added here by the PR that changes the version
|
||||
@@ -0,0 +1,149 @@
|
||||
"""The fake web, profile P2: ONE routed page reused for every address reaches `networkidle` on every navigation, as stock does.
|
||||
|
||||
A page is difficult in the way real ad-heavy pages are: beacons and keepalive fetches fired while a document or a frame is
|
||||
being left, slow fetches the page aborts among them, frames removed or sent to about:blank. The failure is a RATE, not a
|
||||
fixed page: one request whose end the client never hears holds every later address of the same page, canaries included.
|
||||
So each hard page is loaded several times in a row, each followed by the quiet canary, and not one load may be left without
|
||||
`networkidle`. The outcome stock Firefox has on each page is declared in tests/fakeweb/pages.json; scripts/run_fakeweb.py
|
||||
runs stock in the same job and is the CI entry.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
from fakeweb import profile_p2, sites
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
HERE = pathlib.Path(__file__).resolve().parent / "fakeweb"
|
||||
HARD = ["leaving_beacons_subframe", "leaving_beacons", "cancel_among_beacons"]
|
||||
REPETITIONS = 10
|
||||
|
||||
|
||||
def _stock_client():
|
||||
"""The stock Playwright client (a pinned dev dependency), imported by name: the fork's guard forbids a static import."""
|
||||
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
|
||||
pytest.fail("the stock Playwright client is missing (%s): install the wrapper with its dev extra" % exc,
|
||||
pytrace=False)
|
||||
|
||||
|
||||
def test_every_hard_page_reaches_networkidle_every_time_on_a_reused_routed_page(firefox_binary):
|
||||
declared = json.loads((HERE / "pages.json").read_text(encoding="utf-8"))["stock_firefox"]
|
||||
assert all(declared[p] == "idle" for p in HARD), "this test holds the pages stock idles on"
|
||||
origin, _other, stop = sites.start((0, 0))
|
||||
try:
|
||||
cells = profile_p2.run_on_candidate(_stock_client(), firefox_binary, origin, HARD, REPETITIONS)
|
||||
finally:
|
||||
stop()
|
||||
bad = ["round %d %s%s: %s" % (c["round"], c["pattern"], " (canary after %s)" % c["after"] if c["canary"] else "", c["err"])
|
||||
for c in cells if not c["idle"]]
|
||||
assert not bad, "%d of %d navigations did not reach networkidle:\n %s" % (len(bad), len(cells), "\n ".join(bad[:12]))
|
||||
|
||||
|
||||
def _web_processes(root_pid):
|
||||
"""The pids of the engine's web content processes (`-contentproc ... tab`) below `root_pid`."""
|
||||
import psutil
|
||||
|
||||
found = set()
|
||||
try:
|
||||
children = psutil.Process(root_pid).children(recursive=True)
|
||||
except psutil.Error:
|
||||
return found
|
||||
for process in children:
|
||||
try:
|
||||
cmd = process.cmdline()
|
||||
except psutil.Error:
|
||||
continue
|
||||
if "-contentproc" in cmd and cmd[-1] == "tab":
|
||||
found.add(process.pid)
|
||||
return found
|
||||
|
||||
|
||||
def _quiet(root_pid, seconds=3.0, limit=30.0):
|
||||
"""The processes once their set has not changed for `seconds`."""
|
||||
import time
|
||||
|
||||
end = time.time() + limit
|
||||
last, since = _web_processes(root_pid), time.time()
|
||||
while time.time() < end:
|
||||
time.sleep(0.25)
|
||||
now = _web_processes(root_pid)
|
||||
if now != last:
|
||||
last, since = now, time.time()
|
||||
elif time.time() - since >= seconds:
|
||||
break
|
||||
return last
|
||||
|
||||
|
||||
def test_the_other_origin_of_the_fake_web_is_another_site_in_another_process(firefox_binary):
|
||||
"""The page origin and the other origin must be two SITES (127.0.0.1 and localhost), or a frame of the other origin stays in the
|
||||
page's process and the fake web can never exercise a request of a frame of another process (the third cause of the stalled
|
||||
networkidle). With the spares off every new content process was started for a page: the page `ad_iframes` has frames of the
|
||||
other origin, so loading it must add at least one."""
|
||||
from invisible_playwright._juggler.remote import launch_server
|
||||
|
||||
sync_playwright = _stock_client()
|
||||
origin, other, stop = sites.start((0, 0))
|
||||
server = launch_server(headless=True, binary_path=firefox_binary, locale="en-US", timezone="Europe/Rome",
|
||||
extra_prefs={"dom.ipc.processPrelaunch.enabled": False})
|
||||
try:
|
||||
assert origin.split(":")[1] != other.split(":")[1], "A and O are the same host: %s %s" % (origin, other)
|
||||
with sync_playwright() as p:
|
||||
browser = p.firefox.connect(server.ws_endpoint)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.goto(origin + "/p/quiet", wait_until="load")
|
||||
before = _quiet(server.process.pid)
|
||||
page.goto(origin + "/p/ad_iframes", wait_until="load")
|
||||
page.wait_for_timeout(1500)
|
||||
after = _quiet(server.process.pid)
|
||||
context.close()
|
||||
browser.close()
|
||||
finally:
|
||||
server.close()
|
||||
stop()
|
||||
assert len(after - before) >= 1, "the frames of the other origin added no process: before %s, after %s" % (
|
||||
sorted(before), sorted(after))
|
||||
|
||||
|
||||
LOADERS = 3
|
||||
|
||||
|
||||
def test_the_page_that_leaves_with_beacons_reaches_networkidle_every_time_under_a_load_of_other_browsers(firefox_binary):
|
||||
"""MANDATORY CASE. `leaving_beacons_subframe` sends beacons from a frame of another site while it is sent to about:blank. With the
|
||||
context route holding them and other browsers loading pages in the background (the declared load: three loaders of ours, each a
|
||||
browser reloading an ad-heavy page every two seconds), a beacon's channel can be cancelled with its document after the route resumed
|
||||
it, and an engine that does not end that request leaves the page waiting for ever. Quiet, it passes; loaded, Playwright's own Firefox
|
||||
idles 30 rounds of 30 and an engine without the end of a cancelled resumed request idled 1 of 30. All ten rounds must idle."""
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
loader = pathlib.Path(__file__).resolve().parent / "fakeweb" / "loader.py"
|
||||
procs = [subprocess.Popen([sys.executable, str(loader), firefox_binary], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
for _ in range(LOADERS)]
|
||||
origin, _other, stop = sites.start((0, 0))
|
||||
try:
|
||||
import time
|
||||
|
||||
time.sleep(20) # the loaders are up and loading
|
||||
cells = profile_p2.run_on_candidate(_stock_client(), firefox_binary, origin, ["leaving_beacons_subframe"], 10)
|
||||
finally:
|
||||
stop()
|
||||
for proc in procs:
|
||||
proc.terminate()
|
||||
for proc in procs:
|
||||
try:
|
||||
proc.wait(timeout=20)
|
||||
except Exception:
|
||||
proc.kill()
|
||||
bad = ["round %d%s: %s -- in flight: %s" % (c["round"], " (canary)" if c["canary"] else "", c["err"],
|
||||
[(r["type"], r["method"], r["frame"]) for r in c.get("in_flight", [])[:3]])
|
||||
for c in cells if not c["idle"]]
|
||||
assert not bad, "%d of %d navigations did not reach networkidle under load:%s" % (
|
||||
len(bad), len(cells), "".join("\n " + line for line in bad[:6]))
|
||||
Reference in new issue
Block a user