feat(libSceNKWebKit): implement WebCore::Cookie hash and operator== #22451

Merged
RiverWhy merged 6 commits from upstream-pr/22451 into main 2026-11-28 02:04:59 +00:00
RiverWhy commented 2026-11-17 16:41:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-17T16:41:08Z.


What

Implements WebCore::Cookie::hash and WebCore::Cookie::operator==: 2 exports that both throw on main today.

Source: the non-Cocoa Cookie.cpp at e12a212a531a. The PS5 11.x Cookie.cpp and Cookie.h have the same code and fields.

  • operator== compares name, domain, path (WTF::equal) and secure.
  • hash adds StringHash::hash of name, domain and path and secure, modulo 2^32. The cached StringImpl hash is used, and hashSlowCase when there is none.

Layout: 136 bytes, measured by compiling the 2021 field list against that revision's WTF String, Optional<double>, URL and Vector and checked with static_asserts. name is at 0, domain at 16, path at 24, the 16-byte expires at 40, secure at 57 and sameSite at 128.

StringHash::hash faults on a null string, so hash throws for a null name, domain or path. A null cookie also throws.

Debt: a fragment, docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md, adds the entry under Functional and removes the 2 inventory rows.

Overlap: pr_overlap.py finds no open PR with these exports.

  • #18797, #18805, #20327, #21422, #21979, and my other new KillRing and SleepDisabler PRs add an include on the same last line of libSceNKWebKit.hpp, which is a line conflict only.

Tested

Linux Mint 22.3:

  • New nkwebkit_webcorecookie test:
    • 16 random sequences of 500 cookie pairs. The strings are null, empty, 8-bit or 16-bit, with Latin-1 and non-Latin-1 text. The second cookie of each pair has some fields changed, or the same text in the other width. Each sequence hashes the result of == in both directions and both hash values, and the result is compared with the hash from the real 2021 Cookie.cpp and WTF StringHash running the same driver. As a one-off, 300 sequences of 3,000 pairs also matched.
    • a known cookie (n, example.com, /, secure) hashes to the oracle's 21286027;
    • null cookies and a null name are refused.
  • Negative control: dropping secure from operator== fails the transcript check.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5360984030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22451). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-17T16:41:08Z. --- ### What Implements `WebCore::Cookie::hash` and `WebCore::Cookie::operator==`: 2 exports that both throw on `main` today. Source: the non-Cocoa [Cookie.cpp](https://github.com/WebKit/WebKit/blob/e12a212a531aeddc11259e8515671cf5188e038d/Source/WebCore/platform/network/Cookie.cpp#L31-L44) at `e12a212a531a`. The PS5 11.x `Cookie.cpp` and `Cookie.h` have the same code and fields. - `operator==` compares `name`, `domain`, `path` (`WTF::equal`) and `secure`. - `hash` adds `StringHash::hash` of `name`, `domain` and `path` and `secure`, modulo 2^32. The cached `StringImpl` hash is used, and `hashSlowCase` when there is none. Layout: 136 bytes, measured by compiling the 2021 field list against that revision's WTF `String`, `Optional<double>`, `URL` and `Vector` and checked with `static_assert`s. `name` is at 0, `domain` at 16, `path` at 24, the 16-byte `expires` at 40, `secure` at 57 and `sameSite` at 128. `StringHash::hash` faults on a null string, so `hash` throws for a null name, domain or path. A null cookie also throws. Debt: a fragment, `docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md`, adds the entry under Functional and removes the 2 inventory rows. Overlap: `pr_overlap.py` finds no open PR with these exports. - #18797, #18805, #20327, #21422, #21979, and my other new KillRing and SleepDisabler PRs add an include on the same last line of `libSceNKWebKit.hpp`, which is a line conflict only. ### Tested Linux Mint 22.3: - New `nkwebkit_webcorecookie` test: - 16 random sequences of 500 cookie pairs. The strings are null, empty, 8-bit or 16-bit, with Latin-1 and non-Latin-1 text. The second cookie of each pair has some fields changed, or the same text in the other width. Each sequence hashes the result of `==` in both directions and both `hash` values, and the result is compared with the hash from the real 2021 `Cookie.cpp` and WTF `StringHash` running the same driver. As a one-off, 300 sequences of 3,000 pairs also matched. - a known cookie (`n`, `example.com`, `/`, secure) hashes to the oracle's 21286027; - null cookies and a null name are refused. - Negative control: dropping `secure` from `operator==` fails the transcript check. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-17 16:44:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T16:44:59Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fa9c87ade7:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_webcorecookie_tests built cleanly.
  • CTest (nkwebkit_webcorecookie):
    1/1 Test #4506: nkwebkit_webcorecookie ...........   Passed    0.05 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4506: nkwebkit_webcorecookie ...........Subprocess aborted***Exception:   0.29 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified WebCoreCookieExports.hpp struct layout, size (136 bytes), member offsets, and static_asserts against WebKit Cookie.h definitions
    • Verified WebCore::Cookie::operator== compares name, domain, path via WTF::equal and secure via boolean equality
    • Verified WebCore::Cookie::hash implementation and StringHash logic with cached hashAndFlags and _ZNK3WTF10StringImpl12hashSlowCaseEv fallback
    • Verified null pointer handling in Checked and StringHash, throwing std::invalid_argument as specified in debt documentation
    • Verified technical debt fragment docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md format and removed inventory symbols
    • Verified unit test coverage in core/libs/prx/libSceNKWebKit/tests/WebCoreCookie.cpp including null argument checks, known cookie hash verification, and transcript permutations

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5942677672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22451#pullrequestreview-5942677672). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T16:44:59Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `fa9c87ade7`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_webcorecookie_tests` built cleanly. - **CTest** (`nkwebkit_webcorecookie`): ``` 1/1 Test #4506: nkwebkit_webcorecookie ........... Passed 0.05 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4506: nkwebkit_webcorecookie ...........Subprocess aborted***Exception: 0.29 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified WebCoreCookieExports.hpp struct layout, size (136 bytes), member offsets, and static_asserts against WebKit Cookie.h definitions - Verified WebCore::Cookie::operator== compares name, domain, path via WTF::equal and secure via boolean equality - Verified WebCore::Cookie::hash implementation and StringHash logic with cached hashAndFlags and _ZNK3WTF10StringImpl12hashSlowCaseEv fallback - Verified null pointer handling in Checked and StringHash, throwing std::invalid_argument as specified in debt documentation - Verified technical debt fragment docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md format and removed inventory symbols - Verified unit test coverage in core/libs/prx/libSceNKWebKit/tests/WebCoreCookie.cpp including null argument checks, known cookie hash verification, and transcript permutations Looks Good To Me
MarcZX10 commented 2026-11-19 00:33:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T00:33:14Z.

Review: COMMENTED


Reviewed — comments

Changes are required before merge: confirm the guest ABI behavior for null WTF::String values before relying on the implementation’s different null handling.

What I ran

Reviewed head 0f412bbac2066964d1b362a338dffc71968b3ef6 using the prepared diff and repo_read.py for targeted source ranges. No build or tests were run. The author reports Linux Mint tests and a negative control in the PR description; those were not run in this review.

Results

Check Result Note
Diff and targeted source review passed Implementation, ABI declarations, and relevant WTF helpers inspected
Build and tests not run No commands executed
Full changed-file review not run Two oversized files excluded by the review manifest

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp:47 rejects null string implementations in hash, while operator== delegates to WTF equality at lines 59–61. The PR description says upstream StringHash throws for null values, but does not establish how the actual console String/equality implementation handles nulls. Verify this behavior against the PS5 module or an appropriate ABI oracle and align both operations with it; current tests encode the implementation’s null assumptions rather than verifying console behavior.

Not verified

  • core/libs/prx/libSceNKWebKit/Export.cpp and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp were excluded as too large. Their changed hunks were present in diff.patch and inspected, but their full text was not read.
  • The PR’s reported test runs, negative control, console behavior, build integration, and runtime export resolution were not independently verified.
  • Other changed files whose full text was included in the manifest were read: core/libs/prx/libSceNKWebKit/include/WebCoreCookieExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp, core/libs/prx/libSceNKWebKit/tests/WebCoreCookie.cpp, and docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md.

To get this to a good state

Nothing is required. Optional: confirm null-string behavior against the console module and adjust the tests or implementation if it differs.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967465522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22451#pullrequestreview-5967465522). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T00:33:14Z. **Review:** COMMENTED --- # Reviewed — comments Changes are required before merge: confirm the guest ABI behavior for null `WTF::String` values before relying on the implementation’s different null handling. ## What I ran Reviewed head `0f412bbac2066964d1b362a338dffc71968b3ef6` using the prepared diff and `repo_read.py` for targeted source ranges. No build or tests were run. The author reports Linux Mint tests and a negative control in the PR description; those were not run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Implementation, ABI declarations, and relevant WTF helpers inspected | | Build and tests | not run | No commands executed | | Full changed-file review | not run | Two oversized files excluded by the review manifest | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp:47` rejects null string implementations in `hash`, while `operator==` delegates to WTF equality at lines 59–61. The PR description says upstream `StringHash` throws for null values, but does not establish how the actual console `String`/equality implementation handles nulls. Verify this behavior against the PS5 module or an appropriate ABI oracle and align both operations with it; current tests encode the implementation’s null assumptions rather than verifying console behavior. ## Not verified - `core/libs/prx/libSceNKWebKit/Export.cpp` and `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp` were excluded as too large. Their changed hunks were present in `diff.patch` and inspected, but their full text was not read. - The PR’s reported test runs, negative control, console behavior, build integration, and runtime export resolution were not independently verified. - Other changed files whose full text was included in the manifest were read: `core/libs/prx/libSceNKWebKit/include/WebCoreCookieExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/WebCoreCookie.cpp`, `core/libs/prx/libSceNKWebKit/tests/WebCoreCookie.cpp`, and `docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md`. ## To get this to a good state Nothing is required. Optional: confirm null-string behavior against the console module and adjust the tests or implementation if it differs.
MarcZX10 commented 2026-11-19 03:49:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T03:49:03Z.

