Skip to content

test: cover non-ASCII white space in Date.parse - #35290

Closed
robobun wants to merge 1 commit into
mainfrom
farm/2e2495d4/date-parse-unicode-ws
Closed

robobun wants to merge 1 commit into
mainfrom
farm/2e2495d4/date-parse-unicode-ws

Conversation

@robobun

@robobun robobun commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Behaviour change: none

Problem

Fix

  • Add five tests to test/js/node/v8/v8-date-parser.test.js, the existing file for this parser.
  • They take NBSP, BOM and each Zs code point at five positions in a date. They also take look-alike code points, 8-bit and 16-bit strings, local-time forms, and the ISO date-time form.
  • Correct because each expected value is what Node v26.3.0 returns. The file passes under Node in four time zones.
  • Verified: bun bd test test/js/node/v8/v8-date-parser.test.js passes 10 of 10 on main (f8bc171). bun 1.3.14 is older than the change and fails three of the new tests.

Background

  • Date.parse and new Date(string) use a port of V8's date parser, JSDateMath-v8.cpp in the WebKit fork. The port reads UTF-8 bytes and knows ASCII white space only.
  • DateCache::parseDate replaces each non-ASCII ECMAScript WhiteSpace code point with a space before the parse. Only the fork has that step, so a WebKit upgrade can lose it.
  • The first version of this PR added a new file, test/js/bun/jsc/date-parse.test.ts. The parser already has a test file, so the rows are there now.
Notes

Where the change is on main

What each test does

Test bun 1.3.14 main
NBSP, BOM and every Zs code point separate tokens (17 code points, 5 positions) fail: 16 code points give NaN, U+202F already worked pass
code points that only look like white space make the date invalid (U+0085, U+00AD, U+180E, U+200B to U+200D, U+2028, U+2029, U+2060) pass pass
NBSP in an 8-bit string and in a 16-bit string fail pass
forms in local time (7/23/2026, 10:00:00\u00a0AM, 2026-07-23\u00a0, 2026-07-23\u3000) fail pass
the ISO date-time form takes no white space pass pass
  • The second and the fifth test pass before and after. They keep the replacement from growing past what V8 accepts: line terminators stay invalid, and "\ufeff2026-07-23T10:00:00Z" stays NaN, as in Node.
  • The local-time test compares with new Date(2026, 6, 23, 10), so it does not depend on the time zone of the machine.

Not covered: U+000B after a time

  • U+000B (VT) is an ECMAScript WhiteSpace code point too, but it is ASCII. DateCache::parseDate does not replace it in an 8-bit string, and isASCIIWhitespace in the scanner has no VT.
  • Date.parse("Jul 23 2026 10:00:00\vGMT+0000") is NaN on main and 1784800800000 in Node. The same date in a 16-bit string parses. VT in other places parses.
  • That needs a change in the parser. It is not part of this PR.

Earlier state of this PR

  • It set WEBKIT_VERSION to autobuild-preview-pr-324-c0a3ca4d and added 141 tests in a new file. The preview release is gone and main has moved the pin many times since.

@robobun

robobun commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: this PR now adds tests only. The change itself is oven-sh/WebKit#324, and main has it.

Reproduced with bun 1.3.14, which is older than the change. Date.parse("Jul\u00a023\u00a02026\u00a010:00:00\u00a0GMT+0000") is NaN there and 1784800800000 in Node v26.3.0, and three of the five new tests fail. On main, bun bd test test/js/node/v8/v8-date-parser.test.js passes 10 of 10.

@robobun

robobun commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 6:35 PM PT - Oct 16th, 2026

✅ @robobun, your commit 526fa68a26bbbe76a14bc1fe73ae4969d2dc2694 passed in Build #126897! 🎉


🧪   To try this PR locally:

bunx bun-pr 35290

That installs a local version of the PR into your bun-35290 executable, so you can run:

bun-35290 --bun

oven-sh/WebKit#324 made Date.parse and new Date(string) take NBSP, BOM
and each Zs code point as a separator, as V8 does. bun has it since the
WebKit pin of 21b593c. No test covered it.

