diff --git a/OAT.xml b/OAT.xml index 9705a1cbe38d1ac277d21d688189b738b49a37d6..8ff45553be8521d2ba414fb0010e7abd27473cbd 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1347,131 +1347,10 @@ Note:If the text contains special characters, please escape them according to th - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/.gitignore b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/.gitignore new file mode 100755 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/.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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/app.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/app.json5 new file mode 100755 index 0000000000000000000000000000000000000000..74bec7c9311f63a6ee93453115cb7fc039fce91a --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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.managecookiesdata", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..a18fe4d21dc26eda73e5b6389b6303c33d4b1bd2 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ManageCookiesData" + } + ] +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/README.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/README.md new file mode 100755 index 0000000000000000000000000000000000000000..de3b5837e83342984f31f13565c85cd621b2a6d6 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/README.md @@ -0,0 +1,120 @@ +# 管理Cookie及数据存储 + +### 介绍 + +1. 实现对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/web/web-cookie-and-data-storage-mgmt.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。 + +### Cache_one + +#### 介绍 + +1. 本示例主要介绍管理Cookie及数据存储的缓存与存储管理。使用了cacheMode()接口配置页面资源的缓存模式。 + +#### 效果预览 + +| 主页 | +| --------------------------------------------------------- | +| | + +使用说明 + +1. 使用cacheMode()配置页面资源的缓存模式为None,加载资源使用cache,如果cache中无该资源则从网络中获取。 + +### Cache_two + +#### 介绍 + +1. 本示例主要介绍管理Cookie及数据存储的缓存与存储管理相关功能,通过removeCache()接口清除已经缓存的资源。 + +#### 效果预览 + +| 主页 | +| --------------------------------------------------------- | +| | + +使用说明 + +1. 点击按钮触发removeCache()接口清除已经缓存的资源。 + +### CookieManagement + +#### 介绍 + +1. 本示例主要介绍管理Cookie及数据存储。使用了configCookieSync()接口来设置单个Cookie的值。 + +#### 效果预览 + +| 主页 | +| ------------------------------------------------------------ | +| | + +使用说明 + +1. 点击按钮使用configCookieSync()接口为example.com设置单个Cookie的值。 + +### DomStorage + +#### 介绍 + +1. 本示例主要介绍管理Cookie及数据存储的缓存与存储管理相关部分Dom Storage。使用domStorageAccess()接口进行使能配置。 + +#### 效果预览 + +| 主页 | +| ---------------------------------------------------------- | +| | + +使用说明 + +1. 通过Web组件的属性接口domStorageAccess()配置Dom Storage。 + +### 工程目录 + +``` +entry/src/main/ +|---ets +|---|---entryability +|---|---|---EntryAbility.ets +|---|---pages +|---|---|---Index.ets // 首页 +|---|---|---Cache_one +|---|---|---Cache_two +|---|---|---CookieManagement +|---|---|---DomStorage +|---resources // 静态资源 +|---ohosTest +|---|---ets +|---|---|---tests +|---|---|---|---Ability.test.ets // 自动化测试用例 +``` + +### 相关权限 + +[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 +3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + + + + + diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..87d40a385e30dc461bee671328ee541abfafd5de --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/build-profile.json5 @@ -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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/code-linter.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/code-linter.json5 new file mode 100755 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/.gitignore b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/.gitignore new file mode 100755 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/build-profile.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..b4d65d490ef6cbe22d933b9231555210f1555786 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/obfuscation-rules.txt b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/obfuscation-rules.txt new file mode 100755 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..4bf3e2a9b1ae7381cf9363dff1cbcc1861a41e7b --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..b23d2fe946b5f93ddc577864f9da7c6516f59209 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..1504a74f09dfdcfae408be979f99369a2c5affab --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_one.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_one.ets new file mode 100755 index 0000000000000000000000000000000000000000..a7eaf905b4bc6ea23f236239a1d68490df8346f9 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_one.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + @State mode: CacheMode = CacheMode.None; + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .cacheMode(this.mode) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_two.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_two.ets new file mode 100755 index 0000000000000000000000000000000000000000..39b9f7e731f37453a457256dec2b5f2d06dbb5b8 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Cache_two.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + @State mode: CacheMode = CacheMode.None; + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('removeCache') + .onClick(() => { + try { + // 设置为true时同时清除rom和ram中的缓存,设置为false时只清除ram中的缓存 + this.controller.removeCache(true); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }); + Web({ src: 'www.example.com', controller: this.controller }) + .cacheMode(this.mode) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/CookieManagement.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/CookieManagement.ets new file mode 100755 index 0000000000000000000000000000000000000000..94ddfd5817e1f30499cb754df203d29954851460 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/CookieManagement.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. + */ + +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('configCookieSync') + .onClick(() => { + try { + webview.WebCookieManager.configCookieSync('https://www.example.com', 'value=test'); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }); + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/DomStorage.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/DomStorage.ets new file mode 100755 index 0000000000000000000000000000000000000000..91cf3853834d26673d5974a6856a3aa7814f5b76 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/DomStorage.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .domStorageAccess(true) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Index.ets new file mode 100755 index 0000000000000000000000000000000000000000..e83116cccc8d394565e52ef171bbd27c8382538d --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { router } from '@kit.ArkUI' + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('CookieManagement') + .onClick(() => { + router.pushUrl({ url: 'pages/CookieManagement' }); + }) + Button('Cache_one') + .onClick(() => { + router.pushUrl({ url: 'pages/Cache_one' }); + }) + Button('Cache_two') + .onClick(() => { + router.pushUrl({ url: 'pages/Cache_two' }); + }) + Button('DomStorage') + .onClick(() => { + router.pushUrl({ url: 'pages/DomStorage' }); + }) + }.height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..81751d0bc4dd4f2a057a34d8d37bb8c1396fcf7e --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..9e4de973ce90b2e9bfa4200579b6346cf4bc15e7 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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": "ManageCookiesData" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/background.png new file mode 100755 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/foreground.png new file mode 100755 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/layered_image.json new file mode 100755 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/startIcon.png new file mode 100755 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/backup_config.json new file mode 100755 index 0000000000000000000000000000000000000000..d742c2f96e7dd0f406f499941f3147345e998f95 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..8735b3efde9ed236be7dd4199f38e7dce8cfbe68 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,9 @@ +{ + "src": [ + "pages/Index", + "pages/CookieManagement", + "pages/Cache_two", + "pages/Cache_one", + "pages/DomStorage" + ] +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/en_US/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..9e4de973ce90b2e9bfa4200579b6346cf4bc15e7 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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": "ManageCookiesData" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/main/resources/zh_CN/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..442eeb5fe4fa0a0fd935c79c87c6c979b3a54eb3 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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": "ManageCookiesData" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/mock/mock-config.json5 new file mode 100755 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..c7f6dd0893adfc24e9a78a9ee0f66c1f5e84d76a --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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('Cache_one', 0, async (done: Function) => { + console.info('uitest: Cache_one begin'); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + }; + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('Cache_one')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let text1 = await web1.getText(); + expect(text1).assertContain('www.example.com'); + + await driver.pressBack(); + console.info("uitest: Cache_one end"); + done(); + }); + + it('Cache_two', 0, async (done: Function) => { + console.info("uitest: Cache_two begin"); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('Cache_two')); + await button1.click(); + await driver.delayMs(1000); + + const button2 = await driver.findComponent(ON.type('Button')); + await button2.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let text1 = await web1.getText(); + expect(text1).assertContain('www.example.com'); + + await driver.pressBack(); + console.info("uitest: Cache_two end"); + done(); + }); + + it('CookieManagement', 0, async (done: Function) => { + console.info("uitest: CookieManagement begin"); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('CookieManagement')); + await button1.click(); + await driver.delayMs(1000); + + const button = await driver.findComponent(ON.type('Button')); + await button.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let text1 = await web1.getText(); + expect(text1).assertContain('www.example.com'); + + await driver.pressBack(); + console.info("uitest: CookieManagement end"); + done(); + }); + + it('DomStorage', 0, async (done: Function) => { + console.info("uitest: DomStorage begin"); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('DomStorage')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let text1 = await web1.getText(); + expect(text1).assertContain('www.example.com'); + + console.info("uitest: DomStorage end"); + done(); + }); + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/ohosTest/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..9983b2ba4e55e31a172f0328c82c9a75bfa00ded --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/test/List.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/entry/src/test/LocalUnit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/hvigor/hvigor-config.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/hvigor/hvigor-config.json5 new file mode 100755 index 0000000000000000000000000000000000000000..c61d3eed60978a00d9a67b754ec36c0c9dcde929 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/hvigorfile.ts b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/oh-package.json5 b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..4c8bad9bdbdd8da17793a0e43f29d9e7232dce00 --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/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/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/ohosTest.md b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/ohosTest.md new file mode 100755 index 0000000000000000000000000000000000000000..bd75da366bbf9fd2586a30fadbaf73f681beb8ac --- /dev/null +++ b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/ohosTest.md @@ -0,0 +1,23 @@ +### Cache_one + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------- | ------------ | --------------------------------- | -------------------- | -------- | -------- | +| 管理Cookie及数据存储 | 设备运转正常 | 应用启动成功,点击removeCache按钮 | 清除rom和ram中的缓存 | Yes | Pass | + +### Cache_two + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------- | ------------ | ------------ | ------------------------------------ | -------- | -------- | +| 管理Cookie及数据存储 | 设备运转正常 | 应用启动成功 | 成功配置页面资源的缓存模式为None模式 | Yes | Pass | + +### CookieManagement + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------- | ------------ | -------------------------------------- | ---------------------------------- | -------- | -------- | +| 管理Cookie及数据存储 | 设备运转正常 | 应用启动成功,点击configCookieSync按钮 | 单个Cookie的值“value=test”设置成功 | Yes | Pass | + +### DomStorage + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| -------------------- | ------------ | ------------ | --------------- | -------- | -------- | +| 管理Cookie及数据存储 | 设备运转正常 | 应用启动成功 | 使能Dom Storage | Yes | Pass | diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_one.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_one.png new file mode 100755 index 0000000000000000000000000000000000000000..b519a6915fe29d4c35014427a740efef2f54f3be Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_one.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_two.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_two.png new file mode 100755 index 0000000000000000000000000000000000000000..cc9751214bb8f1b626abbb07131f0bcb5a56b1de Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/Cache_two.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/CookieManagement.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/CookieManagement.png new file mode 100755 index 0000000000000000000000000000000000000000..7226dba6e72950639ad4e07323b53fcd860521d0 Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/CookieManagement.png differ diff --git a/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/DomStorage.png b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/DomStorage.png new file mode 100755 index 0000000000000000000000000000000000000000..2737f7f92ba24dc12c23b527253054bec2961fea Binary files /dev/null and b/code/DocsSample/ArkWeb/SetBasicAttrsEvts/ManageCookiesData/screenshots/DomStorage.png differ