diff --git a/LifecycleWebComp/.gitignore b/LifecycleWebComp/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/LifecycleWebComp/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/LifecycleWebComp/AppScope/app.json5 b/LifecycleWebComp/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c280ad8998ec933a13d5f497a6d439143c5eb8c2
--- /dev/null
+++ b/LifecycleWebComp/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.lifecyclewebcomp",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/LifecycleWebComp/AppScope/resources/base/element/string.json b/LifecycleWebComp/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..db726d0837ef849bc208a86e9467181653f73010
--- /dev/null
+++ b/LifecycleWebComp/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "LifecycleWebComp"
+ }
+ ]
+}
diff --git a/LifecycleWebComp/AppScope/resources/base/media/app_icon.png b/LifecycleWebComp/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/LifecycleWebComp/AppScope/resources/base/media/app_icon.png differ
diff --git a/LifecycleWebComp/README.md b/LifecycleWebComp/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9575c892f64700b8c5aea8953289ca269ec81276
--- /dev/null
+++ b/LifecycleWebComp/README.md
@@ -0,0 +1,62 @@
+# Web组件的生命周期
+
+### 介绍
+
+本工程主要实现了对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/web/web-event-sequence.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### 效果预览
+
+| 日志效果 |
+| --------------------------------------- |
+|  |
+
+使用说明
+
+1. 此 Web 组件无页面展示,运行时通过系统日志输出相关信息。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+无。
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/LifecycleWebComp > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/LifecycleWebComp/build-profile.json5 b/LifecycleWebComp/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d8f458efb875310bfaca49b33a5a8fc651e1ebd7
--- /dev/null
+++ b/LifecycleWebComp/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/code-linter.json5 b/LifecycleWebComp/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..eff2dbc9b8a447e5a99b0aab08ca2b766d786bf6
--- /dev/null
+++ b/LifecycleWebComp/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/.gitignore b/LifecycleWebComp/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/LifecycleWebComp/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/build-profile.json5 b/LifecycleWebComp/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..31bf2f4c4df15f0403582b255ebdff1354312357
--- /dev/null
+++ b/LifecycleWebComp/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/hvigorfile.ts b/LifecycleWebComp/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3
--- /dev/null
+++ b/LifecycleWebComp/entry/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/LifecycleWebComp/entry/obfuscation-rules.txt b/LifecycleWebComp/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/LifecycleWebComp/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/oh-package.json5 b/LifecycleWebComp/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4e54d14e1b444a338b2c922f94a4fe4deed5be45
--- /dev/null
+++ b/LifecycleWebComp/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets b/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..217744d8eb6d893e1138cd660209ce4d0441ac4f
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..6b744d7eaa66e51e79fc4e0896e251292ee767c5
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/ets/pages/Index.ets b/LifecycleWebComp/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5e904676c4acbaa978d796dc71ce3ca78d084010
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start the_status_of_web_component_web_page_loading]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { promptAction } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ responseWeb: WebResourceResponse = new WebResourceResponse();
+ heads: Header[] = new Array();
+ @State webData: string = '\n' +
+ '\n' +
+ '
\n' +
+ '\n' +
+ '';
+
+ aboutToAppear(): void {
+ try {
+ webview.WebviewController.setWebDebuggingAccess(true);
+ } catch (error) {
+ console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ }
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('index.html'), controller: this.controller })
+ .onControllerAttached(() => {
+ // 推荐在此loadUrl、设置自定义用户代理、注入JS对象等
+ console.log('onControllerAttached execute');
+ })
+ .onLoadIntercept((event) => {
+ if (event) {
+ console.log('onLoadIntercept url:' + event.data.getRequestUrl());
+ console.log('url:' + event.data.getRequestUrl());
+ console.log('isMainFrame:' + event.data.isMainFrame());
+ console.log('isRedirect:' + event.data.isRedirect());
+ console.log('isRequestGesture:' + event.data.isRequestGesture());
+ }
+ // 返回true表示阻止此次加载,否则允许此次加载
+ return true;
+ })
+ .onOverrideUrlLoading((webResourceRequest: WebResourceRequest) => {
+ if (webResourceRequest && webResourceRequest.getRequestUrl() == 'about:blank') {
+ return true;
+ }
+ return false;
+ })
+ .onInterceptRequest((event) => {
+ if (event) {
+ console.log('url:' + event.request.getRequestUrl());
+ }
+ let head1: Header = {
+ headerKey: 'Connection',
+ headerValue: 'keep-alive'
+ }
+ let head2: Header = {
+ headerKey: 'Cache-Control',
+ headerValue: 'no-cache'
+ }
+ let length = this.heads.push(head1);
+ length = this.heads.push(head2);
+ this.responseWeb.setResponseHeader(this.heads);
+ this.responseWeb.setResponseData(this.webData);
+ this.responseWeb.setResponseEncoding('utf-8');
+ this.responseWeb.setResponseMimeType('text/html');
+ this.responseWeb.setResponseCode(200);
+ this.responseWeb.setReasonMessage('OK');
+ // 返回响应数据则按照响应数据加载,无响应数据则返回null表示按照原来的方式加载
+ return this.responseWeb;
+ })
+ .onPageBegin((event) => {
+ if (event) {
+ console.log('onPageBegin url:' + event.url);
+ }
+ })
+ .onFirstContentfulPaint(event => {
+ if (event) {
+ console.log('onFirstContentfulPaint:' + '[navigationStartTick]:' +
+ event.navigationStartTick + ', [firstContentfulPaintMs]:' +
+ event.firstContentfulPaintMs);
+ }
+ })
+ .onProgressChange((event) => {
+ if (event) {
+ console.log('newProgress:' + event.newProgress);
+ }
+ })
+ .onPageEnd((event) => {
+ // 推荐在此事件中执行JavaScript脚本
+ if (event) {
+ console.log('onPageEnd url:' + event.url);
+ }
+ })
+ .onPageVisible((event) => {
+ console.log('onPageVisible url:' + event.url);
+ })
+ .onRenderExited((event) => {
+ if (event) {
+ console.log('onRenderExited reason:' + event.renderExitReason);
+ }
+ })
+ .onDisAppear(() => {
+ promptAction.showToast({
+ message: 'The web is hidden',
+ duration: 2000
+ });
+ })
+ }
+ }
+}
+// [End the_status_of_web_component_web_page_loading]
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/module.json5 b/LifecycleWebComp/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..cb5df2316a385286bf09b1aab230f0bf56d8b993
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/base/element/color.json b/LifecycleWebComp/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/base/element/string.json b/LifecycleWebComp/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..38f261172dc69d5f1652c4a07e5197966e5d449f
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LifecycleWebComp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/base/media/background.png b/LifecycleWebComp/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/LifecycleWebComp/entry/src/main/resources/base/media/background.png differ
diff --git a/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png b/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/LifecycleWebComp/entry/src/main/resources/base/media/foreground.png differ
diff --git a/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json b/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png b/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/LifecycleWebComp/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json b/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json b/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json b/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..38f261172dc69d5f1652c4a07e5197966e5d449f
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LifecycleWebComp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/main/resources/rawfile/index.html b/LifecycleWebComp/entry/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..844921321627bd854c9219a879ff5c656da188e9
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/rawfile/index.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
Hello, ArkWeb
+
+
diff --git a/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json b/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..00df20570eb1892ed5e7d19b125c9f65988634c4
--- /dev/null
+++ b/LifecycleWebComp/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LifecycleWebComp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/mock/mock-config.json5 b/LifecycleWebComp/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..26ed9f53bc46192a07ad5ab16ea24e7ce9a79328
--- /dev/null
+++ b/LifecycleWebComp/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets b/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..72a538fe044d7e7dbbac4010a47249c3eeabeeb7
--- /dev/null
+++ b/LifecycleWebComp/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('testUiExample',0, async (done: Function) => {
+ console.info("uitest: TestUiExample begin");
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('index.html');
+
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets b/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e909c66ab67746c53f694cc12a0a604748a8b661
--- /dev/null
+++ b/LifecycleWebComp/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/ohosTest/module.json5 b/LifecycleWebComp/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5f63462032245655b8df990c83c5d7312015c089
--- /dev/null
+++ b/LifecycleWebComp/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/LifecycleWebComp/entry/src/test/List.test.ets b/LifecycleWebComp/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ab6445db05608a5b7f851a85add24f32b890b0f8
--- /dev/null
+++ b/LifecycleWebComp/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/entry/src/test/LocalUnit.test.ets b/LifecycleWebComp/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4b7b4eb2ff9627c7184e386fe88c2ba1b507f905
--- /dev/null
+++ b/LifecycleWebComp/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/LifecycleWebComp/hvigor/hvigor-config.json5 b/LifecycleWebComp/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..76e3231223076011f7f4400f54fa73a5ab0141d4
--- /dev/null
+++ b/LifecycleWebComp/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/LifecycleWebComp/hvigorfile.ts b/LifecycleWebComp/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775
--- /dev/null
+++ b/LifecycleWebComp/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/LifecycleWebComp/oh-package.json5 b/LifecycleWebComp/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d7622199b7ba60be5983122081f71ae9ebef0c4b
--- /dev/null
+++ b/LifecycleWebComp/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/LifecycleWebComp/ohosTest.md b/LifecycleWebComp/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..cbf90fb29998b1baec6a0ea45fdd2c6ff8633012
--- /dev/null
+++ b/LifecycleWebComp/ohosTest.md
@@ -0,0 +1,4 @@
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | ---------------- | -------- | -------- |
+| Web组件的生命周期 | 设备运转正常 | 应用启动成功 | 日志输出相关信息 | Yes | Pass |
+
diff --git a/LifecycleWebComp/screenshots/LifecycleWebComp.png b/LifecycleWebComp/screenshots/LifecycleWebComp.png
new file mode 100644
index 0000000000000000000000000000000000000000..879273b457515acee4cc9752e74440204b7ac63c
Binary files /dev/null and b/LifecycleWebComp/screenshots/LifecycleWebComp.png differ
diff --git a/ManageWebCompSecPriv/.gitignore b/ManageWebCompSecPriv/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebCompSecPriv/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/AppScope/app.json5 b/ManageWebCompSecPriv/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..f3bfcf54902f2bda4cd2cee4b827b89e2ba7ee37
--- /dev/null
+++ b/ManageWebCompSecPriv/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.managewebcompsecpriv",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebCompSecPriv/AppScope/resources/base/element/string.json b/ManageWebCompSecPriv/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..8e172ff2061de12c25e977effcf18d7629db4cd7
--- /dev/null
+++ b/ManageWebCompSecPriv/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ManageWebCompSecPriv"
+ }
+ ]
+}
diff --git a/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png b/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebCompSecPriv/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebCompSecPriv/README.md b/ManageWebCompSecPriv/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..58fe7b5dfe2faef450e0f689d957b17962f8a5a8
--- /dev/null
+++ b/ManageWebCompSecPriv/README.md
@@ -0,0 +1,270 @@
+## 解决Web组件本地资源跨域问题
+
+### 介绍
+
+1. 本示例主要介绍解决Web组件本地资源跨域问题,利用Web组件的onInterceptRequest方法,对本地资源进行拦截和相应的替换。
+2. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-cross-origin.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### LocCrossOriginResAccSol_one
+
+##### 介绍
+
+1. 本示例主要介绍解决Web组件本地资源跨域问题,利用Web组件的onInterceptRequest方法,对本地资源进行拦截和相应的替换。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 针对本地index.html,使用http或者https协议代替file协议或者resource协议,构造一个属于自己的域名。
+
+#### LocCrossOriginResAccSol_two
+
+##### 介绍
+
+1. 本示例主要介绍解决Web组件本地资源跨域问题,通过setPathAllowingUniversalAccess设置一个路径列表。当使用file协议访问该列表中的资源时,允许进行跨域访问本地文件。
+
+##### 效果预览
+
+| 主页 | 跨域访问 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 通过setPathAllowingUniversalAccess设置一个路径列表。当使用file协议访问该列表中的资源时,允许进行跨域访问本地文件。
+1. index.html页面加载完成后,页面上显示一个按钮stealFile,点击stealFile按钮触发getFile函数跨域访问本地resfile/js/script.js文件。
+
+## 使用智能防跟踪功能
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-intelligent-tracking-prevention.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### AddIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,调用addIntelligentTrackingPreventionBypassingList接口设置需要绕过智能防跟踪功能的域名列表。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击addIntelligentTrackingPreventionBypassingList按钮设置需要绕过智能防跟踪功能的域名。
+
+#### ClearIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用clearIntelligentTrackingPreventionBypassingList接口清除通过addIntelligentTrackingPreventionBypassingList接口设置的所有域名。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击clearIntelligentTrackingPreventionBypassingList按钮清除通过addIntelligentTrackingPreventionBypassingList接口设置的所有域名。
+
+#### EnableIntTrackPrevent
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,调用enableIntelligentTrackingPrevention接口使能或者关闭相应Web组件的智能防跟踪功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击enableIntelligentTrackingPrevention按钮使能相应Web组件的智能防跟踪功能。
+
+#### IsIntTrackPreventEnabled
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用isIntelligentTrackingPreventionEnabled接口判断当前Web组件是否开启了智能防跟踪功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击isIntelligentTrackingPreventionEnabled按钮判断当前Web组件是否开启了智能防跟踪功能。
+
+#### OnIntTrackPreventResult
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用onIntelligentTrackingPreventionResult接口,以回调的方式异步获取拦截的跟踪型网站的域名和访问的网站域名信息。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击onIntelligentTrackingPreventionResult按钮,获取拦截的跟踪型网站的域名和访问的网站域名信息。
+
+#### RemoveIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用removeIntelligentTrackingPreventionBypassingList接口移除通过addIntelligentTrackingPreventionBypassingList接口设置的部分域名列表。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击removeIntelligentTrackingPreventionBypassingList按钮,移除通过addIntelligentTrackingPreventionBypassingList接口设置的部分域名列表。
+
+## 使用Web组件的广告过滤功能
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-adsblock.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### EnablingAdsBlocking
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,应用可以通过AdsBlockManager提供的setAdsBlockRules()接口设置自定义的easylist过滤规则,并通过Web组件的enableAdsBlock()接口使能广告过滤特性。
+
+##### 效果预览
+
+| 主页 | 文件选择器 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| /> | |
+
+使用说明
+
+1. 点击setAdsBlockRules按钮,通过文件选择器设置自定义的easylist过滤规则。
+
+#### DisAdsBlockSpecDomPages_one
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,在Web组件的广告过滤开关开启后,应用有时候会期望关闭一些特定页面的广告过滤功能,AdsBlockManager提供了addAdsBlockDisallowedList()接口完成此功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击addAdsBlockDisallowedList按钮关闭特定域名页面的广告过滤。
+
+#### DisAdsBlockSpecDomPages_two
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,使用addAdsBlockDisallowedList()接口添加域名。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击addAdsBlockDisallowedList按钮添加域名。
+
+#### CollectingAdsBlockingInformation
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,在Web组件的广告过滤开关开启后,访问的网页如果发生了广告过滤,会通过Web组件的onAdsBlocked()回调接口通知到应用,应用可根据需要进行过滤信息的收集和统计。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 使用onAdsBlocked接口收集广告过滤的信息。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---CollectingAdsBlockingInformation
+|---|---|---DisAdsBlockSpecDomPages_one
+|---|---|---DisAdsBlockSpecDomPages_two
+|---|---|---LocCrossOriginResAccSol_one
+|---|---|---LocCrossOriginResAccSol_two
+|---|---|---AddIntTrackPreventByPassList
+|---|---|---ClearIntTrackPreventByPassList
+|---|---|---EnableIntTrackPrevent
+|---|---|---IsIntTrackPreventEnabled
+|---|---|---OnIntTrackPreventResult
+|---|---|---RemoveIntTrackPreventByPassList
+|---|---|---EnablingAdsBlocking
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebCompSecPriv > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
diff --git a/ManageWebCompSecPriv/build-profile.json5 b/ManageWebCompSecPriv/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edcfa0a0b72fb77e6fa0828177e088eec84f61eb
--- /dev/null
+++ b/ManageWebCompSecPriv/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ {
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/code-linter.json5 b/ManageWebCompSecPriv/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebCompSecPriv/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/.gitignore b/ManageWebCompSecPriv/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/build-profile.json5 b/ManageWebCompSecPriv/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/hvigorfile.ts b/ManageWebCompSecPriv/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebCompSecPriv/entry/obfuscation-rules.txt b/ManageWebCompSecPriv/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/oh-package.json5 b/ManageWebCompSecPriv/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..aa1655f7bbde61df1c1a081b565110487297ab79
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start set_domains_to_bypass_intelligent_tracking]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('addIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ try {
+ let hostList = ['www.test1.com', 'www.test2.com', 'www.test3.com'];
+ webview.WebviewController.addIntelligentTrackingPreventionBypassingList(hostList);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End set_domains_to_bypass_intelligent_tracking]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..49754ae2a245269f8aaec2dbcd2934e959e8bcb4
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start clear_all_intelligent_tracking_prevention_bypasses]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('clearIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ webview.WebviewController.clearIntelligentTrackingPreventionBypassingList();
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ }
+ }
+}
+// [End clear_all_intelligent_tracking_prevention_bypasses]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets
new file mode 100644
index 0000000000000000000000000000000000000000..2d271fae7990654324db8a7e4aeb8b3b363caec9
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start collect_information_about_ad_filtering]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ @State totalAdsBlockCounts: number = 0;
+ // [StartExclude collect_information_about_ad_filtering]
+ @State myString: string = 'onAdsBlocked';
+ // [EndExclude collect_information_about_ad_filtering]
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ .onAdsBlocked((details: AdsBlockedDetails) => {
+ if (details) {
+ console.log(' Blocked ' + details.adsBlocked.length + ' in ' + details.url);
+ let adList: string[] = Array.from(new Set(details.adsBlocked));
+ this.totalAdsBlockCounts += adList.length;
+ console.log('Total blocked counts :' + this.totalAdsBlockCounts);
+ }
+ })
+ }
+ }
+}
+// [End collect_information_about_ad_filtering]
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f7649e9937a547b1fc4a4034afce0a877e524fc5
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start turn_off_ad_filtering_for_specific_domain_pages]
+import { webview } from '@kit.ArkWeb';
+
+// [StartExclude turn_off_ad_filtering_for_specific_domain_pages]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude turn_off_ad_filtering_for_specific_domain_pages]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ textInputController: TextInputController = new TextInputController();
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController})
+ .id('input_url')
+ .height(40)
+ .margin(5)
+ .borderColor(Color.Blue)
+ .onChange((value: string) => {
+ this.inputText = value;
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('Go') }
+ .onClick(() => {
+ this.controller.loadUrl(this.inputText);
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('addAdsBlockDisallowedList') }
+ .onClick(() => {
+ let arrDomainSuffixes: string[] = [];
+ arrDomainSuffixes.push('example.com');
+ arrDomainSuffixes.push('abcdefg.cn');
+ webview.AdsBlockManager.addAdsBlockDisallowedList(arrDomainSuffixes);
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End turn_off_ad_filtering_for_specific_domain_pages]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c407061e161f5f86af1b1272e265f1d59262e821
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start set_up_page_level_ad_filtering_switch]
+import { webview } from '@kit.ArkWeb';
+
+// [StartExclude set_up_page_level_ad_filtering_switch]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude set_up_page_level_ad_filtering_switch]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ textInputController: TextInputController = new TextInputController();
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController})
+ .id('input_url')
+ .height(40)
+ .margin(5)
+ .borderColor(Color.Blue)
+ .onChange((value: string) => {
+ this.inputText = value;
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('Go'); }
+ .onClick(() => {
+ this.controller.loadUrl(this.inputText);
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('addAdsBlockAllowedList'); }
+ .onClick(() => {
+ let arrDisallowDomainSuffixes = ['example.com'];
+ webview.AdsBlockManager.addAdsBlockDisallowedList(arrDisallowDomainSuffixes);
+
+ let arrAllowedDomainSuffixes = ['news.example.com', 'sport.example.com'];
+ webview.AdsBlockManager.addAdsBlockAllowedList(arrAllowedDomainSuffixes);
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End set_up_page_level_ad_filtering_switch]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ab7767a6c6bb65d34e0c320e9d6b126039a8e77d
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start enable_or_disable_web_component_anti_tracking]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('enableIntelligentTrackingPrevention')
+ .onClick(() => {
+ try {
+ this.controller.enableIntelligentTrackingPrevention(true);
+ console.log('enableIntelligentTrackingPrevention: true');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End enable_or_disable_web_component_anti_tracking]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8eb4a81e2d203fc04af163a09aaf5601ef77c7c7
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start app_select_list_rule_file_for_ad_filter]
+import { webview } from '@kit.ArkWeb';
+import { picker, fileUri } from '@kit.CoreFileKit';
+
+// [StartExclude app_select_list_rule_file_for_ad_filter]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude app_select_list_rule_file_for_ad_filter]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ Button({type: ButtonType.Capsule}) {
+ Text('setAdsBlockRules');
+ }
+ .onClick(() => {
+ try {
+ let documentSelectionOptions: picker.DocumentSelectOptions = new picker.DocumentSelectOptions();
+ let documentPicker: picker.DocumentViewPicker = new picker.DocumentViewPicker();
+ documentPicker.select(documentSelectionOptions).then((documentSelectResult: string[]) => {
+ if (documentSelectResult && documentSelectResult.length > 0) {
+ let fileRealPath = new fileUri.FileUri(documentSelectResult[0]);
+ console.info('DocumentViewPicker.select successfully, uri: ' + fileRealPath);
+ webview.AdsBlockManager.setAdsBlockRules(fileRealPath.path, true);
+ }
+ })
+ } catch (err) {
+ console.error('DocumentViewPicker.select failed with err:' + err);
+ }
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End app_select_list_rule_file_for_ad_filter]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cb5f033b5edc90ee98d926d2590e6c02294df4b6
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('LocCrossOriginResAccSol_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_one' });
+ })
+ Button('LocCrossOriginResAccSol_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_two' });
+ })
+ Button('AddIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/AddIntTrackPreventByPassList' });
+ })
+ Button('ClearIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ClearIntTrackPreventByPassList' });
+ })
+ Button('EnableIntTrackPrevent')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EnableIntTrackPrevent' });
+ })
+ Button('IsIntTrackPreventEnabled')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/IsIntTrackPreventEnabled' });
+ })
+ Button('OnIntTrackPreventResult')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnIntTrackPreventResult' });
+ })
+ Button('RemoveIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/RemoveIntTrackPreventByPassList' });
+ })
+ Button('EnablingAdsBlocking')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EnablingAdsBlocking' });
+ })
+ Button('DisAdsBlockSpecDomPages_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_one' });
+ })
+ Button('DisAdsBlockSpecDomPages_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_two' });
+ })
+ Button('CollectingAdsBlockingInformation')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/CollectingAdsBlockingInformation' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b33603d2c083d817a71949d8e8c4ac533582e4fc
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start check_if_web_component_anti_tracking_on]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('isIntelligentTrackingPreventionEnabled')
+ .onClick(() => {
+ try {
+ let result = this.controller.isIntelligentTrackingPreventionEnabled();
+ console.log('result: ' + result);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End check_if_web_component_anti_tracking_on]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..89333b69cb353cc31ca718d0175cae53d6bd1de7
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_loccross_one]
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World';
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ // 构造域名和本地文件的映射表
+ schemeMap = new Map([
+ [resourceToString($r('app.string.web_path')) + '/index.html', 'index.html'],
+ [resourceToString($r('app.string.web_path')) + '/js/script.js', 'js/script.js'],
+ ]);
+ // 构造本地文件和构造返回的格式mimeType
+ mimeTypeMap = new Map([
+ ['index.html', 'text/html'],
+ ['js/script.js', 'text/javascript']
+ ]);
+
+ build() {
+ Row() {
+ Column() {
+ // 针对本地index1.html,使用http或者https协议代替file协议或者resource协议,并且构造一个属于自己的域名。
+ // 本例中构造www.example.com为例。
+ Web({ src: resourceToString($r('app.string.web_path')) + '/index.html', controller: this.webviewController })
+ .javaScriptAccess(true)
+ .fileAccess(true)
+ .domStorageAccess(true)
+ .geolocationAccess(true)
+ .width('100%')
+ .height('100%')
+ .onInterceptRequest((event) => {
+ if (!event) {
+ return;
+ }
+ // 此处匹配自己想要加载的本地离线资源,进行资源拦截替换,绕过跨域
+ if (this.schemeMap.has(event.request.getRequestUrl())) {
+ let rawfileName: string = this.schemeMap.get(event.request.getRequestUrl())!;
+ let mimeType = this.mimeTypeMap.get(rawfileName);
+ if (typeof mimeType === 'string') {
+ let response = new WebResourceResponse();
+ // 构造响应数据,如果本地文件在rawfile下,可以通过如下方式设置
+ response.setResponseData($rawfile(rawfileName));
+ response.setResponseEncoding('utf-8');
+ response.setResponseMimeType(mimeType);
+ response.setResponseCode(200);
+ response.setReasonMessage('OK');
+ response.setResponseIsReady(true);
+ return response;
+ }
+ }
+ return null;
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+// [End cors_loccross_one]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..aae56aaced7fd6f3c2611a7080e2c823b87ea13d
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_loccross_two]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: WebviewController = new webview.WebviewController();
+
+ build() {
+ Row() {
+ Web({ src: '', controller: this.controller })
+ .onControllerAttached(() => {
+ try {
+ // 设置允许可以跨域访问的路径列表
+ this.controller.setPathAllowingUniversalAccess([
+ getContext().resourceDir,
+ getContext().filesDir + '/example'
+ ]);
+ this.controller.loadUrl('file://' + getContext().resourceDir + '/index.html');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ .javaScriptAccess(true)
+ .fileAccess(true)
+ .domStorageAccess(true)
+ }
+ }
+}
+// [End cors_loccross_two]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets
new file mode 100644
index 0000000000000000000000000000000000000000..23fdec43f07cb906691e0505bdc65cd5306e1e36
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start retrieve_blocked_and_visited_domain_names]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ // 需要打开智能防跟踪功能,才会触发onIntelligentTrackingPreventionResult回调
+ Button('enableIntelligentTrackingPrevention')
+ .onClick(() => {
+ try {
+ this.controller.enableIntelligentTrackingPrevention(true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ .onIntelligentTrackingPreventionResult((details) => {
+ console.log('onIntelligentTrackingPreventionResult: [websiteHost]= ' + details.host +
+ ', [trackerHost]=' + details.trackerHost);
+ })
+ }
+ }
+}
+// [End retrieve_blocked_and_visited_domain_names]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets b/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ed8c741879f229405e43b14fbc72650b4df53ec9
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start partial_domain_name_list]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('removeIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ try {
+ let hostList = [ 'www.test1.com', 'www.test2.com' ];
+ webview.WebviewController.removeIntelligentTrackingPreventionBypassingList(hostList);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End partial_domain_name_list]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/module.json5 b/ManageWebCompSecPriv/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json b/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json b/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..68f2a3f7cd4e6b25d5f6224c60837ba99c25ec76
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebCompSecPriv"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png b/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png b/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json b/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png b/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json b/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json b/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..8a72c3b7803a5e5cd787f8239bc1a60b9f60391c
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,17 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/LocCrossOriginResAccSol_one",
+ "pages/LocCrossOriginResAccSol_two",
+ "pages/AddIntTrackPreventByPassList",
+ "pages/ClearIntTrackPreventByPassList",
+ "pages/EnableIntTrackPrevent",
+ "pages/IsIntTrackPreventEnabled",
+ "pages/OnIntTrackPreventResult",
+ "pages/RemoveIntTrackPreventByPassList",
+ "pages/EnablingAdsBlocking",
+ "pages/DisAdsBlockSpecDomPages_one",
+ "pages/DisAdsBlockSpecDomPages_two",
+ "pages/CollectingAdsBlockingInformation"
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json b/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..6aba54ea1bb3ac12f412cb39a46e76081f6fcc31
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebCompSecPriv"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html b/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..01ba29a16a4306f3ed6bd10c2c7a9cdb84e5285e
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js b/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js
new file mode 100644
index 0000000000000000000000000000000000000000..dfd1c0b8cb035c61be2f521a59d66908d4b4c023
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_script_raw]
+const body = document.body;
+const element = document.createElement('div');
+element.textContent = 'success';
+body.appendChild(element);
+// [End cors_script_raw]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html b/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..e8aa15081537f3f522e4ed361345524ca955f8f3
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+ Demo
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js b/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js
new file mode 100644
index 0000000000000000000000000000000000000000..9853f099a5d5f45d51460a9c53fd067ed68eb240
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/resfile/js/script.js
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_script]
+const body = document.body;
+const element = document.createElement('div');
+element.textContent = 'success';
+body.appendChild(element);
+// [End cors_script]
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json b/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..fa45cf3851f9f2519e27031ca337ffd4bd784ce5
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebCompSecPriv"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/mock/mock-config.json5 b/ManageWebCompSecPriv/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9f1d36678d8f270241ce6d2f73e6654664986586
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /**
+ * 打开应用,点击 LocCrossOriginResAccSol_one 按钮
+ * 对本地资源进行拦截和相应的替换
+ */
+ it('LocCrossOriginResAccSol_one', 0, async (done: Function) => {
+ console.info('uitest: LocCrossOriginResAccSol_one begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LocCrossOriginResAccSol_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('index.html');
+
+ await driver.pressBack();
+ console.info('uitest: LocCrossOriginResAccSol_one end');
+ done();
+ });
+
+ /**
+ * 点击 LocCrossOriginResAccSol_two 按钮,跨域访问本地文件
+ */
+ it('LocCrossOriginResAccSol_two', 0, async (done: Function) => {
+ console.info('uitest: LocCrossOriginResAccSol_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LocCrossOriginResAccSol_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.type('button'));
+ await button3.click();
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src = await web1.getText();
+ expect(src).assertContain('');
+
+ await driver.pressBack();
+ console.info('uitest: LocCrossOriginResAccSol_two end');
+ done();
+ });
+
+ /**
+ * 点击 AddIntTrackPreventByPassList 按钮
+ * 设置需要绕过智能防跟踪功能的域名列表
+ */
+ it('AddIntTrackPreventByPassList',0, async (done: Function) => {
+ console.info('uitest: AddIntTrackPreventByPassList begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('AddIntTrackPreventByPassList'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: AddIntTrackPreventByPassList end');
+ done();
+ });
+
+ /**
+ * 点击 ClearIntTrackPreventByPassList 按钮
+ * 清除通过 addIntelligentTrackingPreventionBypassingList 接口设置的所有域名
+ */
+ it('ClearIntTrackPreventByPassList',0, async (done: Function) => {
+ console.info('uitest: ClearIntTrackPreventByPassList begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('ClearIntTrackPreventByPassList'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: ClearIntTrackPreventByPassList end');
+ done();
+ });
+
+ /**
+ * 点击 EnableIntTrackPrevent 按钮
+ * 使能或者关闭相应Web组件的智能防跟踪功能
+ */
+ it('EnableIntTrackPrevent',0, async (done: Function) => {
+ console.info('uitest: EnableIntTrackPrevent begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('EnableIntTrackPrevent'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: EnableIntTrackPrevent end');
+ done();
+ });
+
+ /**
+ * 点击 IsIntTrackPreventEnabled 按钮
+ * 判断当前Web组件是否开启了智能防跟踪功能
+ */
+ it('IsIntTrackPreventEnabled',0, async (done: Function) => {
+ console.info('uitest: IsIntTrackPreventEnabled begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('IsIntTrackPreventEnabled'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: IsIntTrackPreventEnabled end');
+ done();
+ });
+
+ /**
+ * 点击 OnIntTrackPreventResult 按钮
+ * 异步获取拦截的跟踪型网站的域名和访问的网站域名信息
+ */
+ it('OnIntTrackPreventResult',0, async (done: Function) => {
+ console.info('uitest: OnIntTrackPreventResult begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('OnIntTrackPreventResult'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: OnIntTrackPreventResult end');
+ done();
+ });
+
+ /**
+ * 点击 RemoveIntTrackPreventByPassList 按钮
+ * 移除通过 addIntelligentTrackingPreventionBypassingList 接口设置的部分域名列表
+ */
+ it('RemoveIntTrackPreventByPassList',0, async (done: Function) => {
+ console.info('uitest: RemoveIntTrackPreventByPassList begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('RemoveIntTrackPreventByPassList'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: RemoveIntTrackPreventByPassList end');
+ done();
+ });
+
+ /**
+ * 点击 EnablingAdsBlocking 按钮
+ * 设置自定义的easylist过滤规则并使能广告过滤特性
+ */
+ it('EnablingAdsBlocking',0, async (done: Function) => {
+ console.info('uitest: EnablingAdsBlocking begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('EnablingAdsBlocking'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.pressBack();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: EnablingAdsBlocking end');
+ done();
+ });
+
+ /**
+ * 点击 DisAdsBlockSpecDomPages_one 按钮
+ * 关闭一些特定页面的广告过滤功能
+ */
+ it('DisAdsBlockSpecDomPages_one',0, async (done: Function) => {
+ console.info('uitest: DisAdsBlockSpecDomPages_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(5000);
+
+ const button1 = await driver.findComponent(ON.text('DisAdsBlockSpecDomPages_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('Go'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('addAdsBlockDisallowedList'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: DisAdsBlockSpecDomPages_one end');
+ done();
+ });
+
+ /**
+ * 点击 DisAdsBlockSpecDomPages_two 按钮
+ * 使用 addAdsBlockDisallowedList 接口添加域名
+ */
+ it('DisAdsBlockSpecDomPages_two',0, async (done: Function) => {
+ console.info('uitest: DisAdsBlockSpecDomPages_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(5000);
+
+ const button1 = await driver.findComponent(ON.text('DisAdsBlockSpecDomPages_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('Go'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('addAdsBlockAllowedList'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: DisAdsBlockSpecDomPages_two end');
+ done();
+ });
+
+ /**
+ * 点击 CollectingAdsBlockingInformation 按钮
+ * 触发发生了广告过滤后过滤信息的收集和统计
+ */
+ it('CollectingAdsBlockingInformation',0, async (done: Function) => {
+ console.info('uitest: CollectingAdsBlockingInformation begin');
+ const driver = Driver.create();
+ await driver.delayMs(5000);
+
+ const button1 = await driver.findComponent(ON.text('CollectingAdsBlockingInformation'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const type1 = await driver.findComponent(ON.type('Web'));
+ let text: string = await type1.getText();
+ expect(text).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: CollectingAdsBlockingInformation end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/ohosTest/module.json5 b/ManageWebCompSecPriv/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebCompSecPriv/entry/src/test/List.test.ets b/ManageWebCompSecPriv/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets b/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebCompSecPriv/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebCompSecPriv/hvigor/hvigor-config.json5 b/ManageWebCompSecPriv/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebCompSecPriv/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebCompSecPriv/hvigorfile.ts b/ManageWebCompSecPriv/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebCompSecPriv/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebCompSecPriv/oh-package.json5 b/ManageWebCompSecPriv/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebCompSecPriv/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebCompSecPriv/ohosTest.md b/ManageWebCompSecPriv/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..a63576a348152f48f2d0a0658a723c18c0b87e15
--- /dev/null
+++ b/ManageWebCompSecPriv/ohosTest.md
@@ -0,0 +1,71 @@
+### LocCrossOriginResAccSol_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------------- | ------------ | ------------ | ------------------ | -------- | -------- |
+| 解决Web组件本地资源跨域问题 | 设备运转正常 | 应用启动成功 | 加载index.html页面 | Yes | Pass |
+
+### LocCrossOriginResAccSol_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------------- | ------------------------------------ | ------------------------------- | ------------------------------------ | -------- | -------- |
+| 解决Web组件本地资源跨域问题 | 设备运转正常,index.html页面加载完成 | 应用启动成功,点击stealFile按钮 | 跨域访问本地resfile/js/script.js文件 | Yes | Pass |
+
+### AddIntTrackPreventByPassList
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------------------------------------------------------ | -------------------------------- | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击addIntelligentTrackingPreventionBypassingList按钮 | 设置需要绕过智能防跟踪功能的域名 | Yes | Pass |
+
+### ClearIntTrackPreventByPassList
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击clearIntelligentTrackingPreventionBypassingList按钮 | 清除通过addIntelligentTrackingPreventionBypassingList接口设置的所有域名 | Yes | Pass |
+
+### EnableIntTrackPrevent
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | --------------------------------------------------------- | ------------------------------- | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击enableIntelligentTrackingPrevention按钮 | 使能相应Web组件的智能防跟踪功能 | Yes | Pass |
+
+### IsIntTrackPreventEnabled
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------------------------------------------------------ | --------------------------------------- | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击isIntelligentTrackingPreventionEnabled按钮 | 判断当前Web组件是否开启了智能防跟踪功能 | Yes | Pass |
+
+### OnIntTrackPreventResult
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ----------------------------------------------------------- | ------------------------------------------------ | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击onIntelligentTrackingPreventionResult按钮 | 获取拦截的跟踪型网站的域名和访问的网站域名信息。 | Yes | Pass |
+
+### RemoveIntTrackPreventByPassList
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- |
+| 使用智能防跟踪功能 | 设备运转正常 | 应用启动成功,点击removeIntelligentTrackingPreventionBypassingList按钮 | 移除通过addIntelligentTrackingPreventionBypassingList接口设置的部分域名列表 | Yes | Pass |
+
+### EnablingAdsBlocking
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | -------------------------------------- | -------------- | -------- | -------- |
+| 使用Web组件的广告过滤功能 | 设备运转正常 | 应用启动成功,点击setAdsBlockRules按钮 | 打开文件选择器 | Yes | Pass |
+
+### DisAdsBlockSpecDomPages_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ----------------------------------------------- | -------------------------- | -------- | -------- |
+| 使用Web组件的广告过滤功能 | 设备运转正常 | 应用启动成功,点击addAdsBlockDisallowedList按钮 | 关闭特定域名页面的广告过滤 | Yes | Pass |
+
+### DisAdsBlockSpecDomPages_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ----------------------------------------------- | -------- | -------- | -------- |
+| 使用Web组件的广告过滤功能 | 设备运转正常 | 应用启动成功,点击addAdsBlockDisallowedList按钮 | 添加域名 | Yes | Pass |
+
+### CollectingAdsBlockingInformation
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ------------ | ------------------ | -------- | -------- |
+| 使用Web组件的广告过滤功能 | 设备运转正常 | 应用启动成功 | 收集广告过滤的信息 | Yes | Pass |
diff --git a/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png b/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png
new file mode 100644
index 0000000000000000000000000000000000000000..ccbe69798a139432a565a9c74bef18fe5bc6f1e1
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/AddIntTrackPreventByPassList.png differ
diff --git a/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png b/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png
new file mode 100644
index 0000000000000000000000000000000000000000..c0438ba8b3ce0f30d8a340873cb43aef719de170
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/ClearIntTrackPreventByPassList.png differ
diff --git a/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png b/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png
new file mode 100644
index 0000000000000000000000000000000000000000..5e3d62abefcb00d148eeaf9cfa91c255b8344a1c
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/CollectingAdsBlockingInformation.png differ
diff --git a/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png b/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png
new file mode 100644
index 0000000000000000000000000000000000000000..7e75e856cddf583d86e17f86a68f0c689836f298
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_one.png differ
diff --git a/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png b/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png
new file mode 100644
index 0000000000000000000000000000000000000000..5f334f78a76bedca13310e917768027abaa16789
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/DisAdsBlockSpecDomPages_two.png differ
diff --git a/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png b/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png
new file mode 100644
index 0000000000000000000000000000000000000000..3b2c90131beb736c785746ec54c922640cc906da
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/EnableIntTrackPrevent.png differ
diff --git a/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png b/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..6d6d41b49abab13406bdf04923b905d00081d7b6
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_1.png differ
diff --git a/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png b/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..e327def8ac32a67e40b0f1319fc5ea6359dc5fe2
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/EnablingAdsBlocking_2.png differ
diff --git a/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png b/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png
new file mode 100644
index 0000000000000000000000000000000000000000..31f7613ec78b6a724259d2b80cd3f7d41170241a
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/IsIntTrackPreventEnabled.png differ
diff --git a/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png
new file mode 100644
index 0000000000000000000000000000000000000000..a7cfbd1b813c8eacd6962fdc9552954f5b19f2a5
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_one.png differ
diff --git a/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..816ee5693ab636c82957c6c524f5e7f10bea78a3
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_1.png differ
diff --git a/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..8eb796240d9933f65ff4681d59075b93479d0809
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/LocCrossOriginResAccSol_two_2.png differ
diff --git a/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png b/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png
new file mode 100644
index 0000000000000000000000000000000000000000..bc6f50d9eaeaedf1a0fe0f907f00e6ad44f369df
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/OnIntTrackPreventResult.png differ
diff --git a/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png b/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png
new file mode 100644
index 0000000000000000000000000000000000000000..47389d196eca6812e5ed0fd941798d677785836a
Binary files /dev/null and b/ManageWebCompSecPriv/screenshots/RemoveIntTrackPreventByPassList.png differ
diff --git a/ManageWebPageFileIO/.gitignore b/ManageWebPageFileIO/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageFileIO/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageFileIO/AppScope/app.json5 b/ManageWebPageFileIO/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c81be320936ad21787cdb02b4d04f1015bfae2ea
--- /dev/null
+++ b/ManageWebPageFileIO/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.managewebpagefileio",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageFileIO/AppScope/resources/base/element/string.json b/ManageWebPageFileIO/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..651c9e36903ecf6afe4187bce123a1a3ab00c38d
--- /dev/null
+++ b/ManageWebPageFileIO/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ManageWebPageFileIO"
+ }
+ ]
+}
diff --git a/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png b/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageFileIO/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageFileIO/README.md b/ManageWebPageFileIO/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b0609d97d25ba3b6935cef98bae7dd621c30369
--- /dev/null
+++ b/ManageWebPageFileIO/README.md
@@ -0,0 +1,133 @@
+## 上传文件
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-file-upload.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### UploadFiles
+
+#### 介绍
+
+1. 本示例主要介绍Web组件上传文件功能,Web组件支持前端页面选择文件上传功能,应用开发者可以使用onShowvfileSelector)接口来处理前端页面文件上传的请求,如果应用开发者不做任何处理,Web会提供默认行为来处理前端页面文件上传的请求。
+
+#### 效果预览
+
+| 主页 | |
+| ---------------------------------------------------------- | ---------------------------------------------------------- |
+| | |
+
+使用方法
+
+1. 在主页点击选择文件按钮触发onShowFileSelector事件创建DocumentSelectOptions和DocumentViewPicker,用于打开文件选择器,弹出文件选择器,用户可选择一个文件。
+
+## 使用Web组件的下载能力
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-download.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### ListenForPageDown
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件监听页面触发的下载功能,通过setDownloadDelegate()向Web组件注册一个DownloadDelegate来监听页面触发的下载任务。资源由Web组件来下载,Web组件会通过DownloadDelegate将下载的进度通知给应用。
+
+#### 效果预览
+
+| 主页 | 下载 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+2. 点击下载download.html链接,触发下载任务。
+
+### InitiatingADownloadTask
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件的下载能力。在Web组件启动时,可通过resumeDownload()接口恢复未完成的下载任务。
+
+
+#### 效果预览
+
+| 主页 | 下载 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+1. 使用startDownload()接口发起一个下载。
+
+### ResumeDownload
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件的下载能力。使用startDownload()接口发起一个下载,Web组件发起的下载会根据当前显示的url以及Web组件默认的Referrer Policy来计算referrer。
+
+
+#### 效果预览
+
+| 主页 |
+| ----------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+1. 使用startDownload()接口发起一个下载。
+1. 通过record按钮将当前下载任务保存至持久化文件中,记录下载任务信息。
+1. 点击recovery按钮恢复下载任务。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---UploadFiles.ets
+|---|---|---downloadUtil.ets
+|---|---|---Index.ets // 首页
+|---|---|---InitiatingADownloadTask.ets
+|---|---|---ListenForPageDown.ets
+|---|---|---ResumeDownload.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageFileIO > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageFileIO/build-profile.json5 b/ManageWebPageFileIO/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ManageWebPageFileIO/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/code-linter.json5 b/ManageWebPageFileIO/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageFileIO/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/.gitignore b/ManageWebPageFileIO/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageFileIO/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/build-profile.json5 b/ManageWebPageFileIO/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageFileIO/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/hvigorfile.ts b/ManageWebPageFileIO/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ManageWebPageFileIO/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageFileIO/entry/obfuscation-rules.txt b/ManageWebPageFileIO/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageFileIO/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/oh-package.json5 b/ManageWebPageFileIO/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageFileIO/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..80e8214f747914b9b3b64331d9eb37fd1619a007
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('UploadFiles')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UploadFiles' });
+ })
+ Button('ListenForPageDown')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ListenForPageDown' });
+ })
+ Button('InitiatingADownloadTask')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/InitiatingADownloadTask' });
+ })
+ Button('ResumeDownload')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ResumeDownload' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5b876e5f292321bcd2a884cd16a2f360516b7f02
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start init_download_task]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ @State myText: string = 'download';
+
+ build() {
+ Column() {
+ Text(this.myText)
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // 传入一个下载路径,并开始下载。
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download update guid: ' + webDownloadItem.getGuid());
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ this.myText = 'download finish';
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('startDownload')
+ .onClick(() => {
+ try {
+ // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。
+ // 开发者需要替换为自己想要下载的内容的地址。
+ this.controller.startDownload(resourceToString($r('app.string.web_path')));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End init_download_task]
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets
new file mode 100644
index 0000000000000000000000000000000000000000..733a26d4b9600db7f50a41cc0b338561f1584951
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start download_delegate]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ @State myText: string = 'download';
+
+ build() {
+ Column() {
+ Text(this.myText)
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // Pass in a download path and start the download.
+ // If the path is invalid, the file will be downloaded to the
+ // default directory at /data/storage/el2/base/cache/web/.
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ // Unique ID of a download task.
+ console.log('download update guid: ' + webDownloadItem.getGuid());
+ // Download progress.
+ console.log('download update guid: ' + webDownloadItem.getPercentComplete());
+ // Current download speed.
+ console.log('download update speed: ' + webDownloadItem.getCurrentSpeed());
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ // Error code of a download task failure.
+ console.log('download failed guid: ' + webDownloadItem.getLastErrorCode());
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ this.myText = 'download finish';
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index.html'), controller: this.controller })
+ }
+ }
+}
+// [End download_delegate]
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c0d230cdc7916565a9760fad159c3f84b950243c
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start recovery_download_task]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { DownloadUtil, fileName, filePath } from './downloadUtil'; // downloadUtil.ets 见下文
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ download: webview.WebDownloadItem = new webview.WebDownloadItem();
+ // 用于记录失败的下载任务。
+ failedData: Uint8Array = new Uint8Array();
+
+ build() {
+ Column() {
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // 传入一个下载路径,并开始下载。
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download update percent complete: ' + webDownloadItem.getPercentComplete());
+ this.download = webDownloadItem;
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ // 序列化失败的下载任务到一个字节数组。
+ this.failedData = webDownloadItem.serialize();
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ webview.WebDownloadManager.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('startDownload')
+ .onClick(() => {
+ try {
+ // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。
+ // 开发者需要替换为自己想要下载的内容的地址。
+ this.controller.startDownload(resourceToString($r('app.string.web_path')));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 将当前的下载任务信息序列化保存,用于后续恢复下载任务。
+ // 当前用例仅展示下载一个任务的场景,多任务场景请按需扩展。
+ Button('record')
+ .onClick(() => {
+ try {
+ // 保存当前下载数据到持久化文档中。
+ DownloadUtil.saveDownloadInfo(DownloadUtil.uint8ArrayToStr(this.download.serialize()));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 从序列化的下载任务信息中,恢复下载任务。
+ // 按钮触发时必须保证WebDownloadManager.setDownloadDelegate设置完成。
+ Button('recovery')
+ .onClick(() => {
+ try {
+ // 当前默认持久化文件存在,用户根据实际情况增加判断。
+ let webDownloadItem =
+ webview.WebDownloadItem.deserialize(
+ DownloadUtil.strToUint8Array(DownloadUtil.readFileSync(filePath, fileName)));
+ webview.WebDownloadManager.resumeDownload(webDownloadItem);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End recovery_download_task]
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f5e26614ec7193c00bd97c8ca7aca9b5d14d66b1
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_file_upload]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { picker } from '@kit.CoreFileKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('local.html'), controller: this.controller })
+ .onShowFileSelector((event) => {
+ console.log('MyFileUploader onShowFileSelector invoked');
+ const documentSelectOptions = new picker.DocumentSelectOptions();
+ let uri: string | null = null;
+ const documentViewPicker = new picker.DocumentViewPicker();
+ documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => {
+ uri = documentSelectResult[0];
+ console.info('documentViewPicker.select to file succeed and uri is:' + uri);
+ if (event) {
+ event.result.handleFileList([uri]);
+ }
+ }).catch((err: BusinessError) => {
+ console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
+ })
+ return true;
+ })
+ }
+ }
+}
+// [End web_file_upload]
diff --git a/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets b/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets
new file mode 100644
index 0000000000000000000000000000000000000000..be9907e29f5341089f5e24a75fbefb6b08917e44
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start task_info_persistence_util]
+import { util } from '@kit.ArkTS';
+import fileStream from '@ohos.file.fs';
+
+const helper = new util.Base64Helper();
+
+export const filePath = getContext().filesDir;
+export const fileName = 'demoFile.txt';
+export namespace DownloadUtil {
+
+ export function uint8ArrayToStr(uint8Array: Uint8Array): string {
+ return helper.encodeToStringSync(uint8Array);
+ }
+
+ export function strToUint8Array(str: string): Uint8Array {
+ return helper.decodeSync(str);
+ }
+
+ export function saveDownloadInfo(downloadInfo: string): void {
+ if (!fileExists(filePath)) {
+ mkDirectorySync(filePath);
+ }
+
+ writeToFileSync(filePath, fileName, downloadInfo);
+ }
+
+ export function fileExists(filePath: string): boolean {
+ try {
+ return fileStream.accessSync(filePath);
+ } catch (error) {
+ return false;
+ }
+ }
+
+ export function mkDirectorySync(directoryPath: string, recursion?: boolean): void {
+ try {
+ fileStream.mkdirSync(directoryPath, recursion ?? false);
+ } catch (error) {
+ console.error(`mk dir error. err message: ${error.message}, err code: ${error.code}`);
+ }
+ }
+
+ export function writeToFileSync(dir: string, fileName: string, msg: string): void {
+ let file = fileStream.openSync(dir + '/' + fileName, fileStream.OpenMode.WRITE_ONLY | fileStream.OpenMode.CREATE);
+ fileStream.writeSync(file.fd, msg);
+ }
+
+ export function readFileSync(dir: string, fileName: string): string {
+ return fileStream.readTextSync(dir + '/' + fileName);
+ }
+
+}
+// [End task_info_persistence_util]
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/module.json5 b/ManageWebPageFileIO/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json b/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json b/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..883cf5800d2f788f5b396cc9fbe250677c524829
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageFileIO"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png b/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png b/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..c163d886b69f969ad6975c6ac9fc06556384d468
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/UploadFiles",
+ "pages/ListenForPageDown",
+ "pages/InitiatingADownloadTask",
+ "pages/ResumeDownload"
+ ]
+}
diff --git a/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json b/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..3b22824ad2f373eba1f5d72ee7ae6cddd9f82a8f
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageFileIO"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html b/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html
new file mode 100644
index 0000000000000000000000000000000000000000..79e8cc88be2c00e1a49303cd9ddffeb2e55b6c25
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
download test
+
+
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html b/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..3dab642cbf493c630cec7194e2ea9c24d9dfadc8
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/rawfile/index.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+Download
+
+
diff --git a/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html b/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html
new file mode 100644
index 0000000000000000000000000000000000000000..a02fa4eb2b9854bcea11238cd13e25bafc9e9156
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/rawfile/local.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..24c323f82206183076757243cbd869c488fd30f1
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageFileIO"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/mock/mock-config.json5 b/ManageWebPageFileIO/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..bb7966dc1b673cb46d7ead5c41419c25af4522ae
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 UploadFiles 按钮
+ * 处理前端页面文件上传的请求
+ */
+ it('UploadFiles', 0, async (done: Function) => {
+ console.info('uitest: UploadFiles begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UploadFiles'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.clickable(true).enabled(true));
+ await button2.click();
+ await driver.delayMs(3000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('local.html');
+
+ await driver.pressBack();
+ await driver.delayMs(1000);
+ await driver.pressBack();
+ await driver.delayMs(1000);
+ console.info('uitest: UploadFiles end');
+ done();
+ });
+
+ /*
+ * 点击 ListenForPageDown 按钮
+ * 使用Web组件监听页面触发的下载
+ */
+ it('ListenForPageDown', 0, async (done: Function) => {
+ console.info('uitest: ListenForPageDown begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('ListenForPageDown'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('setDownloadDelegate'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Download'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index.html');
+
+ const type1 = await driver.findComponent(ON.type('Text'));
+ let text1: string = await type1.getText();
+ expect(text1).assertEqual('download finish');
+
+ await driver.pressBack();
+ console.info('uitest: ListenForPageDown end');
+ done();
+ });
+
+ /*
+ * 点击 InitiatingADownloadTask 按钮
+ * 使用Web组件的下载能力
+ */
+ it('InitiatingADownloadTask',0, async (done: Function) => {
+ console.info('uitest: InitiatingADownloadTask begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('InitiatingADownloadTask'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('setDownloadDelegate'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('startDownload'));
+ await button3.click();
+ await driver.delayMs(4000);
+
+ const type1 = await driver.findComponent(ON.type('Text'));
+ let text1: string = await type1.getText();
+ expect(text1).assertEqual('download finish');
+
+ await driver.pressBack();
+ console.info('uitest: InitiatingADownloadTask end');
+ done();
+ });
+
+ /*
+ * 点击 ResumeDownload 按钮
+ * 发起一个下载,Web组件发起的下载会根据当前显示的url以及Web组件默认的Referrer Policy来计算referrer
+ */
+ it('ResumeDownload',0, async (done: Function) => {
+ console.info('uitest: ResumeDownload begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('ResumeDownload'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('setDownloadDelegate'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('startDownload'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('record'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.text('recovery'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: ResumeDownload end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/ohosTest/module.json5 b/ManageWebPageFileIO/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageFileIO/entry/src/test/List.test.ets b/ManageWebPageFileIO/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets b/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageFileIO/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageFileIO/hvigor/hvigor-config.json5 b/ManageWebPageFileIO/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageFileIO/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageFileIO/hvigorfile.ts b/ManageWebPageFileIO/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageFileIO/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageFileIO/oh-package.json5 b/ManageWebPageFileIO/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageFileIO/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageFileIO/ohosTest.md b/ManageWebPageFileIO/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..09391f96fdc12e8ac2491af0cc7af217d206c44b
--- /dev/null
+++ b/ManageWebPageFileIO/ohosTest.md
@@ -0,0 +1,28 @@
+#### UploadFiles
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| -------- | ------------ | ------------------------------------ | -------------- | -------- | -------- |
+| 上传文件 | 设备运转正常 | 应用启动成功,在主页点击选择文件按钮 | 弹出文件选择器 | Yes | Pass |
+
+#### ListenForPageDown
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------- | ---------------- | ----------------------------------------- | ---------------------------- | -------- | -------- |
+| 使用Web组件的下载能力 | 设备运转正常 | 应用启动成功,点击setDownloadDelegate按钮 | 定义下载委托回调 | Yes | Pass |
+| download | 定义下载委托回调 | 点击下载download.html链接 | 触发下载任务,为Text组件更名 | Yes | Pass |
+
+#### InitiatingADownloadTask
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------- | ---------------- | ----------------------------------------- | ---------------------------- | -------- | -------- |
+| 使用Web组件的下载能力 | 设备运转正常 | 应用启动成功,点击setDownloadDelegate按钮 | 定义下载委托回调 | Yes | Pass |
+| startDownload() | 定义下载委托回调 | 使用startDownload按钮 | 发起一个下载,为Text组件更名 | Yes | Pass |
+
+#### ResumeDownload
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------- | ---------------- | ----------------------------------------- | -------------------------------- | -------- | -------- |
+| 使用Web组件的下载能力 | 设备运转正常 | 应用启动成功,点击setDownloadDelegate按钮 | 定义下载委托回调 | Yes | Pass |
+| startDownload() | 定义下载委托回调 | 使用startDownload按钮 | 发起一个下载,为Text组件更名 | Yes | Pass |
+| 记录下载任务信息 | 发起一个下载 | 点击record按钮 | 将当前下载任务保存至持久化文件中 | Yes | Pass |
+| 恢复下载任务 | 记录下载任务信息 | 点击recovery按钮 | 恢复下载任务 | Yes | Pass |
diff --git a/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png b/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..638d816041eeaa5df04c9ea8d9faed0a43c074a5
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_1.png differ
diff --git a/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png b/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..1126c64170901e237ae6a5c3189b61577afea4bc
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/InitiatingADownloadTask_2.png differ
diff --git a/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png b/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..da6c2b942cf47810384d06a6e68975a7e32c4ccf
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/ListenForPageDown_1.png differ
diff --git a/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png b/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..474253d8840f12efe2c581698a4a34878d3e5e03
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/ListenForPageDown_2.png differ
diff --git a/ManageWebPageFileIO/screenshots/ResumeDownload.png b/ManageWebPageFileIO/screenshots/ResumeDownload.png
new file mode 100644
index 0000000000000000000000000000000000000000..84aa81093ac4cbd3c800d30633ae81f8e96587aa
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/ResumeDownload.png differ
diff --git a/ManageWebPageFileIO/screenshots/UploadFiles_1.png b/ManageWebPageFileIO/screenshots/UploadFiles_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..83e3761eb2482a0bd2822c7624d49ed19e090809
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/UploadFiles_1.png differ
diff --git a/ManageWebPageFileIO/screenshots/UploadFiles_2.png b/ManageWebPageFileIO/screenshots/UploadFiles_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..1fa35a07316427ee7d43b791e721d0b634d985e9
Binary files /dev/null and b/ManageWebPageFileIO/screenshots/UploadFiles_2.png differ
diff --git a/ManageWebPageInteracts/.gitignore b/ManageWebPageInteracts/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageInteracts/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageInteracts/AppScope/app.json5 b/ManageWebPageInteracts/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..ce3d05eda7baad507acf0e8de81df905cdf32d67
--- /dev/null
+++ b/ManageWebPageInteracts/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.managewebpageinteracts",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageInteracts/AppScope/resources/base/element/string.json b/ManageWebPageInteracts/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..be8d935f6276f0e2833fde78d0f8320e6447b4f7
--- /dev/null
+++ b/ManageWebPageInteracts/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ManageWebPageInteracts"
+ }
+ ]
+}
diff --git a/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png b/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageInteracts/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageInteracts/README.md b/ManageWebPageInteracts/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..0802ff52bb78c2892693bfb7fd56a773022fbc23
--- /dev/null
+++ b/ManageWebPageInteracts/README.md
@@ -0,0 +1,151 @@
+# entry:
+
+## Web组件嵌套滚动
+
+### 介绍
+
+#### ImpNestedScroll
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-nested-scrolling.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+##### 效果预览
+
+| 主页 |
+| ---------------------------------------------------------- |
+| |
+
+##### 使用说明
+
+1. 设置滚动模式(前)
+ - 在 切换前滚动模式 区域,点击 SELF_ONLY、SELF_FIRST、PARENT_FIRST、PARALLEL 按钮,可分别将 NestedScrollModeF 设置为相应的滚动模式,此模式用于控制 Web 视图向前滚动(scrollForward)时与父组件的交互方式。
+2. 设置滚动模式(后)
+ - 在 切换后滚动模式 区域,同样点击上述按钮,可设置NestedScrollModeB,用于控制 Web 视图向后滚动(scrollBackward)时的交互模式。
+
+## Web组件对接软键盘
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-docking-softkeyboard.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### SetSKBMode_one
+
+##### 介绍
+
+1. 本示例主要介绍Web组件对接软键盘,在UIContext的键盘避让模式为Offset模式情况下,通过WebKeyboardAvoidMode()设置ArkWeb组件的键盘避让模式。
+
+##### 效果预览
+
+| 主页 | 软键盘 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击输入框拉起软键盘。
+
+#### OnIntKbdAttachSysCustIn
+
+##### 介绍
+
+1. 本示例主要介绍拦截系统软键盘与自定义软键盘输入,调用onInterceptKeyboardAttach来拦截系统软键盘的弹出。
+
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击未设置特殊属性的输入框,将默认使用系统默认键盘。
+2. 点击设置了keyboard-return属性的输入框,根据属性值获取对应的enterKeyType,以改变系统键盘回车键的行为。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---OnIntKbdAttachSysCustIn.ets
+|---|---|---SetSKBMode_one.ets
+|---|---|---ImpNestedScroll.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## entry2:
+
+### SetSKBMode_two
+
+#### 介绍
+
+1. 本示例主要介绍Web组件对接软键盘,设置UIContext的软键盘避让模式setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE),应用窗口高度可缩小避开软键盘,ArkWeb组件跟随ArkUI重新布局。
+
+#### 效果预览
+
+| 主页 | 软键盘 |
+| ----------------------------------------------------------- | ----------------------------------------------------------- |
+| | |
+
+使用说明
+
+1. 点击输入框拉起软键盘。
+
+### 工程目录
+
+```
+entry2/src/main/
+|---ets
+|---|---entry2ability
+|---|---|---Entry2Ability.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageInteracts > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageInteracts/build-profile.json5 b/ManageWebPageInteracts/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c00db5abef42d324e414e34ba929de407db76b8a
--- /dev/null
+++ b/ManageWebPageInteracts/build-profile.json5
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry2",
+ "srcPath": "./entry2",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/code-linter.json5 b/ManageWebPageInteracts/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageInteracts/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/.gitignore b/ManageWebPageInteracts/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageInteracts/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/build-profile.json5 b/ManageWebPageInteracts/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageInteracts/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/hvigorfile.ts b/ManageWebPageInteracts/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageInteracts/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageInteracts/entry/obfuscation-rules.txt b/ManageWebPageInteracts/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageInteracts/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/oh-package.json5 b/ManageWebPageInteracts/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageInteracts/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets b/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets
new file mode 100644
index 0000000000000000000000000000000000000000..502a4cc8780ad87d5ceff274637b369f27c1af63
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start nested_scrolling]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct NestedScroll {
+ private scrollerForScroll: Scroller = new Scroller();
+ controller: webview.WebviewController = new webview.WebviewController();
+ controller2: webview.WebviewController = new webview.WebviewController();
+ // NestedScrollMode设置成SELF_ONLY时,Web网页滚动到页面边缘后,不与父组件联动,父组件仍无法滚动。
+ @State nestedScrollMode0: NestedScrollMode = NestedScrollMode.SELF_ONLY;
+ // NestedScrollMode设置成SELF_FIRST时,Web网页滚动到页面边缘后,父组件继续滚动。
+ @State nestedScrollMode1: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ // NestedScrollMode设置为PARENT_FIRST时,父组件先滚动,滚动至边缘后通知Web继续滚动。
+ @State nestedScrollMode2: NestedScrollMode = NestedScrollMode.PARENT_FIRST;
+ // NestedScrollMode设置为PARALLEL时,父组件与Web同时滚动。
+ @State nestedScrollMode3: NestedScrollMode = NestedScrollMode.PARALLEL;
+ @State nestedScrollModeF: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ @State nestedScrollModeB: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ // scroll竖向的滚动
+ @State scrollDirection: ScrollDirection = ScrollDirection.Vertical;
+
+ build() {
+ Flex() {
+ Scroll(this.scrollerForScroll) {
+ Column({ space: 5 }) {
+ Row({}) {
+ Text('切换前滚动模式').fontSize(5)
+ Button('SELF_ONLY').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode0
+ }).fontSize(5)
+ Button('SELF_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode1
+ }).fontSize(5)
+ Button('PARENT_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode2
+ }).fontSize(5)
+ Button('PARALLEL').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode3
+ }).fontSize(5)
+ }
+
+ Row({}) {
+ Text('切换后滚动模式').fontSize(5)
+ Button('SELF_ONLY').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode0
+ }).fontSize(5)
+ Button('SELF_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode1
+ }).fontSize(5)
+ Button('PARENT_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode2
+ }).fontSize(5)
+ Button('PARALLEL').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode3
+ }).fontSize(5)
+ }
+
+ Text('当前内嵌前滚动模式 scrollForward ---' + `${this.nestedScrollModeF}`).fontSize(10)
+ Text('当前内嵌后滚动模式 scrollBackward ---' + `${this.nestedScrollModeB}`).fontSize(10)
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Web({ src: 'www.example.com', controller: this.controller })
+ .nestedScroll({
+ scrollForward: this.nestedScrollModeF,
+ scrollBackward: this.nestedScrollModeB,
+ })
+ .height('40%')
+ .width('100%')
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Web({ src: 'www.example.com', controller: this.controller2 })
+ .nestedScroll({
+ scrollForward: this.nestedScrollModeF,
+ scrollBackward: this.nestedScrollModeB,
+ })
+ .height('40%')
+ .width('90%')
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ }.width('95%').border({ width: 5 })
+ }
+ .width('100%').height('120%').border({ width: 5 }).scrollable(this.scrollDirection)
+ }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding(20)
+ }
+}
+// [End nested_scrolling]
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets b/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f9b6f41e802970502c50ee0ea64b70bc455da97a
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('ImpNestedScroll')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ImpNestedScroll' });
+ })
+ Button('OnIntKbdAttachSysCustIn')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnIntKbdAttachSysCustIn' });
+ })
+ Button('SetSKBMode_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/SetSKBMode_one' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets b/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ed6dd8f9d0e1e447a3f91400877713906f6e9d57
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start soft_keyboard_web]
+import { webview } from '@kit.ArkWeb';
+import { inputMethodEngine } from '@kit.IMEKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ webKeyboardController: WebKeyboardController = new WebKeyboardController();
+ inputAttributeMap: Map = new Map([
+ ['UNSPECIFIED', inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED],
+ ['GO', inputMethodEngine.ENTER_KEY_TYPE_GO],
+ ['SEARCH', inputMethodEngine.ENTER_KEY_TYPE_SEARCH],
+ ['SEND', inputMethodEngine.ENTER_KEY_TYPE_SEND],
+ ['NEXT', inputMethodEngine.ENTER_KEY_TYPE_NEXT],
+ ['DONE', inputMethodEngine.ENTER_KEY_TYPE_DONE],
+ ['PREVIOUS', inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS]
+ ]);
+
+ /**
+ * 自定义键盘组件Builder
+ */
+ @Builder
+ customKeyboardBuilder() {
+ // 这里实现自定义键盘组件,对接WebKeyboardController实现输入、删除、关闭等操作。
+ Row() {
+ Text('finish')
+ .fontSize(20)
+ .fontColor(Color.Blue)
+ .onClick(() => {
+ this.webKeyboardController.close();
+ })
+ // 插入字符。
+ Button('insertText').onClick(() => {
+ this.webKeyboardController.insertText('insert ');
+ }).margin({
+ bottom: 200,
+ });
+ // 从后往前删除length参数指定长度的字符。
+ Button('deleteForward').onClick(() => {
+ this.webKeyboardController.deleteForward(1);
+ }).margin({
+ bottom: 200,
+ });
+ // 从前往后删除length参数指定长度的字符。
+ Button('deleteBackward').onClick(() => {
+ this.webKeyboardController.deleteBackward(1);
+ }).margin({
+ left: -220,
+ });
+ // 插入功能按键。
+ Button('sendFunctionKey').onClick(() => {
+ this.webKeyboardController.sendFunctionKey(6);
+ })
+ }
+ }
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('index.html'), controller: this.controller })
+ .onInterceptKeyboardAttach((keyBoardCallBackInfo) => {
+ // option初始化,默认使用系统默认键盘
+ let option: WebKeyboardOptions = {
+ useSystemKeyboard: true,
+ };
+ if (!keyBoardCallBackInfo) {
+ return option;
+ }
+
+ // 保存WebKeyboardController,使用自定义键盘时候,需要使用该handler控制输入、删除、软键盘关闭等行为
+ this.webKeyboardController = keyBoardCallBackInfo.controller;
+ let attributes: Record = keyBoardCallBackInfo.attributes;
+ // 遍历attributes
+ let attributeKeys = Object.keys(attributes);
+ for (let i = 0; i < attributeKeys.length; i++) {
+ console.log('WebCustomKeyboard key = ' + attributeKeys[i] + ', value = ' + attributes[attributeKeys[i]]);
+ }
+
+ if (attributes) {
+ if (attributes['data-keyboard'] == 'customKeyboard') {
+ // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有data-keyboard,且值为customKeyboard,则使用自定义键盘
+ console.log('WebCustomKeyboard use custom keyboard');
+ option.useSystemKeyboard = false;
+ // 设置自定义键盘builder
+ option.customKeyboard = () => {
+ this.customKeyboardBuilder();
+ }
+ return option;
+ }
+
+ if (attributes['keyboard-return'] != undefined) {
+ // 根据html可编辑元素的属性,判断使用不同的软键盘,例如这里如果属性包含有keyboard-return,使用系统键盘,并且指定系统软键盘enterKey类型
+ option.useSystemKeyboard = true;
+ let enterKeyType: number | undefined = this.inputAttributeMap.get(attributes['keyboard-return']);
+ if (enterKeyType != undefined) {
+ option.enterKeyType = enterKeyType;
+ }
+ return option;
+ }
+ }
+
+ return option;
+ })
+ }
+ }
+}
+// [End soft_keyboard_web]
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets b/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9d04e9146f1c3eaa821bebc51a94f07561961b2c
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/ets/pages/SetSKBMode_one.ets
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start soft_keyboard_setmode]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct KeyboardAvoidExample {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Row().height('50%').width('100%').backgroundColor(Color.Gray)
+ Web({ src: $rawfile('SetSKBModeIndex.html'), controller: this.controller })
+ .keyboardAvoidMode(WebKeyboardAvoidMode.OVERLAYS_CONTENT) //此时ArkWeb组件不会调整任何视口的大小大小
+ Text('I can see the bottom of the page')
+ .width('100%')
+ .textAlign(TextAlign.Center)
+ .backgroundColor(Color.Pink)
+ .layoutWeight(1)
+ }.width('100%').height('100%')
+ }
+}
+// [End soft_keyboard_setmode]
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/module.json5 b/ManageWebPageInteracts/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json b/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json b/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..a660c237c2319d4f72e68f5c1caafb9fb065b72c
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageInteracts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png b/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageInteracts/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png b/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageInteracts/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageInteracts/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..08d6cd1a732e2be0fea3683042318567db9eb26f
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,8 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/ImpNestedScroll",
+ "pages/OnIntKbdAttachSysCustIn",
+ "pages/SetSKBMode_one"
+ ]
+}
diff --git a/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json b/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..a660c237c2319d4f72e68f5c1caafb9fb065b72c
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageInteracts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html b/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html
new file mode 100644
index 0000000000000000000000000000000000000000..61538c5f011d7b79e613fa0ff14c35ff008e246a
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/rawfile/SetSKBModeIndex.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 测试网页
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key UNSPECIFIED:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key GO:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key SEARCH:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key SEND:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key NEXT:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key DONE:
+
+
+
+
input标签,系统键盘自定义enterKeyType属性 enter key PREVIOUS:
+
+
+
+
input标签,应用自定义键盘:
+
+
+
+
+
diff --git a/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..dce1868b4c1a653b60d10f637996503b2b90d241
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageInteracts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/mock/mock-config.json5 b/ManageWebPageInteracts/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..89cfee09caf5b351f7709a00a4b92931e68ed55d
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 ImpNestedScroll 按钮
+ * 设置滚动模式
+ */
+ it('ImpNestedScroll', 0, async (done: Function) => {
+ console.info('uitest: ImpNestedScroll begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('ImpNestedScroll'));
+ await button1.click();
+ await driver.delayMs(500);
+
+ const button2 = await driver.findComponent(ON.text('SELF_ONLY'));
+ await button2.click();
+ await driver.delayMs(500);
+
+ const button3 = await driver.findComponent(ON.text('SELF_FIRST'));
+ await button3.click();
+ await driver.delayMs(500);
+
+ const button4 = await driver.findComponent(ON.text('PARENT_FIRST'));
+ await button4.click();
+ await driver.delayMs(500);
+
+ const button5 = await driver.findComponent(ON.text('PARALLEL'));
+ await button5.click();
+ await driver.delayMs(500);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('www.example.com');
+
+ await driver.pressBack();
+ console.info('uitest: ImpNestedScroll end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 OnIntKbdAttachSysCustIn 按钮
+ * 调用onInterceptKeyboardAttach来拦截系统软键盘的弹出
+ */
+ it('OnIntKbdAttachSysCustIn', 0, async (done: Function) => {
+ console.info('uitest: OnIntKbdAttachSysCustIn begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('OnIntKbdAttachSysCustIn'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const input1 = await driver.findComponent(ON.clickable(true).enabled(true));
+ await input1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index.html');
+
+ await driver.pressBack();
+ await driver.pressBack();
+ console.info('uitest: OnIntKbdAttachSysCustIn end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 SetSKBMode_one 按钮
+ * 设置ArkWeb组件的键盘避让模式
+ */
+ it('SetSKBMode_one', 0, async (done: Function) => {
+ console.info('uitest: SetSKBMode_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('SetSKBMode_one'));
+ await button1.click();
+ await driver.delayMs(2000);
+
+ const input1 = await driver.findComponent(ON.clickable(true).enabled(true));
+ await input1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('SetSKBModeIndex.html');
+
+ await driver.pressBack();
+ console.info('uitest: SetSKBMode_one end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/ohosTest/module.json5 b/ManageWebPageInteracts/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageInteracts/entry/src/test/List.test.ets b/ManageWebPageInteracts/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets b/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageInteracts/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/.gitignore b/ManageWebPageInteracts/entry2/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/build-profile.json5 b/ManageWebPageInteracts/entry2/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9edfdf8c4a72db3313433e7366df25b6beb1c3a7
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/hvigorfile.ts b/ManageWebPageInteracts/entry2/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageInteracts/entry2/obfuscation-rules.txt b/ManageWebPageInteracts/entry2/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/oh-package.json5 b/ManageWebPageInteracts/entry2/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2944307304532e967f4956384cc91447f2c9bf8c
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "name": "entry2",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f7cf84b7a4732e1e1512ce7602c303c116cd4fc6
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window, KeyboardAvoidMode } from '@kit.ArkUI';
+
+export default class Entry2Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ // [Start soft_keyboard_entryability]
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ let keyboardAvoidMode = windowStage.getMainWindowSync().getUIContext().getKeyboardAvoidMode();
+ // 设置虚拟键盘抬起时压缩页面大小为减去键盘的高度
+ windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE);
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ // [End soft_keyboard_entryability]
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f9a6b459004e1f1d0aefe9350f2c2ee907f66ff3
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class Entry2BackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets b/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ac257ec08718a4fe4c8f383f07aa413a1bb8e6c3
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/ets/pages/Index.ets
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start soft_keyboard_index]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct KeyboardAvoidExample {
+ controller: webview.WebviewController = new webview.WebviewController();
+ build() {
+ Column() {
+ Row().height('50%').width('100%').backgroundColor(Color.Gray)
+ Web({ src: $rawfile('index.html'),controller: this.controller})
+ Text('I can see the bottom of the page').width('100%').textAlign(TextAlign.Center).backgroundColor(Color.Pink).layoutWeight(1)
+ }.width('100%').height('100%')
+ }
+}
+// [End soft_keyboard_index]
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/module.json5 b/ManageWebPageInteracts/entry2/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..7ef3d746a37c973a35599267383dee3b96d7eddb
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/module.json5
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "module": {
+ "name": "entry2",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "Entry2Ability",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry2Ability",
+ "srcEntry": "./ets/entry2ability/Entry2Ability.ets",
+ "description": "$string:Entry2Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry2Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "Entry2BackupAbility",
+ "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json b/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json b/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2098765bde8417c3acfa9fd16eecdbdf37cba011
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry2Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry2Ability_label",
+ "value": "ManageWebPageInteracts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png b/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageInteracts/entry2/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png b/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageInteracts/entry2/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json b/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png b/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageInteracts/entry2/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json b/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json b/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html b/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..4699c0c00f733ad2b5675eaf7e9898c61d3e0700
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/main/resources/rawfile/index.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 测试网页
+
+
+
DEMO
+
+
+
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/mock/mock-config.json5 b/ManageWebPageInteracts/entry2/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2417dae33e86618dcf41b9c0c0f2835b30e47b34
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..2fe0b328f2c2ffec62bdd561344aa5ef4911dae0
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 UploadFiles 按钮
+ * 设置UIContext的软键盘避让模式
+ */
+ it('TestUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry2Ability'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry2Ability');
+ await driver.delayMs(5000);
+
+ const input1 = await driver.findComponent(ON.clickable(true).enabled(true));
+ await input1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index.html');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets b/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/ohosTest/module.json5 b/ManageWebPageInteracts/entry2/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..def0d923e01bc24b31568e4855ae4f6989f5f017
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/ohosTest/module.json5
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "module": {
+ "name": "entry2_test",
+ "type": "feature",
+ "deviceTypes": [
+ "phone",
+ "2in1",
+ "car"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/test/List.test.ets b/ManageWebPageInteracts/entry2/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets b/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageInteracts/entry2/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageInteracts/hvigor/hvigor-config.json5 b/ManageWebPageInteracts/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageInteracts/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageInteracts/hvigorfile.ts b/ManageWebPageInteracts/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageInteracts/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageInteracts/oh-package.json5 b/ManageWebPageInteracts/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageInteracts/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageInteracts/ohosTest.md b/ManageWebPageInteracts/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..5e7e391d23ad1648fb318f86edf186312263fb1b
--- /dev/null
+++ b/ManageWebPageInteracts/ohosTest.md
@@ -0,0 +1,31 @@
+## entry:
+
+### ImpNestedScroll
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ---------------------------------------- | ------------------------------- | ------------------------------------------------------------ | -------- | -------- |
+| Web组件嵌套滚动 | 设备运转正常,example.com 页面可正常访问 | 应用启动成功,点击SELF_ONLY按钮 | 当前内嵌前滚动模式 scrollForward ---NestedScrollMode.SELF_ONLY | Yes | Pass |
+| 设置滚动模式(前) | 设备运转正常,example.com 页面可正常访问 | 点击SELF_FIRST按钮 | 当前内嵌前滚动模式 scrollForward ---NestedScrollMode.SELF_FIRST | Yes | Pass |
+| 设置滚动模式(前) | 设备运转正常,example.com 页面可正常访问 | 点击PARENT_FIRST按钮 | 当前内嵌前滚动模式 scrollForward ---NestedScrollMode.PARENT_FIRST | Yes | Pass |
+| 设置滚动模式(前) | 设备运转正常,example.com 页面可正常访问 | 点击PARALLEL 按钮 | 当前内嵌前滚动模式 scrollForward ---NestedScrollMode.PARALLEL | Yes | Pass |
+
+### OnIntKbdAttachSysCustIn
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| -------------------------------- | ------------ | ------------------------ | -------- | -------- | -------- |
+| 拦截系统软键盘与自定义软键盘输入 | 设备运转正常 | 应用启动成功,点击输入框 | 弹出键盘 | Yes | Pass |
+
+### SetSKBMode_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ---------------------------------- | -------------------------- | -------- | -------- |
+| Web组件对接软键盘 | 设备运转正常 | 应用启动成功,点击输入框拉起软键盘 | 应用窗口高度缩小避开软键盘 | Yes | Pass |
+
+## entry2:
+
+### SetSKBMode_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ---------------------------------- | -------------------------- | -------- | -------- |
+| Web组件对接软键盘 | 设备运转正常 | 应用启动成功,点击输入框拉起软键盘 | 应用窗口高度缩小避开软键盘 | Yes | Pass |
+
diff --git a/ManageWebPageInteracts/screenshots/ImpNestedScroll.png b/ManageWebPageInteracts/screenshots/ImpNestedScroll.png
new file mode 100644
index 0000000000000000000000000000000000000000..bfb841ff5c9ef3f4b33df5f9bf8c2fef6c20dd60
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/ImpNestedScroll.png differ
diff --git a/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png b/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png
new file mode 100644
index 0000000000000000000000000000000000000000..0bdd2dc4c67bcee1b60eb0f6d98c2ab19c74bcdb
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/OnIntKbdAttachSysCustIn.png differ
diff --git a/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png b/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..435149dcebea920a056e829852f1c9906f142aa0
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/SetSKBMode_one_1.png differ
diff --git a/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png b/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..a4056bf1dc11cc4b1fc8972ad486b0b770d2334a
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/SetSKBMode_one_2.png differ
diff --git a/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png b/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..7e7edaa392c118a336f7ecc67550a9071a640000
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/SetSKBMode_two_1.png differ
diff --git a/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png b/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..78452f56bd471af2e1b138629e31f3f82156287a
Binary files /dev/null and b/ManageWebPageInteracts/screenshots/SetSKBMode_two_2.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b0c7bc7d9468973a02c86fae0a80050c9598dcc2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.acceleratepageaccess",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..09408da82ddf7aa37250665e2742bc8e2069dc22
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AcceleratePageAccess"
+ }
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md b/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..283f29112585c46d279ff5b6b832616162c71833
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md
@@ -0,0 +1,253 @@
+# 加速Web页面的访问
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-predictor.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### Entry:
+
+#### PrepareForPageLoad_one
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,可以通过prepareForPageLoad()来预解析或者预连接将要加载的页面。
+
+##### 效果预览
+
+| 主页 | loadDate |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 在Web组件的onAppear中对要加载的页面进行预连接。
+1. 点击超链接跳转下一界面。
+1. 点击loadData按钮返回上个界面。
+
+### Entry1:
+
+#### PrepareForPageLoad_two
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,可以通过initializeBrowserEngine()来提前初始化内核,然后在初始化内核后调用 prepareForPageLoad()对即将要加载的页面进行预解析、预连接。
+##### 效果预览
+
+| 主页 | loadDate |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. Ability的onCreate中提前初始化Web内核并对首页进行预连接。
+
+### Entry2:
+
+#### Prefetching
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,如果能够预测到Web组件将要加载的页面或者即将要跳转的页面,可以通过prefetchPage()来预加载即将要加载页面。
+
+##### 效果预览
+
+| 主页 |
+| -------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 在onPageEnd的时候触发下一个要访问的页面的预加载。
+
+#### PrefetchingAPOSTRequest_one
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,通过prefetchResource()预获取将要加载页面中的post请求。在页面加载结束时,可以通过clearPrefetchedResource()清除后续不再使用的预获取资源缓存。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 对要加载页面中的post请求进行预获取。在onPageEnd中,可以清除预获取的post请求缓存。
+
+#### PrefetchingAPOSTRequest_two
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,如果能够预测到Web组件将要加载页面或者即将要跳转页面中的post请求。可以通过prefetchResource()预获取即将要加载页面的post请求。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 在onPageEnd中,触发预获取一个要访问页面的post请求。
+
+#### PrefetchingAPOSTRequest_three
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,通过initializeBrowserEngine()提前初始化内核,然后在初始化内核后调用prefetchResource()预获取将要加载页面中的post请求。这种方式适合提前预获取首页的post请求。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 在Ability的onCreate中,提前初始化Web内核并预获取首页的post请求。
+
+### Entry3:
+
+#### PrecompForCompCache
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,通过precompileJavaScript()在页面加载前提前生成脚本文件的编译缓存。
+
+##### 效果预览
+
+| 主页 | 加载页面 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 应用启动时EntryAbility将UIContext存到localstorage,初始化预编译Web组件生成编译缓存。
+2. 点击加载页面按钮,创建businessNode,加载业务用Web组件展示business.html页面,此时会使用之前生成的编译缓存。
+
+### Entry4:
+
+#### InjOffResNoInt
+
+##### 介绍
+
+1. 本示例主要介绍加速Web页面的访问,可以通过injectOfflineResources()在页面加载前提前将图片、样式表或脚本资源注入到应用的内存缓存中。
+
+##### 效果预览
+
+| 主页 | 加载页面 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 进入Index.ets页面自动触发aboutToAppear方法。
+2. 点击加载页面按钮创建businessNode,加载业务用Web组件,展示business.html页面。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+
+entry1/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+
+entry2/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---Prefetching.ets
+|---|---|---PrefetchingAPOSTRequest_one.ets
+|---|---|---PrefetchingAPOSTRequest_three.ets
+|---|---|---PrefetchingAPOSTRequest_two.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+
+entry3/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---BusinessWebview.ets
+|---|---|---DynamicComponent.ets
+|---|---|---Index.ets // 首页
+|---|---|---PrecompileConfig.ets
+|---|---|---Precompile Webview.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+
+entry4/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---BusinessWebview.ets
+|---|---|---DynamicComponent.ets
+|---|---|---Index.ets // 首页
+|---|---|---Inject Webview.ets
+|---|---|---Resource.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..91a9926d9991ebd0faf86984be0a7f95893101df
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry1",
+ "srcPath": "./entry1",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry2",
+ "srcPath": "./entry2",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry3",
+ "srcPath": "./entry3",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry4",
+ "srcPath": "./entry4",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..6bf0e4fed027a57256e805bbbeb305052bb0b4be
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadData')
+ .onClick(() => {
+ if (this.webviewController.accessBackward()) {
+ this.webviewController.backward();
+ }
+ })
+ Web({ src: resourceToString($r('app.string.web_path_one')), controller: this.webviewController })
+ .onAppear(() => {
+ // 指定第二个参数为true,代表要进行预连接,如果为false该接口只会对网址进行dns预解析
+ // 第三个参数为要预连接socket的个数。最多允许6个。
+ webview.WebviewController.prepareForPageLoad(resourceToString($r('app.string.web_path_one')), true, 2);
+ })
+ }
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..65e6e287e05d404b31a376c49615635f654367cf
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "AcceleratePageAccess"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ },
+ {
+ "name": "web_path_one",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0838a23893a22a87feea786664077715b79cf52e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "AcceleratePageAccess"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..5fd56f1eb0b9b271fbe3be4dc307c05d954eee7b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "AcceleratePageAccess"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4387b1d1e8e1e4e55c8e53794278b34203de2801
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 预解析或者预连接将要加载的页面
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(3000);
+
+ const clickText = await driver.findComponent(ON.type('link'));
+ await clickText.click();
+ await driver.delayMs(3000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c4e8768835e5e869bbd19dfb80d2e323afaa6f2d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry1",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3377c9ffaec9f544b5a916055d599c55761194c0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start initialize_kernel_in_onCreate_and_pre_connect_to_homepage]
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+import { webview } from '@kit.ArkWeb';
+
+export default class Entry1Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ console.log('EntryAbility onCreate');
+ webview.WebviewController.initializeWebEngine();
+ // 预连接时,需要將'https://www.example.com'替换成真实要访问的网站地址。
+
+ webview.WebviewController.prepareForPageLoad(this.context.resourceManager.getStringSync($r('app.string.web_path_one')), true, 2);
+ AppStorage.setOrCreate('abilityWant', want);
+ console.log('EntryAbility onCreate done');
+ }
+
+ // [StartExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage]
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+ // [EndExclude initialize_kernel_in_onCreate_and_pre_connect_to_homepage]
+}
+// [End initialize_kernel_in_onCreate_and_pre_connect_to_homepage]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1a2fe4d9484543336d2e6c7bfce18192eb7278aa
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start previously_connect_in_onAppear_to_pages_being_loaded]
+import { webview } from '@kit.ArkWeb';
+// [StartExclude previously_connect_in_onAppear_to_pages_being_loaded]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude previously_connect_in_onAppear_to_pages_being_loaded]
+
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadData')
+ .onClick(() => {
+ if (this.webviewController.accessBackward()) {
+ this.webviewController.backward();
+ }
+ })
+ Web({ src: $r('app.string.web_path_one'), controller: this.webviewController })
+ .onAppear(() => {
+ // 指定第二个参数为true,代表要进行预连接,如果为false该接口只会对网址进行dns预解析
+ // 第三个参数为要预连接socket的个数。最多允许6个。
+ webview.WebviewController.prepareForPageLoad(resourceToString($r('app.string.web_path_one')), true, 2);
+ })
+ }
+ }
+}
+//[End previously_connect_in_onAppear_to_pages_being_loaded]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5303c59d21b19cfd2c0a4299ec6ea72fede11eba
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry1",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry1Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry1Ability",
+ "srcEntry": "./ets/entry1ability/Entry1Ability.ets",
+ "description": "$string:Entry1Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry1Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..76a37f8e3d89782b8d1c1215279ecf96c008d58e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry1Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry1Ability_label",
+ "value": "AcceleratePageAccess"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ },
+ {
+ "name": "web_path_one",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..92f3212a1bf7d5c1936e398fec3c79bdf642d910
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 对即将要加载的页面进行预解析、预连接
+ */
+ it('TestUiExample', 0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry1Ability'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry1Ability');
+ await driver.delayMs(3000);
+
+ const clickText = await driver.findComponent(ON.type('link'));
+ await clickText.click();
+ await driver.delayMs(5000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..a8392c11cf0dbecb4cdc78dc93d456a3a8e6ff41
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry1_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6f8ebfffe80a99a9743e76a638cdd63c2b6ec72f
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry2",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dab8f3ea7260551b9dc6606eb397e396d241e701
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class Entry2Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e330ef4623eab184383297cf399532844448f58c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('Prefetching')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Prefetching' });
+ })
+ Button('PrefetchingAPOSTRequest_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/PrefetchingAPOSTRequest_one' });
+ })
+ Button('PrefetchingAPOSTRequest_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/PrefetchingAPOSTRequest_two' });
+ })
+ Button('PrefetchingAPOSTRequest_three')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/PrefetchingAPOSTRequest_three' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets
new file mode 100644
index 0000000000000000000000000000000000000000..57d3b8e6e3b826c4740f5812e69e7138d2f89cd5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start on_page_end_triggers_preload_of_next_page]
+import { webview } from '@kit.ArkWeb';
+// [StartExclude on_page_end_triggers_preload_of_next_page]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude on_page_end_triggers_preload_of_next_page]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: 'www.example.com', controller: this.webviewController })
+ .onPageEnd(() => {
+ // 预加载https://www.iana.org/help/example-domains。
+ this.webviewController.prefetchPage(resourceToString($r('app.string.domains_path')));
+ })
+ }
+ }
+}
+// [End on_page_end_triggers_preload_of_next_page]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7440060a2fd78d48fb53e4ed48817f9a21855879
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//[Start prefetch_post_request_on_page_end_clear_cache]
+import { webview } from '@kit.ArkWeb';
+// [StartExclude prefetch_post_request_on_page_end_clear_cache]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude prefetch_post_request_on_page_end_clear_cache]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $r('app.string.web_path'), controller: this.webviewController})
+ .onAppear(() => {
+ // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。
+ webview.WebviewController.prefetchResource(
+ {url:resourceToString($r('app.string.post_path')),
+ method:'POST',
+ formData:'a=x&b=y',},
+ [{headerKey:'c',
+ headerValue:'z',},],
+ 'KeyX', 500);
+ })
+ .onPageEnd(() => {
+ // 清除后续不再使用的预获取资源缓存。
+ webview.WebviewController.clearPrefetchedResource(['KeyX',]);
+ })
+ }
+ }
+}
+//[End prefetch_post_request_on_page_end_clear_cache]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b5b280f4b561f8638c51c5247704d1e179a6193f
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start on_page_end_trigger_prefetch_post_request_access_page]
+import { webview } from '@kit.ArkWeb';
+// [StartExclude on_page_end_trigger_prefetch_post_request_access_page]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude on_page_end_trigger_prefetch_post_request_access_page]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $r('app.string.web_path'), controller: this.webviewController})
+ .onPageEnd(() => {
+ // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。
+ webview.WebviewController.prefetchResource(
+ {url:resourceToString($r('app.string.web_path')) + '/post?e=f&g=h',
+ method:'POST',
+ formData:'a=x&b=y',},
+ [{headerKey:'c',
+ headerValue:'z',},],
+ 'KeyX', 500);
+ })
+ }
+ }
+}
+//[End on_page_end_trigger_prefetch_post_request_access_page]
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..bf09aea7ff25030baf584fd14c09ade89265977c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start initialize_kernel_in_onCreate_and_pre_fetch_post_request]
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $r('app.string.web_path'), controller: this.webviewController})
+ .onPageEnd(() => {
+ // 预获取时,需要將'https://www.example1.com/post?e=f&g=h'替换成真实要访问的网站地址。
+ webview.WebviewController.prefetchResource(
+ {url:resourceToString($r('app.string.post_path')),
+ method:'POST',
+ formData:'a=x&b=y',},
+ [{headerKey:'c',
+ headerValue:'z',},],
+ 'KeyX', 500);
+ })
+ }
+ }
+}
+// [End initialize_kernel_in_onCreate_and_pre_fetch_post_request]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..7c87a975ff65dac27497e22e35d2efa530f8064f
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry2Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry2Ability",
+ "srcEntry": "./ets/entry2ability/Entry2Ability.ets",
+ "description": "$string:Entry2Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry2Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b363550515903b8badcdcbf12d372a6791349190
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry2Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry2Ability_label",
+ "value": "AcceleratePageAccess"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ },
+ {
+ "name": "domains_path",
+ "value": "https://www.iana.org/help/example-domains"
+ },
+ {
+ "name": "post_path",
+ "value": "https://www.example1.com/post?e=f&g=h"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1c4e7fcde829651559470084dc4c22f2f3c88b58
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/Prefetching",
+ "pages/PrefetchingAPOSTRequest_one",
+ "pages/PrefetchingAPOSTRequest_two",
+ "pages/PrefetchingAPOSTRequest_three"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4ad971c822e74f7fa1ac058671ad091bc5bf2497
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 Prefetching 按钮
+ * 通过 prefetchPage 来预加载即将要加载页面
+ */
+ it('Prefetching', 0, async (done: Function) => {
+ console.info('uitest: Prefetching begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry2Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry2Ability');
+ await driver.delayMs(3000);
+
+ const button1 = await driver.findComponent(ON.text('Prefetching'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: Prefetching end');
+ done();
+ });
+
+ /*
+ * 点击 PrefetchingAPOSTRequest_one 按钮
+ * 预获取将要加载页面中的post请求
+ * 在页面加载结束时,清除后续不再使用的预获取资源缓存
+ */
+ it('PrefetchingAPOSTRequest_one', 0, async (done: Function) => {
+ console.info('uitest: PrefetchingAPOSTRequest_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('PrefetchingAPOSTRequest_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: PrefetchingAPOSTRequest_one end');
+ done();
+ });
+
+ /*
+ * 点击 PrefetchingAPOSTRequest_two 按钮
+ * 通过 prefetchResource 预获取即将要加载页面的post请求
+ */
+ it('PrefetchingAPOSTRequest_two', 0, async (done: Function) => {
+ console.info('uitest: PrefetchingAPOSTRequest_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('PrefetchingAPOSTRequest_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: PrefetchingAPOSTRequest_two end');
+ done();
+ });
+
+ /*
+ * 点击 PrefetchingAPOSTRequest_three 按钮
+ * 在初始化内核后调用 prefetchResource 预获取将要加载页面中的post请求
+ */
+ it('PrefetchingAPOSTRequest_three', 0, async (done: Function) => {
+ console.info('uitest: PrefetchingAPOSTRequest_three begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('PrefetchingAPOSTRequest_three'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: PrefetchingAPOSTRequest_three end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..031b54bde39f1b8ca1884b863026dbc91fd5a75a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..655d244a4ec5c8e387d7ebfb66967132c8c952f6
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry3",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..407cf0869b146854e930d446181307ab937540b9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start save_the_uiContext_to_localstorage_in_entry_ability]
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { window } from '@kit.ArkUI';
+// [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+import { hilog } from '@kit.PerformanceAnalysisKit';
+// [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+
+const localStorage: LocalStorage = new LocalStorage('uiContext');
+
+export default class Entry3Ability extends UIAbility {
+ public storage: LocalStorage = localStorage;
+ // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+ // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+ // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ windowStage.loadContent('pages/Index', this.storage, (err, data) => {
+ if (err.code) {
+ return;
+ }
+
+ this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext());
+ });
+ }
+
+ // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+ // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+ // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ // [StartExclude save_the_uiContext_to_localstorage_in_entry_ability]
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+ // [EndExclude save_the_uiContext_to_localstorage_in_entry_ability]
+}
+// [End save_the_uiContext_to_localstorage_in_entry_ability]
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets
new file mode 100644
index 0000000000000000000000000000000000000000..510e5960466050eb2ef8f19cb9f7b22a3addf5b5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start write_code_for_business_components]
+import { BuilderData } from './DynamicComponent';
+
+@Builder
+function webBuilder(data: BuilderData) {
+ // 此处组件可根据业务需要自行扩展
+ Web({ src: data.url, controller: data.controller })
+ .cacheMode(CacheMode.Default)
+}
+
+export const businessWebview = wrapBuilder(webBuilder);
+// [End write_code_for_business_components]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d0fc29ad852969d54cf5a1db9efafdd369dd7c60
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start underlying_code_required_for_dynamic_components]
+import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI';
+
+export interface BuilderData {
+ url: string;
+ controller: WebviewController;
+}
+
+const storage = LocalStorage.getShared();
+
+export class NodeControllerImpl extends NodeController {
+ private rootNode: BuilderNode | null = null;
+ private wrappedBuilder: WrappedBuilder | null = null;
+
+ constructor(wrappedBuilder: WrappedBuilder) {
+ super();
+ this.wrappedBuilder = wrappedBuilder;
+ }
+
+ makeNode(): FrameNode | null {
+ if (this.rootNode != null) {
+ return this.rootNode.getFrameNode();
+ }
+ return null;
+ }
+
+ initWeb(url: string, controller: WebviewController) {
+ if(this.rootNode != null) {
+ return;
+ }
+
+ const uiContext: UIContext = storage.get('uiContext') as UIContext;
+ if (!uiContext) {
+ return;
+ }
+ this.rootNode = new BuilderNode(uiContext);
+ this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller });
+ }
+}
+
+export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => {
+ const baseNode = new NodeControllerImpl(wrappedBuilder);
+ baseNode.initWeb(data.url, data.controller);
+ return baseNode;
+}
+// [End underlying_code_required_for_dynamic_components]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..434a2ccf53015a2a93e547b040e2a60058c0afb8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start dynamic_webview_component_loading]
+import { webview } from '@kit.ArkWeb';
+import { NodeController } from '@kit.ArkUI';
+import { createNode } from "./DynamicComponent";
+import { precompileWebview } from "./PrecompileWebview";
+import { businessWebview } from "./BusinessWebview";
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct Index {
+ @State precompileNode: NodeController | undefined = undefined;
+ precompileController: webview.WebviewController = new webview.WebviewController();
+
+ @State businessNode: NodeController | undefined = undefined;
+ businessController: webview.WebviewController = new webview.WebviewController();
+
+ aboutToAppear(): void {
+ // 初始化用于注入本地资源的Web组件
+ this.precompileNode = createNode(precompileWebview,
+ { url: resourceToString($r('app.string.web_path_one')) + 'empty.html', controller: this.precompileController});
+ }
+
+ build() {
+ Column() {
+ // 在适当的时机加载业务用Web组件,本例以Button点击触发为例
+ Button('加载页面')
+ .onClick(() => {
+ this.businessNode = createNode(businessWebview, {
+ url: resourceToString($r('app.string.web_path_one')) + 'business.html',
+ controller: this.businessController
+ });
+ })
+ // 用于业务的Web组件
+ NodeContainer(this.businessNode);
+ }
+ }
+}
+// [End dynamic_webview_component_loading]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets
new file mode 100644
index 0000000000000000000000000000000000000000..75d2750e83bb4114e32dd9ca2339ef17b9ee0e0d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start compile_resource_allocation_information]
+import { webview } from '@kit.ArkWeb'
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+export interface Config {
+ url: string,
+ localPath: string, // 本地资源路径
+ options: webview.CacheOptions
+}
+
+export let configs: Config[] = [
+ {
+ url: resourceToString($r('app.string.web_path')),
+ localPath: 'example.js',
+ options: {
+ responseHeaders: [
+ { headerKey: 'E-Tag', headerValue: 'aWO42N9P9dG/5xqYQCxsx+vDOoU='},
+ { headerKey: 'Last-Modified', headerValue: 'Wed, 21 Mar 2025 10:38:41 GMT'}
+ ]
+ }
+ }
+]
+// [End compile_resource_allocation_information]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets
new file mode 100644
index 0000000000000000000000000000000000000000..6be26765077a847037648081f343b359a30ad7a7
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start read_local_js_resource_from_rawfile_dir_via_file_api]
+import { BuilderData } from './DynamicComponent';
+import { Config, configs } from './PrecompileConfig';
+
+@Builder
+function webBuilder(data: BuilderData) {
+ Web({ src: data.url, controller: data.controller })
+ .onControllerAttached(() => {
+ precompile(data.controller, configs);
+ })
+ .fileAccess(true)
+}
+
+export const precompileWebview = wrapBuilder(webBuilder);
+
+export const precompile = async (controller: WebviewController, configs: Array) => {
+ for (const config of configs) {
+ let content = await readRawFile(config.localPath);
+
+ try {
+ controller.precompileJavaScript(config.url, content, config.options)
+ .then(errCode => {
+ console.error('precompile successfully! ' + errCode);
+ }).catch((errCode: number) => {
+ console.error('precompile failed. ' + errCode);
+ });
+ } catch (err) {
+ console.error('precompile failed. ' + err.code + ' ' + err.message);
+ }
+ }
+}
+
+async function readRawFile(path: string) {
+ try {
+ return await getContext().resourceManager.getRawFileContent(path);;
+ } catch (err) {
+ return new Uint8Array(0);
+ }
+}
+// [End read_local_js_resource_from_rawfile_dir_via_file_api]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5566c38cae3156d6470062ff659b9f0a54160541
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry3Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry3Ability",
+ "srcEntry": "./ets/entry3ability/Entry3Ability.ets",
+ "description": "$string:Entry3Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry3Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..6894c74192e3a04b77939f14374213985e80eedb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry3Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry3Ability_label",
+ "value": "AcceleratePageAccess"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/example.js"
+ },
+ {
+ "name": "web_path_one",
+ "value": "https://www.example.com/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7216209578b1a72626a3341d0f398fcd2b454688
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 通过 precompileJavaScript 在页面加载前提前生成脚本文件的编译缓存
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry3Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry3Ability');
+ await driver.delayMs(3000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edaba8aaabfc3819914b5d624d6d0143e85b5b86
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..ac50b7be8601621317e98fd352affe020e0897c7
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry4",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8ab5d17a3c7efdffe8b5fa34e9aec4f7ce9237c0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start save_uiContext_to_localstorage_in_entry_ability]
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { window } from '@kit.ArkUI';
+// [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+import { hilog } from '@kit.PerformanceAnalysisKit';
+// [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+
+const localStorage: LocalStorage = new LocalStorage('uiContext');
+
+export default class Entry4Ability extends UIAbility {
+ public storage: LocalStorage = localStorage;
+ // [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+ // [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+
+ // [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+ // [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ windowStage.loadContent('pages/Index', this.storage, (err, data) => {
+ if (err.code) {
+ return;
+ }
+
+ this.storage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext());
+ });
+ }
+ // [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+ // [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+ // [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+ // [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+ // [StartExclude save_uiContext_to_localstorage_in_entry_ability]
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+ // [EndExclude save_uiContext_to_localstorage_in_entry_ability]
+}
+// [End save_uiContext_to_localstorage_in_entry_ability]
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f37c63bfdff0f3f42dee6da7e069016bbae7dd2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start write_code_for_business_components]
+import { BuilderData } from './DynamicComponent';
+
+@Builder
+function webBuilder(data: BuilderData) {
+ // 此处组件可根据业务需要自行扩展
+ Web({ src: data.url, controller: data.controller })
+ .cacheMode(CacheMode.Default)
+}
+
+export const businessWebview = wrapBuilder(webBuilder);
+// [End write_code_for_business_components]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d0fc29ad852969d54cf5a1db9efafdd369dd7c60
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start underlying_code_required_for_dynamic_components]
+import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI';
+
+export interface BuilderData {
+ url: string;
+ controller: WebviewController;
+}
+
+const storage = LocalStorage.getShared();
+
+export class NodeControllerImpl extends NodeController {
+ private rootNode: BuilderNode | null = null;
+ private wrappedBuilder: WrappedBuilder | null = null;
+
+ constructor(wrappedBuilder: WrappedBuilder) {
+ super();
+ this.wrappedBuilder = wrappedBuilder;
+ }
+
+ makeNode(): FrameNode | null {
+ if (this.rootNode != null) {
+ return this.rootNode.getFrameNode();
+ }
+ return null;
+ }
+
+ initWeb(url: string, controller: WebviewController) {
+ if(this.rootNode != null) {
+ return;
+ }
+
+ const uiContext: UIContext = storage.get('uiContext') as UIContext;
+ if (!uiContext) {
+ return;
+ }
+ this.rootNode = new BuilderNode(uiContext);
+ this.rootNode.build(this.wrappedBuilder, { url: url, controller: controller });
+ }
+}
+
+export const createNode = (wrappedBuilder: WrappedBuilder, data: BuilderData) => {
+ const baseNode = new NodeControllerImpl(wrappedBuilder);
+ baseNode.initWeb(data.url, data.controller);
+ return baseNode;
+}
+// [End underlying_code_required_for_dynamic_components]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..42fb5389701472c2a44fbc56eccfc531217e5c4e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start dynamic_webview_component_loading]
+import { webview } from '@kit.ArkWeb';
+import { NodeController } from '@kit.ArkUI';
+import { createNode } from "./DynamicComponent";
+import { injectWebview } from "./InjectWebview";
+import { businessWebview } from "./BusinessWebview";
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct Index {
+ @State injectNode: NodeController | undefined = undefined;
+ injectController: webview.WebviewController = new webview.WebviewController();
+
+ @State businessNode: NodeController | undefined = undefined;
+ businessController: webview.WebviewController = new webview.WebviewController();
+
+ aboutToAppear(): void {
+ // 初始化用于注入本地资源的Web组件, 提供一个空的html页面作为url即可
+ this.injectNode = createNode(injectWebview,
+ { url: resourceToString($r('app.string.web_path_two')), controller: this.injectController});
+ }
+
+ build() {
+ Column() {
+ // 在适当的时机加载业务用Web组件,本例以Button点击触发为例
+ Button("加载页面")
+ .onClick(() => {
+ this.businessNode = createNode(businessWebview, {
+ url: resourceToString($r('app.string.web_path_three')),
+ controller: this.businessController
+ });
+ })
+ // 用于业务的Web组件
+ NodeContainer(this.businessNode);
+ }
+ }
+}
+// [End dynamic_webview_component_loading]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9ccca1250e3ea1d0b6f0b400555fe142b35979ed
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start local_resources_content_read_from_rawfile_directory_by_file_operation]
+import { webview } from '@kit.ArkWeb';
+import { resourceConfigs } from './Resource';
+import { BuilderData } from './DynamicComponent';
+
+@Builder
+function webBuilder(data: BuilderData) {
+ Web({ src: data.url, controller: data.controller })
+ .onControllerAttached(async () => {
+ try {
+ data.controller.injectOfflineResources(await getData ());
+ } catch (err) {
+ console.error('error: ' + err.code + ' ' + err.message);
+ }
+ })
+ .fileAccess(true)
+}
+
+export const injectWebview = wrapBuilder(webBuilder);
+
+export async function getData() {
+ const resourceMapArr: webview.OfflineResourceMap[] = [];
+
+ // 读取配置,从rawfile目录中读取文件内容
+ for (let config of resourceConfigs) {
+ let buf: Uint8Array = new Uint8Array(0);
+ if (config.localPath) {
+ buf = await readRawFile(config.localPath);
+ }
+
+ resourceMapArr.push({
+ urlList: config.urlList,
+ resource: buf,
+ responseHeaders: config.responseHeaders,
+ type: config.type,
+ })
+ }
+
+ return resourceMapArr;
+}
+
+export async function readRawFile(url: string) {
+ try {
+ return await getContext().resourceManager.getRawFileContent(url);
+ } catch (err) {
+ return new Uint8Array(0);
+ }
+}
+// [End local_resources_content_read_from_rawfile_directory_by_file_operation]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0c7ab57171147e3cd14c9d8b4ab18a3d3aff6ec1
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start compile_resource_allocation_information]
+import { webview } from '@kit.ArkWeb';
+// [StartExclude compile_resource_allocation_information]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude compile_resource_allocation_information]
+export interface ResourceConfig {
+ urlList: Array,
+ type: webview.OfflineResourceType,
+ responseHeaders: Array,
+ localPath: string, // 本地资源存放在rawfile目录下的路径
+}
+
+export const resourceConfigs: ResourceConfig[] = [
+ {
+ localPath: 'example.png',
+ urlList: [
+ resourceToString($r('app.string.web_path')),
+ resourceToString($r('app.string.web_path')) + 'path1/example.png',
+ resourceToString($r('app.string.web_path')) + 'path2/example.png',
+ ],
+ type: webview.OfflineResourceType.IMAGE,
+ responseHeaders: [
+ { headerKey: 'Cache-Control', headerValue: 'max-age=1000' },
+ { headerKey: 'Content-Type', headerValue: 'image/png' },
+ ]
+ },
+ {
+ localPath: 'example.js',
+ urlList: [ // 仅提供一个url,这个url既作为资源的源,也作为资源的网络请求地址
+ resourceToString($r('app.string.web_path_one')),
+ ],
+ type: webview.OfflineResourceType.CLASSIC_JS,
+ responseHeaders: [
+ // 以方式使用,提供额外的响应头
+ { headerKey: 'Cross-Origin', headerValue:'anonymous' }
+ ]
+ },
+];
+// [End compile_resource_allocation_information]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..deb14ccf497e2f20636824d146b1151003e73946
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/module.json5
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry4",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry4Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry4Ability",
+ "srcEntry": "./ets/entry4ability/Entry4Ability.ets",
+ "description": "$string:Entry4Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry4Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..a39e01b4cb88b74852959299e45081ef36225449
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/element/string.json
@@ -0,0 +1,32 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry4Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry4Ability_label",
+ "value": "AcceleratePageAccess"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ },
+ {
+ "name": "web_path_one",
+ "value": "https://www.example.com/example.js"
+ },
+ {
+ "name": "web_path_two",
+ "value": "https://www.example.com/empty.html"
+ },
+ {
+ "name": "web_path_three",
+ "value": "https://www.example.com/business.html"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f7e364d114bba0ed5aaa78fb4e4ddc3284d43c07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 testUiExample 按钮
+ * 通过 injectOfflineResources 在页面加载前
+ * 提前将图片、样式表或脚本资源注入到应用的内存缓存中
+ */
+ it('testUiExample', 0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry4Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry4Ability');
+ await driver.delayMs(1000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..12ba91e94655586fb5e48c90b290e66be7e85db2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry4_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/List.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigor/hvigor-config.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigorfile.ts b/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/oh-package.json5 b/ManageWebPageLoadBrowse/AcceleratePageAccess/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/ohosTest.md b/ManageWebPageLoadBrowse/AcceleratePageAccess/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..f863c19a3505cbee1f1c5baface0d39d6d9682ca
--- /dev/null
+++ b/ManageWebPageLoadBrowse/AcceleratePageAccess/ohosTest.md
@@ -0,0 +1,60 @@
+### entry:
+
+#### PrepareForPageLoad_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------ | ------------ | ------------------------------ | ----------------------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 在Web组件的onAppear中对要加载的页面进行预连接。 | Yes | Pass |
+| 对要加载的页面进行预连接 | 设备运转正常 | 应用启动成功,点击超链接 | 跳转下一界面 | Yes | Pass |
+| 对要加载的页面进行预连接 | 设备运转正常 | 应用启动成功,点击loadData按钮 | 返回上个界面 | Yes | Pass |
+
+### entry1:
+
+#### PrepareForPageLoad_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | ----------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 提前初始化Web内核并对首页进行预连接 | Yes | Pass |
+
+### entry2:
+
+#### Prefetching
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | ----------------------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 在onPageEnd的时候触发下一个要访问的页面的预加载 | Yes | Pass |
+
+#### PrefetchingAPOSTRequest_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | ---------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 对要加载页面中的post请求进行预获取 | Yes | Pass |
+
+#### PrefetchingAPOSTRequest_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | ---------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 触发预获取一个要访问页面的post请求 | Yes | Pass |
+
+#### PrefetchingAPOSTRequest_three
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | --------------------------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功 | 提前初始化Web内核并预获取首页的post请求 | Yes | Pass |
+
+### entry3:
+
+#### PrecompForCompCache
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------ | --------------------------------------- | -------- | -------- |
+加速Web页面的访问 | 设备运转正常 | 应用启动成功,点击加载页面按钮 | Web组件展示business.html页面 | Yes | Pass
+
+### entry4:
+
+#### InjOffResNoInt
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------- | ------------ | ------------------------------ | --------------------- | -------- | -------- |
+| 加速Web页面的访问 | 设备运转正常 | 应用启动成功,点击加载页面按钮 | 展示business.html页面 | Yes | Pass |
+
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_1.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..b4729cdae9c9085ba0040d7ecb29b7bd8c1036fe
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_1.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_2.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..54be046496ae7f60d3c28b5178233ef16b1c091f
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/InjOffResNoInt_2.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_1.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..09d06a879ef9febc1b7339a4746470ff58c05a2e
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_1.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_2.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..01220d1c0b744e5546bbbab2e28ef742790c1a01
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrecompForCompCache_2.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/Prefetching.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/Prefetching.png
new file mode 100644
index 0000000000000000000000000000000000000000..5f61e45500639335b1b39e6edb175a039a66b444
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/Prefetching.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_one.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_one.png
new file mode 100644
index 0000000000000000000000000000000000000000..fd072ee17f59e08c3d22ce5136f8b19530021981
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_one.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_three.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_three.png
new file mode 100644
index 0000000000000000000000000000000000000000..ad69bdeb06388dd0641924fdf90b7bbcb8bfa53f
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_three.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_two.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_two.png
new file mode 100644
index 0000000000000000000000000000000000000000..de0f3ca0bbc8b26592b56d9baac562e6740ff6e2
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrefetchingAPOSTRequest_two.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_1.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..a7393739771049d346dd4ae96e595ba7ce7688ab
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_1.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_2.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c3c305daef50a66f2076342f2ecf18f49274ef07
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_one_2.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_1.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..1895cd088a4cd1ca459e2947a3158b14a1975a7f
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_1.png differ
diff --git a/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_2.png b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..e1b373b554dcad3b62966368846a56deb38f0e9a
Binary files /dev/null and b/ManageWebPageLoadBrowse/AcceleratePageAccess/screenshots/PrepareForPageLoad_two_2.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/.gitignore b/ManageWebPageLoadBrowse/CustomizePageResp/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/app.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5b9869dfe7935ef0bcd722584ff83f11316f7e71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.customizepageresp",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/element/string.json b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..34d26963fce287cb8ae0050e26b5f74233654c19
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "CustomizePageResp"
+ }
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/media/app_icon.png b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/README.md b/ManageWebPageLoadBrowse/CustomizePageResp/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..8c3bcba21c7ad5b02f035df0b2020bdf69a3b90d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/README.md
@@ -0,0 +1,86 @@
+# 自定义页面请求响应
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-resource-interception-request-mgmt.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### OnInterceptRequest_one
+
+#### 介绍
+
+1. 本示例主要介绍自定义页面请求响应,Web网页上发起资源加载请求,应用层收到资源请求消息。应用层构造本地资源响应消息发送给Web内核。Web内核解析应用层响应信息,根据此响应信息进行页面资源加载。
+
+#### 效果预览
+
+| 主页 | |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 通过拦截页面请求,在应用侧代码构建响应资源,实现自定义页面响应场景。
+
+### OnInterceptRequest_two
+
+#### 介绍
+
+1. 本示例主要介绍自定义页面请求响应,Web组件通过拦截页面请求,应用侧代码构建响应资源,在响应头中添加“ResponseDataID”字段,开启生成CodeCache的功能。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 拦截页面请求,应用侧代码构建响应资源。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---OnInterceptRequest_one
+|---|---|---OnInterceptRequest_two
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/build-profile.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/code-linter.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/.gitignore b/ManageWebPageLoadBrowse/CustomizePageResp/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/build-profile.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/hvigorfile.ts b/ManageWebPageLoadBrowse/CustomizePageResp/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/obfuscation-rules.txt b/ManageWebPageLoadBrowse/CustomizePageResp/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/oh-package.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..23a5f218909827e91bf6f66ce3d472c99df7c7c2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a10f87a5bbe120280306cc35e5eb8de074c1fa27
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('OnInterceptRequest_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnInterceptRequest_one' });
+ })
+ Button('OnInterceptRequest_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnInterceptRequest_two' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..99b4325373d0f329d3c81f87eb45df1fbd3bdbf6
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start build_response_resources_to_implement_custom_page_response_scenarios]
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ responseResource: WebResourceResponse = new WebResourceResponse();
+ // 开发者自定义响应数据
+ @State webData: string = '\n' +
+ '\n' +
+ '\n' +
+ 'intercept test\n' +
+ '\n' +
+ '\n' +
+ '
intercept ok
\n' +
+ '\n' +
+ ''
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('index1.html'), controller: this.controller })
+ .onInterceptRequest((event) => {
+ if (event) {
+ console.info('url:' + event.request.getRequestUrl());
+ // 拦截页面请求
+ if (event.request.getRequestUrl() !== resourceToString($r('app.string.web_path')) + '/test.html') {
+ return null;
+ }
+ }
+ // 构造响应数据
+ this.responseResource.setResponseData(this.webData);
+ this.responseResource.setResponseEncoding('utf-8');
+ this.responseResource.setResponseMimeType('text/html');
+ this.responseResource.setResponseCode(200);
+ this.responseResource.setReasonMessage('OK');
+ return this.responseResource;
+ })
+ }
+ }
+}
+// [End build_response_resources_to_implement_custom_page_response_scenarios]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..87a466a73fdd1c638d152ea6a56c1c70c943d1dc
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start build_response_resource_enable_gen]
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ responseResource: WebResourceResponse = new WebResourceResponse();
+ // 开发者自定义响应数据(响应数据长度需大于等于1024才会生成codecache)
+ @State jsData: string = 'let text_msg = "the modified content:version 0000000000001";\n' +
+ 'let element1 = window.document.getElementById("div-1");\n' +
+ 'let element2 = window.document.getElementById("div-2");\n' +
+ 'let element3 = window.document.getElementById("div-3");\n' +
+ 'let element4 = window.document.getElementById("div-4");\n' +
+ 'let element5 = window.document.getElementById("div-5");\n' +
+ 'let element6 = window.document.getElementById("div-6");\n' +
+ 'let element7 = window.document.getElementById("div-7");\n' +
+ 'let element8 = window.document.getElementById("div-8");\n' +
+ 'let element9 = window.document.getElementById("div-9");\n' +
+ 'let element10 = window.document.getElementById("div-10");\n' +
+ 'let element11 = window.document.getElementById("div-11");\n' +
+ 'element1.innerHTML = text_msg;\n' +
+ 'element2.innerHTML = text_msg;\n' +
+ 'element3.innerHTML = text_msg;\n' +
+ 'element4.innerHTML = text_msg;\n' +
+ 'element5.innerHTML = text_msg;\n' +
+ 'element6.innerHTML = text_msg;\n' +
+ 'element7.innerHTML = text_msg;\n' +
+ 'element8.innerHTML = text_msg;\n' +
+ 'element9.innerHTML = text_msg;\n' +
+ 'element10.innerHTML = text_msg;\n' +
+ 'element11.innerHTML = text_msg;\n';
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('index2.html'), controller: this.controller })
+ .onInterceptRequest((event) => {
+ // 拦截页面请求
+ if (event?.request.getRequestUrl() == resourceToString($r('app.string.web_path')) + '/test.js') {
+ // 构造响应数据
+ this.responseResource.setResponseHeader([
+ {
+ // 格式:不超过13位纯数字。js识别码,Js有更新时必须更新该字段
+ headerKey: 'ResponseDataID',
+ headerValue: '0000000000001'
+ }]);
+ this.responseResource.setResponseData(this.jsData);
+ this.responseResource.setResponseEncoding('utf-8');
+ this.responseResource.setResponseMimeType('application/javascript');
+ this.responseResource.setResponseCode(200);
+ this.responseResource.setReasonMessage('OK');
+ return this.responseResource;
+ }
+ return null;
+ })
+ }
+ }
+}
+// [End build_response_resource_enable_gen]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/module.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..7b32b8b4664df463e48b5ad0d0299be7cdde75d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "CustomizePageResp"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..43e2753929e3bc3abc1c145486b09be18bc1892c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,7 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/OnInterceptRequest_one",
+ "pages/OnInterceptRequest_two"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/en_US/element/string.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b1a7057a5c1e388a8008d99c604b564dce1f5e89
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "CustomizePageResp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index1.html b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index1.html
new file mode 100644
index 0000000000000000000000000000000000000000..1a4ebd18dfb3e976a382a81de459ab9b1c9296da
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index1.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+intercept test!
+
+
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index2.html b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index2.html
new file mode 100644
index 0000000000000000000000000000000000000000..1119af3481ca4ebf008455519a1c2632f0d5c869
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/rawfile/index2.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
+
+
+
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d4c9e1478d869b1ac4894955c2600173e5fa04d3
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "CustomizePageResp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..43afd1c79414996342a92b8e6eb3ea00ae27ffa0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 OnInterceptRequest_one 按钮
+ * 应用层构造本地资源响应消息发送给Web内核
+ * Web内核解析应用层响应信息,根据此响应信息进行页面资源加载
+ */
+ it('OnInterceptRequest_one',0, async (done: Function) => {
+ console.info('uitest: OnInterceptRequest_one begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(3000);
+
+ const button1 = await driver.findComponent(ON.text('OnInterceptRequest_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const clickText = await driver.findComponent(ON.clickable(true).enabled(true));
+ await clickText.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('index1.html');
+
+ await driver.pressBack();
+ console.info('uitest: OnInterceptRequest_one end');
+ done();
+ });
+
+ /*
+ * 点击 OnInterceptRequest_two 按钮
+ * Web组件通过拦截页面请求,应用侧代码构建响应资源
+ * 在响应头中添加“ResponseDataID”字段,开启生成CodeCache的功能
+ */
+ it('OnInterceptRequest_two',0, async (done: Function) => {
+ console.info('uitest: OnInterceptRequest_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('OnInterceptRequest_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const clickText = await driver.findComponent(ON.clickable(true).enabled(true));
+ await clickText.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('index2.html');
+
+ console.info('uitest: OnInterceptRequest_two end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts b/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 b/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md b/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..4231c946ba5e54812a5735db3aec93a85e465c81
--- /dev/null
+++ b/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md
@@ -0,0 +1,11 @@
+#### OnInterceptRequest_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------ | ------------------------------ | -------- | -------- |
+| 自定义页面请求响应 | 设备运转正常 | 应用启动成功 | 拦截页面请求自定义页面响应场景 | Yes | Pass |
+
+#### OnInterceptRequest_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------ | ------------ | ------------ | ------------------------------------ | -------- | -------- |
+| 自定义页面请求响应 | 设备运转正常 | 应用启动成功 | 拦截页面请求,应用侧代码构建响应资源 | Yes | Pass |
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..5921aacb8fb3bd418ea2ab998e4b3909d96bf104
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..3cccbb3464cb4c53486a27c8f01210550c916f52
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png differ
diff --git a/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png
new file mode 100644
index 0000000000000000000000000000000000000000..348f6eac4920aed40cc1e2523a0756f8dee2efc7
Binary files /dev/null and b/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/.gitignore b/ManageWebPageLoadBrowse/LoadPages/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 b/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..a0839764e9f5191469c5b58f2a8ec6114aa3bdcd
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.loadpages",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json b/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..20d3fed609c211fb436f66442a2576b24d1a59ac
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "LoadPages"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png b/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/README.md b/ManageWebPageLoadBrowse/LoadPages/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b59e60742046073fb91f237485f502c119f680c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/README.md
@@ -0,0 +1,138 @@
+# 使用Web组件加载页面
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-page-loading-with-web-components.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### LoadingWebPages
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件加载页面,开发者可以在Web组件创建时,指定默认加载的网络页面。在默认页面加载完成后,如果开发者需要变更此Web组件显示的网络页面,可以通过调用loadUrl()接口加载指定的网页。
+
+#### 效果预览
+
+| 主页 | loadUrl |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击loadUrl按钮加载指定的网页来变更此Web组件显示的网络页面。
+
+### LoadingLocalPages
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件加载页面,将本地页面文件放在应用的rawfile目录下,开发者可以在Web组件创建的时候指定默认加载的本地页面 ,并且加载完成后可通过调用loadUrl()接口变更当前Web组件的页面。
+
+#### 效果预览
+
+| 主页 | loadUrl |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击loadUrl按钮来变更当前Web组件的页面。
+
+### LoadingHTMLRichTextData
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件加载页面,Web组件可以通过loadData()接口实现加载HTML格式的文本数据。
+
+#### 效果预览
+
+| 主页 | loadData |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击loadUrl按钮加载HTML格式的文本数据。
+
+### LoadLocalPageFileInSandboxPath_one
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件加载页面,通过构造的单例对象GlobalContext获取沙箱路径,加载沙箱路径下的本地页面文件,需要开启应用中文件系统的访问fileAccess权限。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 通过构造的单例对象GlobalContext获取沙箱路径,加载沙箱路径下的本地页面文件。
+
+### LoadLocalPageFileInSandboxPath_two
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件加载页面,Web组件可以通过data url方式直接加载HTML字符串。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 通过data url方式直接加载HTML字符串。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---GlobalContext.ets
+|---|---|---Index.ets // 首页
+|---|---|---LoadingHTMLRichTextData.ets
+|---|---|---Loading LocalPages.ets
+|---|---|---Loading WebPages.ets
+|---|---|---Load LocalPageFileInSandboxPath_one.ets
+|---|---|---Load LocalPageFileInSandboxPath_two.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 b/ManageWebPageLoadBrowse/LoadPages/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 b/ManageWebPageLoadBrowse/LoadPages/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore b/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 b/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts b/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt b/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 b/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4e388d7c0789a2fde9a1dbc86eb58c8c77b8b856
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start after_load_complete_call_to_change_page]
+export class GlobalContext {
+ private constructor() {}
+ private static instance: GlobalContext;
+ private _objects = new Map();
+
+ public static getContext(): GlobalContext {
+ if (!GlobalContext.instance) {
+ GlobalContext.instance = new GlobalContext();
+ }
+ return GlobalContext.instance;
+ }
+
+ getObject(value: string): Object | undefined {
+ return this._objects.get(value);
+ }
+
+ setObject(key: string, objectClass: Object): void {
+ this._objects.set(key, objectClass);
+ }
+}
+// [End after_load_complete_call_to_change_page]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8414f37f6e33158c3cb833f41062d18b735051df
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('LoadingWebPages')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LoadingWebPages' });
+ })
+ Button('LoadingLocalPages')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LoadingLocalPages' });
+ })
+ Button('LoadingHTMLRichTextData')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LoadingHTMLRichTextData' });
+ })
+ Button('LoadLocalPageFileInSandboxPath_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LoadLocalPageFileInSandboxPath_one' });
+ })
+ Button('LoadLocalPageFileInSandboxPath_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LoadLocalPageFileInSandboxPath_two' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7265103ddffb308500e88278d43868f1ac9f5271
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start load_local_page_file_in_sandbox_path]
+import { webview } from '@kit.ArkWeb';
+import { GlobalContext } from './GlobalContext';
+
+let url = 'file://' + GlobalContext.getContext().getObject('filesDir') + '/index.html';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Text('loading success');
+ // 加载沙箱路径文件。
+ Web({ src: url, controller: this.controller });
+ }
+ }
+}
+// [End load_local_page_file_in_sandbox_path]
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..208359c5f04520d90de51e7eb805f0f0a7a66264
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start web_components_load_html_strings_by_data_url]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ htmlStr: string = 'data:text/html, Source:
source
';
+
+ build() {
+ Column() {
+ // 组件创建时,加载htmlStr
+ Web({ src: this.htmlStr, controller: this.controller });
+ }
+ }
+}
+// [End web_components_load_html_strings_by_data_url]
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cc56f8160ac8640379d79cd3752462ccd690cc69
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start devs_load_page_fragments_for_quick_loading]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadData')
+ .onClick(() => {
+ try {
+ // 点击按钮时,通过loadData,加载HTML格式的文本数据
+ this.controller.loadData(
+ 'Source:
source
',
+ 'text/html',
+ 'UTF-8'
+ );
+ } catch (error) {
+ console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 组件创建时,加载www.example.com
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End devs_load_page_fragments_for_quick_loading]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets
new file mode 100644
index 0000000000000000000000000000000000000000..781bbe446f028de2b05bfcac1510cac7dea85ad5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// [Start after_load_complete_call_to_change_page]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadUrl')
+ .onClick(() => {
+ try {
+ // 点击按钮时,通过loadUrl,跳转到local1.html
+ this.controller.loadUrl($rawfile('local1.html'));
+ } catch (error) {
+ console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 组件创建时,通过$rawfile加载本地文件local.html
+ Web({ src: $rawfile('local.html'), controller: this.controller });
+ }
+ }
+}
+// [End after_load_complete_call_to_change_page]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e1bb08055573f295a89c60d8119d3fc2df4bd2a2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start use_load_interface_to_show_web_changes]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadUrl')
+ .onClick(() => {
+ try {
+ // 点击按钮时,通过loadUrl,跳转到www.example1.com
+ this.controller.loadUrl('www.example1.com');
+ } catch (error) {
+ console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 组件创建时,加载www.example.com
+ Web({ src: 'www.example.com', controller: this.controller });
+ }
+ }
+}
+// [End use_load_interface_to_show_web_changes]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..ee18f9ce4fbbaa1861e1de23ff3e4846c93efc87
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions":[
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..13ba44d53db0cce9e6b90d39a451fb166108470b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LoadPages"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..55043dfca0e13cb4390abc45b022b0aa9ec038c9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,10 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/LoadingWebPages",
+ "pages/LoadingLocalPages",
+ "pages/LoadingHTMLRichTextData",
+ "pages/LoadLocalPageFileInSandboxPath_one",
+ "pages/LoadLocalPageFileInSandboxPath_two"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..13ba44d53db0cce9e6b90d39a451fb166108470b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LoadPages"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html
new file mode 100644
index 0000000000000000000000000000000000000000..4e7956396344e0db753afb9431de6cfa7b0a1e07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..becedf26056eeec62877304965a627eece9f3da3
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "LoadPages"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4843837034de0f1083ef3ff7cb78ca3d120146b0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 LoadingWebPages 按钮
+ * 在默认页面加载完成后,调用 loadUrl 接口加载指定的网页
+ */
+ it('LoadingWebPages', 0, async (done: Function) => {
+ console.info('uitest: LoadingWebPages begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(4000);
+
+ const button1 = await driver.findComponent(ON.text('LoadingWebPages'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: LoadingWebPages end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 LoadingLocalPages 按钮
+ * 默认页面加载完成后可通过调用 loadUrl 接口变更当前Web组件的页面
+ */
+ it('LoadingLocalPages', 0, async (done: Function) => {
+ console.info('uitest: LoadingLocalPages begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LoadingLocalPages'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ let src: string = await type.getText();
+ expect(src).assertContain('local.html');
+
+ await driver.pressBack();
+ console.info('uitest: LoadingLocalPages end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 LoadingHTMLRichTextData 按钮
+ * 通过 loadData 接口实现加载HTML格式的文本数据
+ */
+ it('LoadingHTMLRichTextData', 0, async (done: Function) => {
+ console.info('uitest: LoadingHTMLRichTextData begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LoadingHTMLRichTextData'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button = await driver.findComponent(ON.type('Button'));
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: LoadingHTMLRichTextData end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 LoadLocalPageFileInSandboxPath_one 按钮
+ * 加载沙箱路径下的本地页面文件,需要开启应用中文件系统的访问fileAccess权限
+ */
+ it('LoadLocalPageFileInSandboxPath_one', 0, async (done: Function) => {
+ console.info('uitest: LoadLocalPageFileInSandboxPath_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LoadLocalPageFileInSandboxPath_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const type1 = await driver.findComponent(ON.type('Text'));
+ let text1: string = await type1.getText();
+ expect(text1).assertContain('loading success');
+
+ await driver.pressBack();
+ console.info('uitest: LoadLocalPageFileInSandboxPath_one end');
+ done();
+ });
+
+ /*
+ * 打开应用,点击 LoadLocalPageFileInSandboxPath_two 按钮
+ * 通过data url方式直接加载HTML字符串
+ */
+ it('LoadLocalPageFileInSandboxPath_two', 0, async (done: Function) => {
+ console.info('uitest: LoadLocalPageFileInSandboxPath_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('LoadLocalPageFileInSandboxPath_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('Source:');
+
+ await driver.pressBack();
+ console.info('uitest: LoadLocalPageFileInSandboxPath_two end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 b/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts b/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 b/ManageWebPageLoadBrowse/LoadPages/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/LoadPages/ohosTest.md b/ManageWebPageLoadBrowse/LoadPages/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..af2960f92e5798733ea4e4ba0974f6c1d3238b11
--- /dev/null
+++ b/ManageWebPageLoadBrowse/LoadPages/ohosTest.md
@@ -0,0 +1,30 @@
+#### LoadingWebPages
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------- | ------------ | ----------------------------- | -------------- | -------- | -------- |
+| 使用Web组件加载页面 | 设备运转正常 | 应用启动成功,点击loadUrl按钮 | 加载指定的网页 | Yes | Pass |
+
+#### LoadingLocalPages
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------- | ------------ | ----------------------------- | --------------------- | -------- | -------- |
+| 使用Web组件加载页面 | 设备运转正常 | 应用启动成功,点击loadUrl按钮 | 变更当前Web组件的页面 | Yes | Pass |
+
+#### LoadingHTMLRichTextData
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------- | ------------ | ----------------------------- | ---------------------- | -------- | -------- |
+| 使用Web组件加载页面 | 设备运转正常 | 应用启动成功,点击loadUrl按钮 | 加载HTML格式的文本数据 | Yes | Pass |
+
+#### LoadLocalPageFileInSandboxPath_one
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------- | ------------ | ------------ | ---------------------------------------- | -------- | -------- |
+| 使用Web组件加载页面 | 设备运转正常 | 应用启动成功 | 获取沙箱路径加载沙箱路径下的本地页面文件 | Yes | Pass |
+
+#### LoadLocalPageFileInSandboxPath_two
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------- | ------------ | ------------ | ---------------------------------- | -------- | -------- |
+| 使用Web组件加载页面 | 设备运转正常 | 应用启动成功 | 通过data url方式直接加载HTML字符串 | Yes | Pass |
+
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png
new file mode 100644
index 0000000000000000000000000000000000000000..a7c815eb6349f7cf7eb93464d57f666fb7d21fc7
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png
new file mode 100644
index 0000000000000000000000000000000000000000..03d9599d1612eb550fa3edb973024838fd7f63f9
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..dfc5745ac65d84f78a68c07b30a69fc42ef6200f
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..89b1161c6af2b78263d8d73d873b003671c4662c
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..385ef0d06d87a17b50786e29cee0465b25a882e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..b7ec203d712bd013a4bccbb66b5a62916a70b147
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..eb39d90e0f1758ba3640bd6021f031f7d99c885c
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png differ
diff --git a/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..8794cba878eb7e77ac5fcb6757ba2383fae77e5d
Binary files /dev/null and b/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore b/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..829e8ba122dafa9aad9d543ebd9a3a6e1fb0dd10
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.managepageredirectnav",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f2843105d1f0874209a5c4a51a1d2c67d51e296c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ManagePageRedirectNav"
+ }
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md b/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..f8b5cd6550c4b89f300311133bb8db8c65ea62ea
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md
@@ -0,0 +1,104 @@
+# 管理页面跳转及浏览记录导航
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-redirection-and-browsing-history-mgmt.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### HistoryNavigati
+
+#### 介绍
+
+1. 本示例主要介绍管理页面跳转及浏览记录导航,如果存在历史记录,accessBackward()接口会返回true。同样可以使用accessForward()接口检查是否存在前进的历史记录。
+
+#### 效果预览
+
+| 主页 | More information... |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击More information...链接到达下一界面,来生成历史记录。
+1. 点击loadData按钮来触发前端页面的后退操作。
+
+### PageRedirection
+
+#### 介绍
+
+1. 本示例主要介绍页面跳转管理和浏览记录导航。当用户点击网页链接需要跳转到应用内其它页面时,可以通过使用Web组件的onLoadIntercept()接口来实现。
+
+#### 效果预览
+
+| 主页 | 跳转 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 在前端route.html页面点击超链接,可跳转到应用的ProfilePage.ets页面。
+
+### CrossApplicationRedirection
+
+#### 介绍
+
+本示例主要介绍页面管理及浏览记录导航功能,Web组件支持通过点击前端的超链接实现跨应用跳转。
+
+#### 效果预览
+
+| | |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+
+使用说明
+
+1. 点击超链接导航至其它应用。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---CrossApplication Redirection.ets
+|---|---|---HistoryNavigati.ets
+|---|---|---Index.ets // 首页
+|---|---|---PageRedirection.ets
+|---|---|---ProfilePage.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..23a5f218909827e91bf6f66ce3d472c99df7c7c2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a449c95a90bfa7742231fc94c65d08cc41e49e20
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { webview } from '@kit.ArkWeb';
+import { call } from '@kit.TelephonyKit';
+// [Start click_link_call_html_to_reach_phone_dialing_screen]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('call.html'), controller: this.webviewController })
+ .onLoadIntercept((event) => {
+ if (event) {
+ let url: string = event.data.getRequestUrl();
+ // 判断链接是否为拨号链接
+ if (url.indexOf('tel://') === 0) {
+ // 跳转拨号界面
+ call.makeCall(url.substring(6), (err) => {
+ if (!err) {
+ console.info('make call succeeded.');
+ } else {
+ console.info('make call fail, err is:' + JSON.stringify(err));
+ }
+ });
+ return true;
+ }
+ }
+ return false;
+ })
+ }
+ }
+}
+//[End click_link_call_html_to_reach_phone_dialing_screen]
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cf577c6cbf0c81e5995f9f18c2560fc73a455733
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { webview } from '@kit.ArkWeb';
+
+// [Start button_click_trigger_back]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('loadData')
+ .onClick(() => {
+ if (this.webviewController.accessBackward()) {
+ this.webviewController.backward();
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.webviewController });
+ }
+ }
+}
+// [End button_click_trigger_back]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4914a5f5df429036d7259d9a47334c52f77beb4a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('HistoryNavigati')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/HistoryNavigati' });
+ })
+ Button('PageRedirection')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/PageRedirection' });
+ })
+ Button('CrossApplicationRedirection')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/CrossApplicationRedirection' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d57537f43fd67eb4d8e08905dfbdfd87dcf66fec
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { webview } from '@kit.ArkWeb';
+import { router } from '@kit.ArkUI';
+
+// [Start index_load_route_link_to_profile]
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ // 资源文件route.html存放路径src/main/resources/rawfile
+ Web({ src: $rawfile('route.html'), controller: this.webviewController })
+ .onLoadIntercept((event) => {
+ if (event) {
+ let url: string = event.data.getRequestUrl();
+ if (url.indexOf('native://') === 0) {
+ // 跳转其他界面
+ router.pushUrl({ url: url.substring(9) });
+ return true;
+ }
+ }
+ return false;
+ })
+ }
+ }
+}
+// [End index_load_route_link_to_profile]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fa930b9d9c7dfc80242309d1e9da19825de225b8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start navigate_to_profile_page]
+@Entry
+@Component
+struct ProfilePage {
+ @State message: string = 'Hello World';
+
+ build() {
+ Column() {
+ Text(this.message)
+ .fontSize(20)
+ }
+ }
+}
+// [End navigate_to_profile_page]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..51119df58d8798ee0c2863b48d2a3ce7e940555b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManagePageRedirectNav"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/cn/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..52f59acd8b0887f9a2cd26f9588d76ca542cb6d5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/HistoryNavigati",
+ "pages/PageRedirection",
+ "pages/CrossApplicationRedirection",
+ "pages/ProfilePage"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..c25ce9fcda427231c8f659e42517bef4b4325c41
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManagePageRedirectNav"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html
new file mode 100644
index 0000000000000000000000000000000000000000..ea7fea2546ac643d56202049eedb0da4cf3345ab
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html
new file mode 100644
index 0000000000000000000000000000000000000000..ecc87a41688d026c9cda4f9294ea208679a7c728
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..166ab4c2891df93540a9f2407b2436874fd85e19
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManagePageRedirectNav"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9e979df586c8784a60472e053f76dbced15a916c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 HistoryNavigati 按钮
+ * 点击 loadData 按钮来触发前端页面的后退操作
+ */
+ it('HistoryNavigati',0, async (done: Function) => {
+ console.info('uitest: HistoryNavigati begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(4000);
+
+ const button1 = await driver.findComponent(ON.text('HistoryNavigati'));
+ await button1.click();
+ await driver.delayMs(3000);
+
+ const clickText = await driver.findComponent(ON.type('link'));
+ await clickText.click();
+ await driver.delayMs(3000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: HistoryNavigati end');
+ done();
+ });
+
+ /*
+ * 点击 PageRedirection 按钮
+ * 点击网页中的链接跳转到应用内其他页面
+ */
+ it('PageRedirection',0, async (done: Function) => {
+ console.info('uitest: PageRedirection begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('PageRedirection'));
+ await button1.click();
+ await driver.delayMs(3000);
+
+ const clickText = await driver.findComponent(ON.clickable(true).enabled(true));
+ await clickText.click();
+ await driver.delayMs(1000);
+
+ const text = await driver.findComponent(ON.text('Hello World'));
+ let type: string = await text.getType();
+ expect(type).assertEqual('Text');
+ await driver.delayMs(1000);
+
+ await driver.pressBack();
+ await driver.delayMs(1000);
+ await driver.pressBack();
+ console.info('uitest: PageRedirection end');
+ done();
+ });
+
+ /*
+ * 点击 CrossApplicationRedirection 按钮
+ * 击前端页面超链接跳转到其他应用
+ */
+ it('CrossApplicationRedirection',0, async (done: Function) => {
+ console.info('uitest: CrossApplicationRedirection begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('CrossApplicationRedirection'));
+ await button1.click();
+ await driver.delayMs(3000);
+
+ const clickText = await driver.findComponent(ON.clickable(true).enabled(true));
+ await clickText.click();
+ await driver.delayMs(1000);
+
+ const type = await driver.findComponent(ON.type('Web'));
+ expect(type).assertEqual(null);
+
+ await driver.pressBack();
+ console.info('uitest: CrossApplicationRedirection end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts b/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 b/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md b/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..2715364d3358506aeeaec98c1746d511a2fa447d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md
@@ -0,0 +1,18 @@
+#### HistoryNavigati
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| -------------------------- | ------------------------------------------------------------ | -------------------------------------------------------- | ------------ | -------- | -------- |
+| 管理页面跳转及浏览记录导航 | 设备运行正常,点击More information...链接到达下一界面,来生成历史记录 | 应用启动成功,点击loadData按钮来触发前端页面的后退操作。 | 回到初始页面 | Yes | Pass |
+
+#### PageRedirection
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| -------------------------- | ------------ | -------------------------------------------- | ------------------------------- | -------- | -------- |
+| 管理页面跳转及浏览记录导航 | 设备运行正常 | 应用启动成功,在前端route.html页面点击超链接 | 跳转到应用的ProfilePage.ets页面 | Yes | Pass |
+
+#### CrossApplicationRedirection
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ---------------------- | ------------ | ---------------------------- | -------- | -------- | -------- |
+| 管理页面跳转及浏览记录 | 设备运行正常 | 应用启动成功,点击超链接跳转 | 跳转成功 | Yes | Pass |
+
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..4c3276769353a7d3da5af26b6d6961353df34fc5
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..fc4e7fd04c1e2d0cb4a42462515928bbb1f5104b
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..2de3e6fa56de1cbf0b0813ee2209922d4c04d900
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..5f6bd0efb6f23713a1b5bad0b17f57f7917ecd52
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..4cf9dd40a3961a799edbca39b9ffc888f4f3c8ac
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png differ
diff --git a/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..66705fe72f9b1a329413c5ef85d31a64d983cafe
Binary files /dev/null and b/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e5c664911c57e8483759f0ead8b22ff2e2af1005
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.netreqinterceptcachewinops",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..ac0ab70b4d42157f3ba34fcf9e9a4608fcb1a4c0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "NetReqInterceptCacheWinOps"
+ }
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..fe0d75e5db78c0071605b42f4c8409e959575473
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+## entry:
+
+### 拦截Web组件发起的网络请求
+
+#### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-scheme-handler.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### InterceptNetRequest
+
+##### 介绍
+
+1. 本示例主要实现拦截Web组件发起的网络请求,为Web组件设置网络拦截器, 设置自定义scheme需要遵循的规则,获取被拦截请求的请求信息并为被拦截的请求提供自定义的响应体。
+
+##### 效果预览
+
+| 主页 | 本地MP4文件 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 通过网络拦截接口对Web组件发出的请求进行拦截,并可以为被拦截的请求提供自定义的响应头以及响应体。
+1. 点击link链接请求视频资源,读取本地mp4文件。
+
+##### 工程目录
+
+```
+entry/src/main/
+|---cpp // cpp文件夹
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+##### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## entry2:
+
+### Web组件前进后退缓存
+
+#### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-set-back-forward-cache.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### SetBackForwardCache
+
+##### 介绍
+
+1. 本示例主要设置Web组件前进后退缓存,Web组件为开发者提供了启用和配置前进后退缓存(以下简称BFCache)的功能。启用此功能后,能够显著提升用户返回至先前浏览网页的速度,开发者需要在调用initializeWebEngine()初始化ArkWeb内核之前调用enableBackForwardCache()来开启BFCache,启用BFCache后仅能存储一个页面,Web组件默认进入BFCache的页面可保持存活状态600秒。开发者可通过调用setBackForwardCacheOptions()设置每个Web实例的前进后退缓存策略,使BFCache能够容纳更多页面,从而在用户连续进行前进后退操作时,提供更快的加载速度。同时,开发者还能修改每个页面在缓存中的停留时间,延长页面在BFCache中的驻留期限,进而优化用户的浏览体验。
+
+##### 效果预览
+
+| 主页 | 超链接 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击Add options按钮设置Web组件可以缓存的数量上限为10,每个页面在缓存中停留300s。
+2. 点击Backward按钮会触发WebviewController的backward方法,使Web视图后退到上一个浏览页面(如果存在上一页面且在后退缓存范围内),实现类似以于浏览器后退按钮的功能。
+3. 点击Forward按钮调用WebviewController的forward方法,使Web视图前进到下一个浏览页面(如果存在下一页且在前进缓存范围内),与Backward按钮相对应。
+
+##### 工程目录
+
+```
+entry2/src/main/
+|---ets
+|---|---entry2ability
+|---|---|---Entry2Ability.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+##### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## entry3:
+
+### Web组件在不同的窗口间迁移
+
+#### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-component-migrate.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### MigrateWebCompWin
+
+##### 介绍
+
+1. 本示例主要介绍Web组件在不同的窗口间迁移,Web组件在不同窗口间迁移是基于自定义节点能力实现的。通过BuilderNode,开发者可创建Web组件的离线节点,并结合自定义占位节点控制Web节点的挂载与移除。当从一个窗口上移除Web节点并挂载到另一个窗口中,即完成Web组件在窗口间的迁移。
+
+##### 效果预览
+
+| 主页 | 挂载 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| | |
+
+使用说明
+
+1. 点击 Attach Webview 按钮,挂载 Web 视图,刷新NodeContainer使 Web 视图显示在页面上。
+1. 点击 Detach Webview 按钮,卸载 Web 视图,刷新NodeContainer使 Web 视图将从页面上移除。
+
+##### 工程目录
+
+```
+entry3/src/main/
+|---ets
+|---|---entry3ability
+|---|---|---Entry3Ability.ets
+|---|---pages
+|---|---|---common.ets // 提供动态挂载Web组件能力
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+##### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..638ae10f4bf8fc8c16156b4fdb6d62535fb58b28
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry2",
+ "srcPath": "./entry2",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry3",
+ "srcPath": "./entry3",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..f24addba76d1c74999c890245fdc45a1c681db97
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "abiFilters": ["arm64-v8a", "x86_64"],
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1686eb5df713cd6fd4c5da0dd7aeeb5d580861a9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.4.1)
+project(schemehandler)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_INFO_FILE)
+ include(${PACKAGE_INFO_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED rawfile_request.cpp hello.cpp)
+target_link_libraries(entry PUBLIC librawfile.z.so libace_napi.z.so libohweb.so libhilog_ndk.z.so)
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ece7e82f1eeb0ab691c41323648fe0d9a630881
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start set_intercept_web_module_request_example]
+#include "hilog/log.h"
+#include "napi/native_api.h"
+#include "rawfile_request.h"
+#include "rawfile/raw_file_manager.h"
+#include "web/arkweb_scheme_handler.h"
+#include "web/arkweb_net_error_list.h"
+
+#undef LOG_TAG
+#define LOG_TAG "ss-handler"
+
+// [Start set_intercept_web_module_request]
+ArkWeb_SchemeHandler *g_schemeHandler;
+// [StartExclude set_intercept_web_module_request]
+ArkWeb_SchemeHandler *g_schemeHandlerForSW;
+NativeResourceManager *g_resourceManager;
+
+// 注册三方协议的配置,需要在Web内核初始化之前调用,否则会注册失败。
+static napi_value RegisterCustomSchemes(napi_env env, napi_callback_info info)
+{
+ OH_LOG_INFO(LOG_APP, "register custom schemes");
+ // [Start register_set_custom_schemes]
+ OH_ArkWeb_RegisterCustomSchemes("custom", ARKWEB_SCHEME_OPTION_STANDARD | ARKWEB_SCHEME_OPTION_CORS_ENABLED);
+ OH_ArkWeb_RegisterCustomSchemes("custom-local", ARKWEB_SCHEME_OPTION_LOCAL);
+ OH_ArkWeb_RegisterCustomSchemes(
+ "custom-csp-bypassing", ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD);
+ OH_ArkWeb_RegisterCustomSchemes("custom-isolated", ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED);
+ // [End register_set_custom_schemes]
+ return nullptr;
+}
+
+// 请求开始的回调,在该函数中我们创建一个RawfileRequest来实现对Web内核请求的拦截。
+void OnURLRequestStart(const ArkWeb_SchemeHandler *schemeHandler,
+ ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ bool *intercept)
+{
+ *intercept = true;
+ RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager);
+ OH_ArkWebResourceRequest_SetUserData(resourceRequest, request);
+ request->Start();
+}
+
+// 请求结束的回调,在该函数中我们需要标记RawfileRequest已经结束了,内部不应该再使用ResourceHandler。
+void OnURLRequestStop(const ArkWeb_SchemeHandler *schemeHandler,
+ const ArkWeb_ResourceRequest *request)
+{
+ if (!request) {
+ OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr.");
+ return;
+ }
+
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request);
+ if (rawfileRequest) {
+ rawfileRequest->Stop();
+ }
+}
+
+void OnURLRequestStartForSW(const ArkWeb_SchemeHandler *schemeHandler,
+ ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ bool *intercept)
+{
+ *intercept = true;
+ RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager);
+ OH_ArkWebResourceRequest_SetUserData(resourceRequest, request);
+ request->Start();
+}
+
+void OnURLRequestStopForSW(const ArkWeb_SchemeHandler *schemeHandler,
+ const ArkWeb_ResourceRequest *request)
+{
+ if (!request) {
+ OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr.");
+ return;
+ }
+
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request);
+ if (rawfileRequest) {
+ rawfileRequest->Stop();
+ }
+}
+
+// 设置SchemeHandler。
+static napi_value SetSchemeHandler(napi_env env, napi_callback_info info)
+{
+ OH_LOG_INFO(LOG_APP, "set scheme handler");
+ // [EndExclude set_intercept_web_module_request]
+ // [Start set_intercept_web_module_request_custom]
+ OH_ArkWeb_CreateSchemeHandler(&g_schemeHandler);
+ OH_ArkWeb_CreateSchemeHandler(&g_schemeHandlerForSW);
+
+ OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandler, OnURLRequestStart);
+ OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandler, OnURLRequestStop);
+
+ // [StartExclude set_intercept_web_module_request_custom]
+ OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandlerForSW, OnURLRequestStart);
+ OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandlerForSW, OnURLRequestStop);
+ // [EndExclude set_intercept_web_module_request_custom]
+
+ OH_ArkWeb_SetSchemeHandler("custom", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-csp-bypassing", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-isolated", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-local", "scheme-handler", g_schemeHandler);
+ // [End set_intercept_web_module_request_custom]
+ OH_ArkWeb_SetSchemeHandler("https", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("http", "scheme-handler", g_schemeHandler);
+ // [End set_intercept_web_module_request]
+
+ OH_ArkWebServiceWorker_SetSchemeHandler("https", g_schemeHandlerForSW);
+ return nullptr;
+}
+
+static napi_value InitResourceManager(napi_env env, napi_callback_info info)
+{
+ size_t argc = 2;
+ napi_value argv[2] = {nullptr};
+ napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
+ g_resourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[0]);
+ return nullptr;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"setSchemeHandler", nullptr, SetSchemeHandler, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"initResourceManager", nullptr, InitResourceManager, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"registerCustomSchemes", nullptr, RegisterCustomSchemes, nullptr, nullptr, nullptr, napi_default, nullptr}
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
+// [End set_intercept_web_module_request_example]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c11c8b57c075b5322df845f7fdc371f8b49caa0
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "napi/native_api.h"
+
+static napi_value Add(napi_env env, napi_callback_info info)
+{
+ size_t argc = 2;
+ napi_value args[2] = {nullptr};
+
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ napi_valuetype valuetype0;
+ napi_typeof(env, args[0], &valuetype0);
+
+ napi_valuetype valuetype1;
+ napi_typeof(env, args[1], &valuetype1);
+
+ double value0;
+ napi_get_value_double(env, args[0], &value0);
+
+ double value1;
+ napi_get_value_double(env, args[1], &value1);
+
+ napi_value sum;
+ napi_create_double(env, value0 + value1, &sum);
+
+ return sum;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3ce2921a733d274ed070f46475e2d5edac50ece
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start intercepted_request_processing_cpp]
+#include "rawfile_request.h"
+#include "threads.h"
+
+#include "hilog/log.h"
+#include "rawfile/raw_file.h"
+#include "rawfile/raw_file_manager.h"
+
+#undef LOG_TAG
+#define LOG_TAG "ss-handler"
+
+namespace {
+
+uint8_t g_buffer[1024];
+cnd_t g_httpBodyCnd;
+mtx_t g_httpBodyMtx;
+const int HTTP_OK = 200;
+const int HTTP_NOT_FOUND = 404;
+const int BUFFER_SIZE = 1000;
+
+// HttpBodyStream的读回调。
+void ReadCallback(const ArkWeb_HttpBodyStream *httpBodyStream, uint8_t* buffer, int bytesRead)
+{
+ OH_LOG_INFO(LOG_APP, "read http body back.");
+ bool isEof = OH_ArkWebHttpBodyStream_IsEof(httpBodyStream);
+ if (!isEof && bytesRead != 0) {
+ memset(buffer, 0, BUFFER_SIZE);
+ OH_ArkWebHttpBodyStream_Read(httpBodyStream, buffer, BUFFER_SIZE);
+ } else {
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebHttpBodyStream_GetUserData(httpBodyStream);
+ if (rawfileRequest) {
+ rawfileRequest->ReadRawfileDataOnWorkerThread();
+ cnd_signal(&g_httpBodyCnd);
+ }
+ }
+}
+
+int ReadHttpBodyOnWorkerThread(void* userData)
+{
+ memset(g_buffer, 0, BUFFER_SIZE);
+ ArkWeb_HttpBodyStream *httpBodyStream = (ArkWeb_HttpBodyStream *)userData;
+ OH_ArkWebHttpBodyStream_Read(httpBodyStream, g_buffer, BUFFER_SIZE);
+ int initResult = cnd_init(&g_httpBodyCnd);
+ if (initResult == 0) {
+ OH_LOG_INFO(LOG_APP, "cnd_init success.");
+ } else {
+ OH_LOG_INFO(LOG_APP, "cnd_init fail.");
+ }
+ int mtxResult = mtx_init(&g_httpBodyMtx, mtx_plain);
+ if (mtxResult == 0) {
+ OH_LOG_INFO(LOG_APP, "mtx_init success.");
+ } else {
+ OH_LOG_INFO(LOG_APP, "mtx_init fail.");
+ }
+ int waitResult = cnd_wait(&g_httpBodyCnd, &g_httpBodyMtx);
+ if (waitResult == 0) {
+ OH_LOG_INFO(LOG_APP, "cnd_wait success.");
+ } else {
+ OH_LOG_INFO(LOG_APP, "cnd_wait fail.");
+ }
+ return 0;
+}
+
+int ReadRawfileOnWorkerThread(void* userData)
+{
+ RawfileRequest* rawfileRequest = (RawfileRequest*)userData;
+ if (rawfileRequest) {
+ rawfileRequest->ReadRawfileDataOnWorkerThread();
+ }
+ return 0;
+}
+
+// ArkWeb_HttpBodyStream的初始化回调。
+void InitCallback(const ArkWeb_HttpBodyStream *httpBodyStream, ArkWeb_NetError result)
+{
+ OH_LOG_INFO(LOG_APP, "init http body stream done %{public}d.", result);
+ bool isChunked = OH_ArkWebHttpBodyStream_IsChunked(httpBodyStream);
+ OH_LOG_INFO(LOG_APP, "http body stream is chunked %{public}d.", isChunked);
+ thrd_t th;
+ if (thrd_create(&th, ReadHttpBodyOnWorkerThread, (void *)httpBodyStream) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "create thread failed.");
+ return;
+ }
+
+ if (thrd_detach(th) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "detach thread failed.");
+ }
+}
+
+const int BLOCK_SIZE = 1024 * 8;
+const int MAXWHILE = 100;
+
+} // namespace
+
+RawfileRequest::RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ const NativeResourceManager* resourceManager)
+ : resourceRequest_(resourceRequest),
+ resourceHandler_(resourceHandler),
+ resourceManager_(resourceManager) {}
+
+RawfileRequest::~RawfileRequest() {}
+
+void RawfileRequest::Start()
+{
+ OH_LOG_INFO(LOG_APP, "start a rawfile request.");
+ // [Start get_intercepted_request_info]
+ char* url;
+ OH_ArkWebResourceRequest_GetUrl(resourceRequest_, &url);
+ std::string urlStr(url);
+ std::size_t position = urlStr.rfind('/');
+ if (position != std::string::npos) {
+ rawfilePath_ = urlStr.substr(position + 1);
+ }
+ OH_ArkWeb_ReleaseString(url);
+ // [End get_intercepted_request_info]
+
+ // [Start set_intercepted_request_response]
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWeb_CreateResponse(&response_);
+ // [EndExclude set_intercepted_request_response]
+ OH_ArkWebResourceRequest_GetHttpBodyStream(resourceRequest(), &stream_);
+ if (stream_) {
+ OH_LOG_ERROR(LOG_APP, "have http body stream");
+ // [Start get_put_post_request_data]
+ OH_ArkWebHttpBodyStream_SetUserData(stream_, this);
+ OH_ArkWebHttpBodyStream_SetReadCallback(stream_, ReadCallback);
+ OH_ArkWebHttpBodyStream_Init(stream_, InitCallback);
+ // [End get_put_post_request_data]
+ } else {
+ thrd_t th;
+ if (thrd_create(&th, ReadRawfileOnWorkerThread, static_cast(this)) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "create thread failed.");
+ return;
+ }
+
+ if (thrd_detach(th) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "detach thread failed.");
+ }
+ }
+}
+
+// 在worker线程中读取rawfile,并通过ResourceHandler返回给Web内核。
+void RawfileRequest::ReadRawfileDataOnWorkerThread()
+{
+ OH_LOG_INFO(LOG_APP, "read rawfile in worker thread.");
+ const struct UrlInfo {
+ std::string resource;
+ std::string mimeType;
+ } urlInfos[] = {
+ {"test.html", "text/html"},
+ {"video.html", "text/html"},
+ {"isolated.html", "text/html"},
+ {"csp_bypassing.html", "text/html"},
+ {"post_data.html", "text/html"},
+ {"chunked_post_stream.html", "text/html"},
+ {"local.html", "text/html"},
+ {"service_worker.html", "text/html"},
+ {"csp_script.js", "text/javascript"},
+ {"sw.js", "text/javascript"},
+ {"isolated_script.js", "text/javascript"},
+ {"local_script.js", "text/javascript"},
+ {"test.mp4", "video/mp4"},
+ {"xhr", "application/json"}
+ };
+
+ if (!resourceManager()) {
+ OH_LOG_ERROR(LOG_APP, "read rawfile error, resource manager is nullptr.");
+ return;
+ }
+
+ RawFile *rawfile = OH_ResourceManager_OpenRawFile(resourceManager(), RawfilePath().c_str());
+ // [StartExclude set_intercepted_request_response]
+ if (!rawfile) {
+ OH_ArkWebResponse_SetStatus(response(), HTTP_NOT_FOUND);
+ } else {
+ OH_ArkWebResponse_SetStatus(response(), HTTP_OK);
+ }
+ // [EndExclude set_intercepted_request_response]
+
+ for (auto &urlInfo : urlInfos) {
+ if (urlInfo.resource == RawfilePath()) {
+ OH_ArkWebResponse_SetMimeType(response(), urlInfo.mimeType.c_str());
+ break;
+ }
+ }
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWebResponse_SetCharset(response(), "UTF-8");
+ // [EndExclude set_intercepted_request_response]
+
+ long len = OH_ResourceManager_GetRawFileSize(rawfile);
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWebResponse_SetHeaderByName(response(), "content-length", std::to_string(len).c_str(), false);
+ // EndExclude set_intercepted_request_response]
+ DidReceiveResponse();
+
+ long consumed = 0;
+ uint8_t buffer[BLOCK_SIZE];
+ int i = 0;
+ while (++i < MAXWHILE) {
+ int ret = OH_ResourceManager_ReadRawFile(rawfile, buffer, BLOCK_SIZE);
+ if (ret > 0) {
+ OH_LOG_INFO(LOG_APP, "read rawfile %{public}d bytes.", ret);
+ } else if (ret == 0) {
+ OH_LOG_INFO(LOG_APP, "read rawfile Reached end of file, %{public}d bytes read.", ret);
+ break;
+ } else {
+ OH_LOG_ERROR(LOG_APP, "read rawfile Error, %{public}d bytes read.", ret);
+ break;
+ }
+ consumed += ret;
+ OH_ResourceManager_SeekRawFile(rawfile, consumed, 0);
+ DidReceiveData(buffer, ret);
+ memset(buffer, 0, BLOCK_SIZE);
+ }
+
+ OH_ResourceManager_CloseRawFile(rawfile);
+ DidFinish();
+}
+
+void RawfileRequest::Stop()
+{
+ OH_LOG_INFO(LOG_APP, "stop the rawfile request.");
+ std::lock_guard guard(mutex_);
+ stopped_ = true;
+ if (response_) {
+ OH_ArkWeb_DestroyResponse(response_);
+ }
+ OH_ArkWebResourceRequest_Destroy(resourceRequest_);
+ OH_ArkWebResourceHandler_Destroy(resourceHandler_);
+}
+
+void RawfileRequest::DidReceiveResponse()
+{
+ OH_LOG_INFO(LOG_APP, "did receive response.");
+ std::lock_guard guard(mutex_);
+ if (!stopped_) {
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWebResourceHandler_DidReceiveResponse(resourceHandler_, response_);
+ // [EndExclude set_intercepted_request_response]
+ }
+}
+
+void RawfileRequest::DidReceiveData(const uint8_t *buffer, int64_t bufLen)
+{
+ OH_LOG_INFO(LOG_APP, "did receive data.");
+ std::lock_guard guard(mutex_);
+ if (!stopped_) {
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWebResourceHandler_DidReceiveData(resourceHandler_, buffer, bufLen);
+ // [EndExclude set_intercepted_request_response]
+ }
+}
+
+void RawfileRequest::DidFinish()
+{
+ OH_LOG_INFO(LOG_APP, "did finish.");
+ std::lock_guard guard(mutex_);
+ if (!stopped_) {
+ // [StartExclude set_intercepted_request_response]
+ OH_ArkWebResourceHandler_DidFinish(resourceHandler_);
+ // [EndExclude set_intercepted_request_response]
+ // [End set_intercepted_request_response]
+ }
+}
+
+void RawfileRequest::DidFailWithError(ArkWeb_NetError errorCode)
+{
+ OH_LOG_INFO(LOG_APP, "did finish with error %{public}d.", errorCode);
+ if (!stopped_) {
+ OH_ArkWebResourceHandler_DidFailWithError(resourceHandler_, errorCode);
+ }
+}
+// [End intercepted_request_processing_cpp]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..09f6814761da59b2a5d3becf46da90aa2242fb10
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start rawfile_request_head]
+#ifndef RAWFILE_REQUEST_H
+#define RAWFILE_REQUEST_H
+
+#include
+#include
+
+#include
+#include "web/arkweb_scheme_handler.h"
+#include "web/arkweb_net_error_list.h"
+
+class RawfileRequest {
+public:
+ RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ const NativeResourceManager* resourceManager);
+ ~RawfileRequest();
+
+ void Start();
+ void Stop();
+ void ReadRawfileDataOnWorkerThread();
+
+ const ArkWeb_ResourceHandler *resourceHandler() { return resourceHandler_; }
+ const ArkWeb_ResourceRequest *resourceRequest() { return resourceRequest_; }
+ const NativeResourceManager *resourceManager() { return resourceManager_; }
+ ArkWeb_Response *response() { return response_; }
+ ArkWeb_HttpBodyStream *stream() { return stream_; }
+ const std::string RawfilePath() { return rawfilePath_; }
+
+ void DidReceiveResponse();
+ void DidReceiveData(const uint8_t *buffer, int64_t bufLen);
+ void DidFinish();
+ void DidFailWithError(ArkWeb_NetError errorCode);
+
+private:
+ const ArkWeb_ResourceRequest *resourceRequest_{nullptr};
+ const ArkWeb_ResourceHandler *resourceHandler_{nullptr};
+ const NativeResourceManager *resourceManager_{nullptr};
+ ArkWeb_Response *response_;
+ bool stopped_{false};
+ std::string rawfilePath_;
+ ArkWeb_HttpBodyStream *stream_{nullptr};
+ std::mutex mutex_;
+};
+
+#endif // RAWFILE_REQUEST_H
+// [End rawfile_request_head]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..97cceb187e4be3d5dd3eabe9644ec47805207ac7
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { resourceManager } from "@kit.LocalizationKit";
+
+// [Start export_register_set_init_schemes]
+export const registerCustomSchemes: () => void;
+export const setSchemeHandler: () => void;
+export const initResourceManager: (resmgr: resourceManager.ResourceManager) => void;
+// [End export_register_set_init_schemes]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./Index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8ddc53ccb115af8a04b0e6818d575dcfdf1f6769
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start register_init_scheme_example]
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+import { webview } from '@kit.ArkWeb';
+
+// [Start register_init_scheme]
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ // 注册三方协议的配置。
+ testNapi.registerCustomSchemes();
+ // 初始化Web组件内核,该操作会初始化Browser进程以及创建BrowserContext。
+ webview.WebviewController.initializeWebEngine();
+ // 设置SchemeHandler。
+ testNapi.setSchemeHandler();
+ }
+
+ // [StartExclude register_init_scheme]
+ onDestroy(): void {
+
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ return;
+ }
+ });
+ }
+
+ onWindowStageDestroy(): void {
+
+ }
+
+ onForeground(): void {
+
+ }
+
+ onBackground(): void {
+
+ }
+ // [EndExclude register_init_scheme]
+};
+// [End register_init_scheme]
+// [End register_init_scheme_example]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5420d2ebfb72569a014a35e174aa9edc7248582b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start set_test_html]
+import testNapi from 'libentry.so';
+import { webview } from '@kit.ArkWeb';
+import { resourceManager } from '@kit.LocalizationKit';
+
+@Entry
+@Component
+struct Index {
+ mycontroller: webview.WebviewController = new webview.WebviewController('scheme-handler');
+
+ build() {
+ Row() {
+ Column() {
+ Button('goback').onClick( event => {
+ this.mycontroller.backward();
+ })
+
+ Web({ src: $rawfile('test.html'), controller: this.mycontroller})
+ .javaScriptAccess(true)
+ .width('100%')
+ .height('100%')
+ .databaseAccess(true)
+ .fileAccess(false)
+ .domStorageAccess(true)
+ .cacheMode(CacheMode.Default)
+ .onPageBegin( event => {
+ testNapi.initResourceManager(getContext().resourceManager);
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+// [End set_test_html]
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2889111cbccda2943046e3a1421d6576262e402e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "NetReqInterceptCacheWinOps"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2889111cbccda2943046e3a1421d6576262e402e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "NetReqInterceptCacheWinOps"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html
new file mode 100644
index 0000000000000000000000000000000000000000..645cd7833b21a64e904b8747e2824e7f9ef6dcb7
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..8621810e79f5f987fbc16a20cd72200d33fe140a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// [Start csp_rules_java_script]
+const body = document.body;
+const element = document.createElement('div');
+element.textContent = 'csp_script.js bypass the csp rules';
+body.appendChild(element);
+// [End csp_rules_java_script]
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html
new file mode 100644
index 0000000000000000000000000000000000000000..bc04b313506d81f61fb720c4df39f99f9138d500
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
scheme: custom-isolated
+
options: ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED
+
isolated_script.js 被拦截
+
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..5ad02d6e0384ff6ab826ab4d25028c54e5afcd74
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// [Start isolated_script_java_script]
+const element = document.getElementById('isolated_test');
+element.textContent = 'isolated_script.js not blocked';
+// [End isolated_script_java_script]
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html
new file mode 100644
index 0000000000000000000000000000000000000000..48ae7287bb6eb547f3e6af93822a6a2395554b28
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
scheme: custom-local
+
options: ARKWEB_SCHEME_OPTION_LOCAL
+
local_script.js 被拦截
+
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..b09eb3740e6f590481b9cc9f6832e15b6e9dd3de
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// [Start local_script_java_script]
+const element = document.getElementById('local_test');
+element.textContent = 'local_script.js not blocked.';
+// [End local_script_java_script]
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html
new file mode 100644
index 0000000000000000000000000000000000000000..cbb19dd30b4670af0cd983c6b86e91ffd283bc1f
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
test xhr post
+
test xhr put
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..e971e1c41387fc0a6e34e39d7a5ec6477419a3e2
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js
new file mode 100644
index 0000000000000000000000000000000000000000..cdc5590284c2fb3fb66db687cdffc22f33782338
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// [Start add_event_listener_java_script]
+self.addEventListener('install', event => {
+ console.log('v1 installing');
+ event.waitUntil(
+ caches.open('static-v1').then(cache => cache.add('/cat.svg'))
+ );
+});
+
+self.addEventListener('activate', event => {
+ console.log('v1 now redy to handle fetches.');
+});
+// [End add_event_listener_java_script]
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html
new file mode 100644
index 0000000000000000000000000000000000000000..957e0b9cc9468930d06bade7bf15c6ea0ebbc90e
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
网络拦截测试demo
+拦截视频资源请求,读取本地mp4文件
+测试三方协议忽略csp检查,并成功拦截
+测试拦截设置ISOLATED属性的三方协议
+测试拦截设置LOCAL属性的三方协议
+测试拦截service worker触发的请求
+测试读取blob类型http body stream
+测试读取chunked类型http body stream
+
+
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..ea7b6c492bd757159d6fd62dd848a376bf918740
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html
new file mode 100644
index 0000000000000000000000000000000000000000..87ccf17357ff0339a98a46c4f4f2077bac25699b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr
new file mode 100644
index 0000000000000000000000000000000000000000..42d4264b05a9fa4c2a5bf7e90c6f003e17588137
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr
@@ -0,0 +1,16 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..9096f0eec925f8fad0a201dd68e989ac2137ed90
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "NetReqInterceptCacheWinOps"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets
new file mode 100644
index 0000000000000000000000000000000000000000..133fac9027ff6bbdcccfe98838fdbb2dc34639ab
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const nativeMock: Record = {
+ 'add': (a: number, b: number) => {
+ return a + b;
+ },
+};
+
+export default nativeMock;
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2c7d2ba82b796a2850ced0a277d261d7d7355416
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "libentry.so": {
+ "source": "src/mock/Libentry.mock.ets"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..be2af5338287767cc4f8e7a9c828728053e40ca8
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /**
+ * 打开应用,拦截Web组件发起的网络请求
+ */
+ it('testUiExample', 0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(3000);
+
+ const button = await driver.findComponent(ON.text('goback'));
+ const clickText = await driver.findComponent(ON.type('link'));
+ await clickText.click();
+ await driver.delayMs(2000);
+
+ await button.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('test.html');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6f8ebfffe80a99a9743e76a638cdd63c2b6ec72f
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry2",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0686a465f4e01e6afec667246536c3770fda73f9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_module_open_bf_cache]
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+import { webview } from '@kit.ArkWeb';
+
+export default class Entry2Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ let features = new webview.BackForwardCacheSupportedFeatures();
+ features.nativeEmbed = true;
+ features.mediaTakeOver = true;
+ webview.WebviewController.enableBackForwardCache(features);
+ webview.WebviewController.initializeWebEngine();
+ AppStorage.setOrCreate('abilityWant', want);
+ }
+ // [End web_module_open_bf_cache]
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f9a6b459004e1f1d0aefe9350f2c2ee907f66ff3
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class Entry2BackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..446ba7f8d6e676fb4293c037059eeee221396316
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_module_page_set]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct Index {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Row() {
+ Button('Add options').onClick((event: ClickEvent) => {
+ let options = new webview.BackForwardCacheOptions();
+ options.size = 10;
+ options.timeToLive = 300;
+ this.controller.setBackForwardCacheOptions(options);
+ })
+ Button('Backward').onClick((event: ClickEvent) => {
+ this.controller.backward();
+ })
+ Button('Forward').onClick((event: ClickEvent) => {
+ this.controller.forward();
+ })
+ }
+ Web({ src: 'https://www.example.com', controller: this.controller })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
+// [End Web_module_page_set]
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..90a4604809422135bc23f5a1d55f88ba15ad078d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "Entry2Ability",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry2Ability",
+ "srcEntry": "./ets/entry2ability/Entry2Ability.ets",
+ "description": "$string:Entry2Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry2Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "Entry2BackupAbility",
+ "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..548e6b522b6158085c11a1e61c7ce27152a67f30
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry2Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry2Ability_label",
+ "value": "NetReqInterceptCacheWinOps"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dfe20be2b7aebdfd54b3025e5c5a3af35b814ca1
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /**
+ * 打开应用,使用Web组件前进后退缓存
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry2Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry2Ability');
+ await driver.delayMs(4000);
+ const button1 = await driver.findComponent(ON.text('Add options'));
+ const button2 = await driver.findComponent(ON.text('Backward'));
+ const button3 = await driver.findComponent(ON.text('Forward'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const clickText = await driver.findComponent(ON.type('link'));
+ await clickText.click();
+ await driver.delayMs(1000);
+
+ await button2.click();
+ await driver.delayMs(1000);
+
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const web = await driver.findComponent(ON.type('Web'));
+ let src: string = await web.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..17410acb16bcc114982071879ee6b1f000794e19
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..655d244a4ec5c8e387d7ebfb66967132c8c952f6
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry3",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..069b292b0af70b3d468200c78ee1a6322194daf7
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+// [Start create_main_window]
+import { createNWeb, defaultUrl } from '../pages/common';
+
+// [StartExclude create_main_window]
+export default class Entry3Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+ // [EndExclude create_main_window]
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建,应用仅创建一个Web组件
+ createNWeb(defaultUrl, windowStage.getMainWindowSync().getUIContext());
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+ // [End create_main_window]
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..2aa69cc19dbf5dde17260f3b99bc5d5683d0303c
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_module_dynamic_attach_detach]
+// 使用NodeController的Page页
+import { getBuilderNode, MyNodeController, defaultUrl, getWebviewController } from './common';
+
+@Entry
+@Component
+struct Index {
+ private nodeController : MyNodeController =
+ new MyNodeController(getBuilderNode(defaultUrl), getWebviewController(defaultUrl));
+
+ build() {
+ Row() {
+ Column() {
+ Button('Attach Webview')
+ .onClick(() => {
+ // 注意不要将同一个节点同时挂载在不同的页面上!
+ this.nodeController.attachWeb();
+ this.nodeController.rebuild();
+ })
+ Button('Detach Webview')
+ .onClick(() => {
+ this.nodeController.detachWeb();
+ this.nodeController.rebuild();
+ })
+ // NodeContainer用于与NodeController节点绑定,rebuild会触发makeNode
+ // Page页通过NodeContainer接口绑定NodeController,实现动态组件页面显示
+ NodeContainer(this.nodeController)
+ .height('80%')
+ .width('80%')
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+// [End web_module_dynamic_attach_detach]
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f5fa3e58a33fb108813444bf3ed4b64e92145af5
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start dynamic_web_module_manage]
+// 提供动态挂载Web组件能力
+import { UIContext, NodeController, BuilderNode, FrameNode } from '@kit.ArkUI';
+import { webview } from '@kit.ArkWeb';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+export const defaultUrl : string = 'www.example.com';
+
+// Data为入参封装类
+class Data{
+ public url: string = '';
+ public webController: webview.WebviewController | null = null;
+
+ constructor(url: string, webController: webview.WebviewController) {
+ this.url = url;
+ this.webController = webController;
+ }
+}
+
+// @Builder中为动态组件的具体组件内容
+@Builder
+function webBuilder(data:Data) {
+ Web({ src: data.url, controller: data.webController })
+ .width('100%')
+ .height('100%')
+ .borderStyle(BorderStyle.Dashed)
+ .borderWidth(2)
+}
+
+let wrap = wrapBuilder<[Data]>(webBuilder);
+
+// 用于控制和反馈对应的NodeContainer上的节点的行为,需要与NodeContainer一起使用
+export class MyNodeController extends NodeController {
+ private builderNode: BuilderNode<[Data]> | null | undefined = null;
+ private webController : webview.WebviewController | null | undefined = null;
+ private rootNode : FrameNode | null = null;
+
+ constructor(builderNode : BuilderNode<[Data]> | undefined, webController : webview.WebviewController | undefined) {
+ super();
+ this.builderNode = builderNode;
+ this.webController = webController;
+ }
+
+ // 必须要重写的方法,用于构建节点数、返回节点挂载在对应NodeContainer中
+ // 在对应NodeContainer创建的时候调用或者通过rebuild方法调用刷新
+ makeNode(uiContext: UIContext): FrameNode | null {
+ // 该节点会被挂载在NodeContainer的父节点下
+ return this.rootNode;
+ }
+
+ // 挂载Webview
+ attachWeb() : void {
+ if (this.builderNode) {
+ let frameNode : FrameNode | null = this.builderNode.getFrameNode();
+ if (frameNode?.getParent() != null) {
+ // 挂载自定义节点前判断该节点是否已经被挂载
+ hilog.error(0x0000, 'testTag', '%{public}s', 'The frameNode is already attached');
+ return;
+ }
+ this.rootNode = this.builderNode.getFrameNode();
+ }
+ }
+
+ // 卸载Webview
+ detachWeb() : void {
+ this.rootNode = null;
+ }
+
+ getWebController() : webview.WebviewController | null | undefined {
+ return this.webController;
+ }
+}
+
+// 创建Map保存所需要的BuilderNode
+let builderNodeMap : Map | undefined> = new Map();
+// 创建Map保存所需要的webview.WebviewController
+let webControllerMap : Map = new Map();
+
+// 初始化需要UIContext对象,UIContext对象可通过窗口或自定义组件的getUIContext方法获取
+export const createNWeb = (url: string, uiContext: UIContext) => {
+ // 创建WebviewController
+ let webController = new webview.WebviewController() ;
+ // 创建BuilderNode
+ let builderNode : BuilderNode<[Data]> = new BuilderNode(uiContext);
+ // 创建动态Web组件
+ builderNode.build(wrap, new Data(url, webController));
+
+ // 保存BuilderNode
+ builderNodeMap.set(url, builderNode);
+ // 保存WebviewController
+ webControllerMap.set(url, webController);
+}
+
+// 自定义获取BuilderNode的接口
+export const getBuilderNode = (url : string) : BuilderNode<[Data]> | undefined => {
+ return builderNodeMap.get(url);
+}
+// 自定义获取WebviewController的接口
+export const getWebviewController = (url : string) : webview.WebviewController | undefined => {
+ return webControllerMap.get(url);
+}
+// [End dynamic_web_module_manage]
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5566c38cae3156d6470062ff659b9f0a54160541
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry3Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry3Ability",
+ "srcEntry": "./ets/entry3ability/Entry3Ability.ets",
+ "description": "$string:Entry3Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry3Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0149cd890e824afa27522e2c2619eb1af870b7e6
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ }
+ ,{
+ "name": "Entry3Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry3Ability_label",
+ "value": "NetReqInterceptCacheWinOps"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f76790cc9bbcaeff8e4261f449a25498dbcfc14d
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /**
+ * 打开应用,使Web组件在不同的窗口间迁移
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry3Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry3Ability');
+ await driver.delayMs(3000);
+
+ const button1 = await driver.findComponent(ON.text('Attach Webview'));
+ const button2 = await driver.findComponent(ON.text('Detach Webview'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src1: string = await web1.getText();
+ expect(src1).assertContain('www.example.com');
+
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const web2 = await driver.findComponent(ON.type('Web'));
+ expect(web2).assertEqual(null);
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edaba8aaabfc3819914b5d624d6d0143e85b5b86
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..748fe87614e0f8e3e00968aa66845118a81eb916
--- /dev/null
+++ b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md
@@ -0,0 +1,5 @@
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | -------------------------------------- | ------------------------------- | -------- | -------- |
+| 拦截Web组件发起的网络请求 | 设备运转正常 | 应用启动成功,点击link链接请求视频资源 | 跳转视频资源页,读取本地mp4文件 | Yes | Pass |
+| 资源页按钮点击 | 位于资源页 | 点击按钮 | 跳转主页 | Yes | Pass |
+
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..e8e9e6c44c1150016138cf6d544b6f19f48f3e23
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..4071262951432b162f41bc7872458d9a806d4a95
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..68483b6904f2089e5de4eab60995b07c743f0280
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..389930d3b0933c9420e2be528c3f0386d7269eda
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..1dcad318644d71c56792ec76d711762e9b697228
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png differ
diff --git a/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..b32bfa47c6bb1dec72022ce376f7e69579ac621a
Binary files /dev/null and b/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png differ
diff --git a/ProcessWebPageCont/.gitignore b/ProcessWebPageCont/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/ProcessWebPageCont/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/ProcessWebPageCont/AppScope/app.json5 b/ProcessWebPageCont/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4b1ce53f111420364c0803811493cd969dc80603
--- /dev/null
+++ b/ProcessWebPageCont/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.processwebpagecont",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ProcessWebPageCont/AppScope/resources/base/element/string.json b/ProcessWebPageCont/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..4779102effef55e6d1414c9166b60b0783cdc210
--- /dev/null
+++ b/ProcessWebPageCont/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ProcessWebPageCont"
+ }
+ ]
+}
diff --git a/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png b/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png differ
diff --git a/ProcessWebPageCont/README.md b/ProcessWebPageCont/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..33ca5a3f5ed5dacf7ba2dfe6bb1b0ea5a1237864
--- /dev/null
+++ b/ProcessWebPageCont/README.md
@@ -0,0 +1,135 @@
+## 使用Web组件打印前端页面
+
+### 介绍
+
+2. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-print.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### InitiatePrintW3CAPI
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件打印前端页面,通过创建打印适配器,拉起打印应用,并对当前Web页面内容进行渲染,渲染后生成的PDF文件信息通过fd传递给打印框架。W3C标准协议接口window.print()方法用于打印当前页面或弹出打印对话框。该方法没有任何参数,只需要在JavaScript中调用即可。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击print按钮,触发window.print()操作,即可对页面内容进行打印。
+
+### InitiatePrintAppAPI
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件打印前端页面,应用侧通过调用createWebPrintDocumentAdapter创建打印适配器,通过将适配器传入打印的print接口调起打印。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击createWebPrintDocumentAdapter按钮应用侧会创建打印适配器,并将其传入打印接口,以触发打印操作。
+
+## 使用Web组件的PDF文档预览能力
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-pdf-preview.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### PreviewPDF
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件的PDF文档预览能力。Web组件提供了在网页中预览PDF的能力。应用可以通过Web组件的src参数和loadUrl()接口中传入PDF文件,来加载PDF文档。根据PDF文档来源不同,可以分为三种常用场景:加载网络PDF文档、加载本地PDF文档、加载应用内resource资源PDF文档。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------- |
+| |
+
+使用说明
+
+1. Web组件创建时指定默认加载的网络PDF文档example.com/test.pdf。
+
+## 网页中安全区域计算和避让适配
+
+### 介绍
+
+### CalcAdjustSafeArea
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-safe-area-insets.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### 介绍
+
+1. 本示例主要介绍网页中安全区域计算和避让适配。Web组件提供了利用W3C CSS进行安全区域计算并避让适配的能力,用来支持异形屏幕设备在沉浸式效果下页面的正常显示。此时,网页开发者想对重叠元素进行避让,就可以该能力。ArkWeb内核将持续监测Web组件及系统安全区域的位置与尺寸,依据两者的重叠部分,计算出当前Web组件的安全区域,以及在各个方向上所需避让的具体距离。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 通过expandSafeArea来开启沉浸式效果。Web组件根据实际情况对网页元素进行相应的避让,防止与系统的非安全区域发生重叠遮挡。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---InitiatePrintAppAPI
+|---|---|---InitiatePrintW3CAPI
+|---|---|---PreviewPDF
+|---|---|---CalcAdjustSafeArea
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+[ohos.permission.PRINT](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionprint)
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/ProcessWebPageCont > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
+
diff --git a/ProcessWebPageCont/build-profile.json5 b/ProcessWebPageCont/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ProcessWebPageCont/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/code-linter.json5 b/ProcessWebPageCont/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ProcessWebPageCont/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/.gitignore b/ProcessWebPageCont/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ProcessWebPageCont/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/build-profile.json5 b/ProcessWebPageCont/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ProcessWebPageCont/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/hvigorfile.ts b/ProcessWebPageCont/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ProcessWebPageCont/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ProcessWebPageCont/entry/obfuscation-rules.txt b/ProcessWebPageCont/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ProcessWebPageCont/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/oh-package.json5 b/ProcessWebPageCont/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ProcessWebPageCont/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets b/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets b/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a357e5996f55843b6b23feb7dae4b176cba2b0e6
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start use_expand_safe_area_to_enable_immersive_effect]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: 'www.example.com', controller: this.controller })
+ .width('100%').height('100%')
+ .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
+ }
+ }
+}
+// [End use_expand_safe_area_to_enable_immersive_effect]
diff --git a/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets b/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1def271b5633e957e9dd40c3b9591542f5cae01f
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('InitiatePrintW3CAPI')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/InitiatePrintW3CAPI' });
+ })
+ Button('InitiatePrintAppAPI')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/InitiatePrintAppAPI' });
+ })
+ Button('PreviewPDF')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/PreviewPDF' });
+ })
+ Button('CalcAdjustSafeArea')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/CalcAdjustSafeArea' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets b/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets
new file mode 100644
index 0000000000000000000000000000000000000000..30eecf7173f0c347787a368ec2b185ff925d4e3d
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start create_web_print_document]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { print } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('createWebPrintDocumentAdapter')
+ .onClick(() => {
+ try {
+ let webPrintDocadapter = this.controller.createWebPrintDocumentAdapter('example.pdf');
+ print.print('example_jobid', webPrintDocadapter, null, getContext());
+ } catch (error) {
+ console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller });
+ }
+ }
+}
+// [End create_web_print_document]
diff --git a/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets b/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7d1281e593d6ba6c272dcd97a49da7cc006a16c2
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start w3c_print_html]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct Index {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Row() {
+ Column() {
+ Web({ src: $rawfile('print.html'), controller: this.controller })
+ .javaScriptAccess(true)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+// [End w3c_print_html]
diff --git a/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets b/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dad0b0ca9293ff918383646cded1535936ae35c1
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_module_create_load_pdf]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({
+ src:
+ $r('app.string.web_path'), // 方式一 加载网络PDF文档
+ // getContext(this).filesDir + '/test.pdf', // 方式二 加载本地应用沙箱内PDF文档
+ // 'resource://rawfile/test.pdf', // 方式三 应用内resource资源PDF文档
+ // $rawfile('test.pdf'), // 方式四 应用内resource资源PDF文档
+ controller: this.controller
+ })
+ .domStorageAccess(true)
+ }
+ }
+}
+// [End web_module_create_load_pdf]
diff --git a/ProcessWebPageCont/entry/src/main/module.json5 b/ProcessWebPageCont/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..70729d262d8e46da160838ad06ca01e2f48b6f46
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/module.json5
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ // [Start web_module_print_html]
+ // [Start web_module_preview_pdf]
+ "requestPermissions":[
+ // [StartExclude web_module_preview_pdf]
+ {
+ "name" : "ohos.permission.PRINT"
+ },
+ // EndExclude web_module_preview_pdf]
+ // [StartExclude web_module_print_html]
+ {
+ "name" : "ohos.permission.INTERNET"
+ }
+ // [EndExclude web_module_print_html]
+ ],
+ // [End web_module_preview_pdf]
+ // [End web_module_print_html]
+ }
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/element/color.json b/ProcessWebPageCont/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/element/string.json b/ProcessWebPageCont/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1f758cd41cf67e4c769d7526ee83f962d0d865c6
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ProcessWebPageCont"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/test.pdf"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/media/background.png b/ProcessWebPageCont/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ProcessWebPageCont/entry/src/main/resources/base/media/background.png differ
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png b/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json b/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png b/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json b/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json b/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..ead1e2c5ae06ebd7246b0a4028b9899b3de9574a
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/InitiatePrintW3CAPI",
+ "pages/InitiatePrintAppAPI",
+ "pages/PreviewPDF",
+ "pages/CalcAdjustSafeArea"
+ ]
+}
diff --git a/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json b/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..448a2a5210af13626ae587985d80eb8c51800e4d
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ProcessWebPageCont"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html b/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html
new file mode 100644
index 0000000000000000000000000000000000000000..7225f16ebc840f16091bc9e7c75380f4c1104470
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+ printTest
+
+
+
+
+
+
+
This is a test page for printing
+
+
+
+
+
content content content
+
+
+
+
+
Thing
+
Chairs
+
+
+
+
+
1
+
blue
+
+
+
2
+
green
+
+
+
+
+
content content content
+
content content content
+
+
diff --git a/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf b/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..f9dac5633ffc24eea33331035efbdbaffceb0031
Binary files /dev/null and b/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf differ
diff --git a/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json b/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..88de2d38c7e3b4d9017b102162dee18ed9bc4794
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ProcessWebPageCont"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/mock/mock-config.json5 b/ProcessWebPageCont/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets b/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..328b7bb43ddfe2b41224a082e95263ec212bc34e
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 InitiatePrintW3CAPI 按钮
+ * 触发 window.print 操作对页面内容进行打印
+ */
+ it('InitiatePrintW3CAPI', 0, async (done: Function) => {
+ console.info('uitest: InitiatePrintW3CAPI begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(3000);
+
+ const button1 = await driver.findComponent(ON.text('InitiatePrintW3CAPI'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('print.html');
+
+ await driver.pressBack();
+ console.info('uitest: InitiatePrintW3CAPI end');
+ done();
+ });
+
+ /*
+ * 点击 InitiatePrintAppAPI 按钮
+ * 创建打印适配器,将适配器传入打印的print接口调起打印
+ */
+ it('InitiatePrintAppAPI', 0, async (done: Function) => {
+ console.info('uitest: InitiatePrintAppAPI begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('InitiatePrintAppAPI'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('example.com');
+
+ await driver.pressBack();
+ console.info('uitest: InitiatePrintAppAPI end');
+ done();
+ });
+
+ /*
+ * 点击 PreviewPDF 按钮
+ * 使用Web组件的PDF文档预览能力加载PDF文档
+ */
+ it('PreviewPDF', 0, async (done: Function) => {
+ console.info('uitest: PreviewPDF begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('PreviewPDF'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('example.com/test.pdf');
+
+ await driver.pressBack();
+ console.info('uitest: PreviewPDF end');
+ done();
+ });
+
+ /*
+ * 点击 CalcAdjustSafeArea 按钮
+ * 进行安全区域计算并避让适配支持异形屏幕设备在沉浸式效果下页面的正常显示
+ */
+ it('CalcAdjustSafeArea', 0, async (done: Function) => {
+ console.info('uitest: CalcAdjustSafeArea begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('CalcAdjustSafeArea'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('example.com');
+
+ console.info('uitest: CalcAdjustSafeArea end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets b/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/ohosTest/module.json5 b/ProcessWebPageCont/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/ProcessWebPageCont/entry/src/test/List.test.ets b/ProcessWebPageCont/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets b/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/ProcessWebPageCont/hvigor/hvigor-config.json5 b/ProcessWebPageCont/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb
--- /dev/null
+++ b/ProcessWebPageCont/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/ProcessWebPageCont/hvigorfile.ts b/ProcessWebPageCont/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce
--- /dev/null
+++ b/ProcessWebPageCont/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ProcessWebPageCont/oh-package.json5 b/ProcessWebPageCont/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998
--- /dev/null
+++ b/ProcessWebPageCont/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "modelVersion": "5.0.0",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/ProcessWebPageCont/ohosTest.md b/ProcessWebPageCont/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..a93a5b8216aaab3fa52497aba5b07499e2460066
--- /dev/null
+++ b/ProcessWebPageCont/ohosTest.md
@@ -0,0 +1,24 @@
+#### InitiatePrintW3CAPI
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------- | ------------ | --------------------------- | ---------------------- | -------- | -------- |
+| 使用Web组件打印前端页面 | 设备运转正常 | 应用启动成功,点击print按钮 | 触发window.print()操作 | Yes | Pass |
+
+#### InitiatePrintAppAPI
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------- | ------------ | --------------------------------------------------- | ------------ | -------- | -------- |
+| 使用Web组件打印前端页面 | 设备运转正常 | 应用启动成功,点击createWebPrintDocumentAdapter按钮 | 触发打印操作 | Yes | Pass |
+
+#### PreviewPDF
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ---------------------------- | ------------ | ------------ | -------------------------------------- | -------- | -------- |
+| 使用Web组件的PDF文档预览能力 | 设备运转正常 | 应用启动成功 | Web组件创建时指定默认加载的网络PDF文档 | Yes | Pass |
+
+#### CalcAdjustSafeArea
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ---------------------------- | ---------------------------- | ------------ | ------------------------------------------- | -------- | -------- |
+| 网页中安全区域计算和避让适配 | 设备运转正常,开启沉浸式效果 | 应用启动成功 | Web组件根据实际情况对网页元素进行相应的避让 | Yes | Pass |
+
diff --git a/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png b/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png
new file mode 100644
index 0000000000000000000000000000000000000000..bacf76e4cca730d6869a641b88c9ab43a1c654c6
Binary files /dev/null and b/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png differ
diff --git a/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png b/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png
new file mode 100644
index 0000000000000000000000000000000000000000..f3e5eb8f67cca636ea0608cd5af117cc0e8f6542
Binary files /dev/null and b/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png differ
diff --git a/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png b/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png
new file mode 100644
index 0000000000000000000000000000000000000000..6e8241f75e8b4701ee18405f97b5b9f7e65efa87
Binary files /dev/null and b/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png differ
diff --git a/ProcessWebPageCont/screenshots/PreviewPDF.png b/ProcessWebPageCont/screenshots/PreviewPDF.png
new file mode 100644
index 0000000000000000000000000000000000000000..979eb15ac49c64537b600b4fe1e1e4c03b931c52
Binary files /dev/null and b/ProcessWebPageCont/screenshots/PreviewPDF.png differ
diff --git a/README.md b/README.md
index 98edb9ddb70ba5567278a771dee8be1f843275d1..0cb263c5bbc17552a32b216fdc97ad0894bde094 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,42 @@
* [ArkWebSchemeHandler: 拦截Web组件发起的网络请求](ArkWebSchemeHandler)
+* [LifecycleWebComp:Web组件的生命周期](LifecycleWebComp)
+
+* [ManageWebCompSecPriv:解决Web组件本地资源跨域问题](ManageWebCompSecPriv)
+
+* [ManageWebPageFileIO:上传文件](ManageWebPageFileIO)
+
+* [ManageWebPageInteracts:管理网页交互](ManageWebPageInteracts)
+
+* [ManageWebPageLoadBrowse:管理网页加载与浏览记录](ManageWebPageLoadBrowse)
+
+ - [AcceleratePageAccess:加速Web页面的访问](ManageWebPageLoadBrowse/AcceleratePageAccess)
+ - [CustomizePageResp:自定义页面请求响应](ManageWebPageLoadBrowse/CustomizePageResp)
+
+ - [LoadPages:使用Web组件加载页面](ManageWebPageLoadBrowse/LoadPages)
+ - [ManagePageRedirectNav:管理页面跳转及浏览记录导航](ManageWebPageLoadBrowse/ManagePageRedirectNav)
+ - [NetReqInterceptCacheWinOps:拦截Web组件发起的网络请求](ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry)
+ - [NetReqInterceptCacheWinOps:Web组件前进后退缓存](ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2)
+ - [NetReqInterceptCacheWinOps:Web组件在不同的窗口间迁移](ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3)
+
+* [ProcessWebPageCont:使用Web组件打印前端页面](ProcessWebPageCont)
+
+* [SetBasicAttrsEvts:设置基本属性和事件](SetBasicAttrsEvts)
+
+ - [SetBasicAttrsEvtsOne:使用隐私模式](SetBasicAttrsEvts/SetBasicAttrsEvtsOne)
+ - [SetBasicAttrsEvtsTwo:管理Cookie及数据存储](SetBasicAttrsEvts/SetBasicAttrsEvtsTwo)
+
+* [UseFrontendJSApp:在应用中使用前端页面JavaScript](UseFrontendJSApp)
+
+* [UseOfflineWebComp:使用离线Web组件](UseOfflineWebComp)
+
+* [UseSameLayerRender:同层渲染](UseSameLayerRender)
+
+* [UsingWebMultimedia:使用网页多媒体](UsingWebMultimedia)
+
+* [WebRenderLayout:Web渲染和布局](WebRenderLayout)
+
## 使用说明
1. 将独立的应用示例工程导入DevEco Studio进行编译构建及运行调试。
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..0f85c5557290b6c5fe654a0173b9db71c296633d
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.setbasicattrsevtsone",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f3bc9e64fec3aceeac9b80739ca1dae60be59090
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "SetBasicAttrsEvtsOne"
+ }
+ ]
+}
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/AppScope/resources/base/media/app_icon.png differ
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..d2c0dbcbdf13fc8040b6a72ea8793fd16b944248
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/README.md
@@ -0,0 +1,318 @@
+# 使用隐私模式
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-incognito-mode.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+### AllowGeolocation
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过allowGeolocation设置隐私模式下的Web组件允许指定来源使用地理位置。
+
+#### 效果预览
+
+| 主页 |
+| ----------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式
+2. 点击按钮通过allowGeolocation设置隐私模式下的Web组件允许指定来源使用地理位置。
+
+### ClearAllCookiesSync
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过clearAllCookiesSync清除隐私模式下所有cookie。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+1. 点击按钮通过clearAllCookiesSync清除隐私模式下所有cookie。
+
+### ConfigCookieSync
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过configCookieSync设置隐私模式下指定url的单个cookie的值。
+
+#### 效果预览
+
+| 主页 |
+| ----------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+2. 点击按钮通过configCookieSync设置隐私模式下指定url的单个cookie的值。
+
+### DeleteAllData
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过deleteAllData清除隐私模式下Web SQL当前使用的所有存储。
+
+#### 效果预览
+
+| 主页 |
+| -------------------------------------------------------- |
+| |
+
+使用说明
+
+1,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+
+2 , 点击按钮通过deleteAllData清除隐私模式下Web SQL当前使用的所有存储。
+
+### DeleteGeolocation
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过deleteGeolocation清除隐私模式下指定来源的地理位置权限状态。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+2. 点击按钮通过deleteGeolocation清除隐私模式下指定来源的地理位置权限状态。
+
+### ExistCookie
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过existCookie查询隐私模式下是否存在cookie。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+2. 点击按钮通过existCookie查询隐私模式下是否存在cookie。
+
+### FetchCookieSync
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过fetchCookieSync获取隐私模式下指定url对应cookie的值。
+
+#### 效果预览
+
+| 主页 |
+| ---------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+2. 点击按钮通过fetchCookieSync获取隐私模式下指定url对应cookie的值。
+
+### GetAccessibleGeolocation
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,通过getAccessibleGeolocation以回调方式异步获取隐私模式下指定源的地理位置权限状态。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,来开启Web组件的隐私模式。
+2. 点击按钮通过getAccessibleGeolocation以回调方式异步获取隐私模式下指定源的地理位置权限状态。
+
+### IncognitoMode_one
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,将可选参数incognitoMode设置为true,来开启Web组件的隐私模式,当使用隐私模式时,浏览网页时的Cookie、 Cache Data等数据不会保存在本地的持久化文件,当隐私模式的Web组件被销毁时,Cookie、 Cache Data等数据将不被记录下来。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 将可选参数incognitoMode设置为true,创建隐私模式的Web组件。
+
+### IncognitoMode_two
+
+#### 介绍
+
+1. 本示例主要介绍使用隐私模式,通过isIncogntoMode判断当前Web组件是否是隐私模式。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+| |
+
+使用说明
+
+1. 点击按钮通过isIncogntoMode判断当前Web组件是否是隐私模式。
+
+# 在新窗口中打开页面
+
+### OpenPageNewWin
+
+#### 介绍
+
+1. 本示例主要介绍在新窗口中打开页面,通过multiWindowAccess()接口来设置是否允许网页在新窗口打开。
+2. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-open-in-new-window.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### 效果预览
+
+| 主页 | 新窗口页面 |
+| ----------------------------------------------------------- | ----------------------------------------------------------- |
+| | |
+
+使用说明
+
+1. 通过multiWindowAccess()接口来设置是否允许网页在新窗口打开。
+1. 点击按钮在新窗口打开网页。
+
+# 管理位置权限
+
+### ManageLocPerms
+
+#### 介绍
+
+1. 本示例主要介绍管理位置权限,可以通过onGeolocationShow()接口对某个网站进行位置权限管理。Web组件根据接口响应结果,决定是否赋予前端页面权限。
+2. 实现对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/web/web-geolocation-permission.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### 效果预览
+
+| 主页 | 提示框 |
+| ----------------------------------------------------------- | ----------------------------------------------------------- |
+| | |
+
+使用说明
+
+1. 通过onGeolocationShow()接口对某个网站进行位置权限管理。
+1. 点击按钮,Web组件通过弹窗的形式通知应用侧位置权限请求消息。
+
+# 设置深色模式
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-set-dark-mode.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+### DarkMode_one
+
+#### 介绍
+
+1. 本示例主要介绍对前端页面进行深色模式配置,使用darkMode()接口可以配置不同的深色模式。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 使用darkMode()接口将页面深色模式配置为跟随系统。
+
+### DarkMode_two
+
+#### 介绍
+
+1. 本示例主要介绍对前端页面进行深色模式配置,通过forceDarkAccess()接口可将前端页面强制配置深色模式。
+
+#### 效果预览
+
+| 主页 |
+| ------------------------------------------------------- |
+| |
+
+使用说明
+
+1. 将深色模式配置成WebDarkMode.On,并通过forceDarkAccess()接口将页面强制配置为深色模式。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---DarkMode_one.ets
+|---|---|---DarkMode_two.ets
+|---|---|---AllowGeolocation
+|---|---|---ClearAllCookiesSync
+|---|---|---ConfigCookieSync
+|---|---|---DeleteAllData
+|---|---|---DeleteGeolocation
+|---|---|---ExistCookie
+|---|---|---FetchCookieSync
+|---|---|---GetAccessibleGeolocation
+|---|---|---IncognitoMode_one
+|---|---|---IncognitoMode_two
+|---|---|---OpenPageNewWin.ets
+|---|---|---ManageLocPerms.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+## 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+[ohos.permission.LOCATION](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionlocation)
+
+[ohos.permission.APPROXIMATELY_LOCATION](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionapproximatelylocation)
+
+[ohos.permission.LOCATION_IN_BACKGROUND](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionlocationinbackground)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/DocsSample/ArkWeb/SetBasicAttrsEvts/SetBasicAttrsEvtsOne > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets
new file mode 100644
index 0000000000000000000000000000000000000000..96167cf5d798feae39d86710b5ee195f507eaed6
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/AllowGeolocation.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start setting_the_web_component_in_privacy_mode_allows_specifying_the_geolocation_of_the_source_used]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ origin: string = 'file:///';
+
+ build() {
+ Column() {
+ Button('allowGeolocation')
+ .onClick(() => {
+ try {
+ // allowGeolocation第二个参数表示隐私模式(true)或非隐私模式(false)下,允许指定来源使用地理位置。
+ webview.GeolocationPermissions.allowGeolocation(this.origin, true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End setting_the_web_component_in_privacy_mode_allows_specifying_the_geolocation_of_the_source_used]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dde1aa7d0bd4b8e9ab501690b47459063e6cdaf0
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ClearAllCookiesSync.ets
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start clear_all_cookies_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('clearAllCookiesSync')
+ .onClick(() => {
+ // clearAllCookiesSync参数表示清除隐私模式(true)或非隐私模式(false)下,webview的所有内存cookies。
+ webview.WebCookieManager.clearAllCookiesSync(true);
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End clear_all_cookies_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3c5e72cd0afd6e4dfc6d002d7e28532b1adb1b75
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ConfigCookieSync.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start set_the_value_of_a_single_cookie_for_a_specified_url_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('configCookieSync')
+ .onClick(() => {
+ try {
+ // configCookieSync第三个参数表示获取隐私模式(true)或非隐私模式(false)下,对应url的cookies。
+ webview.WebCookieManager.configCookieSync('www.example.com', 'a=b', true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End set_the_value_of_a_single_cookie_for_a_specified_url_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9fad13e49ed848122a37294eca902ba3b8b61ade
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_one.ets
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start configure_page_dark_mode_to_follow_the_system]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ @State mode: WebDarkMode = WebDarkMode.Auto;
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('darkModePage.html'), controller: this.controller })
+ .darkMode(this.mode)
+ }
+ }
+}
+// [End configure_page_dark_mode_to_follow_the_system]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cd0dc35bcea348c0186915a71879e92829fbbeb6
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DarkMode_two.ets
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start force_the_page_to_be_configured_to_dark_mode]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ @State mode: WebDarkMode = WebDarkMode.On;
+ @State access: boolean = true;
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('darkModePage.html'), controller: this.controller })
+ .darkMode(this.mode)
+ .forceDarkAccess(this.access)
+ }
+ }
+}
+// [End force_the_page_to_be_configured_to_dark_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets
new file mode 100644
index 0000000000000000000000000000000000000000..eba8a6b93ec17492b001acb0d90fd90f7f8248d8
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteAllData.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start clear_all_storage_currently_used_by_web_sql_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('deleteAllData')
+ .onClick(() => {
+ try {
+ // deleteAllData参数表示删除所有隐私模式(true)或非隐私模式(false)下,内存中的web数据。
+ webview.WebStorage.deleteAllData(true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index.html'), controller: this.controller, incognitoMode: true })
+ .databaseAccess(true)
+ }
+ }
+}
+// [End clear_all_storage_currently_used_by_web_sql_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9b38112ff6ea0c1a3c4b6d373614aa6f9fdede9a
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/DeleteGeolocation.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start clear_the_geolocation_permission_status_of_the_specified_source_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ origin: string = 'file:///';
+
+ build() {
+ Column() {
+ Button('deleteGeolocation')
+ .onClick(() => {
+ try {
+ // deleteGeolocation第二个参数表示隐私模式(true)或非隐私模式(false)下,清除指定来源的地理位置权限状态。
+ webview.GeolocationPermissions.deleteGeolocation(this.origin, true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End clear_the_geolocation_permission_status_of_the_specified_source_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a4f870530753c4ccb924457eb929bfb9d7e85411
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ExistCookie.ets
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start check_whether_cookies_exist_in_mode]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('existCookie')
+ .onClick(() => {
+ // existCookie参数表示隐私模式(true)或非隐私模式(false)下,查询是否存在cookies。
+ let result = webview.WebCookieManager.existCookie(true);
+ console.log('result: ' + result);
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End check_whether_cookies_exist_in_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a17ed3b40343d58092b9156b79a9d82df1c5f549
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/FetchCookieSync.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start obtain_the_value_of_the_cookie_corresponding_to_the_specified_url_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('fetchCookieSync')
+ .onClick(() => {
+ try {
+ // fetchCookieSync第二个参数表示获取隐私模式(true)或非隐私模式(false)下,webview的内存cookies。
+ let value = webview.WebCookieManager.fetchCookieSync('www.example.com', true);
+ console.log('fetchCookieSync cookie = ' + value);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End obtain_the_value_of_the_cookie_corresponding_to_the_specified_url_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1e37fd79fcd073ea9a487421899fcec2ffdd42aa
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/GetAccessibleGeolocation.ets
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start asynchronously_obtains_the_geolocation_permission_status_of_the_specified_source_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ origin: string = 'file:///';
+
+ build() {
+ Column() {
+ Button('getAccessibleGeolocation')
+ .onClick(() => {
+ try {
+ // getAccessibleGeolocation第三个参数表示隐私模式(true)或非隐私模式(false)下
+ // 以回调方式异步获取指定源的地理位置权限状态。
+ webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
+ if (error) {
+ console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error));
+ return;
+ }
+ console.log('getAccessibleGeolocationAsync result: ' + result);
+ }, true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End asynchronously_obtains_the_geolocation_permission_status_of_the_specified_source_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..95d05d45a2a3d9ac1a635dc9f47c5dcdcc9b3080
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_one.ets
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start create_a_web_component_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true });
+ }
+ }
+}
+// [End create_a_web_component_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..45893f00c020b4a179eae6575e9bed4dc899b280
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/IncognitoMode_two.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start determine_whether_the_current_web_component_is_in_privacy_mode]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('isIncognitoMode')
+ .onClick(() => {
+ try {
+ let result = this.controller.isIncognitoMode();
+ console.log('isIncognitoMode' + result);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller });
+ }
+ }
+}
+// [End determine_whether_the_current_web_component_is_in_privacy_mode]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..420f733900a18591c4b182d382f7b6e6bede3d61
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('DarkMode_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DarkMode_one' });
+ })
+ Button('DarkMode_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DarkMode_two' });
+ })
+ Button('AllowGeolocation')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/AllowGeolocation' });
+ })
+ Button('ClearAllCookiesSync')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ClearAllCookiesSync' });
+ })
+ Button('ConfigCookieSync')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ConfigCookieSync' });
+ })
+ Button('DeleteAllData')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DeleteAllData' });
+ })
+ Button('DeleteGeolocation')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DeleteGeolocation' });
+ })
+ Button('ExistCookie')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ExistCookie' });
+ })
+ Button('FetchCookieSync')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/FetchCookieSync' });
+ })
+ Button('GetAccessibleGeolocation')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/GetAccessibleGeolocation' });
+ })
+ Button('IncognitoMode_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/IncognitoMode_one' });
+ })
+ Button('IncognitoMode_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/IncognitoMode_two' });
+ })
+ Button('OpenPageNewWin')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OpenPageNewWin' });
+ })
+ Button('ManageLocPerms')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ManageLocPerms' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b39a2cf2be2b6dc0d11af46a87c698b4a7b20ac2
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/ManageLocPerms.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start a_pop_up_window_is_used_to_notify_the_app_side_location_permission_request_message]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { abilityAccessCtrl, common } from '@kit.AbilityKit';
+
+let context = getContext(this) as common.UIAbilityContext;
+let atManager = abilityAccessCtrl.createAtManager();
+
+// 向用户请求位置权限设置。
+atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION']).then((data) => {
+ console.info('data:' + JSON.stringify(data));
+ console.info('data permissions:' + data.permissions);
+ console.info('data authResults:' + data.authResults);
+}).catch((error: BusinessError) => {
+ console.error(`Failed to request permissions from user. Code is ${error.code}, message is ${error.message}`);
+})
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('getLocation.html'), controller: this.controller })
+ .geolocationAccess(true)
+ .onGeolocationShow((event) => { // 地理位置权限申请通知
+ AlertDialog.show({
+ title: 'Location permission requests',
+ message: 'Whether to allow access to location information',
+ primaryButton: {
+ value: 'cancel',
+ action: () => {
+ if (event) {
+ event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求
+ }
+ }
+ },
+ secondaryButton: {
+ value: 'ok',
+ action: () => {
+ if (event) {
+ event.geolocation.invoke(event.origin, true, false); // 允许此站点地理位置权限请求
+ }
+ }
+ },
+ cancel: () => {
+ if (event) {
+ event.geolocation.invoke(event.origin, false, false); // 不允许此站点地理位置权限请求
+ }
+ }
+ })
+ })
+ }
+ }
+}
+// [End a_pop_up_window_is_used_to_notify_the_app_side_location_permission_request_message]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets
new file mode 100644
index 0000000000000000000000000000000000000000..af16dd1c6edf119f9f6da7d80d8d45517e3a7f0a
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/ets/pages/OpenPageNewWin.ets
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start receive_a_web_component_new_window_event]
+import { webview } from '@kit.ArkWeb';
+
+// 在同一page页有两个Web组件。在WebComponent新开窗口时,会跳转到NewWebViewComp。
+@CustomDialog
+struct NewWebViewComp {
+ controller?: CustomDialogController;
+ webviewController1: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: '', controller: this.webviewController1 })
+ .javaScriptAccess(true)
+ .multiWindowAccess(false)
+ .onWindowExit(() => {
+ console.info('NewWebViewComp onWindowExit');
+ if (this.controller) {
+ this.controller.close();
+ }
+ })
+ }
+ }
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ dialogController: CustomDialogController | null = null;
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('window.html'), controller: this.controller })
+ .javaScriptAccess(true)
+ // 需要使能multiWindowAccess
+ .multiWindowAccess(true)
+ .allowWindowOpenMethod(true)
+ .onWindowNew((event) => {
+ if (this.dialogController) {
+ this.dialogController.close();
+ }
+ let popController: webview.WebviewController = new webview.WebviewController();
+ this.dialogController = new CustomDialogController({
+ builder: NewWebViewComp({ webviewController1: popController })
+ });
+ this.dialogController.open();
+ // 将新窗口对应WebviewController返回给Web内核。
+ // 如果不需要打开新窗口请调用event.handler.setWebController接口设置成null。
+ // 若不调用event.handler.setWebController接口,会造成render进程阻塞。
+ event.handler.setWebController(popController);
+ })
+ }
+ }
+}
+// [End receive_a_web_component_new_window_event]
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5 b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..394d2a4703ff31b1662e4f09fba46876e701c984
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/module.json5
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ },
+ {
+ "name" : "ohos.permission.LOCATION",
+ "reason": "$string:EntryAbility_desc",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ }
+ },
+ {
+ "name" : "ohos.permission.APPROXIMATELY_LOCATION",
+ "reason": "$string:EntryAbility_desc",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ }
+ },
+ {
+ "name" : "ohos.permission.LOCATION_IN_BACKGROUND",
+ "reason": "$string:EntryAbility_desc",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..18d4ec70763241b2e4e8ece71a5a37f56c0d74c8
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "SetBasicAttrsEvtsOne"
+ },
+ {
+ "name": "use_is_permitted",
+ "value": "本次使用允许"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/background.png differ
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/foreground.png differ
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..873e2af741f7145ca994ad97abad48f571d63589
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,19 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/DarkMode_one",
+ "pages/DarkMode_two",
+ "pages/AllowGeolocation",
+ "pages/ClearAllCookiesSync",
+ "pages/ConfigCookieSync",
+ "pages/DeleteAllData",
+ "pages/DeleteGeolocation",
+ "pages/ExistCookie",
+ "pages/FetchCookieSync",
+ "pages/GetAccessibleGeolocation",
+ "pages/IncognitoMode_one",
+ "pages/IncognitoMode_two",
+ "pages/OpenPageNewWin",
+ "pages/ManageLocPerms"
+ ]
+}
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..80f7dd956c3a63524e9bc87f25a1567069ce3176
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "SetBasicAttrsEvtsOne"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html
new file mode 100644
index 0000000000000000000000000000000000000000..43497f5df3fabd7205aa28942e6dc63e24892b4a
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/darkModePage.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
Dark mode debug page
+
+
+
\ No newline at end of file
diff --git a/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html
new file mode 100644
index 0000000000000000000000000000000000000000..4ae442f92a0e6145b5979fd8f571722c6ca83d10
--- /dev/null
+++ b/SetBasicAttrsEvts/SetBasicAttrsEvtsOne/entry/src/main/resources/rawfile/getLocation.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
diff --git a/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json b/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b060b52e82b9cbdf9b4cf441b8ebc77053cda9f4
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "UseFrontendJSApp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry/src/mock/mock-config.json5 b/UseFrontendJSApp/entry/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets b/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..529c502db25b8b7edfc5ea420457241b8d374b9f
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 通过 runJavaScript 和 runJavaScriptExt 方法调用前端页面的JavaScript相关函数
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ await driver.delayMs(5000);
+
+ const button1 = await driver.findComponent(ON.text('runJavaScript'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('runJavaScriptCodePassed'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const webButton = await driver.findComponent(ON.type('button'));
+ await webButton.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index.html');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets b/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry/src/ohosTest/module.json5 b/UseFrontendJSApp/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UseFrontendJSApp/entry/src/test/List.test.ets b/UseFrontendJSApp/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets b/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/UseFrontendJSApp/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/.gitignore b/UseFrontendJSApp/entry2/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UseFrontendJSApp/entry2/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/build-profile.json5 b/UseFrontendJSApp/entry2/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/UseFrontendJSApp/entry2/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/hvigorfile.ts b/UseFrontendJSApp/entry2/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UseFrontendJSApp/entry2/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UseFrontendJSApp/entry2/obfuscation-rules.txt b/UseFrontendJSApp/entry2/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/UseFrontendJSApp/entry2/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/oh-package.json5 b/UseFrontendJSApp/entry2/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6f8ebfffe80a99a9743e76a638cdd63c2b6ec72f
--- /dev/null
+++ b/UseFrontendJSApp/entry2/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry2",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dab8f3ea7260551b9dc6606eb397e396d241e701
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/entry2ability/Entry2Ability.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class Entry2Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..213e60d6187ea841335f6263f3072b8e1c20e395
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class Entry2BackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..730f850ab03976dfd6e0c92ad1dffdeacf6cad03
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/Index.ets
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('JavaScriptProxy')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/JavaScriptProxy' });
+ })
+ Button('Promise_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Promise_one' });
+ })
+ Button('Promise_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Promise_two' });
+ })
+ Button('RegisterJavaScriptProxy')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/RegisterJavaScriptProxy' });
+ })
+ Button('UsageOfComplexTypes_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UsageOfComplexTypes_one' });
+ })
+ Button('UsageOfComplexTypes_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UsageOfComplexTypes_two' });
+ })
+ Button('UsageOfComplexTypes_three')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UsageOfComplexTypes_three' });
+ })
+ Button('UsageOfComplexTypes_four')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UsageOfComplexTypes_four' });
+ })
+ Button('UsageOfComplexTypes_five')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UsageOfComplexTypes_five' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a1cd4cc07f1b04d30dc9cf8918b25cf8da7746eb
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/JavaScriptProxy.ets
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start functions_that_trigger_a_run_on_the_front_end_page_are_registered_in_the_front_end_page]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(): string {
+ return 'ArkTS Hello World!';
+ }
+}
+
+@Entry
+@Component
+struct WebComponent {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ // 声明需要注册的对象
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // Web组件加载本地index.html页面
+ Web({ src: $rawfile('index1.html'), controller: this.webviewController})
+ // 将对象注入到web端
+ .javaScriptProxy({
+ object: this.testObj,
+ name: 'testObjName',
+ methodList: ['test'],
+ controller: this.webviewController,
+ // 可选参数
+ asyncMethodList: [],
+ permission: '{"javascriptProxyPermission":{"urlPermissionList":' +
+ '[{"scheme":"resource","host":"rawfile","port":"","path":""},' +
+ '{"scheme":"e","host":"f","port":"g","path":"h"}],"methodList":' +
+ '[{"methodName":"test","urlPermissionList":' +
+ '[{"scheme":"https","host":"xxx.com","port":"","path":""},' +
+ '{"scheme":"resource","host":"rawfile","port":"","path":""}]},' +
+ '{"methodName":"test11","urlPermissionList":' +
+ '[{"scheme":"q","host":"r","port":"","path":"t"},' +
+ '{"scheme":"u","host":"v","port":"","path":""}]}]}}'
+ })
+ }
+ }
+}
+// [End functions_that_trigger_a_run_on_the_front_end_page_are_registered_in_the_front_end_page]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..df576803c18cdb35e48140459f394c0ad41faf46
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_one.ets
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start on_the_application_side_of_new_promise]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(): Promise {
+ let p: Promise = new Promise((resolve, reject) => {
+ setTimeout(() => {
+ console.log('Execute Finished');
+ reject('fail');
+ }, 10000);
+ });
+ return p;
+ }
+
+ toString(param: String): void {
+ console.log(' ' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index2.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End on_the_application_side_of_new_promise]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..67fdec8c5f3d40c406ceeac6190168faad1119a7
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/Promise_two.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start on_the_front_end_page_new_promise]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(param:Function): void {
+ setTimeout( () => { param('suc') }, 10000)
+ }
+
+ toString(param:String): void {
+ console.log(' ' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index3.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End on_the_front_end_page_new_promise]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e69d1c30cccae8cbb61c9ef8072d23481eca3030
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/RegisterJavaScriptProxy.ets
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start application_side_api_registration]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(): string {
+ return 'ArkUI Web Component';
+ }
+
+ toString(): void {
+ console.log('Web Component toString');
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString'],
+ // 可选参数, asyncMethodList
+ [],
+ // 可选参数, permission
+ '{"javascriptProxyPermission":{"urlPermissionList":' +
+ '[{"scheme":"resource","host":"rawfile","port":"","path":""},' +
+ '{"scheme":"e","host":"f","port":"g","path":"h"}],"methodList":' +
+ '[{"methodName":"test","urlPermissionList":' +
+ '[{"scheme":"https","host":"xxx.com","port":"","path":""},' +
+ '{"scheme":"resource","host":"rawfile","port":"","path":""}]},' +
+ '{"methodName":"test11","urlPermissionList":[{"scheme":"q","host":"r","port":"","path":"t"},' +
+ '{"scheme":"u","host":"v","port":"","path":""}]}]}}'
+ );
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index4.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End application_side_api_registration]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8d284f5ddc539a42864c2a7fe68bc10be95c4ad6
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_five.ets
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_front_end_page_calls_the_function_in_the_object_on_the_application_side]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class ObjOther {
+ public methodNameListForJsProxy: string[];
+
+ constructor(list: string[]) {
+ this.methodNameListForJsProxy = list;
+ }
+
+ testOther(json: string): void {
+ console.info(json);
+ }
+}
+
+class TestClass {
+public objReturn: ObjOther
+
+ constructor() {
+ this.objReturn = new ObjOther(['testOther']);
+ }
+
+ test(): ESObject {
+ return this.objReturn
+ }
+
+ toString(param: string): void {
+ console.log('Web Component toString' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index5.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End the_front_end_page_calls_the_function_in_the_object_on_the_application_side]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets
new file mode 100644
index 0000000000000000000000000000000000000000..046d6e1c60674e9d5ca76fb13044fccb9b6c3388
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_four.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start call_the_function_in_the_object_of_the_front_end_page_on_the_application_side]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(param: ESObject): void {
+ param.hello('call obj func');
+ }
+
+ toString(param: String): void {
+ console.log('Web Component toString' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index6.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End call_the_function_in_the_object_of_the_front_end_page_on_the_application_side]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..2f115540320bebd5d2a69fc9c90e89ef13f76e9b
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_one.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start pass_an_array_between_the_application_side_and_the_front_end_page]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(): Array {
+ return [1, 2, 3, 4];
+ }
+
+ toString(param: String): void {
+ console.log('Web Component toString' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index7.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End pass_an_array_between_the_application_side_and_the_front_end_page]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets
new file mode 100644
index 0000000000000000000000000000000000000000..32d9ef6c5bee7edbda4c4e2ee6326717eddfbe3c
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_three.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_application_side_calls_the_callback_of_the_front_end_page]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class TestClass {
+ constructor() {
+ }
+
+ test(param: Function): void {
+ param('call callback');
+ }
+
+ toString(param: String): void {
+ console.log('Web Component toString' + param);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index8.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End the_application_side_calls_the_callback_of_the_front_end_page]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ee4d7cbb90d72f446f6787797845c48ac385242a
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/ets/pages/UsageOfComplexTypes_two.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_base_type_is_passed_between_the_app_side_and_front_end_pages]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+class Student {
+ public name: string = '';
+ public age: string = '';
+}
+
+class TestClass {
+ constructor() {
+ }
+
+ // 传递的基础类型name:'jeck', age:'12'。
+ test(): Student {
+ let st: Student = { name: 'jeck', age: '12' };
+ return st;
+ }
+
+ toString(param: ESObject): void {
+ console.log('Web Component toString' + param['name']);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ @State testObj: TestClass = new TestClass();
+
+ build() {
+ Column() {
+ Button('refresh')
+ .onClick(() => {
+ try {
+ this.webviewController.refresh();
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('Register JavaScript To Window')
+ .onClick(() => {
+ try {
+ this.webviewController.registerJavaScriptProxy(this.testObj, 'testObjName', ['test', 'toString']);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('deleteJavaScriptRegister')
+ .onClick(() => {
+ try {
+ this.webviewController.deleteJavaScriptRegister('testObjName');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index9.html'), controller: this.webviewController })
+ }
+ }
+}
+// [End the_base_type_is_passed_between_the_app_side_and_front_end_pages]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/module.json5 b/UseFrontendJSApp/entry2/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..90a4604809422135bc23f5a1d55f88ba15ad078d
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/module.json5
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "Entry2Ability",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry2Ability",
+ "srcEntry": "./ets/entry2ability/Entry2Ability.ets",
+ "description": "$string:Entry2Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry2Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "Entry2BackupAbility",
+ "srcEntry": "./ets/entry2backupability/Entry2BackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json b/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json b/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..7c88d8349f6a73dadf4933bc4f150cb016a226fe
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry2Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry2Ability_label",
+ "value": "UseFrontendJSApp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png b/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UseFrontendJSApp/entry2/src/main/resources/base/media/background.png differ
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png b/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UseFrontendJSApp/entry2/src/main/resources/base/media/foreground.png differ
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json b/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png b/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UseFrontendJSApp/entry2/src/main/resources/base/media/startIcon.png differ
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json b/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json b/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..85f81c85c48178478853558030d3f675380df813
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,14 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/JavaScriptProxy",
+ "pages/RegisterJavaScriptProxy",
+ "pages/Promise_one",
+ "pages/Promise_two",
+ "pages/UsageOfComplexTypes_one",
+ "pages/UsageOfComplexTypes_two",
+ "pages/UsageOfComplexTypes_three",
+ "pages/UsageOfComplexTypes_four",
+ "pages/UsageOfComplexTypes_five"
+ ]
+}
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html
new file mode 100644
index 0000000000000000000000000000000000000000..f191e18ba4a95fff3e0c00a06b8efc58042bed0e
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index1.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html
new file mode 100644
index 0000000000000000000000000000000000000000..7ce3b4e0f6e7224d2d374d758218d12762074285
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index2.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html
new file mode 100644
index 0000000000000000000000000000000000000000..e8d5f8a4bc6bb2a5e7c71dd1755b2163640762d4
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index3.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html
new file mode 100644
index 0000000000000000000000000000000000000000..f191e18ba4a95fff3e0c00a06b8efc58042bed0e
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index4.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html
new file mode 100644
index 0000000000000000000000000000000000000000..39411f1290bcb77735a74018e21440838badf590
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index5.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html
new file mode 100644
index 0000000000000000000000000000000000000000..139cccc5c8e66579033566092b69e28f256fc329
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index6.html
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html
new file mode 100644
index 0000000000000000000000000000000000000000..a40f4ca5f942a89dd8b4fc5867302f142e3c53dd
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index7.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html
new file mode 100644
index 0000000000000000000000000000000000000000..b7092a6123176ec10e701a02f16b038a80db4fc3
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index8.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html
new file mode 100644
index 0000000000000000000000000000000000000000..a40f4ca5f942a89dd8b4fc5867302f142e3c53dd
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/main/resources/rawfile/index9.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/mock/mock-config.json5 b/UseFrontendJSApp/entry2/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets b/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fe6e745d6402255deda1eb8eaae4ead04782fd0c
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用,点击 JavaScriptProxy 按钮
+ * 在Web组件初始化使用 javaScriptProxy 接口注册应用侧代码
+ */
+ it('JavaScriptProxy', 0, async (done: Function) => {
+ console.info('uitest: JavaScriptProxy begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry2Ability'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry2Ability');
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('JavaScriptProxy'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.type('button'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index1.html');
+
+ await driver.pressBack();
+ console.info('uitest: JavaScriptProxy end');
+ done();
+ });
+
+ /*
+ * 点击 Promise_one 按钮
+ * 使用Promise使用场景
+ */
+ it('Promise_one', 0, async (done: Function) => {
+ console.info('uitest: Promise_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('Promise_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ await driver.pressBack();
+ console.info('uitest: Promise_one end');
+ done();
+ });
+
+ /*
+ * 点击 Promise_two 按钮
+ * 使用Promise使用场景
+ */
+ it('Promise_two', 0, async (done: Function) => {
+ console.info('uitest: Promise_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('Promise_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ await driver.pressBack();
+ console.info('uitest: Promise_two end');
+ done();
+ });
+
+ /*
+ * 点击 RegisterJavaScriptProxy 按钮
+ * 使用 registerJavaScriptProxy 接口注册应用侧代码
+ */
+ it('RegisterJavaScriptProxy', 0, async (done: Function) => {
+ console.info('uitest: RegisterJavaScriptProxy begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('RegisterJavaScriptProxy'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index4.html');
+
+ await driver.pressBack();
+ console.info('uitest: RegisterJavaScriptProxy end');
+ done();
+ });
+
+ /*
+ * 点击 UsageOfComplexTypes_one 按钮
+ * 在应用侧和前端页面之间传递Array
+ */
+ it('UsageOfComplexTypes_one', 0, async (done: Function) => {
+ console.info('uitest: UsageOfComplexTypes_one begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UsageOfComplexTypes_one'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index7.html');
+
+ await driver.pressBack();
+ console.info('uitest: UsageOfComplexTypes_one end');
+ done();
+ });
+
+ /*
+ * 点击 UsageOfComplexTypes_two 按钮
+ * 应用侧和前端页面之间传递基础类型,非Function等复杂类型
+ */
+ it('UsageOfComplexTypes_two', 0, async (done: Function) => {
+ console.info('uitest: UsageOfComplexTypes_two begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UsageOfComplexTypes_two'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index9.html');
+
+ await driver.pressBack();
+ console.info('uitest: UsageOfComplexTypes_two end');
+ done();
+ });
+
+ /*
+ * 点击 UsageOfComplexTypes_three 按钮
+ * 使用应用侧调用前端页面的Callback
+ */
+ it('UsageOfComplexTypes_three', 0, async (done: Function) => {
+ console.info('uitest: UsageOfComplexTypes_three begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UsageOfComplexTypes_three'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index8.html');
+
+ await driver.pressBack();
+ console.info('uitest: UsageOfComplexTypes_three end');
+ done();
+ });
+
+ /*
+ * 点击 UsageOfComplexTypes_four 按钮
+ * 应用侧调用前端页面Object里的Function
+ */
+ it('UsageOfComplexTypes_four', 0, async (done: Function) => {
+ console.info('uitest: UsageOfComplexTypes_four begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UsageOfComplexTypes_four'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index6.html');
+
+ await driver.pressBack();
+ console.info('uitest: UsageOfComplexTypes_four end');
+ done();
+ });
+
+ /*
+ * 点击 UsageOfComplexTypes_five 按钮
+ * 前端页面调用应用侧Object里的Function
+ */
+ it('UsageOfComplexTypes_five', 0, async (done: Function) => {
+ console.info('uitest: UsageOfComplexTypes_five begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+
+ const button1 = await driver.findComponent(ON.text('UsageOfComplexTypes_five'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('refresh'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const button3 = await driver.findComponent(ON.text('Register JavaScript To Window'));
+ await button3.click();
+ await driver.delayMs(1000);
+
+ const button4 = await driver.findComponent(ON.text('deleteJavaScriptRegister'));
+ await button4.click();
+ await driver.delayMs(1000);
+
+ const button5 = await driver.findComponent(ON.type('button'));
+ await button5.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index5.html');
+
+ console.info('uitest: UsageOfComplexTypes_five end');
+ done();
+ });
+ })
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets b/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/ohosTest/module.json5 b/UseFrontendJSApp/entry2/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..17410acb16bcc114982071879ee6b1f000794e19
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/ohosTest/module.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry2_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UseFrontendJSApp/entry2/src/test/List.test.ets b/UseFrontendJSApp/entry2/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets b/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/UseFrontendJSApp/entry2/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/.gitignore b/UseFrontendJSApp/entry3/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UseFrontendJSApp/entry3/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/build-profile.json5 b/UseFrontendJSApp/entry3/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/UseFrontendJSApp/entry3/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/hvigorfile.ts b/UseFrontendJSApp/entry3/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UseFrontendJSApp/entry3/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UseFrontendJSApp/entry3/obfuscation-rules.txt b/UseFrontendJSApp/entry3/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/UseFrontendJSApp/entry3/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/oh-package.json5 b/UseFrontendJSApp/entry3/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..655d244a4ec5c8e387d7ebfb66967132c8c952f6
--- /dev/null
+++ b/UseFrontendJSApp/entry3/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry3",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e62e0723b2780a459f90447d95ff110ba058fc00
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/ets/entry3ability/Entry3Ability.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class Entry3Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets b/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fbd0bd1bab826fdc2c0ad69c882481ee047fe643
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/ets/pages/Index.ets
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start create_a_message_port_to_implement_communication_between_the_two_ends]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ ports: webview.WebMessagePort[] = [];
+ @State sendFromEts: string = 'Send this message from ets to HTML';
+ @State receivedFromHtml: string = 'Display received message send from HTML';
+
+ build() {
+ Column() {
+ // Display the content received from the HTML side.
+ Text(this.receivedFromHtml)
+ // Send the content in the text box to the HTML side.
+ TextInput({ placeholder: 'Send this message from ets to HTML' })
+ .onChange((value: string) => {
+ this.sendFromEts = value;
+ })
+
+ // The following can be called in the onPageEnd lifecycle callback.
+ Button('postMessage')
+ .onClick(() => {
+ try {
+ // 1. Create two message ports.
+ this.ports = this.controller.createWebMessagePorts();
+ // 2. Register a callback for the message port (for example, port 1) on the application.
+ this.ports[1].onMessageEvent((result: webview.WebMessage) => {
+ let msg = 'Got msg from HTML:';
+ if (typeof (result) === 'string') {
+ console.info(`received string message from html5, string is: ${result}`);
+ msg = msg + result;
+ } else if (typeof (result) === 'object') {
+ if (result instanceof ArrayBuffer) {
+ console.info(`received arraybuffer from html5, length is: ${result.byteLength}`);
+ msg = msg + 'length is ' + result.byteLength;
+ } else {
+ console.info('not support');
+ }
+ } else {
+ console.info('not support');
+ }
+ this.receivedFromHtml = msg;
+ })
+ // 3. Send the other message port (for example, port 0) to
+ // the HTML side, which then saves the message port.
+ this.controller.postMessage('__init_port__', [this.ports[0]], '*');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+
+ // 4. Use the message port on the application to send messages to
+ // the message port that has been sent to the HTML side.
+ Button('SendDataToHTML')
+ .onClick(() => {
+ try {
+ if (this.ports && this.ports[1]) {
+ this.ports[1].postMessageEvent(this.sendFromEts);
+ } else {
+ console.error(`ports is null, Please initialize first`);
+ }
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index.html'), controller: this.controller })
+ }
+ }
+}
+// [End create_a_message_port_to_implement_communication_between_the_two_ends]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/main/module.json5 b/UseFrontendJSApp/entry3/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..a9345ab1e0f0dbf59e896cd74d2ced8094e7fb9b
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/module.json5
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry3Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry3Ability",
+ "srcEntry": "./ets/entry3ability/Entry3Ability.ets",
+ "description": "$string:Entry3Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry3Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json b/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json b/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1253ae78eed82312b6c4db8b1a11dc6baee5f27c
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry3Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry3Ability_label",
+ "value": "UseFrontendJSApp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png b/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UseFrontendJSApp/entry3/src/main/resources/base/media/background.png differ
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png b/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UseFrontendJSApp/entry3/src/main/resources/base/media/foreground.png differ
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json b/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png b/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UseFrontendJSApp/entry3/src/main/resources/base/media/startIcon.png differ
diff --git a/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json b/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html b/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..7e67007432b4e000fab6254a4fd81bd071066193
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/main/resources/rawfile/index.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+ WebView Message Port Demo
+
+
+
WebView Message Port Demo
+
+
+
+
+
display received message send from ets
+
+
+
diff --git a/UseFrontendJSApp/entry3/src/mock/mock-config.json5 b/UseFrontendJSApp/entry3/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/mock/mock-config.json5
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets b/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..909b4cebec67c5b9af51626c88043ac152a69906
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 建立应用侧与前端页面数据通道
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry3Ability'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry3Ability');
+ await driver.delayMs(5000);
+
+ const button1 = await driver.findComponent(ON.text('postMessage'));
+ await button1.click();
+ await driver.delayMs(1000);
+
+ const button2 = await driver.findComponent(ON.text('SendDataToHTML'));
+ await button2.click();
+ await driver.delayMs(1000);
+
+ const webButton = await driver.findComponent(ON.type('button'));
+ await webButton.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('index.html');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets b/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/ohosTest/module.json5 b/UseFrontendJSApp/entry3/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edaba8aaabfc3819914b5d624d6d0143e85b5b86
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry3_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UseFrontendJSApp/entry3/src/test/List.test.ets b/UseFrontendJSApp/entry3/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets b/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/UseFrontendJSApp/entry3/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/.gitignore b/UseFrontendJSApp/entry4/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UseFrontendJSApp/entry4/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/build-profile.json5 b/UseFrontendJSApp/entry4/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fea31f4580540c7c560b62bf531292c471c410f1
--- /dev/null
+++ b/UseFrontendJSApp/entry4/build-profile.json5
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": ["arm64-v8a", "x86_64"]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/hvigorfile.ts b/UseFrontendJSApp/entry4/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UseFrontendJSApp/entry4/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UseFrontendJSApp/entry4/obfuscation-rules.txt b/UseFrontendJSApp/entry4/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/UseFrontendJSApp/entry4/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/oh-package.json5 b/UseFrontendJSApp/entry4/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..00f4289f03ded4fc5b05708a28cd06c44a0ad53e
--- /dev/null
+++ b/UseFrontendJSApp/entry4/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry4",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry4.so": "file:./src/main/cpp/types/libentry4"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt b/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..14607faba853fe717a19495cfc2364bc8be66216
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,24 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.4.1)
+project(NDKJSBridg)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED hello.cpp jsbridge_object.cpp)
+
+find_library(
+ # Sets the name of the path variable.
+ hilog-lib
+ # Specifies the name of the NDK library that
+ # you want CMake to locate.
+ hilog_ndk.z
+)
+
+target_link_libraries(entry PUBLIC libace_napi.z.so ${hilog-lib} libohweb.so)
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp b/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..096575c6a7109a5cb714c7a936f28dfc0019aebb
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/hello.cpp
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start node_api_layer_code]
+#include "napi/native_api.h"
+#include
+#include
+#include
+#include
+#include
+
+#include "hilog/log.h"
+#include "web/arkweb_interface.h"
+#include "jsbridge_object.h"
+
+constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00;
+std::shared_ptr jsbridge_object_ptr = nullptr;
+static ArkWeb_ControllerAPI *controller = nullptr;
+static ArkWeb_ComponentAPI *component = nullptr;
+
+// 发送JS脚本到H5侧执行,该方法为执行结果的回调。
+static void RunJavaScriptCallback(const char *webTag, const char *result, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit RunJavaScriptCallback webTag:%{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit RunJavaScriptCallback userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->RunJavaScriptCallback(result);
+ } else {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit RunJavaScriptCallback jsb_weak_ptr lock failed");
+ }
+}
+
+// 示例代码 ,注册了1个对象,2个方法
+static void ProxyMethod1(
+ const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod1 webTag:%{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod1 userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->ProxyMethod1(dataArray, arraySize);
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod1 jsb_weak_ptr lock failed");
+ }
+}
+
+static void ProxyMethod2(
+ const char *webTag, const ArkWeb_JavaScriptBridgeData *dataArray, size_t arraySize, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod2 webTag:%{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod2 userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+
+ std::string jsCode = "runJSRetStr()";
+ ArkWeb_JavaScriptObject object = {
+ (uint8_t *)jsCode.c_str(), jsCode.size(),
+ &JSBridgeObject::StaticRunJavaScriptCallback,
+ static_cast(jsbridge_object_ptr->GetWeakPtr())
+ };
+ controller->runJavaScript(webTag, &object);
+
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->ProxyMethod2(dataArray, arraySize);
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ProxyMethod2 JsWeakPtr lock failed");
+ }
+}
+
+void ValidCallback(const char *webTag, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ValidCallback webTag: %{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ValidCallback userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->SaySomething("ValidCallback");
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit ValidCallback jsb_weak_ptr lock failed");
+ }
+
+ // [Start the_front_end_page_calls_application_side_functions]
+ // 注册对象
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy begin");
+ ArkWeb_ProxyMethod method1 = {"method1", ProxyMethod1, static_cast(jsbridge_object_ptr->GetWeakPtr())};
+ ArkWeb_ProxyMethod method2 = {"method2", ProxyMethod2, static_cast(jsbridge_object_ptr->GetWeakPtr())};
+ ArkWeb_ProxyMethod methodList[2] = {method1, method2};
+ // 调用Native Development Kit接口注册对象
+ // 如此注册的情况下,在H5页面就可以使用proxy.method1、proxy.method1调用此文件下的ProxyMethod1和ProxyMethod2方法了
+ ArkWeb_ProxyObject proxyObject = {"ndkProxy", methodList, 2};
+ controller->registerJavaScriptProxy(webTag, &proxyObject);
+ // [End the_front_end_page_calls_application_side_functions]
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit RegisterJavaScriptProxy end");
+}
+
+void LoadStartCallback(const char *webTag, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit LoadStartCallback webTag: %{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit LoadStartCallback userData is null");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->SaySomething("LoadStartCallback");
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
+ "ArkWeb", "Native Development Kit LoadStartCallback jsb_weak_ptr lock failed");
+ }
+}
+
+void LoadEndCallback(const char *webTag, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit LoadEndCallback webTag: %{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit LoadEndCallback userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->SaySomething("LoadEndCallback");
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit LoadEndCallback jsb_weak_ptr lock failed");
+ }
+}
+
+void DestroyCallback(const char *webTag, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit DestoryCallback webTag: %{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit DestroyCallback userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ jsb_ptr->SaySomething("DestroyCallback");
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit DestroyCallback jsb_weak_ptr lock failed");
+ }
+}
+
+void SetComponentCallback(ArkWeb_ComponentAPI * component, const char* webTagValue)
+{
+ // [Start the_native_side_registers_the_callback_of_the_component_lifecycle]
+ if (!ARKWEB_MEMBER_MISSING(component, onControllerAttached)) {
+ component->onControllerAttached(
+ webTagValue, ValidCallback, static_cast(jsbridge_object_ptr->GetWeakPtr()));
+ } else {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onControllerAttached func not exist");
+ }
+
+ if (!ARKWEB_MEMBER_MISSING(component, onPageBegin)) {
+ component->onPageBegin(webTagValue, LoadStartCallback, static_cast(jsbridge_object_ptr->GetWeakPtr()));
+ } else {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageBegin func not exist");
+ }
+
+ if (!ARKWEB_MEMBER_MISSING(component, onPageEnd)) {
+ component->onPageEnd(webTagValue, LoadEndCallback, static_cast(jsbridge_object_ptr->GetWeakPtr()));
+ } else {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onPageEnd func not exist");
+ }
+
+ if (!ARKWEB_MEMBER_MISSING(component, onDestroy)) {
+ component->onDestroy(webTagValue, DestroyCallback, static_cast(jsbridge_object_ptr->GetWeakPtr()));
+ } else {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb", "component onDestroy func not exist");
+ }
+ // [End the_native_side_registers_the_callback_of_the_component_lifecycle]
+}
+
+// [Start parse_and_store_webtags]
+// 解析存储webTag
+static napi_value NativeWebInit(napi_env env, napi_callback_info info)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit start");
+ size_t argc = 1;
+ napi_value args[1] = {nullptr};
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+ // 获取第一个参数webTag
+ size_t webTagSize = 0;
+ napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize);
+ char *webTagValue = new (std::nothrow) char[webTagSize + 1];
+ size_t webTagLength = 0;
+ napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength);
+ OH_LOG_Print(
+ LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit NativeWebInit webTag:%{public}s", webTagValue);
+
+ // 将webTag保存在实例对象中
+ jsbridge_object_ptr = std::make_shared(webTagValue);
+ if (jsbridge_object_ptr)
+ jsbridge_object_ptr->Init();
+// [End parse_and_store_webtags]
+
+ controller = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_CONTROLLER));
+ component = reinterpret_cast(OH_ArkWeb_GetNativeAPI(ARKWEB_NATIVE_COMPONENT));
+ SetComponentCallback(component, webTagValue);
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Native Development Kit NativeWebInit end");
+ return nullptr;
+}
+
+// 发送JS脚本到H5侧执行
+static napi_value RunJavaScript(napi_env env, napi_callback_info info)
+{
+ size_t argc = 2;
+ napi_value args[2] = {nullptr};
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ // 获取第一个参数webTag
+ size_t webTagSize = 0;
+ napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize);
+ char *webTagValue = new (std::nothrow) char[webTagSize + 1];
+ size_t webTagLength = 0;
+ napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength);
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit OH_NativeArkWeb_RunJavaScript webTag:%{public}s", webTagValue);
+
+ // 获取第二个参数 jsCode
+ size_t bufferSize = 0;
+ napi_get_value_string_utf8(env, args[1], nullptr, 0, &bufferSize);
+ char *jsCode = new (std::nothrow) char[bufferSize + 1];
+ size_t byteLength = 0;
+ napi_get_value_string_utf8(env, args[1], jsCode, bufferSize + 1, &byteLength);
+
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "Native Development Kit OH_NativeArkWeb_RunJavaScript jsCode len:%{public}zu", strlen(jsCode));
+
+ // 构造runJS执行的结构体
+ ArkWeb_JavaScriptObject object = {(uint8_t *)jsCode, bufferSize, &JSBridgeObject::StaticRunJavaScriptCallback,
+ static_cast(jsbridge_object_ptr->GetWeakPtr())};
+ controller->runJavaScript(webTagValue, &object);
+ return nullptr;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"runJavaScript", nullptr, RunJavaScript, nullptr, nullptr, nullptr, napi_default, nullptr},
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
+// [End node_api_layer_code]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp b/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b35bebbf50225c26290f8e4bc93d2feffa358523
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start handles_javascript_calls_from_webview]
+#include "jsbridge_object.h"
+
+#include "hilog/log.h"
+
+constexpr unsigned int LOG_PRINT_DOMAIN = 0xFF00;
+
+JSBridgeObject::JSBridgeObject(const char *webTag) : webTag_(webTag) {}
+
+void JSBridgeObject::Init() { weak_ptr_ = shared_from_this(); }
+
+std::weak_ptr *JSBridgeObject::GetWeakPtr() { return &weak_ptr_; }
+
+void JSBridgeObject::StaticRunJavaScriptCallback(
+ const char *webTag, const ArkWeb_JavaScriptBridgeData *data, void *userData)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject StaticRunJavaScriptCallback webTag:%{public}s", webTag);
+ if (!userData) {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject StaticRunJavaScriptCallback userData is nullptr");
+ return;
+ }
+ std::weak_ptr jsb_weak_ptr = *static_cast *>(userData);
+ if (auto jsb_ptr = jsb_weak_ptr.lock()) {
+ std::string result((char *)data->buffer, data->size);
+ jsb_ptr->RunJavaScriptCallback(result.c_str());
+ } else {
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject StaticRunJavaScriptCallback jsb_weak_ptr lock failed");
+ }
+}
+
+void JSBridgeObject::RunJavaScriptCallback(const char *result)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject OH_NativeArkWeb_RunJavaScript result:%{public}s", result);
+}
+
+void JSBridgeObject::ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject ProxyMethod1 argc:%{public}d",
+ arraySize);
+ for (int i = 0; i < arraySize; i++) {
+ std::string result((char *)dataArray[i].buffer, dataArray[i].size);
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject ProxyMethod1 argv[%{public}d]:%{public}s, size:%{public}d",
+ i, result.c_str(), dataArray[i].size);
+ }
+}
+
+void JSBridgeObject::ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize)
+{
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject ProxyMethod2 argc:%{public}d", arraySize);
+ for (int i = 0; i < arraySize; i++) {
+ std::string result((char *)dataArray[i].buffer, dataArray[i].size);
+ OH_LOG_Print(
+ LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb",
+ "JSBridgeObject ProxyMethod2 argv[%{public}d]:%{public}s, size:%{public}d",
+ i, result.c_str(), dataArray[i].size);
+ }
+}
+
+void JSBridgeObject::SaySomething(const char *say)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "JSBridgeObject SaySomething argc:%{public}s", say);
+}
+// [End handles_javascript_calls_from_webview]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h b/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h
new file mode 100644
index 0000000000000000000000000000000000000000..68d1e15bdcdbce0885d887cba00ee53264ed9edb
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/jsbridge_object.h
@@ -0,0 +1,40 @@
+#ifndef HEADER_GUARD_H
+#define HEADER_GUARD_H
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_service_code_on_the_native_side]
+#include "web/arkweb_type.h"
+#include
+
+class JSBridgeObject : public std::enable_shared_from_this {
+public:
+ explicit JSBridgeObject(const char* webTag);
+ ~JSBridgeObject() = default;
+ void Init();
+ std::weak_ptr* GetWeakPtr();
+ static void StaticRunJavaScriptCallback(const char *webTag, const ArkWeb_JavaScriptBridgeData *data,
+ void *userData);
+ void RunJavaScriptCallback(const char *result);
+ void ProxyMethod1(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize);
+ void ProxyMethod2(const ArkWeb_JavaScriptBridgeData *dataArray, int32_t arraySize);
+ void SaySomething(const char* say);
+
+private:
+ std::string webTag_;
+ std::weak_ptr weak_ptr_;
+};
+// [End the_service_code_on_the_native_side]
+#endif // HEADER_GUARD_H
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp b/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..820107b7d23aac8e97b4f6ce2d6517ea2eea824b
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/napi_init.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "napi/native_api.h"
+
+static napi_value Add(napi_env env, napi_callback_info info)
+{
+ size_t argc = 2;
+ napi_value args[2] = {nullptr};
+
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ napi_valuetype valuetype0;
+ napi_typeof(env, args[0], &valuetype0);
+
+ napi_valuetype valuetype1;
+ napi_typeof(env, args[1], &valuetype1);
+
+ double value0;
+ napi_get_value_double(env, args[0], &value0);
+
+ double value1;
+ napi_get_value_double(env, args[1], &value1);
+
+ napi_value sum;
+ napi_create_double(env, value0 + value1, &sum);
+
+ return sum;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts b/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..a12836b52e43cb6d1b8cff089e191a95b44f40a8
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/Index.d.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_arkts_interface_is_exposed_on_the_node_api_side]
+export const nativeWebInit: (webName: string) => void;
+export const runJavaScript: (webName: string, jsCode: string) => void;
+// [End the_arkts_interface_is_exposed_on_the_node_api_side]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5 b/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..1228596cfe7eb84f89b7125abb95de5246a5829c
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/cpp/types/libentry4/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "libentry4.so",
+ "types": "./Index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets b/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets
new file mode 100644
index 0000000000000000000000000000000000000000..84e3ab74f2a987f3a4cf9c6e380c5901b3491478
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/ets/entry4ability/Entry4Ability.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class Entry4Ability extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+};
diff --git a/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets b/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8a21a25554a682bc942ffee2a5b9a2beb088123a
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/ets/pages/Index.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start interact_with_the_webview_via_the_native_api]
+// [Start use_the_native_interface_to_bind_arkweb]
+import testNapi from 'libentry.so';
+import { webview } from '@kit.ArkWeb';
+
+class testObj {
+ constructor() {
+ }
+
+ test(): string {
+ console.log('ArkUI Web Component');
+ return 'ArkUI Web Component';
+ }
+
+ toString(): void {
+ console.log('Web Component toString');
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ // [Start customize_a_webtag_and_send_it_to_the_native_side_of_the_application]
+ webTag: string = 'ArkWeb1';
+ controller: webview.WebviewController = new webview.WebviewController(this.webTag);
+ @State testObjtest: testObj = new testObj();
+
+ aboutToAppear() {
+ console.info('aboutToAppear');
+ //初始化web Native Development Kit
+ testNapi.nativeWebInit(this.webTag);
+ // [End customize_a_webtag_and_send_it_to_the_native_side_of_the_application]
+ }
+ // [End use_the_native_interface_to_bind_arkweb]
+
+ build() {
+ Column() {
+ Row() {
+ Button('runJS hello')
+ .fontSize(12)
+ .onClick(() => {
+ testNapi.runJavaScript(this.webTag, 'runJSRetStr(\"" + "hello" + "\")');
+ })
+ }.height('20%')
+
+ Row() {
+ Web({ src: $rawfile('runJS.html'), controller: this.controller })
+ .javaScriptAccess(true)
+ .fileAccess(true)
+ .onControllerAttached(() => {
+ console.error('Native Development Kit onControllerAttached webId: ' + this.controller.getWebId());
+ })
+ }.height('80%')
+ }
+ }
+}
+// [End interact_with_the_webview_via_the_native_api]
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/module.json5 b/UseFrontendJSApp/entry4/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..afa13b4ebdc29a9cb812bfbb16d66e97039a14e5
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/module.json5
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry4",
+ "type": "feature",
+ "description": "$string:module_desc",
+ "mainElement": "Entry4Ability",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "Entry4Ability",
+ "srcEntry": "./ets/entry4ability/Entry4Ability.ets",
+ "description": "$string:Entry4Ability_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:Entry4Ability_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json b/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json b/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..12e68f45a4cdb0af57c32b313a820ea8d23af66b
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "Entry4Ability_desc",
+ "value": "description"
+ },
+ {
+ "name": "Entry4Ability_label",
+ "value": "UseFrontendJSApp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png b/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UseFrontendJSApp/entry4/src/main/resources/base/media/background.png differ
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png b/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UseFrontendJSApp/entry4/src/main/resources/base/media/foreground.png differ
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json b/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png b/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UseFrontendJSApp/entry4/src/main/resources/base/media/startIcon.png differ
diff --git a/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json b/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html b/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html
new file mode 100644
index 0000000000000000000000000000000000000000..a6ebe9e4665f309fd2ecbe9b256af033154bb055
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/main/resources/rawfile/runJS.html
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+ run javascript demo
+
+
+
run JavaScript Ext demo
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets b/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets
new file mode 100644
index 0000000000000000000000000000000000000000..37c4693badee0bced9f50f020403147ada0e8d44
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/mock/Libentry4.mock.ets
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const nativeMock: Record = {
+ 'add': (a: number, b: number) => {
+ return a + b;
+ },
+};
+
+export default nativeMock;
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/mock/mock-config.json5 b/UseFrontendJSApp/entry4/src/mock/mock-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..cccc61410df447034f1a89e4dae104448202f02a
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/mock/mock-config.json5
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "libentry4.so": {
+ "source": "src/mock/Libentry4.mock.ets"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets b/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f9be87be5508277dddc4e036c2c687d47c3f302a
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+
+ /*
+ * 打开应用
+ * 使用应用侧与前端页面的相互调用
+ */
+ it('testUiExample',0, async (done: Function) => {
+ console.info('uitest: TestUiExample begin');
+ const want: Want = {
+ bundleName: bundleName,
+ abilityName: 'Entry4Ability'
+ }
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ expect(ability.context.abilityInfo.name).assertEqual('Entry4Ability');
+ await driver.delayMs(5000);
+
+ const indexButton = await driver.findComponent(ON.type('Button'));
+ const webButton = await driver.findComponent(ON.type('button'));
+
+ await webButton.click();
+ await driver.delayMs(1000);
+
+ await indexButton.click();
+ await driver.delayMs(1000);
+
+ const web1 = await driver.findComponent(ON.type('Web'));
+ let src: string = await web1.getText();
+ expect(src).assertContain('runJS.html');
+
+ console.info('uitest: TestUiExample end');
+ done();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets b/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import abilityTest from './Ability.test';
+
+export default function testsuite() {
+ abilityTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/ohosTest/module.json5 b/UseFrontendJSApp/entry4/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..12ba91e94655586fb5e48c90b290e66be7e85db2
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry4_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UseFrontendJSApp/entry4/src/test/List.test.ets b/UseFrontendJSApp/entry4/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets b/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee
--- /dev/null
+++ b/UseFrontendJSApp/entry4/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry5/.gitignore b/UseFrontendJSApp/entry5/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UseFrontendJSApp/entry5/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry5/build-profile.json5 b/UseFrontendJSApp/entry5/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fea31f4580540c7c560b62bf531292c471c410f1
--- /dev/null
+++ b/UseFrontendJSApp/entry5/build-profile.json5
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": ["arm64-v8a", "x86_64"]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry5/hvigorfile.ts b/UseFrontendJSApp/entry5/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UseFrontendJSApp/entry5/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UseFrontendJSApp/entry5/obfuscation-rules.txt b/UseFrontendJSApp/entry5/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/UseFrontendJSApp/entry5/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry5/oh-package.json5 b/UseFrontendJSApp/entry5/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..b58415e4585a7d2d30f02bba160d4401c9575b19
--- /dev/null
+++ b/UseFrontendJSApp/entry5/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry5",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry5.so": "file:./src/main/cpp/types/libentry5"
+ }
+}
\ No newline at end of file
diff --git a/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt b/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..46be202fc230d85a6eade7ed2cedec2ad189af17
--- /dev/null
+++ b/UseFrontendJSApp/entry5/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,25 @@
+# entry/src/main/cpp/CMakeLists.txt
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.4.1)
+project(NDKPostMessage)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED hello.cpp)
+
+find_library(
+ # Sets the name of the path variable.
+ hilog-lib
+ # Specifies the name of the NDK library that
+ # you want CMake to locate.
+ hilog_ndk.z
+)
+
+target_link_libraries(entry PUBLIC libace_napi.z.so ${hilog-lib} libohweb.so)
diff --git a/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp b/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cde6ffb2e4639d3818c096981f9a6a07ecb74453
--- /dev/null
+++ b/UseFrontendJSApp/entry5/src/main/cpp/hello.cpp
@@ -0,0 +1,469 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start the_node_api_layer_code_for_the_data_channel_between_the_application_side_and_the_frontend_page]
+#include "napi/native_api.h"
+#include
+#include
+#include
+#include
+#include
+#include