53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
"""Cancel during ICE/offer, then verify a late old error cannot stop a new turn."""
|
|
|
|
import asyncio
|
|
import json
|
|
import pathlib
|
|
|
|
from playwright.async_api import async_playwright
|
|
|
|
OUT = pathlib.Path(__file__).resolve().parents[1] / "evidence"
|
|
|
|
|
|
async def main():
|
|
async with async_playwright() as p:
|
|
browser = await p.chromium.launch(
|
|
args=["--no-sandbox", "--autoplay-policy=no-user-gesture-required"]
|
|
)
|
|
context = await browser.new_context(ignore_https_errors=True)
|
|
page = await context.new_page()
|
|
errors = []
|
|
page.on("pageerror", lambda e: errors.append(str(e)))
|
|
await page.goto("https://192.168.200.12:8014")
|
|
await page.wait_for_function(
|
|
"document.querySelector('#status').textContent.includes('就绪')"
|
|
)
|
|
await page.click("#enter")
|
|
await page.wait_for_function(
|
|
"document.querySelector('#status').textContent.includes('正在听')", timeout=40000
|
|
)
|
|
await page.fill("#text", "这一轮马上取消。")
|
|
await page.click("button[type=submit]")
|
|
await page.wait_for_timeout(100)
|
|
await page.click("#cancel")
|
|
await page.fill("#text", "新一轮只回复:你好。")
|
|
await page.click("button[type=submit]")
|
|
await page.wait_for_function(
|
|
"window.sampleEvents.some(e=>e.event==='first-audible')", timeout=45000
|
|
)
|
|
await page.wait_for_timeout(10000)
|
|
events = await page.evaluate("window.sampleEvents")
|
|
failures = [
|
|
e for e in events if e["event"] == "status" and "媒体协商超时" in str(e["detail"])
|
|
]
|
|
result = {"pageerrors": errors, "late_error_failures": failures, "events": events}
|
|
(OUT / "race-check.json").write_text(json.dumps(result, ensure_ascii=False, indent=2))
|
|
assert not failures
|
|
await page.click("#back")
|
|
await page.wait_for_timeout(4000)
|
|
await browser.close()
|
|
print("ICE cancellation race passed", flush=True)
|
|
|
|
|
|
asyncio.run(main())
|