feat(libSceNKWebKit): implement WKPage state accessors #23137

Merged
ghatwary06 merged 1 commit from upstream-pr/23137 into main 2026-11-18 20:30:28 +00:00
ghatwary06 commented 2026-11-18 19:07:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ghatwary06 on 2026-11-18T19:07:00Z.


What

Implement WKPageIsClosed, WKPageCopyTitle, WKPageCopyActiveURL, WKPageCopyProvisionalURL, WKPageCopyCommittedURL, WKPageGetEstimatedProgress, WKPageCopyApplicationNameForUserAgent, WKPageSetApplicationNameForUserAgent, WKPageCopyCustomUserAgent, WKPageSetCustomUserAgent, WKPageCopyCustomTextEncodingName, WKPageSetCustomTextEncodingName, WKPageSetBackgroundExtendsBeyondPage and WKPageBackgroundExtendsBeyondPage in libSceNKWebKit as host accessors over the Page model, following the pinned WebKit's WKPage.h and WKPage.cpp. Copy exports return an owned reference, URL getters return null when unset and string getters return an empty string; a null string reference to a setter clears the value, as toWTFString does. As with the other WKPage state exports, no export creates a WKPage or loads a document into it yet, so a page reports the defaults until page loading is connected; recorded in the debt fragment.

Tested

Linux (GCC 16, Ninja): new nkwebkit_pagestate test covering defaults, populated state, setter round trips, null and empty strings, and null and wrong-type objects throwing. All 140 nkwebkit_* and the guest_nkwebkit_* tests pass, the new test is clean under LeakSanitizer and AddressSanitizer, and tools/check_conventions.py --base origin/main and tools/debt_fold.py --check pass. Not tested on a console, a title, Windows or macOS.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5382336566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23137). Originally posted by [ghatwary06](https://github.com/ghatwary06) on 2026-11-18T19:07:00Z. --- ### What Implement WKPageIsClosed, WKPageCopyTitle, WKPageCopyActiveURL, WKPageCopyProvisionalURL, WKPageCopyCommittedURL, WKPageGetEstimatedProgress, WKPageCopyApplicationNameForUserAgent, WKPageSetApplicationNameForUserAgent, WKPageCopyCustomUserAgent, WKPageSetCustomUserAgent, WKPageCopyCustomTextEncodingName, WKPageSetCustomTextEncodingName, WKPageSetBackgroundExtendsBeyondPage and WKPageBackgroundExtendsBeyondPage in libSceNKWebKit as host accessors over the `Page` model, following the pinned WebKit's `WKPage.h` and `WKPage.cpp`. Copy exports return an owned reference, URL getters return null when unset and string getters return an empty string; a null string reference to a setter clears the value, as `toWTFString` does. As with the other `WKPage` state exports, no export creates a `WKPage` or loads a document into it yet, so a page reports the defaults until page loading is connected; recorded in the debt fragment. ### Tested Linux (GCC 16, Ninja): new `nkwebkit_pagestate` test covering defaults, populated state, setter round trips, null and empty strings, and null and wrong-type objects throwing. All 140 `nkwebkit_*` and the `guest_nkwebkit_*` tests pass, the new test is clean under LeakSanitizer and AddressSanitizer, and `tools/check_conventions.py --base origin/main` and `tools/debt_fold.py --check` pass. Not tested on a console, a title, Windows or macOS. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 (Claude Code)
PrivacyOnion commented 2026-11-18 19:17:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T19:17:47Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_pagestate_tests built cleanly.
  • CTest (nkwebkit_pagestate):
    1/1 Test #4566: nkwebkit_pagestate ...............   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/Api.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp, core/libs/prx/libSceNKWebKit/src/Configuration.hpp, core/libs/prx/libSceNKWebKit/src/PageState.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null-pointer handling and type safety in WKPage state getters and setters using NKWebKit::Cast and NKWebKit::CastOrNull in core/libs/prx/libSceNKWebKit/src/PageState.cpp
    • Verified copy semantics and memory management for Retained (NKWebKit::ToRef adds reference) and WKString (ToCopiedStringRef returns retained copy or empty string)
    • Verified setter behavior with null references clearing properties via NullableString, matching upstream WebKit toWTFString conventions
    • Verified AGENTS.md compliance, including conventional commit titles, debt fragment format, removal of NotImplemented stubs from Export.cpp/Api.hpp/InventoryExports.hpp, and lack of unauthorized comments
    • Verified test coverage in core/libs/prx/libSceNKWebKit/tests/PageState.cpp exercising defaults, mutations, null/empty strings, URL copies, and invalid argument rejections

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5963415794 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23137#pullrequestreview-5963415794). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T19:17:47Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e7975b00cb`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_pagestate_tests` built cleanly. - **CTest** (`nkwebkit_pagestate`): ``` 1/1 Test #4566: nkwebkit_pagestate ............... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/Api.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp`, `core/libs/prx/libSceNKWebKit/src/Configuration.hpp`, `core/libs/prx/libSceNKWebKit/src/PageState.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null-pointer handling and type safety in WKPage state getters and setters using NKWebKit::Cast and NKWebKit::CastOrNull in core/libs/prx/libSceNKWebKit/src/PageState.cpp - Verified copy semantics and memory management for Retained<URL> (NKWebKit::ToRef adds reference) and WKString (ToCopiedStringRef returns retained copy or empty string) - Verified setter behavior with null references clearing properties via NullableString, matching upstream WebKit toWTFString conventions - Verified AGENTS.md compliance, including conventional commit titles, debt fragment format, removal of NotImplemented stubs from Export.cpp/Api.hpp/InventoryExports.hpp, and lack of unauthorized comments - Verified test coverage in core/libs/prx/libSceNKWebKit/tests/PageState.cpp exercising defaults, mutations, null/empty strings, URL copies, and invalid argument rejections Looks Good To Me
PrivacyOnion commented 2026-11-18 19:53:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T19:53:00Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_pagestate_tests built cleanly.
  • CTest (nkwebkit_pagestate):
    1/1 Test #4567: nkwebkit_pagestate ...............   Passed    0.14 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/Api.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp, core/libs/prx/libSceNKWebKit/src/Configuration.hpp, core/libs/prx/libSceNKWebKit/src/PageState.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WKPage state accessors in core/libs/prx/libSceNKWebKit/src/PageState.cpp use NKWebKit::Cast to validate pageRef and throw std::invalid_argument on nullptr or type mismatches.
    • Verified Retained getters in WKPageCopyActiveURL, WKPageCopyProvisionalURL, and WKPageCopyCommittedURL return nullptr when unset and increment reference counts via NKWebKit::ToRef when present.
    • Verified NullableString and ToCopiedStringRef handle null, empty, and populated WKStringRef inputs/outputs correctly in accordance with WebKit upstream toWTFString conventions.
    • Verified boolean and double accessors (WKPageIsClosed, WKPageBackgroundExtendsBeyondPage, WKPageGetEstimatedProgress, WKPageSetBackgroundExtendsBeyondPage) match the Page struct definitions in Configuration.hpp.
    • Verified technical debt fragment docs/dev/debt/changes/feat-libSceNKWebKit-page-state.md properly documents known gaps and removes stubs matching NIDs.
    • Verified unit test suite in core/libs/prx/libSceNKWebKit/tests/PageState.cpp thoroughly validates defaults, mutations, round-trips, memory releases, and invalid-argument exceptions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5963938370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23137#pullrequestreview-5963938370). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T19:53:00Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `76f4145b7b`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_pagestate_tests` built cleanly. - **CTest** (`nkwebkit_pagestate`): ``` 1/1 Test #4567: nkwebkit_pagestate ............... Passed 0.14 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/Api.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp`, `core/libs/prx/libSceNKWebKit/src/Configuration.hpp`, `core/libs/prx/libSceNKWebKit/src/PageState.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WKPage state accessors in core/libs/prx/libSceNKWebKit/src/PageState.cpp use NKWebKit::Cast to validate pageRef and throw std::invalid_argument on nullptr or type mismatches. - Verified Retained<URL> getters in WKPageCopyActiveURL, WKPageCopyProvisionalURL, and WKPageCopyCommittedURL return nullptr when unset and increment reference counts via NKWebKit::ToRef when present. - Verified NullableString and ToCopiedStringRef handle null, empty, and populated WKStringRef inputs/outputs correctly in accordance with WebKit upstream toWTFString conventions. - Verified boolean and double accessors (WKPageIsClosed, WKPageBackgroundExtendsBeyondPage, WKPageGetEstimatedProgress, WKPageSetBackgroundExtendsBeyondPage) match the Page struct definitions in Configuration.hpp. - Verified technical debt fragment docs/dev/debt/changes/feat-libSceNKWebKit-page-state.md properly documents known gaps and removes stubs matching NIDs. - Verified unit test suite in core/libs/prx/libSceNKWebKit/tests/PageState.cpp thoroughly validates defaults, mutations, round-trips, memory releases, and invalid-argument exceptions. Looks Good To Me
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!23137
No description provided.