mirror of
https://github.com/lexmount/moli.git
synced 2026-10-30 08:07:38 +00:00
test(scripts): synchronize async chunk fixture on execution
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
window.parseTimeDclFired = true;
|
||||
});
|
||||
</script>
|
||||
<script async src="/assets/parse_time_async.js"></script>
|
||||
<script async src="/assets/parse_time_async_chunked.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
window.parseTimeAsyncSawTail = !!document.getElementById("late");
|
||||
window.parseTimeAsyncSawDcl = window.parseTimeDclFired === true;
|
||||
// Release the response tail only after observing the parser's partial DOM.
|
||||
void fetch("/compat/parse-time-async-classic-chunked-executed");
|
||||
@@ -650,6 +650,8 @@ const PARSE_TIME_ASYNC_CLASSIC_HTML: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/parse_time_async_classic.html");
|
||||
const PARSE_TIME_ASYNC_CLASSIC_CHUNKED_HTML: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/parse_time_async_classic_chunked.html");
|
||||
const PARSE_TIME_ASYNC_CLASSIC_CHUNKED_JS: &str =
|
||||
include_str!("../../moli-core/tests/fixtures/runtime/parse_time_async_classic_chunked.js");
|
||||
const PARSE_TIME_ASYNC_CLASSIC_SLOW_CHUNKED_TAIL_HTML: &str = include_str!(
|
||||
"../../moli-core/tests/fixtures/runtime/parse_time_async_classic_slow_chunked_tail.html"
|
||||
);
|
||||
|
||||
@@ -2096,8 +2096,11 @@ pub(super) async fn parse_time_async_classic_chunked_page(headers: HeaderMap) ->
|
||||
{
|
||||
return;
|
||||
}
|
||||
let _ = tokio::time::timeout(Duration::from_millis(500), tail_gate.notified()).await;
|
||||
sleep(Duration::from_millis(20)).await;
|
||||
// A request for the asset does not imply that its body has arrived or
|
||||
// executed. Its dedicated script acknowledges execution before tail
|
||||
// delivery. The timeout is only a bounded failure escape: the test's
|
||||
// before-tail assertions still fail if the parser cannot make progress.
|
||||
let _ = tokio::time::timeout(Duration::from_secs(5), tail_gate.notified()).await;
|
||||
let _ = tx
|
||||
.send(Ok::<Bytes, std::convert::Infallible>(Bytes::from(tail)))
|
||||
.await;
|
||||
@@ -2114,6 +2117,13 @@ pub(super) async fn parse_time_async_classic_chunked_page(headers: HeaderMap) ->
|
||||
.expect("chunked async classic response should build")
|
||||
}
|
||||
|
||||
pub(super) async fn parse_time_async_classic_chunked_executed(headers: HeaderMap) -> StatusCode {
|
||||
if let Some(host_key) = request_host_key(&headers) {
|
||||
notify_parse_time_async_chunked_tail_gate_if_present(&host_key);
|
||||
}
|
||||
StatusCode::NO_CONTENT
|
||||
}
|
||||
|
||||
pub(super) async fn parse_time_async_classic_slow_chunked_tail_page() -> Response {
|
||||
let split_marker = "<script defer";
|
||||
let split_index = PARSE_TIME_ASYNC_CLASSIC_SLOW_CHUNKED_TAIL_HTML
|
||||
@@ -4362,13 +4372,14 @@ pub(super) async fn asset_parse_time_defer_script() -> Response {
|
||||
javascript_response(PARSE_TIME_DEFER_JS)
|
||||
}
|
||||
|
||||
pub(super) async fn asset_parse_time_async_script(headers: HeaderMap) -> Response {
|
||||
if let Some(host_key) = request_host_key(&headers) {
|
||||
notify_parse_time_async_chunked_tail_gate_if_present(&host_key);
|
||||
}
|
||||
pub(super) async fn asset_parse_time_async_script() -> Response {
|
||||
javascript_response(PARSE_TIME_ASYNC_JS)
|
||||
}
|
||||
|
||||
pub(super) async fn asset_parse_time_async_chunked_script() -> Response {
|
||||
javascript_response(PARSE_TIME_ASYNC_CLASSIC_CHUNKED_JS)
|
||||
}
|
||||
|
||||
pub(super) async fn asset_parse_time_async_load_order_script() -> Response {
|
||||
javascript_response(PARSE_TIME_ASYNC_LOAD_ORDER_JS)
|
||||
}
|
||||
|
||||
@@ -1129,6 +1129,10 @@ pub(super) fn build_router() -> Router {
|
||||
"/compat/parse-time-async-classic-chunked",
|
||||
get(parse_time_async_classic_chunked_page),
|
||||
)
|
||||
.route(
|
||||
"/compat/parse-time-async-classic-chunked-executed",
|
||||
get(parse_time_async_classic_chunked_executed),
|
||||
)
|
||||
.route(
|
||||
"/compat/parse-time-async-classic-slow-chunked-tail",
|
||||
get(parse_time_async_classic_slow_chunked_tail_page),
|
||||
@@ -2138,6 +2142,10 @@ pub(super) fn build_router() -> Router {
|
||||
"/assets/parse_time_async.js",
|
||||
get(asset_parse_time_async_script),
|
||||
)
|
||||
.route(
|
||||
"/assets/parse_time_async_chunked.js",
|
||||
get(asset_parse_time_async_chunked_script),
|
||||
)
|
||||
.route(
|
||||
"/assets/parse_time_async_load_order.js",
|
||||
get(asset_parse_time_async_load_order_script),
|
||||
|
||||
Reference in New Issue
Block a user