mirror of
https://github.com/lexmount/moli.git
synced 2026-10-30 16:07:24 +00:00
test(cdp): expect Base64 for intercepted text response bodies
This commit is contained in:
@@ -25,6 +25,16 @@ observed, but it does not replace the executable probe when one can be run. If
|
||||
Chromium cannot be tested, document that limitation explicitly instead of
|
||||
presenting an inferred expectation as verified behavior.
|
||||
|
||||
The `Fetch.getResponseBody` text encoding was calibrated on 2026-10-19 against
|
||||
Debian `/usr/bin/chromium` 145.0.7632.116. A fresh page enabled `Network` and
|
||||
`Fetch` with `requestStage: "Response"`, navigated to a local UTF-8 HTML fixture,
|
||||
and read its paused body before continuing the response. Chromium returned
|
||||
Base64 with `base64Encoded: true`; reading the completed request through
|
||||
`Network.getResponseBody` returned the original text with `base64Encoded: false`.
|
||||
The `network` and `multi-context` groups require the encoded Fetch body and flag,
|
||||
then independently verify the original page-visible text after continuation.
|
||||
Their Network body and `IO.read` stream assertions retain their own contracts.
|
||||
|
||||
The default `cdp-ordering` group locks down Renderer native and Inspector wire
|
||||
publication order. It pipelines Page trees/layout, DOMSnapshot, DOM queries and
|
||||
objects, CSS, AX, and a native backend error before `Runtime.enable`; stylesheet
|
||||
|
||||
@@ -644,10 +644,10 @@ async def run_multi_context_popup_response_stage_body_owner_state_smoke(
|
||||
|
||||
body_a = await _send_cdp(cdp_a, "Fetch.getResponseBody", {"requestId": request_id_a})
|
||||
body_b = await _send_cdp(cdp_b, "Fetch.getResponseBody", {"requestId": request_id_b})
|
||||
assert_equal(body_a.get("body"), "response-stage body", "context A popup Fetch.getResponseBody")
|
||||
assert_equal(body_b.get("body"), "response-stage body", "context B popup Fetch.getResponseBody")
|
||||
assert_equal(body_a.get("base64Encoded"), False, "context A popup Fetch.getResponseBody encoding")
|
||||
assert_equal(body_b.get("base64Encoded"), False, "context B popup Fetch.getResponseBody encoding")
|
||||
assert_equal(body_a.get("body"), RESPONSE_STAGE_BODY_BASE64, "context A popup Fetch.getResponseBody")
|
||||
assert_equal(body_b.get("body"), RESPONSE_STAGE_BODY_BASE64, "context B popup Fetch.getResponseBody")
|
||||
assert_equal(body_a.get("base64Encoded"), True, "context A popup Fetch.getResponseBody encoding")
|
||||
assert_equal(body_b.get("base64Encoded"), True, "context B popup Fetch.getResponseBody encoding")
|
||||
|
||||
if fetch_a.done() or fetch_b.done():
|
||||
raise SmokeError("popup response-stage fetch completed before continueResponse")
|
||||
|
||||
@@ -828,8 +828,12 @@ async def _verify_response_stage_xhr_get_response_body(state: SmokeState) -> Non
|
||||
raise SmokeError(f"missing response-stage XHR networkId: {paused}")
|
||||
|
||||
body = await state.cdp.send("Fetch.getResponseBody", {"requestId": request_id})
|
||||
assert_equal(body.get("body"), "response-stage body", "XHR response-stage Fetch.getResponseBody body")
|
||||
assert_equal(body.get("base64Encoded"), False, "XHR response-stage Fetch.getResponseBody encoding")
|
||||
assert_equal(
|
||||
body.get("body"),
|
||||
base64.b64encode(b"response-stage body").decode("ascii"),
|
||||
"XHR response-stage Fetch.getResponseBody body",
|
||||
)
|
||||
assert_equal(body.get("base64Encoded"), True, "XHR response-stage Fetch.getResponseBody encoding")
|
||||
|
||||
await state.cdp.send("Fetch.continueResponse", {"requestId": request_id})
|
||||
await wait_until(
|
||||
@@ -1613,8 +1617,12 @@ async def _verify_fetch_auth_response_stage(state: SmokeState) -> None:
|
||||
)
|
||||
|
||||
body_result = await state.cdp.send("Fetch.getResponseBody", {"requestId": request_id})
|
||||
assert_equal(body_result.get("base64Encoded"), False, "Fetch auth response-stage body encoding")
|
||||
assert_equal(body_result.get("body"), "authenticated fetch", "Fetch auth response-stage paused body")
|
||||
assert_equal(body_result.get("base64Encoded"), True, "Fetch auth response-stage body encoding")
|
||||
assert_equal(
|
||||
body_result.get("body"),
|
||||
base64.b64encode(b"authenticated fetch").decode("ascii"),
|
||||
"Fetch auth response-stage paused body",
|
||||
)
|
||||
|
||||
await state.cdp.send("Fetch.continueResponse", {"requestId": request_id})
|
||||
await wait_until(
|
||||
|
||||
Reference in New Issue
Block a user