Skip to content

fix(fetch): reject non-null window option in Request constructor#5210

Closed
HiteshShonak wants to merge 3 commits intoboa-dev:mainfrom
HiteshShonak:fix/request-window-validation
Closed

fix(fetch): reject non-null window option in Request constructor#5210
HiteshShonak wants to merge 3 commits intoboa-dev:mainfrom
HiteshShonak:fix/request-window-validation

Conversation

@HiteshShonak
Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes #5209.

It changes the following:

  • Add window field to RequestInit and reject any non-null value with a TypeError.
  • Add a consolidated regression test covering non-null values and confirming null is still accepted.

Testing:

cargo test -p boa_runtime request -- --nocapture

Spec reference: https://fetch.spec.whatwg.org/#dom-request

@HiteshShonak HiteshShonak requested a review from a team as a code owner March 21, 2026 10:02
Copilot AI review requested due to automatic review settings March 21, 2026 10:02
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 21, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 21, 2026
@github-actions github-actions bot added C-Tests Issues and PRs related to the tests. C-Runtime Issues and PRs related to Boa's runtime features labels Mar 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Boa’s Fetch Request implementation to align with the Fetch Standard requirement that the window option must be null, and adds a regression test to ensure non-null values throw.

Changes:

  • Extend RequestInit with a window field and throw a TypeError when window is non-null.
  • Add a regression test that checks several non-null window values throw, while null is accepted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
core/runtime/src/fetch/request.rs Adds window to RequestInit and validates it during request construction.
core/runtime/src/fetch/tests/request.rs Adds a regression test for Request constructor window option behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 21, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,735 50,735 0
Ignored 1,426 1,426 0
Failed 802 802 0
Panics 0 0 0
Conformance 95.79% 95.79% 0.00%

Tested main commit: f5e88de558e038f0ae675a012d59917a098f44b6
Tested PR commit: 77160d3a810f7800c2bcc815dc1cfead68706787
Compare commits: f5e88de...77160d3

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.68%. Comparing base (6ddc2b4) to head (77160d3).
⚠️ Report is 936 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5210       +/-   ##
===========================================
+ Coverage   47.24%   59.68%   +12.44%     
===========================================
  Files         476      589      +113     
  Lines       46892    63480    +16588     
===========================================
+ Hits        22154    37890    +15736     
- Misses      24738    25590      +852     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@zhuzhu81998 zhuzhu81998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think boa is doing anything about window option at all. and this pr does not change that.

@HiteshShonak
Copy link
Copy Markdown
Contributor Author

i dont think boa is doing anything about window option at all. and this pr does not change that.

From the Fetch spec, window is supposed to be null, and WPT has tests that expect a TypeError when it’s non-null. Node.js also throws here.
Right now Boa just ignores the option entirely, which is what this PR is trying to fix by validating it instead of silently accepting it.
Even if some engines are lenient here, this is mainly to align with spec + WPT.

@zhuzhu81998
Copy link
Copy Markdown
Contributor

zhuzhu81998 commented Mar 30, 2026

Right now Boa just ignores the option entirely, which is what this PR is trying to fix by validating it instead of silently accepting it.

#4338 didnt implement everything from fetch.
This pr is not that meaningful, because except the trivial check, this pr is not actually implementing the missing functionality of the window option.

@HiteshShonak
Copy link
Copy Markdown
Contributor Author

This pr is not that meaningful, because except the trivial check, this pr is not actually implementing the missing functionality of the window option.

yeah fair, i was just trying to stop silently accepting invalid values, but fine to wait till fetch is more complete

@jedel1043
Copy link
Copy Markdown
Member

jedel1043 commented Apr 6, 2026

Agreed with @zhuzhu81998, this should be part of a PR that properly implements window handling.

@jedel1043 jedel1043 closed this Apr 6, 2026
@github-actions github-actions bot removed the Waiting On Review Waiting on reviews from the maintainers label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request constructor ignores non-null window option instead of throwing

4 participants