Merge branch 'master' into fws

This commit is contained in:
fangwusheng
2026-03-28 11:24:03 +08:00
6 changed files with 6099 additions and 87 deletions
+346 -77
View File
@@ -24,9 +24,15 @@ import ohos.multimedia.image.PixelMap
import std.collection.*
import ohos.ffi.*
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class BackForwardList {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public prop currentIndex: Int32 {
get() {
@@ -34,7 +40,10 @@ public class BackForwardList {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public prop size: Int32 {
get() {
@@ -42,7 +51,11 @@ public class BackForwardList {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getItemAtIndex(index: Int32): HistoryItem {
return HistoryItem()
}
@@ -52,49 +65,81 @@ public class BackForwardList {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class WebCookieManager {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public static func fetchCookie(url: String, incognito!: Bool = false): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public static func configCookie(url: String, value: String, incognito!: Bool = false): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func setAcceptCookiesEnabled(accept: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func isCookieAllowed(): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func setAcceptThirdPartyCookieEnabled(accept: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func isThirdPartyCookieAllowed(): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func hasCookie(incognito!: Bool = false): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func clearAllCookies(incognito!: Bool = false): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func clearSessionCookie(): Unit {
return ()
}
@@ -104,77 +149,139 @@ public class WebCookieManager {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public enum SecurityLevel {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
NoneLevel
| @!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
|
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
Secure
| @!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
|
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
Warning
| @!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
|
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
Dangerous
| ...
}
extend SecurityLevel <: ToString {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public func toString(): String {
return String()
}
}
extend SecurityLevel <: Equatable<SecurityLevel> {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public operator func ==(other: SecurityLevel): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public operator func !=(other: SecurityLevel): Bool {
return true
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public enum WebHitTestType {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
EditText
| @!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
|
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
Email
| @!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
|
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
Unknown
| ...
}
extend WebHitTestType <: ToString {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public func toString(): String {
return String()
}
}
extend WebHitTestType <: Equatable<WebHitTestType> {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public operator func ==(other: WebHitTestType): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public operator func !=(other: WebHitTestType): Bool {
return true
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class WebHeader {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var headerKey: String
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var headerValue: String
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public init(headerKey: String, headerValue: String) {
super()
this.headerKey = String()
@@ -182,12 +289,21 @@ public class WebHeader {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class HitTestValue {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var hitTestType: WebHitTestType
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var extra: String
public init() {
@@ -197,18 +313,33 @@ public class HitTestValue {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class HistoryItem {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var icon: ?PixelMap
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var historyUrl: String
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var historyRawUrl: String
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public var title: String
public init() {
@@ -220,175 +351,313 @@ public class HistoryItem {
}
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public class WebviewController <: RemoteDataLite {
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public init(webTag!: ?String = None) {
super()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core"]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core"
]
public static func setWebDebuggingAccess(webDebuggingAccess: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func enableSafeBrowsing(enable: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func isSafeBrowsingEnabled(): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func canGoBack(): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func accessStep(step: Int32): Bool {
return true
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func goForward(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func goBack(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func clearHistory(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func reload(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func loadUrl<T>(url: T, headers!: Array<WebHeader> = Array<WebHeader>()): Unit where T <: ResourceStr {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func storeWebArchive(baseName: String, autoName: Bool, callback: AsyncCallback<String>): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func zoom(factor: Float32): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func zoomIn(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func zoomOut(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getUserAgent(): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getTitle(): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getPageHeight(): Int32 {
return 0
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func goBackOrForward(step: Int32): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true, workerthread: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true,
workerthread: true
]
public func stop(): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func registerJavaScriptProxy(funcs: Array<(String) -> String>, name: String, methodList: Array<String>): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func runJavaScript(script: String, callback: AsyncCallback<String>): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getUrl(): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func pageUp(top: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func pageDown(bottom: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getOriginalUrl(): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getBackForwardEntries(): BackForwardList {
return BackForwardList()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func removeCache(clearRom: Bool): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func scrollTo(x: Float32, y: Float32, duration!: ?Int32 = None): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func scrollBy(deltaX: Float32, deltaY: Float32, duration!: ?Int32 = None): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func setCustomUserAgent(userAgent: String): Unit {
return ()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getCustomUserAgent(): String {
return String()
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func getSecurityLevel(): SecurityLevel {
return SecurityLevel.NoneLevel
}
@!APILevel[since: "22", syscap: "SystemCapability.Web.Webview.Core", throwexception: true]
@!APILevel[
since: "22",
syscap: "SystemCapability.Web.Webview.Core",
throwexception: true
]
public func isIncognitoMode(): Bool {
return true
}
}
}
-6
View File
@@ -231,12 +231,6 @@ foreign {
func FfiOHOSWebviewCtlPrefetchResource(request: CRequestInfo, additionalHeaders: ArrWebHeader, cKey: CString,
cacheValidTime: Int32): Int32
func FfiOHOSWebviewCtlClearServiceWorkerWebSchemeHandler(): Unit
func FfiOHOSWebviewCtlSetServiceWorkerWebSchemeHandler(cScheme: CString, classId: Int64, errCode: CPointer<Int32>): Unit
func FfiOHOSWebviewCtlClearWebSchemeHandler(id: Int64, errCode: Int32): Unit
func FfiOHOSWebviewCtlSetWebSchemeHandler(id: Int64, cScheme: CString, classId: Int64, errCode: CPointer<Int32>): Unit
func FfiOHOSWebviewCtlOnCreateNativeMediaPlayer(id: Int64, callbackId: Int64): Unit
File diff suppressed because it is too large Load Diff
@@ -21,4 +21,5 @@ func testsuite(): Unit {
registerTestSuite("Test_webview", {=> Test_webview()})
registerTestSuite("Test_web_cookie_manager", {=> Test_web_cookie_manager()})
registerTestSuite("Test_webview_enum", {=> Test_webview_enum()})
registerTestSuite("Test_webview_llt", {=> Test_webview_llt()})
}
@@ -14,5 +14,5 @@
</div>
<p class="output">display received message send from cangjie</p>
</body>
<script src="xxx.js"></script>
<script src="testMsg.js"></script>
</html>
@@ -13,7 +13,6 @@
* limitations under the License.
*/
//xxx.js
var h5Port;
var output = document.querySelector('.output');
window.addEventListener('message', function (event) {
@@ -47,10 +46,8 @@ window.addEventListener('message', function (event) {
// 3. 使用h5Port往ets侧发送消息.
function PostMsgToCangjie(data) {
// let a = new ArrayBuffer(12);
if (h5Port) {
h5Port.postMessage(data);
// h5Port.postMessage(a);
} else {
console.error("h5Port is null, Please initialize first");
}