Add five tests to test/js/node/v8/v8-date-parser.test.js. Each expected
value is what Node.js v26.3.0 returns.
@robobun robobun changed the title Date.parse: accept Unicode whitespace (NBSP, Zs, BOM) like V8 test: cover non-ASCII white space in Date.parse Oct 16, 2026
@robobun
robobun force-pushed the farm/2e2495d4/date-parse-unicode-ws branch from 33c4224 to 526fa68 Compare October 16, 2026 21:50
@robobun
robobun marked this pull request as ready for review October 16, 2026 21:52
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: oven-sh/bun/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2a2f1f58-cf58-4919-af3a-65fa527d9ea5
📥 Commits

Reviewing files that changed from the base of the PR and between f8bc171 and 526fa68.

📒 Files selected for processing: 1
  • test/js/node/v8/v8-date-parser.test.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@robobun

robobun commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #49189, which combines the open JavaScriptCore test PRs into one. The commit 4202a47ab in that PR is this change, unchanged.

Closing this one in favor of #49189.

@robobun robobun closed this Nov 17, 2026
alii pushed a commit that referenced this pull request Nov 17, 2026
…9189)

### Problem
- 13 open test-only PRs add or tighten regression tests for
JavaScriptCore behavior (JIT tiers, garbage collection, Yarr,
`Date.parse`, stack traces). Each one waits for its own review and its
own CI run.
- None of them changes `src/`. The tests already pass on main.

### Fix
- This PR folds 13 open test-only PRs into one branch. Each commit is
one PR, applied on main (`d3d074e32`) with no other change. Notes lists
them.
- Verified: the 15 touched test files pass on main with the release
build on Linux x64 (527 tests pass, 0 fail). 14 of them also pass with
the debug ASAN build (536 pass, 0 fail). `gc-controller-cadence.test.ts`
builds standalone executables, so I ran it with the release build only.
- One more commit answers review: the large-environment stack tests now
skip when the soft stack limit is under 8 MB (`36cc5602dd`). Before,
they failed there with `E2BIG`.
- The original PRs are closed in favor of this one.

### Background
- Most of these tests pin fixes that reached main through WebKit
upgrades: no tail calls in generator and async bodies, the Yarr
surrogate mask, typed array accounting in the collector, a DFG `!` fold.
- The other tests cover `Error.stackTraceLimit`, `util.getCallSites`,
`Uint8Array.prototype.setFromBase64`, non-ASCII white space in
`Date.parse`, and an import cycle that writes a module variable early.
- Each commit stands alone. To drop one test from this PR, revert its
commit.

<details><summary>Notes</summary>

| PR | Commit | Title |
|---|---|---|
| #35290 | `4202a47ab` | test: cover non-ASCII white space in Date.parse
|
| #39453 | `64ffe6869` | Test Uint8Array.prototype.setFromBase64 into a
zero-length target |
| #40231 | `d4c592fb6` | Add regression tests for the Yarr JIT surrogate
mask |
| #42321 | `d1b832532` | test: module variables written through an
import cycle before the module runs (oven-sh/WebKit#624) |
| #42335 | `7cc721499` | Add tests for the WebKit cf1b36ec8703 upgrade:
no tail calls in generator and async bodies |
| #42501 | `2d63ff35b` | test: cover Error.stackTraceLimit stores from
hot sites and util.getCallSites frame counts |
| #42658 | `8b224c511` | Add a regression test for oven-sh/WebKit#649: a
collection inside a host function hook freed the JIT code of the caller
|
| #42880 | `eb5365ba1` | test: import of a module whose code generation
fails keeps its exception checked |
| #42979 | `3f2401021` | Add tests for oven-sh/WebKit#684: a typed array
vector counts as allocated once, and dead ArrayBuffers do not force full
collections |
| #44302 | `3c3223b7d` | Test that recursion checks hold with a large
environment on Linux |
| #45220 | `46c4fcb46` | Test `!` of Int32 arithmetic under a bitwise
operator in DFG code (WebKit 96115d8717) |
| #46873 | `921106ac1` | test: run the domjit.test.ts loops in a child
process and assert the FTL tier |
| #47137 | `eb854ed20` | test: cover the two Yarr fixes that came with
WebKit 23d7f1dcef62 |

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants