diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b0c7bc7d9468973a02c86fae0a80050c9598dcc2 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..09408da82ddf7aa37250665e2742bc8e2069dc22 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AcceleratePageAccess" + } + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/AppScope/resources/base/media/app_icon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/README.md new file mode 100644 index 0000000000000000000000000000000000000000..90815ece7c446149a071f0b34df5fead4599ebc0 --- /dev/null +++ b/ArkWeb/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 ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess > .git/info/sparse-checkout +git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git +git pull origin master +``` \ No newline at end of file diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..91a9926d9991ebd0faf86984be0a7f95893101df --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bf0e4fed027a57256e805bbbeb305052bb0b4be --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65e6e287e05d404b31a376c49615635f654367cf --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0838a23893a22a87feea786664077715b79cf52e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5fd56f1eb0b9b271fbe3be4dc307c05d954eee7b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4387b1d1e8e1e4e55c8e53794278b34203de2801 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c4e8768835e5e869bbd19dfb80d2e323afaa6f2d --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/entry1ability/Entry1Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..3377c9ffaec9f544b5a916055d599c55761194c0 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a2fe4d9484543336d2e6c7bfce18192eb7278aa --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5303c59d21b19cfd2c0a4299ec6ea72fede11eba --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..76a37f8e3d89782b8d1c1215279ecf96c008d58e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..92f3212a1bf7d5c1936e398fec3c79bdf642d910 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8392c11cf0dbecb4cdc78dc93d456a3a8e6ff41 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry1/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6f8ebfffe80a99a9743e76a638cdd63c2b6ec72f --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/entry2ability/Entry2Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..dab8f3ea7260551b9dc6606eb397e396d241e701 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e330ef4623eab184383297cf399532844448f58c --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/Prefetching.ets new file mode 100644 index 0000000000000000000000000000000000000000..57d3b8e6e3b826c4740f5812e69e7138d2f89cd5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_one.ets new file mode 100644 index 0000000000000000000000000000000000000000..7440060a2fd78d48fb53e4ed48817f9a21855879 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_three.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5b280f4b561f8638c51c5247704d1e179a6193f --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/ets/pages/PrefetchingAPOSTRequest_two.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf09aea7ff25030baf584fd14c09ade89265977c --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7c87a975ff65dac27497e22e35d2efa530f8064f --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b363550515903b8badcdcbf12d372a6791349190 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1c4e7fcde829651559470084dc4c22f2f3c88b58 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ad971c822e74f7fa1ac058671ad091bc5bf2497 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..031b54bde39f1b8ca1884b863026dbc91fd5a75a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry2/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..655d244a4ec5c8e387d7ebfb66967132c8c952f6 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/entry3ability/Entry3Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..407cf0869b146854e930d446181307ab937540b9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/BusinessWebview.ets new file mode 100644 index 0000000000000000000000000000000000000000..510e5960466050eb2ef8f19cb9f7b22a3addf5b5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/DynamicComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0fc29ad852969d54cf5a1db9efafdd369dd7c60 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..434a2ccf53015a2a93e547b040e2a60058c0afb8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..75d2750e83bb4114e32dd9ca2339ef17b9ee0e0d --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/ets/pages/PrecompileWebview.ets new file mode 100644 index 0000000000000000000000000000000000000000..6be26765077a847037648081f343b359a30ad7a7 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5566c38cae3156d6470062ff659b9f0a54160541 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6894c74192e3a04b77939f14374213985e80eedb --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7216209578b1a72626a3341d0f398fcd2b454688 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..edaba8aaabfc3819914b5d624d6d0143e85b5b86 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry3/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ac50b7be8601621317e98fd352affe020e0897c7 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/entry4ability/Entry4Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ab5d17a3c7efdffe8b5fa34e9aec4f7ce9237c0 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/BusinessWebview.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f37c63bfdff0f3f42dee6da7e069016bbae7dd2 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/DynamicComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0fc29ad852969d54cf5a1db9efafdd369dd7c60 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42fb5389701472c2a44fbc56eccfc531217e5c4e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/InjectWebview.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ccca1250e3ea1d0b6f0b400555fe142b35979ed --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets b/ArkWeb/ManageWebPageLoadBrowse/AcceleratePageAccess/entry4/src/main/ets/pages/Resource.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c7ab57171147e3cd14c9d8b4ab18a3d3aff6ec1 --- /dev/null +++ b/ArkWeb/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: [ + // 以 + + \ No newline at end of file diff --git a/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d4c9e1478d869b1ac4894955c2600173e5fa04d3 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..43afd1c79414996342a92b8e6eb3ea00ae27ffa0 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..4231c946ba5e54812a5735db3aec93a85e465c81 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/ohosTest.md @@ -0,0 +1,11 @@ +#### OnInterceptRequest_one + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------ | ------------ | ------------ | ------------------------------ | -------- | -------- | +| 自定义页面请求响应 | 设备运转正常 | 应用启动成功 | 拦截页面请求自定义页面响应场景 | Yes | Pass | + +#### OnInterceptRequest_two + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------ | ------------ | ------------ | ------------------------------------ | -------- | -------- | +| 自定义页面请求响应 | 设备运转正常 | 应用启动成功 | 拦截页面请求,应用侧代码构建响应资源 | Yes | Pass | diff --git a/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png new file mode 100644 index 0000000000000000000000000000000000000000..5921aacb8fb3bd418ea2ab998e4b3909d96bf104 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png new file mode 100644 index 0000000000000000000000000000000000000000..3cccbb3464cb4c53486a27c8f01210550c916f52 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_one_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png new file mode 100644 index 0000000000000000000000000000000000000000..348f6eac4920aed40cc1e2523a0756f8dee2efc7 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/screenshots/OnInterceptRequest_two.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a0839764e9f5191469c5b58f2a8ec6114aa3bdcd --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..20d3fed609c211fb436f66442a2576b24d1a59ac --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/AppScope/resources/base/media/app_icon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/README.md b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8e893a37ff2d282f0179f0ad8ac59f4becad1aad --- /dev/null +++ b/ArkWeb/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 ArkWeb/ManageWebPageLoadBrowse/LoadPages > .git/info/sparse-checkout +git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git +git pull origin master +``` \ No newline at end of file diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/GlobalContext.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e388d7c0789a2fde9a1dbc86eb58c8c77b8b856 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8414f37f6e33158c3cb833f41062d18b735051df --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets new file mode 100644 index 0000000000000000000000000000000000000000..7265103ddffb308500e88278d43868f1ac9f5271 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets new file mode 100644 index 0000000000000000000000000000000000000000..208359c5f04520d90de51e7eb805f0f0a7a66264 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc56f8160ac8640379d79cd3752462ccd690cc69 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets new file mode 100644 index 0000000000000000000000000000000000000000..781bbe446f028de2b05bfcac1510cac7dea85ad5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1bb08055573f295a89c60d8119d3fc2df4bd2a2 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ee18f9ce4fbbaa1861e1de23ff3e4846c93efc87 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..13ba44d53db0cce9e6b90d39a451fb166108470b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..55043dfca0e13cb4390abc45b022b0aa9ec038c9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..13ba44d53db0cce9e6b90d39a451fb166108470b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html new file mode 100644 index 0000000000000000000000000000000000000000..4e7956396344e0db753afb9431de6cfa7b0a1e07 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local.html @@ -0,0 +1,21 @@ + + + + + +

Hello World

+ + diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html new file mode 100644 index 0000000000000000000000000000000000000000..5b3b0b03bbf5da5ac6fc1287737a776b2a9e3d4d --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/rawfile/local1.html @@ -0,0 +1,21 @@ + + + + + +

This is local1 page

+ + diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..becedf26056eeec62877304965a627eece9f3da3 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4843837034de0f1083ef3ff7cb78ca3d120146b0 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/ohosTest.md b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..af2960f92e5798733ea4e4ba0974f6c1d3238b11 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png new file mode 100644 index 0000000000000000000000000000000000000000..a7c815eb6349f7cf7eb93464d57f666fb7d21fc7 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_one.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png new file mode 100644 index 0000000000000000000000000000000000000000..03d9599d1612eb550fa3edb973024838fd7f63f9 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadLocalPageFileInSandboxPath_two.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png new file mode 100644 index 0000000000000000000000000000000000000000..dfc5745ac65d84f78a68c07b30a69fc42ef6200f Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png new file mode 100644 index 0000000000000000000000000000000000000000..89b1161c6af2b78263d8d73d873b003671c4662c Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingHTMLRichTextData_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png new file mode 100644 index 0000000000000000000000000000000000000000..385ef0d06d87a17b50786e29cee0465b25a882e3 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png new file mode 100644 index 0000000000000000000000000000000000000000..b7ec203d712bd013a4bccbb66b5a62916a70b147 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingLocalPages_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png new file mode 100644 index 0000000000000000000000000000000000000000..eb39d90e0f1758ba3640bd6021f031f7d99c885c Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png new file mode 100644 index 0000000000000000000000000000000000000000..8794cba878eb7e77ac5fcb6757ba2383fae77e5d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/LoadPages/screenshots/LoadingWebPages_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..829e8ba122dafa9aad9d543ebd9a3a6e1fb0dd10 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f2843105d1f0874209a5c4a51a1d2c67d51e296c --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ManagePageRedirectNav" + } + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/AppScope/resources/base/media/app_icon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8bd27c6b95d99602af40bdb73f2f9cce4de2e816 --- /dev/null +++ b/ArkWeb/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 ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav > .git/info/sparse-checkout +git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git +git pull origin master +``` \ No newline at end of file diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..23a5f218909827e91bf6f66ce3d472c99df7c7c2 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/CrossApplicationRedirection.ets new file mode 100644 index 0000000000000000000000000000000000000000..a449c95a90bfa7742231fc94c65d08cc41e49e20 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/HistoryNavigati.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf577c6cbf0c81e5995f9f18c2560fc73a455733 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4914a5f5df429036d7259d9a47334c52f77beb4a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/PageRedirection.ets new file mode 100644 index 0000000000000000000000000000000000000000..d57537f43fd67eb4d8e08905dfbdfd87dcf66fec --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/ets/pages/ProfilePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa930b9d9c7dfc80242309d1e9da19825de225b8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..51119df58d8798ee0c2863b48d2a3ce7e940555b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..52f59acd8b0887f9a2cd26f9588d76ca542cb6d5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c25ce9fcda427231c8f659e42517bef4b4325c41 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/call.html new file mode 100644 index 0000000000000000000000000000000000000000..ea7fea2546ac643d56202049eedb0da4cf3345ab --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/rawfile/route.html new file mode 100644 index 0000000000000000000000000000000000000000..ecc87a41688d026c9cda4f9294ea208679a7c728 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..166ab4c2891df93540a9f2407b2436874fd85e19 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e979df586c8784a60472e053f76dbced15a916c --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..2715364d3358506aeeaec98c1746d511a2fa447d --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png new file mode 100644 index 0000000000000000000000000000000000000000..4c3276769353a7d3da5af26b6d6961353df34fc5 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png new file mode 100644 index 0000000000000000000000000000000000000000..fc4e7fd04c1e2d0cb4a42462515928bbb1f5104b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/CrossApplicationRedirection_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png new file mode 100644 index 0000000000000000000000000000000000000000..2de3e6fa56de1cbf0b0813ee2209922d4c04d900 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png new file mode 100644 index 0000000000000000000000000000000000000000..5f6bd0efb6f23713a1b5bad0b17f57f7917ecd52 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/HistoryNavigati_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png new file mode 100644 index 0000000000000000000000000000000000000000..4cf9dd40a3961a799edbca39b9ffc888f4f3c8ac Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png new file mode 100644 index 0000000000000000000000000000000000000000..66705fe72f9b1a329413c5ef85d31a64d983cafe Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/ManagePageRedirectNav/screenshots/PageRedirection_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e5c664911c57e8483759f0ead8b22ff2e2af1005 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0ab70b4d42157f3ba34fcf9e9a4608fcb1a4c0 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NetReqInterceptCacheWinOps" + } + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/AppScope/resources/base/media/app_icon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5bb2b3b5840d156df3064a8e2938b3aa0960f8de --- /dev/null +++ b/ArkWeb/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 ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps > .git/info/sparse-checkout +git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git +git pull origin master +``` \ No newline at end of file diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..638ae10f4bf8fc8c16156b4fdb6d62535fb58b28 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f24addba76d1c74999c890245fdc45a1c681db97 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1686eb5df713cd6fd4c5da0dd7aeeb5d580861a9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/hello.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7ece7e82f1eeb0ab691c41323648fe0d9a630881 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c11c8b57c075b5322df845f7fdc371f8b49caa0 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a3ce2921a733d274ed070f46475e2d5edac50ece --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/rawfile_request.h new file mode 100644 index 0000000000000000000000000000000000000000..09f6814761da59b2a5d3becf46da90aa2242fb10 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97cceb187e4be3d5dd3eabe9644ec47805207ac7 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ddc53ccb115af8a04b0e6818d575dcfdf1f6769 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5420d2ebfb72569a014a35e174aa9edc7248582b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2889111cbccda2943046e3a1421d6576262e402e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2889111cbccda2943046e3a1421d6576262e402e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html new file mode 100644 index 0000000000000000000000000000000000000000..645cd7833b21a64e904b8747e2824e7f9ef6dcb7 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/chunked_post_stream.html @@ -0,0 +1,46 @@ + + + + + + + + +
test post chunked http body.
+ + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html new file mode 100644 index 0000000000000000000000000000000000000000..c80c78270a1b8ad62a0b46b5085789b1d4c3673f --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_bypassing.html @@ -0,0 +1,26 @@ + + + + + + + + +

scheme: custom-csp-bypassing

+

options: ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD

+ + + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/csp_script.js new file mode 100644 index 0000000000000000000000000000000000000000..8621810e79f5f987fbc16a20cd72200d33fe140a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated.html new file mode 100644 index 0000000000000000000000000000000000000000..bc04b313506d81f61fb720c4df39f99f9138d500 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/isolated_script.js new file mode 100644 index 0000000000000000000000000000000000000000..5ad02d6e0384ff6ab826ab4d25028c54e5afcd74 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local.html new file mode 100644 index 0000000000000000000000000000000000000000..48ae7287bb6eb547f3e6af93822a6a2395554b28 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/local_script.js new file mode 100644 index 0000000000000000000000000000000000000000..b09eb3740e6f590481b9cc9f6832e15b6e9dd3de --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html new file mode 100644 index 0000000000000000000000000000000000000000..cbb19dd30b4670af0cd983c6b86e91ffd283bc1f --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/post_data.html @@ -0,0 +1,48 @@ + + + + + + + + +
test xhr post
+
test xhr put
+ + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html new file mode 100644 index 0000000000000000000000000000000000000000..e971e1c41387fc0a6e34e39d7a5ec6477419a3e2 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/service_worker.html @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/sw.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc5590284c2fb3fb66db687cdffc22f33782338 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.html new file mode 100644 index 0000000000000000000000000000000000000000..957e0b9cc9468930d06bade7bf15c6ea0ebbc90e --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ea7b6c492bd757159d6fd62dd848a376bf918740 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/test.mp4 differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html new file mode 100644 index 0000000000000000000000000000000000000000..87ccf17357ff0339a98a46c4f4f2077bac25699b --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/video.html @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/rawfile/xhr new file mode 100644 index 0000000000000000000000000000000000000000..42d4264b05a9fa4c2a5bf7e90c6f003e17588137 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9096f0eec925f8fad0a201dd68e989ac2137ed90 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..133fac9027ff6bbdcccfe98838fdbb2dc34639ab --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2c7d2ba82b796a2850ced0a277d261d7d7355416 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..be2af5338287767cc4f8e7a9c828728053e40ca8 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6f8ebfffe80a99a9743e76a638cdd63c2b6ec72f --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2ability/Entry2Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..0686a465f4e01e6afec667246536c3770fda73f9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/entry2backupability/Entry2BackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9a6b459004e1f1d0aefe9350f2c2ee907f66ff3 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..446ba7f8d6e676fb4293c037059eeee221396316 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..90a4604809422135bc23f5a1d55f88ba15ad078d --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..548e6b522b6158085c11a1e61c7ce27152a67f30 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfe20be2b7aebdfd54b3025e5c5a3af35b814ca1 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..17410acb16bcc114982071879ee6b1f000794e19 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry2/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..655d244a4ec5c8e387d7ebfb66967132c8c952f6 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/entry3ability/Entry3Ability.ets new file mode 100644 index 0000000000000000000000000000000000000000..069b292b0af70b3d468200c78ee1a6322194daf7 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2aa69cc19dbf5dde17260f3b99bc5d5683d0303c --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/ets/pages/common.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5fa3e58a33fb108813444bf3ed4b64e92145af5 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5566c38cae3156d6470062ff659b9f0a54160541 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0149cd890e824afa27522e2c2619eb1af870b7e6 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/background.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/foreground.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f76790cc9bbcaeff8e4261f449a25498dbcfc14d --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..edaba8aaabfc3819914b5d624d6d0143e85b5b86 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/entry3/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998 --- /dev/null +++ b/ArkWeb/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/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..748fe87614e0f8e3e00968aa66845118a81eb916 --- /dev/null +++ b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/ohosTest.md @@ -0,0 +1,5 @@ +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------------- | ------------ | -------------------------------------- | ------------------------------- | -------- | -------- | +| 拦截Web组件发起的网络请求 | 设备运转正常 | 应用启动成功,点击link链接请求视频资源 | 跳转视频资源页,读取本地mp4文件 | Yes | Pass | +| 资源页按钮点击 | 位于资源页 | 点击按钮 | 跳转主页 | Yes | Pass | + diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png new file mode 100644 index 0000000000000000000000000000000000000000..e8e9e6c44c1150016138cf6d544b6f19f48f3e23 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png new file mode 100644 index 0000000000000000000000000000000000000000..4071262951432b162f41bc7872458d9a806d4a95 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/InterceptNetRequest_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png new file mode 100644 index 0000000000000000000000000000000000000000..68483b6904f2089e5de4eab60995b07c743f0280 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png new file mode 100644 index 0000000000000000000000000000000000000000..389930d3b0933c9420e2be528c3f0386d7269eda Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/MigrateWebCompWin_2.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png new file mode 100644 index 0000000000000000000000000000000000000000..1dcad318644d71c56792ec76d711762e9b697228 Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_1.png differ diff --git a/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png new file mode 100644 index 0000000000000000000000000000000000000000..b32bfa47c6bb1dec72022ce376f7e69579ac621a Binary files /dev/null and b/ArkWeb/ManageWebPageLoadBrowse/NetReqInterceptCacheWinOps/screenshots/SetBackForwardCache_2.png differ