From 923c90f0da266e408ec358ca79001b81b1083909 Mon Sep 17 00:00:00 2001 From: xiaye Date: Sun, 27 Apr 2025 21:47:57 +0800 Subject: [PATCH 1/7] =?UTF-8?q?jsdoc=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye --- api/@internal/component/ets/web.d.ts | 70 +++++++++++++++++++++++----- api/@ohos.web.webview.d.ts | 12 ++++- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 667cc3e6dc..d0683ede8a 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -4117,7 +4117,14 @@ declare class WebController { clearHistory(): void; /** - * Loads a piece of code and execute JS code in the context of the currently displayed page. + * Asynchronously execute JavaScript in the context of the currently displayed page. + * The result of the script execution will be returned through an asynchronous callback. + * This method must be used on the UI thread, and the callback will also be invoked on the UI thread. + *

API Note:
+ * The state of JavaScript is no longer persisted across navigations like loadUrl. + * For example, global variables and functions defined before calling loadUrl will not exist in the loaded page. + * It is recommended that applications use registerJavaScriptProxy to ensure that the JavaScript state can be persisted across page navigations. + *

* * @param { object } options The options with a piece of code and a callback. * @syscap SystemCapability.Web.Webview.Core @@ -6345,7 +6352,13 @@ declare class WebAttribute extends CommonMethod { * @since 11 */ /** - * Sets whether enable local file system access in Web. + * Sets whether to enable Access to the file system in the application. + * This setting dose not affect the access to the files specified though $rawfile(filepath/filename). + *

API Note:
+ * fileAccess is disabled by default since API version 12. + * When fileAccess is set to false, files in the read-only /data/storage/el1/bundle/entry/resources/resfile
+ * directory can still be accessed through the file protocol. + *

* * @param { boolean } fileAccess - {@code true} means enable local file system access in Web; {@code false} otherwise. * The default value is false. @@ -6438,6 +6451,17 @@ declare class WebAttribute extends CommonMethod { * @atomicservice * @since 11 */ + /** + * Sets the behavior when a secure origin attempts to load a resource from an insecure origin. + * The default is MixedMode.None, meaning not allow a secure origin to load content from an insecure origin. + * + * @param { MixedMode } mixedMode - The mixed mode, which can be {@link MixedMode}. + * @returns { WebAttribute } + * @syscap SystemCapability.Web.Webview.Core + * @crossplatform + * @atomicservice + * @since 18 + */ mixedMode(mixedMode: MixedMode): WebAttribute; /** @@ -6520,9 +6544,12 @@ declare class WebAttribute extends CommonMethod { * @since 11 */ /** - * Injects the JavaScript object into window and invoke the function in window. + * Registers the supplied ArkTs object in javaScriptProxy into this Web component. + * The object is registered into all frames of the web page, including all frames, using the specified name in javaScriptProxy. + * This allows the methods of the ArkTs object in javaScriptProxy to be accessed from JavaScript. * - * @param { JavaScriptProxy } javaScriptProxy - The JavaScript object to be injected. + * @param { JavaScriptProxy } javaScriptProxy - The ArkTs object in javaScriptProxy will be registered into this Web component, + * and the methods within the methodList of the injected ArkTs object declared in javaScriptProxy can be accessed by JavaScript. * @returns { WebAttribute } * @syscap SystemCapability.Web.Webview.Core * @atomicservice @@ -6802,9 +6829,10 @@ declare class WebAttribute extends CommonMethod { */ /** * Triggered at the end of web page loading. + * This callback is only invoked for the main frame and not for subframes. * * @param { Callback } callback The triggered function at the end of web page loading. - * @returns { WebAttribute } + * @returns { WebAttribute } The WebAttribute object representing the attributes of the web page. * @syscap SystemCapability.Web.Webview.Core * @crossplatform * @atomicservice @@ -6840,7 +6868,8 @@ declare class WebAttribute extends CommonMethod { * @since 11 */ /** - * Triggered at the begin of web page loading. + * Called when the web page starts to be loaded. + * This API is called only for the main frame, and not for the iframe or frameset content. * * @param { Callback } callback The triggered function at the begin of web page loading. * @returns { WebAttribute } @@ -6900,7 +6929,9 @@ declare class WebAttribute extends CommonMethod { * @since 11 */ /** - * Triggered when the title of the main application document changes. + * Notifies the application that the title has changed.. + * If the page being loaded does not specify a title via the element, + * ArkWeb will generate a title baseed on the URL and return it to the application. * * @param { Callback<OnTitleReceiveEvent> } callback The triggered function when the title of the main application document changes. * @returns { WebAttribute } @@ -7725,7 +7756,8 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * @since 11 */ /** - * Triggered when the Web page receives an ssl Error. + * Called to notify users when an SSL error occurs with a request for the main frame. + * To include errors with requests for subframes, use the OnSslErrorEvent API. * * @param { Callback<OnSslErrorEventReceiveEvent> } callback The triggered callback when the Web page receives an ssl Error. * @returns { WebAttribute } @@ -7736,7 +7768,8 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { onSslErrorEventReceive(callback: Callback<OnSslErrorEventReceiveEvent>): WebAttribute; /** - * Triggered when the Web page receives an ssl Error. + * Called to notify users when an SSL error occurs during the loading of resources (for the main frame and subframes). + * To handle SSL errors for requests for the main frame, use the isMainFrame field to distinguish. * * @param { OnSslErrorEventCallback } callback The triggered callback when the Web page receives an ssl Error. * @returns { WebAttribute } @@ -8489,7 +8522,15 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { onIntelligentTrackingPreventionResult(callback: OnIntelligentTrackingPreventionCallback): WebAttribute; /** - * Injects the JavaScripts before Webview creates the DOM tree, and then the JavaScript snippet will run after the document has been created. + * Injects the JavaScripts script into the Web component. + * When the specified page or document starts to be loaded, the script is executed on any page whose source matches scriptRules. + * <p><strong>API Note</strong>:<br> + * The script runs before any JavaScript code of the page, when the DOM tree may not have been loaded or rendered. + * The script is executed in the lexicographic order instead of array sequence. + * if the array sequemce is required, you are advised to use the runJavaScriptOnDocumentStart interface. + * You are not advised to use this API together with runJavaScriptOnDocumentStart. + * </p> + * * @param { Array<ScriptItem> } scripts - The array of the JavaScripts to be injected. * @returns { WebAttribute } * @syscap SystemCapability.Web.Webview.Core @@ -8499,7 +8540,14 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { javaScriptOnDocumentStart(scripts: Array<ScriptItem>): WebAttribute; /** - * Injects the JavaScripts before Webview creates the DOM tree, and then the JavaScript snippet will run after the document has been created. + * Injects the JavaScripts script into the Web component. When the specified page or document has been loaded, + * the script is executed on any page whose source matches scriptRules. + * <p><strong>API NOTE</strong>:<br> + * The script runs before any Javascript code of the page, when the DOM tree has been loaded and rendered. + * The script is excuted in the lexicographic order, not the array order. + * You are not advised to use this API together with runJavaScriptOnDocumentEnd. + * <p> + * * @param { Array<ScriptItem> } scripts - The array of the JavaScripts to be injected. * @returns { WebAttribute } * @syscap SystemCapability.Web.Webview.Core diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index 3d34d4c9ee..e76eb1d200 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -3734,7 +3734,17 @@ declare namespace webview { * @since 11 */ /** - * Registers the JavaScript object and method list. + * Registers the supplied ArkTs object into this Web component. + * The object is registered into all frames of the web page, including all iframes, using the specified name. + * This allows the methods of the ArkTs object to be accessed from JavaScript. + * <p><strong>API Note</strong>:<br> + * Registed objects will not appear in JavaScript until the page is next (re)load. + * To avoid memory leaks, registerJavaScriptProxy must be used together with deleteJavaScriptProxy. + * To avoid security risks, it is recommended that registerJavaScriptProxy be used with trusted web components. + * If the same method is registered repeatedly in both synchronous and asynchronous list, it will default to an asynchronous method. + * The synchronous function list and asynchronous function list cannot be empty at the same time,<br> + * otherwise, this registration will fail. + * <p> * * @param { object } object - Application side JavaScript objects participating in registration. * @param { string } name - The name of the registered object, which is consistent with the -- Gitee From 91473dd194c4fba7f46f36a58c4514de2309aeea Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Sun, 27 Apr 2025 23:03:19 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index d0683ede8a..590417f5a3 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -6443,7 +6443,8 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * @since 8 */ /** - * Sets how to load HTTP and HTTPS content. + * Sets the behavior when a secure origin attempts to load a resource from an insecure origin. + * The default is MixedMode.None, meaning not allow a secure origin to load content from an insecure origin. * * @param { MixedMode } mixedMode - The mixed mode, which can be {@link MixedMode}. * @returns { WebAttribute } @@ -6451,17 +6452,6 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * @atomicservice * @since 11 */ - /** - * Sets the behavior when a secure origin attempts to load a resource from an insecure origin. - * The default is MixedMode.None, meaning not allow a secure origin to load content from an insecure origin. - * - * @param { MixedMode } mixedMode - The mixed mode, which can be {@link MixedMode}. - * @returns { WebAttribute } - * @syscap SystemCapability.Web.Webview.Core - * @crossplatform - * @atomicservice - * @since 18 - */ mixedMode(mixedMode: MixedMode): WebAttribute; /** -- Gitee From c4ae06f91316598a4a1391b957ccbf66897eea40 Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Mon, 28 Apr 2025 11:17:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 590417f5a3..ef82c20180 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -6352,7 +6352,7 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * @since 11 */ /** - * Sets whether to enable Access to the file system in the application. + * Sets whether to enable access to the file system in the application. * This setting dose not affect the access to the files specified though $rawfile(filepath/filename). * <p><strong>API Note</strong>:<br> * fileAccess is disabled by default since API version 12. @@ -8516,8 +8516,8 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * When the specified page or document starts to be loaded, the script is executed on any page whose source matches scriptRules. * <p><strong>API Note</strong>:<br> * The script runs before any JavaScript code of the page, when the DOM tree may not have been loaded or rendered. - * The script is executed in the lexicographic order instead of array sequence. - * if the array sequemce is required, you are advised to use the runJavaScriptOnDocumentStart interface. + * The script is executed in the lexicographic order instead of array order. + * If the array order is required, you are advised to use the runJavaScriptOnDocumentStart interface. * You are not advised to use this API together with runJavaScriptOnDocumentStart. * </p> * @@ -8533,8 +8533,9 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * Injects the JavaScripts script into the Web component. When the specified page or document has been loaded, * the script is executed on any page whose source matches scriptRules. * <p><strong>API NOTE</strong>:<br> - * The script runs before any Javascript code of the page, when the DOM tree has been loaded and rendered. + * The script runs after any Javascript code of the page, when the DOM tree has been loaded and rendered. * The script is excuted in the lexicographic order, not the array order. + * If the array order is required, you are advised to use the runJavaScriptOnDocumentStart interface. * You are not advised to use this API together with runJavaScriptOnDocumentEnd. * <p> * -- Gitee From 852c8a1a8f7d4c4ec155e7455bc0f003a432f53e Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Mon, 28 Apr 2025 11:21:32 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index ef82c20180..8da9e999da 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -8530,8 +8530,8 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { javaScriptOnDocumentStart(scripts: Array<ScriptItem>): WebAttribute; /** - * Injects the JavaScripts script into the Web component. When the specified page or document has been loaded, - * the script is executed on any page whose source matches scriptRules. + * Injects the JavaScripts script into the Web component. + * When the specified page or document has been loaded, the script is executed on any page whose source matches scriptRules. * <p><strong>API NOTE</strong>:<br> * The script runs after any Javascript code of the page, when the DOM tree has been loaded and rendered. * The script is excuted in the lexicographic order, not the array order. -- Gitee From a313c47f202a43c06568a894fc50f6a849324c11 Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Mon, 28 Apr 2025 11:37:27 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 8da9e999da..8d917dbb1c 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -8533,7 +8533,7 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * Injects the JavaScripts script into the Web component. * When the specified page or document has been loaded, the script is executed on any page whose source matches scriptRules. * <p><strong>API NOTE</strong>:<br> - * The script runs after any Javascript code of the page, when the DOM tree has been loaded and rendered. + * The script runs after any JavaScript code of the page, when the DOM tree has been loaded and rendered. * The script is excuted in the lexicographic order, not the array order. * If the array order is required, you are advised to use the runJavaScriptOnDocumentStart interface. * You are not advised to use this API together with runJavaScriptOnDocumentEnd. -- Gitee From 72bfeb3ba83826e5a802fa8e2a20dd7c879a0b07 Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Tue, 29 Apr 2025 11:47:04 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 8d917dbb1c..2bb84827c9 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -6534,12 +6534,12 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * @since 11 */ /** - * Registers the supplied ArkTs object in javaScriptProxy into this Web component. + * Registers the supplied ArkTS object in javaScriptProxy into this Web component. * The object is registered into all frames of the web page, including all frames, using the specified name in javaScriptProxy. - * This allows the methods of the ArkTs object in javaScriptProxy to be accessed from JavaScript. + * This allows the methods of the ArkTS object in javaScriptProxy to be accessed from JavaScript. * - * @param { JavaScriptProxy } javaScriptProxy - The ArkTs object in javaScriptProxy will be registered into this Web component, - * and the methods within the methodList of the injected ArkTs object declared in javaScriptProxy can be accessed by JavaScript. + * @param { JavaScriptProxy } javaScriptProxy - The ArkTS object in javaScriptProxy will be registered into this Web component, + * and the methods within the methodList of the injected ArkTS object declared in javaScriptProxy can be accessed by JavaScript. * @returns { WebAttribute } * @syscap SystemCapability.Web.Webview.Core * @atomicservice -- Gitee From 0c2b68d7f2a8301bc7f25713924ef40ef40945e3 Mon Sep 17 00:00:00 2001 From: xiaye <xiaye1@huawei.com> Date: Tue, 29 Apr 2025 15:45:49 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaye <xiaye1@huawei.com> --- api/@internal/component/ets/web.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 2bb84827c9..4b1597f78d 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -8516,7 +8516,7 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * When the specified page or document starts to be loaded, the script is executed on any page whose source matches scriptRules. * <p><strong>API Note</strong>:<br> * The script runs before any JavaScript code of the page, when the DOM tree may not have been loaded or rendered. - * The script is executed in the lexicographic order instead of array order. + * The script is executed in the lexicographic order, not the array order. * If the array order is required, you are advised to use the runJavaScriptOnDocumentStart interface. * You are not advised to use this API together with runJavaScriptOnDocumentStart. * </p> @@ -8535,7 +8535,7 @@ declare class WebAttribute extends CommonMethod<WebAttribute> { * <p><strong>API NOTE</strong>:<br> * The script runs after any JavaScript code of the page, when the DOM tree has been loaded and rendered. * The script is excuted in the lexicographic order, not the array order. - * If the array order is required, you are advised to use the runJavaScriptOnDocumentStart interface. + * If the array order is required, you are advised to use the runJavaScriptOnDocumentEnd interface. * You are not advised to use this API together with runJavaScriptOnDocumentEnd. * <p> * -- Gitee