ohos: Implement httpUserAgentString in the WebView backend


The setter uses the native WebviewController.setCustomUserAgent(), which
is the only API that changes the real user agent (the outgoing HTTP
"User-Agent" header and navigator.userAgent on the next load).

Overriding navigator.userAgent from page script (e.g. via
Object.defineProperty()) is not used: it only changes the value
JavaScript reads in the current document, leaves the HTTP header
untouched, and is reset on every navigation, so it would not satisfy the
property contract ("the user agent in use, the user-agent string sent
with HTTP").

The getter reads navigator.userAgent through the synchronous JS thread
gateway, returning the effective UA actually in use, as required by the
property contract. The native WebviewController.getUserAgent() is
intentionally not used for the getter: it returns the default UA and
ignores setCustomUserAgent(), so it would misreport the UA once a custom
one is set.

Task-number: QTBUG-146838
Pick-to: 6.12
Change-Id: I8dc0feaa833b1bdd74cd90ec7562c131006caadb
Reviewed-by: Zbigniew Chyla <zbigniew.chyla@qt.io>
Reviewed-by: SanthoshKumar Selvaraj <santhosh.kumar.selvaraj@qt.io>
commit57c7784674e35f981852062f233c1f85e6b1290a
parent2518a389df60963447c3f0228166f81fef251bdc
authorDennis Kim <dennis.kim@qt.io>
committerDennis Kim <dennis.kim@qt.io>
commit timeThu, 9 Jul 2026 21:50:31 +0000