feat(libSceNKWebKit): implement WebCore::AdClickAttribution #24503

Merged
ToRaNek merged 4 commits from upstream-pr/24503 into main 2026-11-23 12:46:45 +00:00
ToRaNek commented 2026-11-20 17:53:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ToRaNek on 2026-11-20T17:53:36Z.


What

Implements the eleven exported members of WebCore::AdClickAttribution, which were throwing stubs:

parseConversionRequest, convertAndGetEarliestTimeToSend, hasHigherPriorityThan, url, urlForTesting, referrer, markAsExpired, hasExpired, markConversionAsSent, wasConversionSent, toString.

They follow AdClickAttribution.cpp on the 64-byte object of AdClickAttribution.h: campaign id at 0, source and destination registrable domains at 8 and 16, click time at 24, Optional<Conversion> at 32 (flag, then data, priority and sent flag from 36), Optional<WallTime> at 48.

Which WebKit. These exports are in the 3.20 inventory only (LegacyExports.hpp). Two facts bound that module's WebKit:

  • the class was renamed to PrivateClickMeasurement on 2020-11-12, so it is older than that;
  • the same list has BasicColorMatrixFilterOperation::transformColor(SRGBA<float>&), and SRGBA<float> reached FilterOperation.h on 2020-06-13, so it is newer than that.

The revision used here (2020-09-10) is inside that window. It matters for one function: parseConversionRequest returned Optional<Conversion> until 2020-03-30 and Expected<Conversion, String> afterwards, under the same mangled name. The window settles it: Expected, 24 bytes, a union of the 12-byte conversion and the error string followed by the flag at 16, returned through a hidden pointer. The layout and the bodies of the other ten members are unchanged since 2019-05-01.

Details worth a look:

  • parseConversionRequest reports every error with a null string. WebKit only builds a message when the Ad Click Attribution debug mode is on, a flag of the RuntimeEnabledFeatures singleton, which is still a stub here and so cannot be turned on. The two number fields go through the same strict parse as StringView::toUInt64Strict (optional +, surrounding white space allowed); the character between them is not checked, as upstream.
  • convertAndGetEarliestTimeToSend returns WTF::Optional<Seconds>, which has a user-provided copy constructor, through a hidden result pointer; the delay is 24 h + randomNumber() * 24 h from libSceJsc's WTF::randomNumber.
  • url, referrer and urlForTesting build their string and hand it to this library's WTF::URL parser; url and referrer return a null URL when the object is not valid or the result does not parse, as upstream does.
  • urlForTesting on an object with no conversion throws std::logic_error, where WebKit hits the release assertion of Optional::value().
  • toString keeps the result 8-bit unless a domain string is 16-bit, as StringBuilder does.

Tested

Windows 11, MinGW GCC 15.2.

  • nkwebkit_adclickattribution (new) passes: 10 accepted and 24 rejected conversion URLs (range limits, field lengths, signs, scheme, credentials, query, fragment, port, prefix case), non-ASCII white space around a number, conversion acceptance by validity and priority, the 24 to 48 hour delay and the stored send time, the sent flag, priority comparison, expiry around the seven-day limit, the two attribution URLs with valid, out-of-range, empty, nullOrigin, unparsable and 16-bit domains, urlForTesting with and without a base query and with 10-digit numbers, every branch of toString, and null arguments.
  • Ten negative controls, each rebuilt and run, each makes the test fail: accepting an equal priority; returning an unparsable URL as is; not treating nullOrigin as empty; a five-day maximum age; dropping the base URL's query; accepting an out-of-range priority; ignoring a query in the request URL; forgetting the port when locating the path; ignoring non-ASCII white space; comparing the scheme without its length.
  • All 169 nkwebkit_* tests pass on the branch.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.

Not tested on a console.

Overlap (python tools/pr_overlap.py --branch feat/nkwebkit-ad-click-attribution):

  • No open PR implements these eleven functions. #24322 (a mass refactor of the stub files) moves the same stubs without implementing them.
  • #18395, #20326, #22674, #22872, #23056 and #24007 remove stubs that sit next to these in Export.cpp and LegacyExports.hpp, so whichever merges second has a trivial textual conflict there.
  • The tool could not compare 42 open PRs that already conflict with main. I compared their diffs, and those of the six above, by hand: none touches an AdClickAttribution line.

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:5417892547 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24503). Originally posted by [ToRaNek](https://github.com/ToRaNek) on 2026-11-20T17:53:36Z. --- ### What Implements the eleven exported members of `WebCore::AdClickAttribution`, which were throwing stubs: `parseConversionRequest`, `convertAndGetEarliestTimeToSend`, `hasHigherPriorityThan`, `url`, `urlForTesting`, `referrer`, `markAsExpired`, `hasExpired`, `markConversionAsSent`, `wasConversionSent`, `toString`. They follow [AdClickAttribution.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/loader/AdClickAttribution.cpp) on the 64-byte object of [AdClickAttribution.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/loader/AdClickAttribution.h): campaign id at 0, source and destination registrable domains at 8 and 16, click time at 24, `Optional<Conversion>` at 32 (flag, then data, priority and sent flag from 36), `Optional<WallTime>` at 48. **Which WebKit.** These exports are in the 3.20 inventory only (`LegacyExports.hpp`). Two facts bound that module's WebKit: - the class was renamed to `PrivateClickMeasurement` on [2020-11-12](https://github.com/WebKit/WebKit/commit/9fd169d0da68), so it is older than that; - the same list has `BasicColorMatrixFilterOperation::transformColor(SRGBA<float>&)`, and `SRGBA<float>` reached `FilterOperation.h` on [2020-06-13](https://github.com/WebKit/WebKit/commit/34fe4d7c1658), so it is newer than that. The revision used here (2020-09-10) is inside that window. It matters for one function: `parseConversionRequest` returned `Optional<Conversion>` until [2020-03-30](https://github.com/WebKit/WebKit/commit/86f03d6c16a7) and `Expected<Conversion, String>` afterwards, under the same mangled name. The window settles it: `Expected`, 24 bytes, a union of the 12-byte conversion and the error string followed by the flag at 16, returned through a hidden pointer. The layout and the bodies of the other ten members are unchanged since 2019-05-01. **Details worth a look:** - `parseConversionRequest` reports every error with a null string. WebKit only builds a message when the Ad Click Attribution debug mode is on, a flag of the `RuntimeEnabledFeatures` singleton, which is still a stub here and so cannot be turned on. The two number fields go through the same strict parse as `StringView::toUInt64Strict` (optional `+`, surrounding white space allowed); the character between them is not checked, as upstream. - `convertAndGetEarliestTimeToSend` returns `WTF::Optional<Seconds>`, which has a user-provided copy constructor, through a hidden result pointer; the delay is `24 h + randomNumber() * 24 h` from libSceJsc's `WTF::randomNumber`. - `url`, `referrer` and `urlForTesting` build their string and hand it to this library's `WTF::URL` parser; `url` and `referrer` return a null `URL` when the object is not valid or the result does not parse, as upstream does. - `urlForTesting` on an object with no conversion throws `std::logic_error`, where WebKit hits the release assertion of `Optional::value()`. - `toString` keeps the result 8-bit unless a domain string is 16-bit, as `StringBuilder` does. ### Tested Windows 11, MinGW GCC 15.2. - `nkwebkit_adclickattribution` (new) passes: 10 accepted and 24 rejected conversion URLs (range limits, field lengths, signs, scheme, credentials, query, fragment, port, prefix case), non-ASCII white space around a number, conversion acceptance by validity and priority, the 24 to 48 hour delay and the stored send time, the sent flag, priority comparison, expiry around the seven-day limit, the two attribution URLs with valid, out-of-range, empty, `nullOrigin`, unparsable and 16-bit domains, `urlForTesting` with and without a base query and with 10-digit numbers, every branch of `toString`, and null arguments. - Ten negative controls, each rebuilt and run, each makes the test fail: accepting an equal priority; returning an unparsable URL as is; not treating `nullOrigin` as empty; a five-day maximum age; dropping the base URL's query; accepting an out-of-range priority; ignoring a query in the request URL; forgetting the port when locating the path; ignoring non-ASCII white space; comparing the scheme without its length. - All 169 `nkwebkit_*` tests pass on the branch. - `python tools/check_conventions.py --base origin/main` and `python tools/debt_fold.py --check` pass. Not tested on a console. **Overlap** (`python tools/pr_overlap.py --branch feat/nkwebkit-ad-click-attribution`): - No open PR implements these eleven functions. #24322 (a mass refactor of the stub files) moves the same stubs without implementing them. - #18395, #20326, #22674, #22872, #23056 and #24007 remove stubs that sit next to these in `Export.cpp` and `LegacyExports.hpp`, so whichever merges second has a trivial textual conflict there. - The tool could not compare 42 open PRs that already conflict with `main`. I compared their diffs, and those of the six above, by hand: none touches an `AdClickAttribution` line. ### 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-20 19:25:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T19:25:13Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_adclickattribution_tests built cleanly.
  • CTest (nkwebkit_adclickattribution):
    1/1 Test #4682: nkwebkit_adclickattribution ......   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/AdClickAttribution.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified libSceNKWebKit/include/AdClickAttributionExports.hpp struct layout, offsets, and static_asserts against WebKit 64-byte WebCore::AdClickAttribution memory layout
    • Verified parseConversionRequest URL path parsing, scheme/credentials/query/fragment rejections, and MaxEntropy bounds validation (<= 63) in AdClickAttribution.cpp
    • Verified convertAndGetEarliestTimeToSend priority comparison (<= existing priority is rejected, higher priority updates and sets 24-48h earliest time to send)
    • Verified null checks for this pointers and arguments across all 11 exported C-linkage entrypoints
    • Verified AGENTS.md compliance regarding comments, debt fragment formatting in docs/dev/debt/changes/, and absence of forbidden files

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998197169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24503#pullrequestreview-5998197169). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T19:25:13Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `c2786eddff`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_adclickattribution_tests` built cleanly. - **CTest** (`nkwebkit_adclickattribution`): ``` 1/1 Test #4682: nkwebkit_adclickattribution ...... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/AdClickAttribution.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified libSceNKWebKit/include/AdClickAttributionExports.hpp struct layout, offsets, and static_asserts against WebKit 64-byte WebCore::AdClickAttribution memory layout - Verified parseConversionRequest URL path parsing, scheme/credentials/query/fragment rejections, and MaxEntropy bounds validation (<= 63) in AdClickAttribution.cpp - Verified convertAndGetEarliestTimeToSend priority comparison (<= existing priority is rejected, higher priority updates and sets 24-48h earliest time to send) - Verified null checks for this pointers and arguments across all 11 exported C-linkage entrypoints - Verified AGENTS.md compliance regarding comments, debt fragment formatting in docs/dev/debt/changes/, and absence of forbidden files Looks Good To Me
MarcZX10 commented 2026-11-20 19:42:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:42:35Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected implementation and ABI declarations show no verified blocking defect; tests were not run independently, so a formal approval is not justified.

What I ran

Reviewed head c2786eddff7589474411be1cafb431c1cc0e54cf using the prepared diff and pinned reader. No test or build commands were run; no execution environment was available.

Results

Check Result Note
Changed code review passed Inspected implementation and ABI changes
Build and tests not run Results in the PR description are author-reported
Console behavior not run No console verification

Negative control

Not run independently. The PR description reports ten negative controls that failed as expected.

Findings

Blocking

None verified in the inspected changes.

Non-blocking

Nothing blocks this; the points below are optional.

  • Consider attaching CI or test output for the reported Windows 11 and MinGW GCC 15.2 run.

Sources

Reviewed the changed implementation, ABI declarations, tests, debt entry, and relevant diff hunks at the pinned head.

Not verified

No build, tests, negative controls, or console behavior were independently verified. Export.cpp was excluded from the prepared full-text bundle; its changed hunks were inspected in the supplied diff, and a content search was used to inspect relevant references. Read: AdClickAttribution.cpp, AdClickAttributionExports.hpp, LegacyExports.hpp, libSceNKWebKit.hpp, tests/AdClickAttribution.cpp, and docs/dev/debt/changes/feat-nkwebkit-ad-click-attribution.md; also inspected the relevant Export.cpp diff hunks. The excluded full text was not read.

To get this to a good state

Nothing is required. Optional: provide CI or test output for the reported run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998398321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24503#pullrequestreview-5998398321). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:42:35Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected implementation and ABI declarations show no verified blocking defect; tests were not run independently, so a formal approval is not justified. ## What I ran Reviewed head `c2786eddff7589474411be1cafb431c1cc0e54cf` using the prepared diff and pinned reader. No test or build commands were run; no execution environment was available. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Inspected implementation and ABI changes | | Build and tests | not run | Results in the PR description are author-reported | | Console behavior | not run | No console verification | ## Negative control Not run independently. The PR description reports ten negative controls that failed as expected. ## Findings ### Blocking None verified in the inspected changes. ### Non-blocking Nothing blocks this; the points below are optional. - Consider attaching CI or test output for the reported Windows 11 and MinGW GCC 15.2 run. ## Sources Reviewed the changed implementation, ABI declarations, tests, debt entry, and relevant diff hunks at the pinned head. ## Not verified No build, tests, negative controls, or console behavior were independently verified. `Export.cpp` was excluded from the prepared full-text bundle; its changed hunks were inspected in the supplied diff, and a content search was used to inspect relevant references. Read: `AdClickAttribution.cpp`, `AdClickAttributionExports.hpp`, `LegacyExports.hpp`, `libSceNKWebKit.hpp`, `tests/AdClickAttribution.cpp`, and `docs/dev/debt/changes/feat-nkwebkit-ad-click-attribution.md`; also inspected the relevant `Export.cpp` diff hunks. The excluded full text was not read. ## To get this to a good state Nothing is required. Optional: provide CI or test output for the reported run.
MarcZX10 commented 2026-11-20 21:14:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:14:50Z.

Review: APPROVED


Reviewed — looks good

The implementation and its added tests look sound at the reviewed head; no blocking defect was verified.

What I ran

  • Reviewed head e2ea92d84ab4b16e5049094ea18323212f488639 using the prepared diff and the pinned reader repo_read.py.
  • No commands or tests were run in this review.

Results

Check Result Note
Changed implementation passed Inspected added functions and ABI declarations
Added tests not run Test execution was not part of this review
Console behavior not run Author reports Windows 11 and MinGW testing

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • core/libs/prx/libSceNKWebKit/Export.cpp full text was excluded as too large; its relevant diff hunks were inspected.
  • Tests, build, and console behavior were not run or independently confirmed.
  • The reviewed files were AdClickAttributionExports.hpp, LegacyExports.hpp, libSceNKWebKit.hpp, AdClickAttribution.cpp, tests/AdClickAttribution.cpp, and docs/dev/debt/changes/feat-nkwebkit-ad-click-attribution.md. Export.cpp was excluded from full text.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5999504059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24503#pullrequestreview-5999504059). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T21:14:50Z. **Review:** APPROVED --- # Reviewed — looks good The implementation and its added tests look sound at the reviewed head; no blocking defect was verified. ## What I ran - Reviewed head `e2ea92d84ab4b16e5049094ea18323212f488639` using the prepared diff and the pinned reader `repo_read.py`. - No commands or tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Changed implementation | passed | Inspected added functions and ABI declarations | | Added tests | not run | Test execution was not part of this review | | Console behavior | not run | Author reports Windows 11 and MinGW testing | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified - `core/libs/prx/libSceNKWebKit/Export.cpp` full text was excluded as too large; its relevant diff hunks were inspected. - Tests, build, and console behavior were not run or independently confirmed. - The reviewed files were `AdClickAttributionExports.hpp`, `LegacyExports.hpp`, `libSceNKWebKit.hpp`, `AdClickAttribution.cpp`, `tests/AdClickAttribution.cpp`, and `docs/dev/debt/changes/feat-nkwebkit-ad-click-attribution.md`. `Export.cpp` was excluded from full text. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-22 19:17:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:17:45Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this review; the points below are optional.

What I ran

Reviewed head 95679347d1cfe84727f41a5649b3cfed5875826b. No commands or tests were run in this review; repo_read.py was used to inspect the prepared bundle and targeted source.

Results

Check Result Note
Diff and implementation review passed No concrete defect found in inspected code
Tests and build not run Results in the description are author-reported
Console behavior not run No console verification supplied

Findings

Blocking

None.

Non-blocking

  • The implementation has useful reported test coverage, including negative controls, but those runs were not independently verified in this review.

Not verified

The full text of Export.cpp was excluded from the review bundle; its changed lines are removals shown in the diff. The test file was read through line 250, and its remaining lines were inspected in the diff rather than the full file. No build, test, or console run was performed here.

Files read: description.md, commits.md, manifest.json, diff.patch, AdClickAttributionExports.hpp, AdClickAttribution.cpp, LegacyExports.hpp, libSceNKWebKit.hpp, and tests/AdClickAttribution.cpp (partial full text). Export.cpp full text was excluded as too large; no other changed file was excluded.

To get this to a good state

Nothing is required. Optional: retain the reported test and negative-control results in CI so they can be checked on the reviewed head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6013969595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24503#pullrequestreview-6013969595). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T19:17:45Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this review; the points below are optional. ## What I ran Reviewed head `95679347d1cfe84727f41a5649b3cfed5875826b`. No commands or tests were run in this review; `repo_read.py` was used to inspect the prepared bundle and targeted source. ## Results | Check | Result | Note | |---|---|---| | Diff and implementation review | passed | No concrete defect found in inspected code | | Tests and build | not run | Results in the description are author-reported | | Console behavior | not run | No console verification supplied | ## Findings ### Blocking None. ### Non-blocking - The implementation has useful reported test coverage, including negative controls, but those runs were not independently verified in this review. ## Not verified The full text of `Export.cpp` was excluded from the review bundle; its changed lines are removals shown in the diff. The test file was read through line 250, and its remaining lines were inspected in the diff rather than the full file. No build, test, or console run was performed here. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `AdClickAttributionExports.hpp`, `AdClickAttribution.cpp`, `LegacyExports.hpp`, `libSceNKWebKit.hpp`, and `tests/AdClickAttribution.cpp` (partial full text). `Export.cpp` full text was excluded as too large; no other changed file was excluded. ## To get this to a good state Nothing is required. Optional: retain the reported test and negative-control results in CI so they can be checked on the reviewed head.
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!24503
No description provided.