Review: COMMENTED


Review unavailable — comments

I could not inspect the prepared review materials or repository source in this environment, so this review is incomplete.

What I ran

No reader commands could be run.

Results

Check Result Note
Review materials not run Reader unavailable
Changed code audit not run Source not inspected

Findings

Blocking

None verified.

Non-blocking

Review cannot establish whether the change is safe to merge without inspecting its diff and source.

Not verified

Description, commits, diff, manifest, changed files and tests were not read.

To get this to a good state

Nothing is required by verified findings. Complete a review after the reader is available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969042151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22451#pullrequestreview-5969042151). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T03:49:03Z. **Review:** COMMENTED --- # Review unavailable — comments I could not inspect the prepared review materials or repository source in this environment, so this review is incomplete. ## What I ran No reader commands could be run. ## Results | Check | Result | Note | |---|---|---| | Review materials | not run | Reader unavailable | | Changed code audit | not run | Source not inspected | ## Findings ### Blocking None verified. ### Non-blocking Review cannot establish whether the change is safe to merge without inspecting its diff and source. ## Not verified Description, commits, diff, manifest, changed files and tests were not read. ## To get this to a good state Nothing is required by verified findings. Complete a review after the reader is available.
MarcZX10 commented 2026-11-26 12:21:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:21:57Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 28514ceec496e9dafabd62a418f2b77b751f8172 using the prepared diff and repo_read.py for targeted source context. No build or test commands were run.

Results

Check Result Note
Source review passed Implementation and ABI declarations read
Tests not run The described Linux test run was author reported
Changed-file coverage not complete Export.cpp was unavailable in the review folder

Findings

Blocking

None.

Non-blocking

  • The implementation intentionally throws for null cookie pointers and null name/domain/path strings. This differs from ordinary non-throwing WebKit behavior if malformed inputs reach these exports. The PR documents the policy; consider confirming these states cannot occur in normal callers.

Not verified

  • core/libs/prx/libSceNKWebKit/Export.cpp was excluded as too large, so its removals were checked only in the prepared diff.
  • No build or tests were run; author-reported results and negative control were not independently verified.
  • No console module comparison was performed, as recorded in the debt entry.
  • Read changed lines in include/InventoryExports.hpp, include/WebCoreCookieExports.hpp, libSceNKWebKit.hpp, src/WebCoreCookie.cpp, tests/WebCoreCookie.cpp, and docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md; Export.cpp was not read. All seven changed paths are listed in the manifest.

To get this to a good state

Nothing is required. Optionally confirm null-input behavior against expected callers and compare the implementation with a console module.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6074042970 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22451#pullrequestreview-6074042970). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T12:21:57Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `28514ceec496e9dafabd62a418f2b77b751f8172` using the prepared diff and `repo_read.py` for targeted source context. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Implementation and ABI declarations read | | Tests | not run | The described Linux test run was author reported | | Changed-file coverage | not complete | `Export.cpp` was unavailable in the review folder | ## Findings ### Blocking None. ### Non-blocking - The implementation intentionally throws for null cookie pointers and null name/domain/path strings. This differs from ordinary non-throwing WebKit behavior if malformed inputs reach these exports. The PR documents the policy; consider confirming these states cannot occur in normal callers. ## Not verified - `core/libs/prx/libSceNKWebKit/Export.cpp` was excluded as too large, so its removals were checked only in the prepared diff. - No build or tests were run; author-reported results and negative control were not independently verified. - No console module comparison was performed, as recorded in the debt entry. - Read changed lines in `include/InventoryExports.hpp`, `include/WebCoreCookieExports.hpp`, `libSceNKWebKit.hpp`, `src/WebCoreCookie.cpp`, `tests/WebCoreCookie.cpp`, and `docs/dev/debt/changes/feat-nkwebkit-cookie-hash.md`; `Export.cpp` was not read. All seven changed paths are listed in the manifest. ## To get this to a good state Nothing is required. Optionally confirm null-input behavior against expected callers and compare the implementation with a console module.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!22451
No description provided.