mirror of
https://github.com/daijro/camoufox.git
synced 2026-09-07 16:01:00 +00:00
Triaged all 76 failures from the full run. None was a Camoufox browser bug --
every one was the vendored harness disagreeing with the Playwright it runs
against, or asserting a response no real server sends. Each was checked against
stock Firefox before being written off.
Harness bugs that hid real coverage:
* conftest's RemoteServer wrote snake_case launch options into a JSON consumed
by the Node driver, which needs camelCase, so `executable_path` was dropped
and launch-server fell back to a Firefox that isn't installed. It printed no
endpoint and all 16 connect tests died on an empty ws_endpoint with a
nonsense "Port should be >= 0 and < 65536. Received type string ('')".
Also drop None-valued options: a null `channel` aborts the driver outright.
16 failed -> 17 passed.
* tests/server.py answered 404/401 with a bare status line -- no Content-Type,
no body. Gecko renders that through the plaintext viewer and then never
fires `load`, leaving readyState at "interactive" forever, so page.goto()
(which waits for `load`) hung for the full timeout. That single defect
accounted for 17 of the 76 failures across five files, and cost 30s each.
Confirmed on stock Firefox too, so it is Gecko behaviour, not ours -- real
servers always send a body. clearcookies alone: 5 failed in 152s -> 7 passed
in 2s.
Removed APIs (gone from every Playwright the package supports, <1.61):
* test_accessibility.py in full -- Page.accessibility no longer exists.
* the two expose_binding(handle=True) tests -- the parameter is gone.
* test_glob_to_regex plus its import shim -- it pinned the old `?`/`[]` glob
wildcards, which upstream deliberately made literals. It only ever exercised
Playwright's private helper, never Camoufox.
Assertion drift, updated to what the current Playwright actually does:
* expect(...) failures raise AssertionError, not playwright.Error.
* editability is undefined for a <button>; use a readonly input.
* timeout wording: 'Expect "x" with timeout Nms', 'Timeout Nms exceeded'.
* traces no longer carry the Python-level `apiName`; action events record
protocol-level class+method ("Frame.goto"). Reading the old key raised
KeyError. 5 failed -> 11 passed.
* APIRequestContext `params` are appended to an existing query rather than
replacing it -- assert the request is built correctly instead.
* test_network asserted "Firefox" in the UA. The bare binary advertises
"Camoufox/<version>"; the Python package rewrites it to "Firefox/<version>"
(verified on the wire and in navigator.userAgent). This suite drives the
bare binary, so assert what this layer can promise.
Left failing on purpose, each reproduced identically on stock Firefox:
test_page_clock::test_should_pause (clock resumes 1-5ms late: 1002 here,
1005 stock), test_page_add_locator_handler::test_should_wait_for_hidden_by_default_2,
test_navigation's empty-url popup readyState, and
test_frame_goto_should_continue_after_client_redirect -- that last one is a
genuine race in the networkidle accounting (a subframe's navigationCommitted
can land after its subresource requests, and Playwright clears inflight
bookkeeping on commit), flaky in both: 3/10 wrong here, 1/10 on stock.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
83 lines
2.7 KiB
Python
83 lines
2.7 KiB
Python
# Copyright (c) Microsoft Corporation.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import json
|
|
import zipfile
|
|
from pathlib import Path
|
|
from typing import Any, Dict, List, Optional, Tuple, TypeVar
|
|
|
|
|
|
def parse_trace(path: Path) -> Tuple[Dict[str, bytes], List[Any]]:
|
|
resources: Dict[str, bytes] = {}
|
|
with zipfile.ZipFile(path, "r") as zip:
|
|
for name in zip.namelist():
|
|
resources[name] = zip.read(name)
|
|
action_map: Dict[str, Any] = {}
|
|
events: List[Any] = []
|
|
for name in ["trace.trace", "trace.network"]:
|
|
for line in resources[name].decode().splitlines():
|
|
if not line:
|
|
continue
|
|
event = json.loads(line)
|
|
if event["type"] == "before":
|
|
event["type"] = "action"
|
|
action_map[event["callId"]] = event
|
|
events.append(event)
|
|
elif event["type"] == "input":
|
|
pass
|
|
elif event["type"] == "after":
|
|
existing = action_map[event["callId"]]
|
|
existing["error"] = event.get("error", None)
|
|
else:
|
|
events.append(event)
|
|
return (resources, events)
|
|
|
|
|
|
def get_trace_actions(events: List[Any]) -> List[str]:
|
|
action_events = sorted(
|
|
list(
|
|
filter(
|
|
lambda e: e["type"] == "action",
|
|
events,
|
|
)
|
|
),
|
|
key=lambda e: e["startTime"],
|
|
)
|
|
# Traces no longer record the Python-level `apiName` ("Page.goto"); action
|
|
# events now carry the protocol-level class and method ("Frame.goto"). The
|
|
# old key is simply absent, so reading it raised KeyError and took down
|
|
# every assertion that inspects a trace.
|
|
return [f'{e["class"]}.{e["method"]}' for e in action_events]
|
|
|
|
|
|
TARGET_CLOSED_ERROR_MESSAGE = "Target page, context or browser has been closed"
|
|
|
|
MustType = TypeVar("MustType")
|
|
|
|
|
|
def must(value: Optional[MustType]) -> MustType:
|
|
assert value
|
|
return value
|
|
|
|
|
|
def chromium_version_less_than(a: str, b: str) -> bool:
|
|
left = list(map(int, a.split(".")))
|
|
right = list(map(int, b.split(".")))
|
|
for i in range(4):
|
|
if left[i] > right[i]:
|
|
return False
|
|
if left[i] < right[i]:
|
|
return True
|
|
return False
|