Repository navigation
Conversation
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5616 +/- ##
===========================================
+ Coverage 47.24% 63.10% +15.86%
===========================================
Files 476 536 +60
Lines 46892 60545 +13653
===========================================
+ Hits 22154 38209 +16055
+ Misses 24738 22336 -2402 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a916460 to
ca5f244
Compare
ca5f244 to
e950d58
Compare
|
Hi! I've pushed a fix for the earlier The failing test started a live TCP server and used a The CI workflows are waiting for approval. Could a maintainer approve them when they have a moment? Thanks! |
Fixes #5310
What was wrong
When
fetch()followed HTTP redirects:JsResponseonly stored a singleurl: JsStringrather than a URL list (Vec<JsString>) as required by WHATWG Fetch §2.2.6 (Response URL list), andResponse.prototype.redirectedwas hardcoded tofalse.BlockingReqwestFetcher::fetchpassed the initialrequest.uri().to_string()toJsResponse::basic, discarding all redirect target URLs followed byreqwest.As a result, after a
302 Location: /target#fragredirect,response.redirectedevaluated tofalseinstead oftrueandresponse.urlreturned the original request URL instead ofhttp://.../target.Evidence
Running
fetch_redirect_updates_url_and_redirectedagainst unmodifiedmain:What changed and why
Following the approach outlined in #5320:
core/runtime/src/fetch/response.rs:url: JsStringonJsResponsewithurl_list: Vec<JsString>.JsResponse::basic_with_url_list(url_list: Vec<JsString>, inner: http::Response<Vec<u8>>)while preservingJsResponse::basic(url: JsString, inner: http::Response<Vec<u8>>)for SemVer compatibility and existing single-URL callers.JsResponse::urlto return""whenurl_listis empty, or the last URL inurl_listserialized without its#fragment.JsResponse::redirectedto returnself.url_list.len() > 1, which also handlesA -> B -> Aredirect loops where the final URL matches the initial URL.core/runtime/src/fetch/fetchers.rs:DefaultforBlockingReqwestFetcherwith a customreqwest::redirect::Policy::custompolicy that records each redirect hop URL into a sharedArc<Mutex<Vec<url::Url>>>, and passes the full[initial_url, ...redirected_urls]list toJsResponse::basic_with_url_list.Trade-offs
BlockingReqwestFetchershares anArc<Mutex<Vec<url::Url>>>with itsreqwest::blocking::Clientredirect policy and clears/takes the recorded URLs around each synchronousself.client.execute(req)call. SinceFetcherinboa_runtimeis single-threaded (Rc<Self>) andBlockingReqwestFetcherexecutes synchronously, requests do not interleave unless a clonedBlockingReqwestFetcheris used concurrently across threads. If you prefer constructing a per-request redirect handler or a different synchronization strategy, happy to adjust.Fetcherimplementations usingJsResponse::basiccontinue to work unchanged (populating a 1-elementurl_list) and can opt intoJsResponse::basic_with_url_listto report redirect chains.Tests
fetch::tests::response::response_url_list_and_redirected(runs under default features) testing empty URL lists on synthetic responses (new Response(),Response.error(),Response.redirect(),Response.json()), single-URL responses, redirected responses with#fragstripping,response.clone(), andA -> B -> Aredirect chains.fetch::tests::response::fetch_redirect_updates_url_and_redirected(underreqwest-blocking) testingBlockingReqwestFetcheragainst a local TCP HTTP server returning302 Location: /target#fragandA -> B -> Aredirect loops.cargo test -p boa_runtime --all-features: 114 unit tests, 9 integration (clone) tests, and 2 doctests passed (0 failures).