Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca7c2cc7fa |
No files matched your search
@@ -0,0 +1,73 @@
|
||||
# isolated-old-hunt.yml - hunt scaffolding, never merged. Runs only on a push to a `hunt/isolated-old**` branch.
|
||||
# The new variant of the isolated-page test (the move on the test's signal) must stay red on the release before the fix (0.42.0 + firefox-52).
|
||||
name: isolated old hunt
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['hunt/isolated-old**']
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: isolated-old-hunt-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
hunt:
|
||||
name: isolated old ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
max-parallel: 1
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-24.04, windows-2022]
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: The old release and the new one, each variant three rounds x5
|
||||
run: |
|
||||
set +e
|
||||
mkdir -p evidence
|
||||
python -m venv old && python -m venv new
|
||||
if [ "$RUNNER_OS" = "Windows" ]; then O=old/Scripts/python; N=new/Scripts/python; else O=old/bin/python; N=new/bin/python; fi
|
||||
$O -m pip install --quiet invisible-playwright==0.42.0
|
||||
$N -m pip install --quiet .
|
||||
if [ "$RUNNER_OS" = "Linux" ]; then $N -m pip install --quiet playwright==1.61.0 && $N -m playwright install-deps firefox; fi
|
||||
for py in old new; do
|
||||
P=$O; [ $py = new ] && P=$N
|
||||
for variant in signal timer; do
|
||||
for n in 1 2 3 4 5; do
|
||||
$P -u scripts/hunt_isolated_old.py $variant > "evidence/${py}_${variant}_$n.log" 2>&1
|
||||
echo "$py $variant $n: $(grep -a '^wrapper\|^RESULT' evidence/${py}_${variant}_$n.log | tr '\n' ' ')"
|
||||
done
|
||||
done
|
||||
done
|
||||
{
|
||||
echo "## isolated page ($RUNNER_OS): RESULT per release and variant"
|
||||
echo '```'
|
||||
for f in evidence/*.log; do echo "$(basename $f) $(grep -a '^RESULT' $f) $(grep -a 'ERROR' $f | head -1 | cut -c1-160)"; done
|
||||
echo '```'
|
||||
} | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: Upload the evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: isolated-old-${{ matrix.os }}-${{ github.run_id }}
|
||||
path: evidence
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,64 @@
|
||||
"""HUNT SCAFFOLDING, NEVER MERGED: the isolated-page rounds of tests/test_an_isolated_page_and_the_next_e2e.py, run with whatever
|
||||
invisible_playwright is installed (the job installs 0.42.0, the release before the fix, with its engine firefox-52).
|
||||
|
||||
Usage: python scripts/hunt_isolated_old.py signal|timer. `signal` is the new variant (the test makes the page move right after the read),
|
||||
`timer` the old one (the page moves 500 ms after load). Prints one line per round: ok, or the error, and a last line RESULT red/green.
|
||||
"""
|
||||
import http.server
|
||||
import sys
|
||||
import threading
|
||||
|
||||
VARIANT = sys.argv[1]
|
||||
MOVE = (b"window.moveOn = () => setTimeout(() => location.replace('/plain' + location.search), 0)" if VARIANT == "signal" else
|
||||
b"addEventListener('load', () => setTimeout(() => location.replace('/plain' + location.search), 500))")
|
||||
PAGES = {"/isolated": b"<!doctype html><html><body><p id=p>isolated</p><script>" + MOVE + b"</script></body></html>",
|
||||
"/plain": b"<!doctype html><html><body><p id=p>plain</p></body></html>"}
|
||||
|
||||
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = self.path.split("?")[0]
|
||||
body = PAGES.get(path, PAGES["/plain"])
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
if path == "/isolated":
|
||||
self.send_header("Cross-Origin-Opener-Policy", "same-origin")
|
||||
self.send_header("Cross-Origin-Embedder-Policy", "require-corp")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
|
||||
srv = http.server.ThreadingHTTPServer(("127.0.0.1", 0), H)
|
||||
srv.daemon_threads = True
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
site = "http://127.0.0.1:%d" % srv.server_address[1]
|
||||
|
||||
import invisible_playwright
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
print("wrapper", getattr(invisible_playwright, "__version__", "?"), flush=True)
|
||||
red = False
|
||||
with InvisiblePlaywright(seed=4321, headless=True) as browser:
|
||||
page = browser.new_page()
|
||||
for i in range(3):
|
||||
try:
|
||||
page.goto("%s/isolated?i=%d" % (site, i), wait_until="domcontentloaded")
|
||||
assert page.evaluate("self.crossOriginIsolated") is True, "not isolated"
|
||||
assert page.locator("#p").inner_text(timeout=10_000) in ("isolated", "plain")
|
||||
if VARIANT == "signal":
|
||||
page.evaluate("moveOn()")
|
||||
page.wait_for_url("**/plain?i=%d" % i, timeout=10_000)
|
||||
assert page.evaluate("self.crossOriginIsolated") is False
|
||||
assert page.locator("#p").inner_text(timeout=10_000) == "plain"
|
||||
assert page.inner_text("#p", timeout=10_000) == "plain"
|
||||
assert page.query_selector("#p") is not None
|
||||
assert page.locator("#p").all_inner_texts() == ["plain"]
|
||||
print("round %d ok" % i, flush=True)
|
||||
except Exception as e:
|
||||
red = True
|
||||
print("round %d ERROR %s" % (i, str(e).splitlines()[0][:200]), flush=True)
|
||||
print("RESULT", "red" if red else "green", flush=True)
|
||||
srv.shutdown()
|
||||
Reference in new issue
Block a user