Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
05edbdf0
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
05edbdf0
编写于
7月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8966 add webView errorCode xts_acts testcases & pages
Merge pull request !8966 from 王闻天/webViewError
上级
a7e4e7fb
a4e31f45
变更
40
隐藏空白更改
内联
并排
Showing
40 changed file
with
5441 addition
and
0 deletion
+5441
-0
arkui/ace_ets_web_dev_webviewControllerError/AppScope/app.json
.../ace_ets_web_dev_webviewControllerError/AppScope/app.json
+21
-0
arkui/ace_ets_web_dev_webviewControllerError/AppScope/resources/base/element/string.json
...ntrollerError/AppScope/resources/base/element/string.json
+8
-0
arkui/ace_ets_web_dev_webviewControllerError/AppScope/resources/base/media/app_icon.png
...ontrollerError/AppScope/resources/base/media/app_icon.png
+0
-0
arkui/ace_ets_web_dev_webviewControllerError/BUILD.gn
arkui/ace_ets_web_dev_webviewControllerError/BUILD.gn
+41
-0
arkui/ace_ets_web_dev_webviewControllerError/Test.json
arkui/ace_ets_web_dev_webviewControllerError/Test.json
+26
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/Application/AbilityStage.ts
...ollerError/entry/src/main/ets/Application/AbilityStage.ts
+9
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/MainAbility.ts
...rollerError/entry/src/main/ets/MainAbility/MainAbility.ts
+37
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContCookieToGeoLocationError.ets
...MainAbility/pages/webViewContCookieToGeoLocationError.ets
+704
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContGetUrlAndOthersError.ets
...ets/MainAbility/pages/webViewContGetUrlAndOthersError.ets
+399
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContJavaScriptError.ets
...main/ets/MainAbility/pages/webViewContJavaScriptError.ets
+219
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContJsMessageExtReturnError.ets
.../MainAbility/pages/webViewContJsMessageExtReturnError.ets
+274
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContMessageError.ets
...rc/main/ets/MainAbility/pages/webViewContMessageError.ets
+138
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageOperationsError.ets
.../ets/MainAbility/pages/webViewContPageOperationsError.ets
+216
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContStoreWebArchiveError.ets
...ets/MainAbility/pages/webViewContStoreWebArchiveError.ets
+213
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContWebMessageExtReturnError.ets
...MainAbility/pages/webViewContWebMessageExtReturnError.ets
+311
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContZoomAndOthersError.ets
...n/ets/MainAbility/pages/webViewContZoomAndOthersError.ets
+331
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...or/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/List.test.ets
...viewControllerError/entry/src/main/ets/test/List.test.ets
+35
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/Utils.ets
..._webviewControllerError/entry/src/main/ets/test/Utils.ets
+169
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContCookieToGeoLocationError.test.ets
...ain/ets/test/webViewContCookieToGeoLocationError.test.ets
+420
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContGetUrlAndOthersError.test.ets
...rc/main/ets/test/webViewContGetUrlAndOthersError.test.ets
+288
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContJavaScriptError.test.ets
...try/src/main/ets/test/webViewContJavaScriptError.test.ets
+145
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContJsMessageExtReturnError.test.ets
...main/ets/test/webViewContJsMessageExtReturnError.test.ets
+123
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContMessageError.test.ets
.../entry/src/main/ets/test/webViewContMessageError.test.ets
+69
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageOperationsError.test.ets
...src/main/ets/test/webViewContPageOperationsError.test.ets
+178
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContStoreWebArchiveError.test.ets
...rc/main/ets/test/webViewContStoreWebArchiveError.test.ets
+134
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContWebMessageExtReturnError.test.ets
...ain/ets/test/webViewContWebMessageExtReturnError.test.ets
+134
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContZoomAndOthersError.test.ets
.../src/main/ets/test/webViewContZoomAndOthersError.test.ets
+266
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/module.json
...web_dev_webviewControllerError/entry/src/main/module.json
+49
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/element/string.json
...erError/entry/src/main/resources/base/element/string.json
+32
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/media/icon.png
...trollerError/entry/src/main/resources/base/media/icon.png
+0
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/profile/main_pages.json
...ror/entry/src/main/resources/base/profile/main_pages.json
+13
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/icon.png
...ControllerError/entry/src/main/resources/rawfile/icon.png
+0
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/index.html
...ntrollerError/entry/src/main/resources/rawfile/index.html
+73
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/index.js
...ControllerError/entry/src/main/resources/rawfile/index.js
+150
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/indexEdit.html
...llerError/entry/src/main/resources/rawfile/indexEdit.html
+22
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/indexNoPermission.html
...r/entry/src/main/resources/rawfile/indexNoPermission.html
+73
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/second.html
...trollerError/entry/src/main/resources/rawfile/second.html
+17
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/testMessageExt.html
...rror/entry/src/main/resources/rawfile/testMessageExt.html
+26
-0
arkui/ace_ets_web_dev_webviewControllerError/signature/openharmony_sx.p7b
...b_dev_webviewControllerError/signature/openharmony_sx.p7b
+0
-0
未找到文件。
arkui/ace_ets_web_dev_webviewControllerError/AppScope/app.json
0 → 100644
浏览文件 @
05edbdf0
{
"app"
:
{
"bundleName"
:
"com.open.harmony.acewebtest"
,
"vendor"
:
"huawei"
,
"versionCode"
:
1000000
,
"versionName"
:
"1.0.0"
,
"debug"
:
false
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:app_name"
,
"description"
:
"$string:description_application"
,
"distributedNotificationEnabled"
:
true
,
"keepAlive"
:
true
,
"singleUser"
:
true
,
"minAPIVersion"
:
10
,
"targetAPIVersion"
:
10
,
"car"
:
{
"apiCompatibleVersion"
:
10
,
"singleUser"
:
false
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/AppScope/resources/base/element/string.json
0 → 100644
浏览文件 @
05edbdf0
{
"string"
:[
{
"name"
:
"app_name"
,
"value"
:
"ohosProject"
}
]
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/AppScope/resources/base/media/app_icon.png
0 → 100644
浏览文件 @
05edbdf0
15.1 KB
arkui/ace_ets_web_dev_webviewControllerError/BUILD.gn
0 → 100644
浏览文件 @
05edbdf0
# Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceWebDevWebViewContErrorTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_web_dev_js_assets",
":ace_ets_web_dev_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceWebDevWebViewControllerErrorTest"
}
ohos_app_scope("ace_ets_web_dev_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_web_dev_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("ace_ets_web_dev_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":ace_ets_web_dev_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
arkui/ace_ets_web_dev_webviewControllerError/Test.json
0 → 100644
浏览文件 @
05edbdf0
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.open.harmony.acewebtest"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[{
"test-file-name"
:
[
"ActsAceWebDevWebViewControllerErrorTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"power-shell wakeup"
,
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/Application/AbilityStage.ts
0 → 100644
浏览文件 @
05edbdf0
import
AbilityStage
from
"
@ohos.app.ability.AbilityStage
"
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
[Demo] MyAbilityStage onCreate
"
)
globalThis
.
stageOnCreateRun
=
1
;
globalThis
.
stageContext
=
this
.
context
;
}
}
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/MainAbility.ts
0 → 100644
浏览文件 @
05edbdf0
import
Ability
from
'
@ohos.app.ability.UIAbility
'
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
){
// Ability is creating, initialize resources for this ability
console
.
log
(
"
[Demo] MainAbility onCreate
"
)
globalThis
.
abilityWant
=
want
;
}
onDestroy
()
{
// Ability is destroying, release resources for this ability
console
.
log
(
"
[Demo] MainAbility onDestroy
"
)
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
"
[Demo] MainAbility onWindowStageCreate windowStage=
"
+
windowStage
)
globalThis
.
windowStage
=
windowStage
globalThis
.
abilityContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/pages/webViewContMessageError
"
,
null
)
}
onWindowStageDestroy
()
{
//Main window is destroyed, release UI related resources
console
.
log
(
"
[Demo] MainAbility onWindowStageDestroy
"
)
}
onForeground
()
{
// Ability has brought to foreground
console
.
log
(
"
[Demo] MainAbility onForeground
"
)
}
onBackground
()
{
// Ability has back to background
console
.
log
(
"
[Demo] MainAbility onBackground
"
)
}
};
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContCookieToGeoLocationError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContCookieToGeoLocationError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitGetCookieInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorTestCode: number = 0;
@State errorMsg: string = 'failed';
origin: string = "";
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContCookieToGeoLocationError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("CookieToGeoLocationErrorTest").key('webViewContCookieToGeoLocationError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitGetCookieInitErr": {
try {
web_webview.WebCookieManager.getCookie('[1,2]');
} catch (error) {
console.error(`emitGetCookieInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 752)
Utils.emitEvent(this.errorMsg, 753)
break;
}
case "emitSetCookieInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
web_webview.WebCookieManager.setCookie('[1,2]', 'a=b');
} catch (error) {
console.error(`emitSetCookieInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 754)
Utils.emitEvent(this.errorMsg, 755)
break;
}
case "emitSetCookieValueErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
web_webview.WebCookieManager.setCookie('https://www.example.com', '');
} catch (error) {
console.error(`emitSetCookieValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 756)
Utils.emitEvent(this.errorMsg, 757)
break;
}
case "emitDeleteOriginValueNullErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
web_webview.WebStorage.deleteOrigin(this.origin);
} catch (error) {
console.error(`emitDeleteOriginValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 758)
Utils.emitEvent(this.errorMsg, 759)
break;
}
case "emitDeleteOriginValueIllegalErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.WebStorage.deleteOrigin(this.origin);
} catch (error) {
console.error(`emitDeleteOriginValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 760)
Utils.emitEvent(this.errorMsg, 761)
break;
}
case "emitDeleteOriginValueErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.WebStorage.deleteOrigin(this.origin);
} catch (error) {
console.error(`emitDeleteOriginValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 762)
Utils.emitEvent(this.errorMsg, 763)
break;
}
case "emitGetOriginsCallbackUnAPIErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.databaseAccess = false;
this.controller.refresh();
web_webview.WebStorage.getOrigins((error, origins) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginsCallbackUnAPIErr getOrigins return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 764)
Utils.emitEvent(this.errorMsg, 765)
return;
}
for (let i = 0; i < origins.length; i++) {
console.log('origin: ' + origins[i].origin);
console.log('usage: ' + origins[i].usage);
console.log('quota: ' + origins[i].quota);
}
})
} catch (error) {
console.error(`emitGetOriginsCallbackUnAPIErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.databaseAccess = true;
break;
}
case "emitGetOriginsPromiseUnAPIErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.databaseAccess = false;
this.controller.refresh();
web_webview.WebStorage.getOrigins()
.then(origins => {
for (let i = 0; i < origins.length; i++) {
console.log('origin: ' + origins[i].origin);
console.log('usage: ' + origins[i].usage);
console.log('quota: ' + origins[i].quota);
}
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginsPromiseUnAPIErr getOrigins return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 766)
Utils.emitEvent(this.errorMsg, 767)
})
} catch (error) {
console.error(`emitGetOriginsPromiseUnAPIErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.databaseAccess = true;
break;
}
case "emitGetOriginQuotaCallbackValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.WebStorage.getOriginQuota(this.origin, (error, quota) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaCallbackValueErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 768)
Utils.emitEvent(this.errorMsg, 769)
return;
}
console.log('quota: ' + quota);
})
} catch (error) {
console.error(`emitGetOriginQuotaCallbackValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginQuotaCallbackValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.WebStorage.getOriginQuota(this.origin, (error, quota) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaCallbackValueIllegalErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 770)
Utils.emitEvent(this.errorMsg, 771)
return;
}
console.log('quota: ' + quota);
})
} catch (error) {
console.error(`emitGetOriginQuotaCallbackValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginQuotaCallbackValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.WebStorage.getOriginQuota(this.origin, (error, quota) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaCallbackValueNullErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 772)
Utils.emitEvent(this.errorMsg, 773)
return;
}
console.log('quota: ' + quota);
})
} catch (error) {
console.error(`emitGetOriginQuotaCallbackValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginQuotaPromiseValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.WebStorage.getOriginQuota(this.origin)
.then(quota => {
console.log('quota: ' + quota);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaPromiseValueErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 774)
Utils.emitEvent(this.errorMsg, 775)
})
} catch (error) {
console.error(`emitGetOriginQuotaPromiseValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginQuotaPromiseValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.WebStorage.getOriginQuota(this.origin)
.then(quota => {
console.log('quota: ' + quota);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaPromiseValueIllegalErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 776)
Utils.emitEvent(this.errorMsg, 777)
})
} catch (error) {
console.error(`emitGetOriginQuotaPromiseValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginQuotaPromiseValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.WebStorage.getOriginQuota(this.origin)
.then(quota => {
console.log('quota: ' + quota);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginQuotaPromiseValueNullErr getOriginQuota return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 778)
Utils.emitEvent(this.errorMsg, 779)
})
} catch (error) {
console.error(`emitGetOriginQuotaPromiseValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsageCallbackValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.WebStorage.getOriginUsage(this.origin, (error, usage) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsageCallbackValueErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 780)
Utils.emitEvent(this.errorMsg, 781)
return;
}
console.log('usage: ' + usage);
})
} catch (error) {
console.error(`emitGetOriginUsageCallbackValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsageCallbackValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.WebStorage.getOriginUsage(this.origin, (error, usage) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsageCallbackValueIllegalErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 782)
Utils.emitEvent(this.errorMsg, 783)
return;
}
console.log('usage: ' + usage);
})
} catch (error) {
console.error(`emitGetOriginUsageCallbackValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsageCallbackValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.WebStorage.getOriginUsage(this.origin, (error, usage) => {
if (error) {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsageCallbackValueNullErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 784)
Utils.emitEvent(this.errorMsg, 785)
return;
}
console.log('usage: ' + usage);
})
} catch (error) {
console.error(`emitGetOriginUsageCallbackValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsagePromiseValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.WebStorage.getOriginUsage(this.origin)
.then(usage => {
console.log('usage: ' + usage);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsagePromiseValueErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 786)
Utils.emitEvent(this.errorMsg, 787)
})
} catch (error) {
console.error(`emitGetOriginUsagePromiseValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsagePromiseValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.WebStorage.getOriginUsage(this.origin)
.then(usage => {
console.log('usage: ' + usage);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsagePromiseValueIllegalErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 788)
Utils.emitEvent(this.errorMsg, 789)
})
} catch (error) {
console.error(`emitGetOriginUsagePromiseValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetOriginUsagePromiseValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.WebStorage.getOriginUsage(this.origin)
.then(usage => {
console.log('usage: ' + usage);
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetOriginUsagePromiseValueNullErr getOriginUsage return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 790)
Utils.emitEvent(this.errorMsg, 791)
})
} catch (error) {
console.error(`emitGetOriginUsagePromiseValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitAllowGeolocationValueErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.GeolocationPermissions.allowGeolocation(this.origin);
} catch (error) {
console.error(`emitAllowGeolocationValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 792)
Utils.emitEvent(this.errorMsg, 793)
break;
}
case "emitAllowGeolocationValueIllegalErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.GeolocationPermissions.allowGeolocation(this.origin);
} catch (error) {
console.error(`emitAllowGeolocationValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 794)
Utils.emitEvent(this.errorMsg, 795)
break;
}
case "emitAllowGeolocationValueNullErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = ""
web_webview.GeolocationPermissions.allowGeolocation(this.origin);
} catch (error) {
console.error(`emitAllowGeolocationValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 796)
Utils.emitEvent(this.errorMsg, 797)
break;
}
case "emitDeleteGeolocationValueErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.GeolocationPermissions.deleteGeolocation(this.origin);
} catch (error) {
console.error(`emitDeleteGeolocationValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 798)
Utils.emitEvent(this.errorMsg, 799)
break;
}
case "emitDeleteGeolocationValueIllegalErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.GeolocationPermissions.deleteGeolocation(this.origin);
} catch (error) {
console.error(`emitDeleteGeolocationValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 800)
Utils.emitEvent(this.errorMsg, 801)
break;
}
case "emitDeleteGeolocationValueNullErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.origin = ""
web_webview.GeolocationPermissions.deleteGeolocation(this.origin);
} catch (error) {
console.error(`emitDeleteGeolocationValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 802)
Utils.emitEvent(this.errorMsg, 803)
break;
}
case "emitGetAccessibleGeolocationCallbackValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) {
console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationCallbackValueErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 804)
Utils.emitEvent(this.errorMsg, 805)
return;
}
console.log('getAccessibleGeolocationAsync result: ' + result);
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationCallbackValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocationCallbackValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) {
console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationCallbackValueIllegalErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 806)
Utils.emitEvent(this.errorMsg, 807)
return;
}
console.log('getAccessibleGeolocationAsync result: ' + result);
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationCallbackValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocationCallbackValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) {
console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationCallbackValueNullErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 808)
Utils.emitEvent(this.errorMsg, 809)
return;
}
console.log('getAccessibleGeolocationAsync result: ' + result);
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationCallbackValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocationPromiseValueErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "/wrongPath%*"
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin)
.then(result => {
console.log('getAccessibleGeolocationPromise result: ' + result);
})
.catch(error => {
console.log('getAccessibleGeolocationPromise error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationPromiseValueErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 810)
Utils.emitEvent(this.errorMsg, 811)
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationPromiseValueErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocationPromiseValueIllegalErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = "[1,a]"
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin)
.then(result => {
console.log('getAccessibleGeolocationPromise result: ' + result);
})
.catch(error => {
console.log('getAccessibleGeolocationPromise error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationPromiseValueIllegalErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 812)
Utils.emitEvent(this.errorMsg, 813)
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationPromiseValueIllegalErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocationPromiseValueNullErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.origin = ""
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin)
.then(result => {
console.log('getAccessibleGeolocationPromise result: ' + result);
})
.catch(error => {
console.log('getAccessibleGeolocationPromise error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitGetAccessibleGeolocationPromiseValueNullErr getAccessibleGeolocation return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 814)
Utils.emitEvent(this.errorMsg, 815)
});
} catch (error) {
console.error(`emitGetAccessibleGeolocationPromiseValueNullErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
}
})
}
Web({src:'www.example.com',controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContGetUrlAndOthersError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
function Uint8ArrayToString(dataArray) {
var dataString = ''
for (var i = 0; i < dataArray.length; i++) {
dataString += String.fromCharCode(dataArray[i])
}
return dataString
}
function ParseX509CertInfo(x509CertArray) {
let res: string = 'getCertificate success: len = ' + x509CertArray.length;
for (let i = 0; i < x509CertArray.length; i++) {
res += ', index = ' + i + ', issuer name = '
+ Uint8ArrayToString(x509CertArray[i].getIssuerName().data) + ', subject name = '
+ Uint8ArrayToString(x509CertArray[i].getSubjectName().data) + ', valid start = '
+ x509CertArray[i].getNotBeforeTime()
+ ', valid end = ' + x509CertArray[i].getNotAfterTime()
}
return res
}
@Entry
@Component
struct webViewContGetUrlAndOthersError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitGetUrlInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorMsg: string = 'failed';
@State step: number = -2;
@State outputStr: string = ''
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContGetUrlAndOthersError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("getUrlAndOthersErrorTest").key('webViewContGetUrlAndOthersError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitGetUrlInitErr": {
try {
this.controllerTwo.getUrl();
} catch (error) {
console.error(`emitGetUrlInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 712)
Utils.emitEvent(this.errorMsg, 713)
break;
}
case "emitStopInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.stop();
} catch (error) {
console.error(`emitStopInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 714)
Utils.emitEvent(this.errorMsg, 715)
break;
}
case "emitBackOrForwardInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.backOrForward(this.step);
} catch (error) {
console.error(`emitBackOrForwardInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 716)
Utils.emitEvent(this.errorMsg, 717)
break;
}
case "emitScrollToInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.scrollTo(50, 50);
} catch (error) {
console.error(`emitScrollToInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 718)
Utils.emitEvent(this.errorMsg, 719)
break;
}
case "emitScrollByInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.scrollBy(50, 50);
} catch (error) {
console.error(`emitScrollByInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 720)
Utils.emitEvent(this.errorMsg, 721)
break;
}
case "emitSlideScrollInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.slideScroll(500, 500);
} catch (error) {
console.error(`emitSlideScrollInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 722)
Utils.emitEvent(this.errorMsg, 723)
break;
}
case "emitGetOriginalUrlInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getOriginalUrl();
} catch (error) {
console.error(`emitGetOriginalUrlInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 724)
Utils.emitEvent(this.errorMsg, 725)
break;
}
case "emitGetFaviconInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getFavicon();
} catch (error) {
console.error(`emitGetFaviconInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 726)
Utils.emitEvent(this.errorMsg, 727)
break;
}
case "emitSetNetworkAvailableInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.setNetworkAvailable(true);
} catch (error) {
console.error(`emitSetNetworkAvailableInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 728)
Utils.emitEvent(this.errorMsg, 729)
break;
}
case "emitHasImageCallBackInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.hasImage((error, data) => {
if (error) {
console.info(`hasImage error: ` + JSON.stringify(error))
return;
}
console.info("hasImage: " + data);
});
} catch (error) {
console.error(`emitHasImageCallBackInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 730)
Utils.emitEvent(this.errorMsg, 731)
break;
}
case "emitHasImagePromiseInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.hasImage()
.then((data) => {
console.info('hasImage: ' + data);
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`emitHasImagePromiseInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 732)
Utils.emitEvent(this.errorMsg, 733)
break;
}
case "emitRemoveCacheInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.removeCache(false);
} catch (error) {
console.error(`emitRemoveCacheInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 734)
Utils.emitEvent(this.errorMsg, 735)
break;
}
case "emitPageUpInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.pageUp(false);
} catch (error) {
console.error(`emitPageUpInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 736)
Utils.emitEvent(this.errorMsg, 737)
break;
}
case "emitPageDownInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.pageDown(false);
} catch (error) {
console.error(`emitPageDownInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 738)
Utils.emitEvent(this.errorMsg, 739)
break;
}
case "emitGetBackForwardEntriesInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getBackForwardEntries();
} catch (error) {
console.error(`emitGetBackForwardEntriesInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 740)
Utils.emitEvent(this.errorMsg, 741)
break;
}
case "emitSerializeWebStateInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.serializeWebState();
} catch (error) {
console.error(`emitSerializeWebStateInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 742)
Utils.emitEvent(this.errorMsg, 743)
break;
}
case "emitRestoreWebStateInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
let size = 8;
let buf = new ArrayBuffer(size);
this.controllerTwo.restoreWebState(new Uint8Array(buf.slice(0, 8)));
} catch (error) {
console.error(`emitRestoreWebStateInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 744)
Utils.emitEvent(this.errorMsg, 745)
break;
}
case "emitGetCertificatePromiseInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getCertificate().then(x509CertArray => {
this.outputStr = ParseX509CertInfo(x509CertArray);
})
} catch (error) {
console.error(`emitGetCertificatePromiseInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 746)
Utils.emitEvent(this.errorMsg, 747)
break;
}
case "emitGetCertificateCallbackInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getCertificate((error, x509CertArray) => {
if (error) {
this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message;
} else {
this.outputStr = ParseX509CertInfo(x509CertArray);
}
})
} catch (error) {
console.error(`emitGetCertificateCallbackInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 748)
Utils.emitEvent(this.errorMsg, 749)
break;
}
case "emitSetAudioMutedInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.setAudioMuted(false)
} catch (error) {
console.error(`emitSetAudioMutedInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 750)
Utils.emitEvent(this.errorMsg, 751)
break;
}
}
})
}
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContJavaScriptError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContJavaScriptError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitRegisterJavaScriptProxyInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorMsg: string = 'failed';
@State webResult: string = '';
@State name: string = 'UnExistObj';
testObj = {
test: (data) => {
return "ArkUI Web Component";
},
toString: () => {
console.log('Web Component toString');
}
}
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContJavaScriptError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("javaScriptErrorTest").key('webViewContJavaScriptError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitRegisterJavaScriptProxyInitErr": {
try {
this.controllerTwo.registerJavaScriptProxy(this.testObj, "objName", ["test", "toString"]);;
} catch (error) {
console.error(`emitRegisterJavaScriptProxyInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 650)
Utils.emitEvent(this.errorMsg, 651)
break;
}
case "emitRunJavaScriptCallbackInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.runJavaScript(
'test()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error));
return;
}
if (result) {
this.webResult = result;
console.info(`The test() return value is: ${result}`);
}
});
} catch (error) {
console.error(`emitRunJavaScriptCallbackInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 652)
Utils.emitEvent(this.errorMsg, 653)
break;
}
case "emitRunJavaScriptPromiseInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.runJavaScript('test()')
.then(function (result) {
console.log('result: ' + result);
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`emitRunJavaScriptPromiseInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 654)
Utils.emitEvent(this.errorMsg, 655)
break;
}
case "emitRunJavaScriptExtCallbackInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.runJavaScriptExt(
'test()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error));
return;
}
if (result) {
console.info(`The test() return value is: ${result}`);
}
});
} catch (error) {
console.error(`emitRunJavaScriptExtCallbackInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 656)
Utils.emitEvent(this.errorMsg, 657)
break;
}
case "emitRunJavaScriptExtPromiseInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.runJavaScriptExt('test()')
.then(function (result) {
console.log('result: ' + result);
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`emitRunJavaScriptExtPromiseInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 658)
Utils.emitEvent(this.errorMsg, 659)
break;
}
case "emitDeleteJavaScriptRegisterInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.deleteJavaScriptRegister(this.name);
} catch (error) {
console.error(`emitDeleteJavaScriptRegisterInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 660)
Utils.emitEvent(this.errorMsg, 661)
break;
}
case "emitDeleteJavaScriptRegisterNameErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controller.registerJavaScriptProxy(this.testObj, "objName", ["test", "toString"]);
this.controller.refresh();
this.controller.deleteJavaScriptRegister(this.name);
} catch (error) {
console.error(`emitDeleteJavaScriptRegisterNameErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 662)
Utils.emitEvent(this.errorMsg, 663)
break;
}
}
})
}
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContJsMessageExtReturnError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContJsMessageExtReturnError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitJsMessageExtGetStringError";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State zoomAccess:boolean=false;
@State errorCode: string = '0';
@State errorTestCode: number = 0;
@State errorMsg: string = 'failed';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContJsMessageExtReturnError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("JsMessageExtErrorTest").key('webViewContJsMessageExtReturnError').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitJsMessageExtGetStringError": {
this.controller.loadUrl($rawfile('testMessageExt.html'));
await Utils.sleep(3000);
try {
this.controller.runJavaScriptExt(
'testArray()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getString();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitJsMessageExtGetStringError runJavaScriptExt getString result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 816)
Utils.emitEvent(this.errorMsg, 817)
return;
}
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitJsMessageExtGetNumberError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.loadUrl($rawfile('testMessageExt.html'));
try {
this.controller.runJavaScriptExt(
'testArrayBuffer()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getNumber();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitJsMessageExtGetNumberError runJavaScriptExt getNumber result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 818)
Utils.emitEvent(this.errorMsg, 819)
return;
}
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitJsMessageExtGetBooleanError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.loadUrl($rawfile('testMessageExt.html'));
try {
this.controller.runJavaScriptExt(
'testNumber()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getBoolean();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitJsMessageExtGetBooleanError runJavaScriptExt getBoolean result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 820)
Utils.emitEvent(this.errorMsg, 821)
return;
}
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitJsMessageExtGetArrayBufferError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.loadUrl($rawfile('testMessageExt.html'));
try {
this.controller.runJavaScriptExt(
'testBoolean()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getArrayBuffer();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitJsMessageExtGetArrayBufferError runJavaScriptExt getArrayBuffer result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 822)
Utils.emitEvent(this.errorMsg, 823)
return;
}
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitJsMessageExtGetArrayError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.loadUrl($rawfile('testMessageExt.html'));
try {
this.controller.runJavaScriptExt(
'testString()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getArray();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitJsMessageExtGetArrayError runJavaScriptExt getArray result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 824)
Utils.emitEvent(this.errorMsg, 825)
return;
}
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
}
})
}
Web({src:'www.example.com',controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
.zoomAccess(this.zoomAccess)
.onPageEnd(err => {
try {
this.controller.runJavaScriptExt(
'testArray()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
try {
let type = result.getType();
console.info('run JavaScript result.getType(): ' + type)
result.getString();
}
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
return;
}
}
});
console.info('url: ', err.url);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContMessageError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContMessageError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
msgPort: web_webview.WebMessagePort[] = null;
@State sendFromEts: string = 'Send this message from ets to HTML';
@State receivedFromHtml: string = 'Display received message send from HTML';
@State str:string="emitPostMessageInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorMsg: string = 'failed';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContMessageError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
private jsObj={
test:(res)=>{
Utils.emitEvent(res,102);
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build(){
Column(){
Row() {
Button("messageEventErrorTest").key('webViewContMessageError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitPostMessageInitErr": {
try {
this.ports = this.controller.createWebMessagePorts();
this.controllerTwo.postMessage('__init_port__', [this.ports[0]], '*');
} catch (error) {
console.error(`emitPostMessageInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
this.controller.runJavaScript("test()",(res) => {
Utils.emitEvent(this.errorCode, 600)
Utils.emitEvent(this.errorMsg, 601)
})
break;
}
case "emitPostMessageEventUnPortErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts();
this.controller.postMessage('__init_port__', [this.ports[0]], '*');
if (this.ports && this.ports[1]) {
this.ports[1].close();
} else {
console.log("ports is null, Please initialize first");
}
this.ports[1].postMessageEvent("post message from ets to html5");
} catch (error) {
console.error(`emitPostMessageEventUnPortErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
this.controller.runJavaScript("test()",(res) => {
Utils.emitEvent(this.errorCode, 602)
Utils.emitEvent(this.errorMsg, 603)
})
break;
}
}
})
}
Web({src:$rawfile('indexEdit.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageOperationsError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContPageOperationsError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitAccessForwardInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorMsg: string = 'failed';
@State steps: number = 2;
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContPageOperationsError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("pageOperationsErrorTest").key('webViewContPageOperationsError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitAccessForwardInitErr": {
try {
this.controllerTwo.accessForward();
} catch (error) {
console.error(`emitAccessForwardInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 630)
Utils.emitEvent(this.errorMsg, 631)
break;
}
case "emitForwardInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.forward();
} catch (error) {
console.error(`emitForwardInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 632)
Utils.emitEvent(this.errorMsg, 633)
break;
}
case "emitAccessBackwardInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.accessBackward();
} catch (error) {
console.error(`emitAccessBackwardInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 634)
Utils.emitEvent(this.errorMsg, 635)
break;
}
case "emitBackwardInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.backward();
} catch (error) {
console.error(`emitBackwardInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 636)
Utils.emitEvent(this.errorMsg, 637)
break;
}
case "emitOnActiveInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.onActive();
} catch (error) {
console.error(`emitOnActiveInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 638)
Utils.emitEvent(this.errorMsg, 639)
break;
}
case "emitOnInactiveInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.onInactive();
} catch (error) {
console.error(`emitOnInactiveInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 640)
Utils.emitEvent(this.errorMsg, 641)
break;
}
case "emitRefreshInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.refresh();
} catch (error) {
console.error(`emitRefreshInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 642)
Utils.emitEvent(this.errorMsg, 643)
break;
}
case "emitAccessStepInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.accessStep(this.steps);
} catch (error) {
console.error(`emitAccessStepInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 644)
Utils.emitEvent(this.errorMsg, 645)
break;
}
case "emitClearHistoryInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.clearHistory();
} catch (error) {
console.error(`emitClearHistoryInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 646)
Utils.emitEvent(this.errorMsg, 647)
break;
}
case "emitGetHitTestInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getHitTest();
} catch (error) {
console.error(`emitGetHitTestInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message
}
Utils.emitEvent(this.errorCode, 648)
Utils.emitEvent(this.errorMsg, 649)
break;
}
}
})
}
Web({src:'www.example.com',controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContStoreWebArchiveError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContStoreWebArchiveError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitStoreWebArchiveCallBackInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State errorCode: string = '0';
@State errorTestCode: number = 0;
@State errorMsg: string = 'failed';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContStoreWebArchiveError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("storeWebArchiveErrorTest").key('webViewContStoreWebArchiveError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitStoreWebArchiveCallBackInitErr": {
try {
this.controllerTwo.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => {
if (error) {
console.info(`save web archive error: ` + JSON.stringify(error));
return;
}
if (filename != null) {
console.info(`save web archive success: ${filename}`);
}
});
} catch (error) {
console.error(`emitStoreWebArchiveCallBackInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 700)
Utils.emitEvent(this.errorMsg, 701)
break;
}
case "emitStoreWebArchiveCallBackPathErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controller.storeWebArchive("/ErrorPath/Error/Err/E12345/Error.html", false, (error, filename) => {
if (error) {
console.info(`save web archive error: ` + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitStoreWebArchiveCallBackPathErr storeWebArchive return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 702)
Utils.emitEvent(this.errorMsg, 703)
return;
}
if (filename != null) {
console.info(`save web archive success: ${filename}`);
}
});
} catch (error) {
console.error(`emitStoreWebArchiveCallBackPathErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitStoreWebArchiveCallBackUnAccessErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.storeWebArchive("/proc/sys/net/core/", true, (error, filename) => {
if (error) {
console.info(`save web archive error: ` + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitStoreWebArchiveCallBackUnAccessErr storeWebArchive return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 704)
Utils.emitEvent(this.errorMsg, 705)
return;
}
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
});
} catch (error) {
console.error(`emitStoreWebArchiveCallBackUnAccessErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitStoreWebArchivePromiseInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.storeWebArchive("/data/storage/el2/base/", true)
.then(filename => {
if (filename != null) {
console.info(`save web archive success: ${filename}`);
}
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
})
} catch (error) {
console.error(`emitStoreWebArchivePromiseInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 706)
Utils.emitEvent(this.errorMsg, 707)
break;
}
case "emitStoreWebArchivePromisePathErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.storeWebArchive("/ErrorPath/Error/Err/E12345/Error.html", false)
.then(filename => {
if (filename != null) {
console.info(`save web archive success: ${filename}`);
}
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitStoreWebArchivePromisePathErr storeWebArchive return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 708)
Utils.emitEvent(this.errorMsg, 709)
})
} catch (error) {
console.error(`emitStoreWebArchivePromisePathErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitStoreWebArchivePromiseUnAccessErr": {
try {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.controller.storeWebArchive("/proc/sys/net/core/", true)
.then(filename => {
if (filename != null) {
console.info(`save web archive success: ${filename}`);
}
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
this.errorTestCode = error.code;
this.errorMsg = error.message;
console.error("emitStoreWebArchivePromiseUnAccessErr storeWebArchive return result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 710)
Utils.emitEvent(this.errorMsg, 711)
})
} catch (error) {
console.error(`emitStoreWebArchivePromiseUnAccessErr ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
}
})
}
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContWebMessageExtReturnError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContWebMessageExtReturnError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[] = null;
nativePort: web_webview.WebMessagePort = null;
@State str:string="emitWebMessageExtGetStringError";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State zoomAccess:boolean=false;
@State errorCode: string = '0';
@State errorTestCode: number = 0;
@State errorMsg: string = 'failed';
@State webResult: string = ''
message: web_webview.WebMessageExt = new web_webview.WebMessageExt();
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContWebMessageExtReturnError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("WebMessageExtErrorTest").key('webViewContWebMessageExtReturnError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitWebMessageExtGetStringError": {
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postErrorToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postErrorToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getString()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetStringError onMessageEventExt getString result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 826)
Utils.emitEvent(this.errorMsg, 827)
}
});
break;
}
case "emitWebMessageExtGetNumberError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postArrayToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postArrayToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getNumber()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetNumberError onMessageEventExt getNumber result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 828)
Utils.emitEvent(this.errorMsg, 829)
}
});
break;
}
case "emitWebMessageExtGetBooleanError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postArrayBufferToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postArrayBufferToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getBoolean()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetBooleanError onMessageEventExt getBoolean result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 830)
Utils.emitEvent(this.errorMsg, 831)
}
});
break;
}
case "emitWebMessageExtGetArrayBufferError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postBooleanToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postBooleanToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getArrayBuffer()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetArrayBufferError onMessageEventExt getArrayBuffer result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 832)
Utils.emitEvent(this.errorMsg, 833)
}
});
break;
}
case "emitWebMessageExtGetArrayError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postNumberToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postNumberToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getArray()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetArrayError onMessageEventExt getArray result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 834)
Utils.emitEvent(this.errorMsg, 835)
}
});
break;
}
case "emitWebMessageExtGetErrorError": {
this.errorTestCode = 0;
this.errorMsg = 'failed';
this.ports = this.controller.createWebMessagePorts(true);
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
this.nativePort = this.ports[0];
this.controller.runJavaScript(
'postStringToApp()',
(error, result) => {
if (error) {
console.info(`run JavaScript error: ` + JSON.stringify(error))
return;
}
if (result) {
this.webResult = result
console.info(`The postStringToApp() return value is: ${result}`)
}
});
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
result.getError()
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
this.errorTestCode = resError.code;
this.errorMsg = resError.message;
console.error("emitWebMessageExtGetErrorError onMessageEventExt getError result is :" + this.errorTestCode + this.errorMsg);
Utils.emitEvent(this.errorTestCode, 836)
Utils.emitEvent(this.errorMsg, 837)
}
});
break;
}
}
})
}
Web({src:$rawfile('indexEdit.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
.zoomAccess(this.zoomAccess)
.onPageEnd(err => {
console.log("In eTS side message onPageEnd init mesaage channel");
console.log("1.create message port")
this.ports = this.controller.createWebMessagePorts(true);
console.log("2.send port1 to HTML5")
this.controller.postMessage("init_web_messageport", [this.ports[1]], "*");
console.log("3.save port0 to current path")
this.nativePort = this.ports[0];
console.log("4.set callback function")
this.nativePort.onMessageEventExt((result) => {
console.log("In eTS side got message");
try {
var type = result.getType();
console.log("In eTS side getType:" + type);
} catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
}
});
console.info('url: ', err.url);
})
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContZoomAndOthersError.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
// @ts-nocheck
@Entry
@Component
struct webViewContZoomAndOthersError {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitZoomInitErr";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" +
" CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State zoomAccess:boolean=false;
@State errorCode: string = '0';
@State errorMsg: string = 'failed';
@State factor: number = 1;
@State searchString: string = "test";
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContZoomAndOthersError page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
build(){
Column(){
Row() {
Button("zoomAndOthersErrorTest").key('webViewContZoomAndOthersError').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitZoomInitErr": {
try {
this.controllerTwo.zoom(this.factor);
} catch (error) {
console.error(`emitZoomInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 664)
Utils.emitEvent(this.errorMsg, 665)
break;
}
case "emitZoomEnableErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controller.zoom(this.factor);
} catch (error) {
console.error(`emitZoomEnableErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 666)
Utils.emitEvent(this.errorMsg, 667)
break;
}
case "emitSearchAllAsyncInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.searchAllAsync(this.searchString);
} catch (error) {
console.error(`emitSearchAllAsyncInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 668)
Utils.emitEvent(this.errorMsg, 669)
break;
}
case "emitClearMatchesInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.clearMatches();
} catch (error) {
console.error(`emitClearMatchesInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 670)
Utils.emitEvent(this.errorMsg, 671)
break;
}
case "emitSearchNextInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.searchNext(true);
} catch (error) {
console.error(`emitSearchNextInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 672)
Utils.emitEvent(this.errorMsg, 673)
break;
}
case "emitClearSslCacheInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.clearSslCache();
} catch (error) {
console.error(`emitClearSslCacheInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 674)
Utils.emitEvent(this.errorMsg, 675)
break;
}
case "emitClearClientAuthenticationCacheInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.clearClientAuthenticationCache();
} catch (error) {
console.error(`emitClearClientAuthenticationCacheInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 676)
Utils.emitEvent(this.errorMsg, 677)
break;
}
case "emitCreateWebMessagePortsInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.createWebMessagePorts();
} catch (error) {
console.error(`emitCreateWebMessagePortsInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 678)
Utils.emitEvent(this.errorMsg, 679)
break;
}
case "emitRequestFocusInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.requestFocus();
} catch (error) {
console.error(`emitRequestFocusInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 680)
Utils.emitEvent(this.errorMsg, 681)
break;
}
case "emitZoomInInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.zoomIn();
} catch (error) {
console.error(`emitZoomInInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 682)
Utils.emitEvent(this.errorMsg, 683)
break;
}
case "emitZoomInEnableErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controller.zoomIn();
} catch (error) {
console.error(`emitZoomInEnableErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 684)
Utils.emitEvent(this.errorMsg, 685)
break;
}
case "emitZoomOutInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.zoomOut();
} catch (error) {
console.error(`emitZoomOutInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 686)
Utils.emitEvent(this.errorMsg, 687)
break;
}
case "emitZoomOutEnableErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controller.zoomOut();
} catch (error) {
console.error(`emitZoomOutEnableErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 688)
Utils.emitEvent(this.errorMsg, 689)
break;
}
case "emitGetHitTestValueInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getHitTestValue();
} catch (error) {
console.error(`emitGetHitTestValueInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 690)
Utils.emitEvent(this.errorMsg, 691)
break;
}
case "emitGetWebIdInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getWebId();
} catch (error) {
console.error(`emitGetWebIdInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 692)
Utils.emitEvent(this.errorMsg, 693)
break;
}
case "emitGetUserAgentInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getUserAgent();
} catch (error) {
console.error(`emitGetUserAgentInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 694)
Utils.emitEvent(this.errorMsg, 695)
break;
}
case "emitGetTitleInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getTitle();
} catch (error) {
console.error(`emitGetTitleInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 696)
Utils.emitEvent(this.errorMsg, 697)
break;
}
case "emitGetPageHeightInitErr": {
try {
this.errorCode = '0';
this.errorMsg = 'failed';
this.controllerTwo.getPageHeight();
} catch (error) {
console.error(`emitGetPageHeightInitErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code;
this.errorMsg = error.message;
}
Utils.emitEvent(this.errorCode, 698)
Utils.emitEvent(this.errorMsg, 699)
break;
}
}
})
}
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.userAgent(this.userAgent)
.zoomAccess(this.zoomAccess)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
05edbdf0
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.myapplication.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/List.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 webViewContMessageError from './webViewContMessageError.test'
import webViewContPageOperationsError from './webViewContPageOperationsError.test'
import webViewContJavaScriptError from './webViewContJavaScriptError.test'
import webViewContZoomAndOthersError from './webViewContZoomAndOthersError.test'
import webViewContStoreWebArchiveError from './webViewContStoreWebArchiveError.test'
import webViewContGetUrlAndOthersError from './webViewContGetUrlAndOthersError.test'
import webViewContCookieToGeoLocationError from './webViewContCookieToGeoLocationError.test'
import webViewContJsMessageExtReturnError from './webViewContJsMessageExtReturnError.test'
import webViewContWebMessageExtReturnError from './webViewContWebMessageExtReturnError.test'
export default function testsuite() {
webViewContMessageError()
webViewContPageOperationsError()
webViewContJavaScriptError()
webViewContZoomAndOthersError()
webViewContStoreWebArchiveError()
webViewContGetUrlAndOthersError()
webViewContCookieToGeoLocationError()
webViewContJsMessageExtReturnError()
webViewContWebMessageExtReturnError()
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/Utils.ets
0 → 100644
浏览文件 @
05edbdf0
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 events_emitter from '@ohos.events.emitter';
import { expect } from "@ohos/hypium";
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
static registerEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEvent(actualValue,eventId){
try {
let backData = {
data: {
"ACTION": actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerEventTwo(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEventTwo(expectedValue,actualValue,eventId){
try {
let backData = {
data: {
"expectedValue":expectedValue,
"actualValue":actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerContainEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static commitKey(emitKey){
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
}
static registerLargerEvent(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContCookieToGeoLocationError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitGetCookieInitErr";
export default function webViewContCookieToGeoLocationError() {
describe('ActsAceWebDevWebViewContCookieToGeoLocationErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContCookieToGeoLocationError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContCookieToGeoLocationError state success " + JSON.stringify(pages));
if (!("webViewContCookieToGeoLocationError" == pages.name)) {
console.info("get webViewContCookieToGeoLocationError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContCookieToGeoLocationError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContCookieToGeoLocationError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContCookieToGeoLocationError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContCookieToGeoLocationError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7700
*tc.name testGetCookieInitErr
*tc.desc test interface of getCookie with wrong format url
*/
it('testGetCookieInitErr',0,async function(done){
emitKey="emitSetCookieInitErr";
Utils.registerEvent("testGetCookieInitErr","17100002",752,done);
Utils.registerEvent("testGetCookieInitErr","Invalid url.",753,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7800
*tc.name testSetCookieInitErr
*tc.desc test interface of setCookie with wrong format url
*/
it('testSetCookieInitErr',0,async function(done){
emitKey="emitSetCookieValueErr";
Utils.registerEvent("testSetCookieInitErr","17100002",754,done);
Utils.registerEvent("testSetCookieInitErr","Invalid url.",755,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7900
*tc.name testSetCookieValueErr
*tc.desc test interface of setCookie with unsupported url value type
*/
it('testSetCookieValueErr',0,async function(done){
emitKey="emitDeleteOriginValueNullErr";
Utils.registerEvent("testSetCookieValueErr","17100005",756,done);
Utils.registerEvent("testSetCookieValueErr","Invalid cookie value.",757,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8000
*tc.name testDeleteOriginValueNullErr
*tc.desc test interface of deleteOrigin with origin null
*/
it('testDeleteOriginValueNullErr',0,async function(done){
emitKey="emitDeleteOriginValueIllegalErr";
Utils.registerEvent("testDeleteOriginValueNullErr","17100011",758,done);
Utils.registerEvent("testDeleteOriginValueNullErr","Invalid origin.",759,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8100
*tc.name testDeleteOriginValueIllegalErr
*tc.desc test interface of deleteOrigin with origin illegal
*/
it('testDeleteOriginValueIllegalErr',0,async function(done){
emitKey="emitDeleteOriginValueErr";
Utils.registerEvent("testDeleteOriginValueIllegalErr","17100011",760,done);
Utils.registerEvent("testDeleteOriginValueIllegalErr","Invalid origin.",761,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8200
*tc.name testDeleteOriginValueErr
*tc.desc test interface of deleteOrigin with origin wrong
*/
it('testDeleteOriginValueErr',0,async function(done){
emitKey="emitGetOriginsCallbackUnAPIErr";
Utils.registerEvent("testDeleteOriginValueErr","17100011",762,done);
Utils.registerEvent("testDeleteOriginValueErr","Invalid origin.",763,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8300
*tc.name testGetOriginsCallbackUnAPIErr
*tc.desc test interface of getOrigins (callback) with no using JS database API
*/
it('testGetOriginsCallbackUnAPIErr',0,async function(done){
emitKey="emitGetOriginsPromiseUnAPIErr";
Utils.registerEvent("testGetOriginsCallbackUnAPIErr",17100012,764,done);
Utils.registerEvent("testGetOriginsCallbackUnAPIErr","Invalid web storage origin.",765,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8400
*tc.name testGetOriginsPromiseUnAPIErr
*tc.desc test interface of getOrigins (promise) with no using JS database API
*/
it('testGetOriginsPromiseUnAPIErr',0,async function(done){
emitKey="emitGetOriginQuotaCallbackValueErr";
Utils.registerEvent("testGetOriginsPromiseUnAPIErr",17100012,766,done);
Utils.registerEvent("testGetOriginsPromiseUnAPIErr","Invalid web storage origin.",767,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8500
*tc.name testGetOriginQuotaCallbackValueErr
*tc.desc test interface of getOriginQuota (callback) with origin wrong
*/
it('testGetOriginQuotaCallbackValueErr',0,async function(done){
emitKey="emitGetOriginQuotaCallbackValueIllegalErr";
Utils.registerEvent("testGetOriginQuotaCallbackValueErr",17100011,768,done);
Utils.registerEvent("testGetOriginQuotaCallbackValueErr","Invalid origin.",769,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8600
*tc.name testGetOriginQuotaCallbackValueIllegalErr
*tc.desc test interface of getOriginQuota (callback) with origin illegal
*/
it('testGetOriginQuotaCallbackValueIllegalErr',0,async function(done){
emitKey="emitGetOriginQuotaCallbackValueNullErr";
Utils.registerEvent("testGetOriginQuotaCallbackValueIllegalErr",17100011,770,done);
Utils.registerEvent("testGetOriginQuotaCallbackValueIllegalErr","Invalid origin.",771,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8700
*tc.name testGetOriginQuotaCallbackValueNullErr
*tc.desc test interface of getOriginQuota (callback) with origin null
*/
it('testGetOriginQuotaCallbackValueNullErr',0,async function(done){
emitKey="emitGetOriginQuotaPromiseValueErr";
Utils.registerEvent("testGetOriginQuotaCallbackValueNullErr",17100011,772,done);
Utils.registerEvent("testGetOriginQuotaCallbackValueNullErr","Invalid origin.",773,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8800
*tc.name testGetOriginQuotaPromiseValueErr
*tc.desc test interface of getOriginQuota (promise) with origin wrong
*/
it('testGetOriginQuotaPromiseValueErr',0,async function(done){
emitKey="emitGetOriginQuotaPromiseValueIllegalErr";
Utils.registerEvent("testGetOriginQuotaPromiseValueErr",17100011,774,done);
Utils.registerEvent("testGetOriginQuotaPromiseValueErr","Invalid origin.",775,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_8900
*tc.name testGetOriginQuotaPromiseValueIllegalErr
*tc.desc test interface of getOriginQuota (promise) with origin illegal
*/
it('testGetOriginQuotaPromiseValueIllegalErr',0,async function(done){
emitKey="emitGetOriginQuotaPromiseValueNullErr";
Utils.registerEvent("testGetOriginQuotaPromiseValueIllegalErr",17100011,776,done);
Utils.registerEvent("testGetOriginQuotaPromiseValueIllegalErr","Invalid origin.",777,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9000
*tc.name testGetOriginQuotaPromiseValueNullErr
*tc.desc test interface of getOriginQuota (promise) with origin null
*/
it('testGetOriginQuotaPromiseValueNullErr',0,async function(done){
emitKey="emitGetOriginUsageCallbackValueErr";
Utils.registerEvent("testGetOriginQuotaPromiseValueNullErr",17100011,778,done);
Utils.registerEvent("testGetOriginQuotaPromiseValueNullErr","Invalid origin.",779,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9100
*tc.name testGetOriginUsageCallbackValueErr
*tc.desc test interface of getOriginUsage (callback) with origin wrong
*/
it('testGetOriginUsageCallbackValueErr',0,async function(done){
emitKey="emitGetOriginUsageCallbackValueIllegalErr";
Utils.registerEvent("testGetOriginUsageCallbackValueErr",17100011,780,done);
Utils.registerEvent("testGetOriginUsageCallbackValueErr","Invalid origin.",781,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9200
*tc.name testGetOriginUsageCallbackValueIllegalErr
*tc.desc test interface of getOriginUsage (callback) with origin illegal
*/
it('testGetOriginUsageCallbackValueIllegalErr',0,async function(done){
emitKey="emitGetOriginUsageCallbackValueNullErr";
Utils.registerEvent("testGetOriginUsageCallbackValueIllegalErr",17100011,782,done);
Utils.registerEvent("testGetOriginUsageCallbackValueIllegalErr","Invalid origin.",783,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9300
*tc.name testGetOriginUsageCallbackValueNullErr
*tc.desc test interface of getOriginUsage (callback) with origin null
*/
it('testGetOriginUsageCallbackValueNullErr',0,async function(done){
emitKey="emitGetOriginUsagePromiseValueErr";
Utils.registerEvent("testGetOriginUsageCallbackValueNullErr",17100011,784,done);
Utils.registerEvent("testGetOriginUsageCallbackValueNullErr","Invalid origin.",785,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9400
*tc.name testGetOriginUsagePromiseValueErr
*tc.desc test interface of getOriginUsage (promise) with origin wrong
*/
it('testGetOriginUsagePromiseValueErr',0,async function(done){
emitKey="emitGetOriginUsagePromiseValueIllegalErr";
Utils.registerEvent("testGetOriginUsagePromiseValueErr",17100011,786,done);
Utils.registerEvent("testGetOriginUsagePromiseValueErr","Invalid origin.",787,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9500
*tc.name testGetOriginUsagePromiseValueIllegalErr
*tc.desc test interface of getOriginUsage (promise) with origin illegal
*/
it('testGetOriginUsagePromiseValueIllegalErr',0,async function(done){
emitKey="emitGetOriginUsagePromiseValueNullErr";
Utils.registerEvent("testGetOriginUsagePromiseValueIllegalErr",17100011,788,done);
Utils.registerEvent("testGetOriginUsagePromiseValueIllegalErr","Invalid origin.",789,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9600
*tc.name testGetOriginUsagePromiseValueNullErr
*tc.desc test interface of getOriginUsage (promise) with origin null
*/
it('testGetOriginUsagePromiseValueNullErr',0,async function(done){
emitKey="emitAllowGeolocationValueErr";
Utils.registerEvent("testGetOriginUsagePromiseValueNullErr",17100011,790,done);
Utils.registerEvent("testGetOriginUsagePromiseValueNullErr","Invalid origin.",791,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9700
*tc.name testAllowGeolocationValueErr
*tc.desc test interface of allowGeolocation with origin wrong
*/
it('testAllowGeolocationValueErr',0,async function(done){
emitKey="emitAllowGeolocationValueIllegalErr";
Utils.registerEvent("testAllowGeolocationValueErr","17100011",792,done);
Utils.registerEvent("testAllowGeolocationValueErr","Invalid origin.",793,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9800
*tc.name testAllowGeolocationValueIllegalErr
*tc.desc test interface of allowGeolocation with origin illegal
*/
it('testAllowGeolocationValueIllegalErr',0,async function(done){
emitKey="emitAllowGeolocationValueNullErr";
Utils.registerEvent("testAllowGeolocationValueIllegalErr","17100011",794,done);
Utils.registerEvent("testAllowGeolocationValueIllegalErr","Invalid origin.",795,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_9900
*tc.name testAllowGeolocationValueNullErr
*tc.desc test interface of allowGeolocation with origin null
*/
it('testAllowGeolocationValueNullErr',0,async function(done){
emitKey="emitDeleteGeolocationValueErr";
Utils.registerEvent("testAllowGeolocationValueNullErr","17100011",796,done);
Utils.registerEvent("testAllowGeolocationValueNullErr","Invalid origin.",797,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0100
*tc.name testDeleteGeolocationValueErr
*tc.desc test interface of deleteGeolocation with origin wrong
*/
it('testDeleteGeolocationValueErr',0,async function(done){
emitKey="emitDeleteGeolocationValueIllegalErr";
Utils.registerEvent("testDeleteGeolocationValueErr","17100011",798,done);
Utils.registerEvent("testDeleteGeolocationValueErr","Invalid origin.",799,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0200
*tc.name testDeleteGeolocationValueIllegalErr
*tc.desc test interface of deleteGeolocation with origin illegal
*/
it('testDeleteGeolocationValueIllegalErr',0,async function(done){
emitKey="emitDeleteGeolocationValueNullErr";
Utils.registerEvent("testDeleteGeolocationValueIllegalErr","17100011",800,done);
Utils.registerEvent("testDeleteGeolocationValueIllegalErr","Invalid origin.",801,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0300
*tc.name testDeleteGeolocationValueNullErr
*tc.desc test interface of deleteGeolocation with origin null
*/
it('testDeleteGeolocationValueNullErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationCallbackValueErr";
Utils.registerEvent("testDeleteGeolocationValueNullErr","17100011",802,done);
Utils.registerEvent("testDeleteGeolocationValueNullErr","Invalid origin.",803,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0400
*tc.name testGetAccessibleGeolocationCallbackValueErr
*tc.desc test interface of getAccessibleGeolocation (callback) with origin wrong
*/
it('testGetAccessibleGeolocationCallbackValueErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationCallbackValueIllegalErr";
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueErr",17100011,804,done);
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueErr","Invalid origin.",805,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0500
*tc.name testGetAccessibleGeolocationCallbackValueIllegalErr
*tc.desc test interface of getAccessibleGeolocation (callback) with origin illegal
*/
it('testGetAccessibleGeolocationCallbackValueIllegalErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationCallbackValueNullErr";
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueIllegalErr",17100011,806,done);
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueIllegalErr","Invalid origin.",807,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0600
*tc.name testGetAccessibleGeolocationCallbackValueNullErr
*tc.desc test interface of getAccessibleGeolocation (callback) with origin null
*/
it('testGetAccessibleGeolocationCallbackValueNullErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationPromiseValueErr";
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueNullErr",17100011,808,done);
Utils.registerEvent("testGetAccessibleGeolocationCallbackValueNullErr","Invalid origin.",809,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0700
*tc.name testGetAccessibleGeolocationPromiseValueErr
*tc.desc test interface of getAccessibleGeolocation (promise) with origin wrong
*/
it('testGetAccessibleGeolocationPromiseValueErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationPromiseValueIllegalErr";
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueErr",17100011,810,done);
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueErr","Invalid origin.",811,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0800
*tc.name testGetAccessibleGeolocationPromiseValueIllegalErr
*tc.desc test interface of getAccessibleGeolocation (promise) with origin illegal
*/
it('testGetAccessibleGeolocationPromiseValueIllegalErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationPromiseValueNullErr";
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueIllegalErr",17100011,812,done);
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueIllegalErr","Invalid origin.",813,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_0900
*tc.name testGetAccessibleGeolocationPromiseValueNullErr
*tc.desc test interface of getAccessibleGeolocation (promise) with origin null
*/
it('testGetAccessibleGeolocationPromiseValueNullErr',0,async function(done){
emitKey="emitGetAccessibleGeolocationPromiseValueNullErr";
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueNullErr",17100011,814,done);
Utils.registerEvent("testGetAccessibleGeolocationPromiseValueNullErr","Invalid origin.",815,done);
sendEventByKey('webViewContCookieToGeoLocationError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContGetUrlAndOthersError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitGetUrlInitErr";
export default function webViewContGetUrlAndOthersError() {
describe('ActsAceWebDevWebViewContGetUrlAndOthersErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContGetUrlAndOthersError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContGetUrlAndOthersError state success " + JSON.stringify(pages));
if (!("webViewContGetUrlAndOthersError" == pages.name)) {
console.info("get webViewContGetUrlAndOthersError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContGetUrlAndOthersError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContGetUrlAndOthersError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContGetUrlAndOthersError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContGetUrlAndOthersError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5700
*tc.name testGetUrlInitErr
*tc.desc test interface of getUrl with not been associated with specific Web Components
*/
it('testGetUrlInitErr',0,async function(done){
emitKey="emitStopInitErr";
Utils.registerEvent("testGetUrlInitErr","17100001",712,done);
Utils.registerEvent("testGetUrlInitErr","Init error. The WebviewController must be associated with a Web component.",713,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5800
*tc.name testStopInitErr
*tc.desc test interface of stop with not been associated with specific Web Components
*/
it('testStopInitErr',0,async function(done){
emitKey="emitBackOrForwardInitErr";
Utils.registerEvent("testStopInitErr","17100001",714,done);
Utils.registerEvent("testStopInitErr","Init error. The WebviewController must be associated with a Web component.",715,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5900
*tc.name testBackOrForwardInitErr
*tc.desc test interface of backOrForward with not been associated with specific Web Components
*/
it('testBackOrForwardInitErr',0,async function(done){
emitKey="emitScrollToInitErr";
Utils.registerEvent("testBackOrForwardInitErr","17100001",716,done);
Utils.registerEvent("testBackOrForwardInitErr","Init error. The WebviewController must be associated with a Web component.",717,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6000
*tc.name testScrollToInitErr
*tc.desc test interface of scrollTo with not been associated with specific Web Components
*/
it('testScrollToInitErr',0,async function(done){
emitKey="emitScrollByInitErr";
Utils.registerEvent("testScrollToInitErr","17100001",718,done);
Utils.registerEvent("testScrollToInitErr","Init error. The WebviewController must be associated with a Web component.",719,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6100
*tc.name testScrollByInitErr
*tc.desc test interface of scrollBy with not been associated with specific Web Components
*/
it('testScrollByInitErr',0,async function(done){
emitKey="emitSlideScrollInitErr";
Utils.registerEvent("testScrollByInitErr","17100001",720,done);
Utils.registerEvent("testScrollByInitErr","Init error. The WebviewController must be associated with a Web component.",721,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6200
*tc.name testSlideScrollInitErr
*tc.desc test interface of slideScroll with not been associated with specific Web Components
*/
it('testSlideScrollInitErr',0,async function(done){
emitKey="emitGetOriginalUrlInitErr";
Utils.registerEvent("testSlideScrollInitErr","17100001",722,done);
Utils.registerEvent("testSlideScrollInitErr","Init error. The WebviewController must be associated with a Web component.",723,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6300
*tc.name testGetOriginalUrlInitErr
*tc.desc test interface of getOriginalUrl with not been associated with specific Web Components
*/
it('testGetOriginalUrlInitErr',0,async function(done){
emitKey="emitGetFaviconInitErr";
Utils.registerEvent("testGetOriginalUrlInitErr","17100001",724,done);
Utils.registerEvent("testGetOriginalUrlInitErr","Init error. The WebviewController must be associated with a Web component.",725,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6400
*tc.name testGetFaviconInitErr
*tc.desc test interface of getFavicon with not been associated with specific Web Components
*/
it('testGetFaviconInitErr',0,async function(done){
emitKey="emitSetNetworkAvailableInitErr";
Utils.registerEvent("testGetFaviconInitErr","17100001",726,done);
Utils.registerEvent("testGetFaviconInitErr","Init error. The WebviewController must be associated with a Web component.",727,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6500
*tc.name testSetNetworkAvailableInitErr
*tc.desc test interface of setNetworkAvailable with not been associated with specific Web Components
*/
it('testSetNetworkAvailableInitErr',0,async function(done){
emitKey="emitHasImageCallBackInitErr";
Utils.registerEvent("testSetNetworkAvailableInitErr","17100001",728,done);
Utils.registerEvent("testSetNetworkAvailableInitErr","Init error. The WebviewController must be associated with a Web component.",729,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6600
*tc.name testHasImageCallBackInitErr
*tc.desc test interface of hasImage (callback) with not been associated with specific Web Components
*/
it('testHasImageCallBackInitErr',0,async function(done){
emitKey="emitHasImagePromiseInitErr";
Utils.registerEvent("testHasImageCallBackInitErr","17100001",730,done);
Utils.registerEvent("testHasImageCallBackInitErr","Init error. The WebviewController must be associated with a Web component.",731,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6700
*tc.name testHasImagePromiseInitErr
*tc.desc test interface of hasImage (promise) with not been associated with specific Web Components
*/
it('testHasImagePromiseInitErr',0,async function(done){
emitKey="emitRemoveCacheInitErr";
Utils.registerEvent("testHasImagePromiseInitErr","17100001",732,done);
Utils.registerEvent("testHasImagePromiseInitErr","Init error. The WebviewController must be associated with a Web component.",733,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6800
*tc.name testRemoveCacheInitErr
*tc.desc test interface of removeCache with not been associated with specific Web Components
*/
it('testRemoveCacheInitErr',0,async function(done){
emitKey="emitPageUpInitErr";
Utils.registerEvent("testRemoveCacheInitErr","17100001",734,done);
Utils.registerEvent("testRemoveCacheInitErr","Init error. The WebviewController must be associated with a Web component.",735,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_6900
*tc.name testPageUpInitErr
*tc.desc test interface of pageUp with not been associated with specific Web Components
*/
it('testPageUpInitErr',0,async function(done){
emitKey="emitPageDownInitErr";
Utils.registerEvent("testPageUpInitErr","17100001",736,done);
Utils.registerEvent("testPageUpInitErr","Init error. The WebviewController must be associated with a Web component.",737,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7000
*tc.name testPageDownInitErr
*tc.desc test interface of pageDown with not been associated with specific Web Components
*/
it('testPageDownInitErr',0,async function(done){
emitKey="emitGetBackForwardEntriesInitErr";
Utils.registerEvent("testPageDownInitErr","17100001",738,done);
Utils.registerEvent("testPageDownInitErr","Init error. The WebviewController must be associated with a Web component.",739,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7100
*tc.name testGetBackForwardEntriesInitErr
*tc.desc test interface of getBackForwardEntries with not been associated with specific Web Components
*/
it('testGetBackForwardEntriesInitErr',0,async function(done){
emitKey="emitSerializeWebStateInitErr";
Utils.registerEvent("testGetBackForwardEntriesInitErr","17100001",740,done);
Utils.registerEvent("testGetBackForwardEntriesInitErr","Init error. The WebviewController must be associated with a Web component.",741,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7200
*tc.name testSerializeWebStateInitErr
*tc.desc test interface of serializeWebState with not been associated with specific Web Components
*/
it('testSerializeWebStateInitErr',0,async function(done){
emitKey="emitRestoreWebStateInitErr";
Utils.registerEvent("testSerializeWebStateInitErr","17100001",742,done);
Utils.registerEvent("testSerializeWebStateInitErr","Init error. The WebviewController must be associated with a Web component.",743,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7300
*tc.name testRestoreWebStateInitErr
*tc.desc test interface of restoreWebState with not been associated with specific Web Components
*/
it('testRestoreWebStateInitErr',0,async function(done){
emitKey="emitGetCertificatePromiseInitErr";
Utils.registerEvent("testRestoreWebStateInitErr","17100001",744,done);
Utils.registerEvent("testRestoreWebStateInitErr","Init error. The WebviewController must be associated with a Web component.",745,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7400
*tc.name testGetCertificatePromiseInitErr
*tc.desc test interface of getCertificate (promise) with not been associated with specific Web Components
*/
it('testGetCertificatePromiseInitErr',0,async function(done){
emitKey="emitGetCertificateCallbackInitErr";
Utils.registerEvent("testGetCertificatePromiseInitErr","17100001",746,done);
Utils.registerEvent("testGetCertificatePromiseInitErr","Init error. The WebviewController must be associated with a Web component.",747,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7500
*tc.name testGetCertificateCallbackInitErr
*tc.desc test interface of getCertificate (callback) with not been associated with specific Web Components
*/
it('testGetCertificateCallbackInitErr',0,async function(done){
emitKey="emitSetAudioMutedInitErr";
Utils.registerEvent("testGetCertificateCallbackInitErr","17100001",748,done);
Utils.registerEvent("testGetCertificateCallbackInitErr","Init error. The WebviewController must be associated with a Web component.",749,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_7600
*tc.name testSetAudioMutedInitErr
*tc.desc test interface of setAudioMuted with not been associated with specific Web Components
*/
it('testSetAudioMutedInitErr',0,async function(done){
emitKey="emitSetAudioMutedInitErr";
Utils.registerEvent("testSetAudioMutedInitErr","17100001",750,done);
Utils.registerEvent("testSetAudioMutedInitErr","Init error. The WebviewController must be associated with a Web component.",751,done);
sendEventByKey('webViewContGetUrlAndOthersError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContJavaScriptError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitRegisterJavaScriptProxyInitErr";
export default function webViewContJavaScriptError() {
describe('ActsAceWebDevWebViewContJavaScriptErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContJavaScriptError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContJavaScriptError state success " + JSON.stringify(pages));
if (!("webViewContJavaScriptError" == pages.name)) {
console.info("get webViewContJavaScriptError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContJavaScriptError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContJavaScriptError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContJavaScriptError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContJavaScriptError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2600
*tc.name testRegisterJavaScriptProxyInitErr
*tc.desc test interface of registerJavaScriptProxy with not been associated with specific Web Components
*/
it('testRegisterJavaScriptProxyInitErr',0,async function(done){
emitKey="emitRunJavaScriptCallbackInitErr";
Utils.registerEvent("testRegisterJavaScriptProxyInitErr","17100001",650,done);
Utils.registerEvent("testRegisterJavaScriptProxyInitErr","Init error. The WebviewController must be associated with a Web component.",651,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2700
*tc.name testRunJavaScriptCallbackInitErr
*tc.desc test interface of runJavaScript (callback) with not been associated with specific Web Components
*/
it('testRunJavaScriptCallbackInitErr',0,async function(done){
emitKey="emitRunJavaScriptPromiseInitErr";
Utils.registerEvent("testRunJavaScriptCallbackInitErr","17100001",652,done);
Utils.registerEvent("testRunJavaScriptCallbackInitErr","Init error. The WebviewController must be associated with a Web component.",653,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2800
*tc.name testRunJavaScriptPromiseInitErr
*tc.desc test interface of runJavaScript (promise) with not been associated with specific Web Components
*/
it('testRunJavaScriptPromiseInitErr',0,async function(done){
emitKey="emitRunJavaScriptExtCallbackInitErr";
Utils.registerEvent("testRunJavaScriptPromiseInitErr","17100001",654,done);
Utils.registerEvent("testRunJavaScriptPromiseInitErr","Init error. The WebviewController must be associated with a Web component.",655,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2900
*tc.name testRunJavaScriptExtCallbackInitErr
*tc.desc test interface of runJavaScriptExt (callback) with not been associated with specific Web Components
*/
it('testRunJavaScriptExtCallbackInitErr',0,async function(done){
emitKey="emitRunJavaScriptExtPromiseInitErr";
Utils.registerEvent("testRunJavaScriptExtCallbackInitErr","17100001",656,done);
Utils.registerEvent("testRunJavaScriptExtCallbackInitErr","Init error. The WebviewController must be associated with a Web component.",657,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3000
*tc.name testRunJavaScriptExtPromiseInitErr
*tc.desc test interface of runJavaScriptExt (promise) with not been associated with specific Web Components
*/
it('testRunJavaScriptExtPromiseInitErr',0,async function(done){
emitKey="emitDeleteJavaScriptRegisterInitErr";
Utils.registerEvent("testRunJavaScriptExtPromiseInitErr","17100001",658,done);
Utils.registerEvent("testRunJavaScriptExtPromiseInitErr","Init error. The WebviewController must be associated with a Web component.",659,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3100
*tc.name testDeleteJavaScriptRegisterInitErr
*tc.desc test interface of deleteJavaScriptRegister with not been associated with specific Web Components
*/
it('testDeleteJavaScriptRegisterInitErr',0,async function(done){
emitKey="emitDeleteJavaScriptRegisterNameErr";
Utils.registerEvent("testDeleteJavaScriptRegisterInitErr","17100001",660,done);
Utils.registerEvent("testDeleteJavaScriptRegisterInitErr","Init error. The WebviewController must be associated with a Web component.",661,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3200
*tc.name testDeleteJavaScriptRegisterNameErr
*tc.desc test interface of deleteJavaScriptRegister with not been registered name
*/
it('testDeleteJavaScriptRegisterNameErr',0,async function(done){
emitKey="emitDeleteJavaScriptRegisterNameErr";
Utils.registerEvent("testDeleteJavaScriptRegisterNameErr","17100008",662,done);
Utils.registerEvent("testDeleteJavaScriptRegisterNameErr","Cannot delete JavaScriptProxy.",663,done);
sendEventByKey('webViewContJavaScriptError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContJsMessageExtReturnError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitJsMessageExtGetStringError";
export default function webViewContJsMessageExtReturnError() {
describe('ActsAceWebDevWebViewContJsMessageExtReturnErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContJsMessageExtReturnError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContJsMessageExtReturnError state success " + JSON.stringify(pages));
if (!("webViewContJsMessageExtReturnError" == pages.name)) {
console.info("get webViewContJsMessageExtReturnError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContJsMessageExtReturnError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContJsMessageExtReturnError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContJsMessageExtReturnError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContJsMessageExtReturnError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1000
*tc.name testJsMessageExtGetStringError
*tc.desc test interface of JsMessageExt getString with unmatched type
*/
it('testJsMessageExtGetStringError',0,async function(done){
emitKey="emitJsMessageExtGetNumberError";
Utils.registerEvent("testJsMessageExtGetStringError","17100014",816,done);
Utils.registerEvent("testJsMessageExtGetStringError","The type does not match with the value of the result.",817,done);
sendEventByKey('webViewContJsMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1100
*tc.name testJsMessageExtGetNumberError
*tc.desc test interface of JsMessageExt getNumber with unmatched type
*/
it('testJsMessageExtGetNumberError',0,async function(done){
emitKey="emitJsMessageExtGetBooleanError";
Utils.registerEvent("testJsMessageExtGetNumberError","17100014",818,done);
Utils.registerEvent("testJsMessageExtGetNumberError","The type does not match with the value of the result.",819,done);
sendEventByKey('webViewContJsMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1200
*tc.name testJsMessageExtGetBooleanError
*tc.desc test interface of JsMessageExt getBoolean with unmatched type
*/
it('testJsMessageExtGetBooleanError',0,async function(done){
emitKey="emitJsMessageExtGetArrayBufferError";
Utils.registerEvent("testJsMessageExtGetBooleanError","17100014",820,done);
Utils.registerEvent("testJsMessageExtGetBooleanError","The type does not match with the value of the result.",821,done);
sendEventByKey('webViewContJsMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1300
*tc.name testJsMessageExtGetArrayBufferError
*tc.desc test interface of JsMessageExt getArrayBuffer with unmatched type
*/
it('testJsMessageExtGetArrayBufferError',0,async function(done){
emitKey="emitJsMessageExtGetArrayError";
Utils.registerEvent("testJsMessageExtGetArrayBufferError","17100014",822,done);
Utils.registerEvent("testJsMessageExtGetArrayBufferError","The type does not match with the value of the result.",823,done);
sendEventByKey('webViewContJsMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1400
*tc.name testJsMessageExtGetArrayError
*tc.desc test interface of JsMessageExt getArray with unmatched type
*/
it('testJsMessageExtGetArrayError',0,async function(done){
emitKey="emitJsMessageExtGetArrayError";
Utils.registerEvent("testJsMessageExtGetArrayError","17100014",824,done);
Utils.registerEvent("testJsMessageExtGetArrayError","The type does not match with the value of the result.",825,done);
sendEventByKey('webViewContJsMessageExtReturnError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContMessageError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
let emitKey = "emitPostMessageInitErr";
export default function webViewContMessageError() {
describe('ActsAceWebDevWebViewContMessageErrorTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContMessageError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContMessageError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_0100
*tc.name testPostMessageInitErr
*tc.desc test interface of postMessage with not been associated with specific Web Components
*/
it('testPostMessageInitErr',0,async function(done){
emitKey="emitPostMessageEventUnPortErr";
Utils.registerEvent("testPostMessageInitErr","17100001",600,done);
Utils.registerEvent("testPostMessageInitErr","Init error. The WebviewController must be associated with a Web component",601,done);
sendEventByKey('webViewContMessageError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_0200
*tc.name testPostMessageEventPortClose
*tc.desc test interface of postMessageEvent with WebMessagePort been closed by ets
*/
it('testPostMessageEventPortClose',0,async function(done){
emitKey="emitPostMessageEventUnPortErr";
Utils.registerEvent("testPostMessageEventPortClose","17100010",602,done);
Utils.registerEvent("testPostMessageEventPortClose","Can not post message using this port.",603,done);
sendEventByKey('webViewContMessageError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageOperationsError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitAccessForwardInitErr";
export default function webViewContPageOperationsError() {
describe('ActsAceWebDevWebViewContPageOperationsErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContPageOperationsError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContPageOperationsError state success " + JSON.stringify(pages));
if (!("webViewContPageOperationsError" == pages.name)) {
console.info("get webViewContPageOperationsError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContPageOperationsError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContPageOperationsError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContPageOperationsError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContPageOperationsError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_1600
*tc.name testAccessForwardInitErr
*tc.desc test interface of accessForward with not been associated with specific Web Components
*/
it('testAccessForwardInitErr',0,async function(done){
emitKey="emitForwardInitErr";
Utils.registerEvent("testAccessForwardInitErr","17100001",630,done);
Utils.registerEvent("testAccessForwardInitErr","Init error. The WebviewController must be associated with a Web component.",631,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_1700
*tc.name testForwardInitErr
*tc.desc test interface of forward with not been associated with specific Web Components
*/
it('testForwardInitErr',0,async function(done){
emitKey="emitAccessBackwardInitErr";
Utils.registerEvent("testForwardInitErr","17100001",632,done);
Utils.registerEvent("testForwardInitErr","Init error. The WebviewController must be associated with a Web component.",633,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_1800
*tc.name testAccessBackwardInitErr
*tc.desc test interface of accessBackward with not been associated with specific Web Components
*/
it('testAccessBackwardInitErr',0,async function(done){
emitKey="emitBackwardInitErr";
Utils.registerEvent("testAccessBackwardInitErr","17100001",634,done);
Utils.registerEvent("testAccessBackwardInitErr","Init error. The WebviewController must be associated with a Web component.",635,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_1900
*tc.name testBackwardInitErr
*tc.desc test interface of backward with not been associated with specific Web Components
*/
it('testBackwardInitErr',0,async function(done){
emitKey="emitOnActiveInitErr";
Utils.registerEvent("testBackwardInitErr","17100001",636,done);
Utils.registerEvent("testBackwardInitErr","Init error. The WebviewController must be associated with a Web component.",637,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2000
*tc.name testOnActiveInitErr
*tc.desc test interface of onActive with not been associated with specific Web Components
*/
it('testOnActiveInitErr',0,async function(done){
emitKey="emitOnInactiveInitErr";
Utils.registerEvent("testOnActiveInitErr","17100001",638,done);
Utils.registerEvent("testOnActiveInitErr","Init error. The WebviewController must be associated with a Web component.",639,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2100
*tc.name testOnInactiveInitErr
*tc.desc test interface of onInactive with not been associated with specific Web Components
*/
it('testOnInactiveInitErr',0,async function(done){
emitKey="emitRefreshInitErr";
Utils.registerEvent("testOnInactiveInitErr","17100001",640,done);
Utils.registerEvent("testOnInactiveInitErr","Init error. The WebviewController must be associated with a Web component.",641,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2200
*tc.name testRefreshInitErr
*tc.desc test interface of refresh with not been associated with specific Web Components
*/
it('testRefreshInitErr',0,async function(done){
emitKey="emitAccessStepInitErr";
Utils.registerEvent("testRefreshInitErr","17100001",642,done);
Utils.registerEvent("testRefreshInitErr","Init error. The WebviewController must be associated with a Web component.",643,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2300
*tc.name testAccessStepInitErr
*tc.desc test interface of accessStep with not been associated with specific Web Components
*/
it('testAccessStepInitErr',0,async function(done){
emitKey="emitClearHistoryInitErr";
Utils.registerEvent("testAccessStepInitErr","17100001",644,done);
Utils.registerEvent("testAccessStepInitErr","Init error. The WebviewController must be associated with a Web component.",645,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2400
*tc.name testClearHistoryInitErr
*tc.desc test interface of clearHistory with not been associated with specific Web Components
*/
it('testClearHistoryInitErr',0,async function(done){
emitKey="emitGetHitTestInitErr";
Utils.registerEvent("testClearHistoryInitErr","17100001",646,done);
Utils.registerEvent("testClearHistoryInitErr","Init error. The WebviewController must be associated with a Web component.",647,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_2500
*tc.name testGetHitTestInitErr
*tc.desc test interface of getHitTest with not been associated with specific Web Components
*/
it('testGetHitTestInitErr',0,async function(done){
emitKey="emitGetHitTestInitErr";
Utils.registerEvent("testGetHitTestInitErr","17100001",648,done);
Utils.registerEvent("testGetHitTestInitErr","Init error. The WebviewController must be associated with a Web component.",649,done);
sendEventByKey('webViewContPageOperationsError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContStoreWebArchiveError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitStoreWebArchiveCallBackInitErr";
export default function webViewContStoreWebArchiveError() {
describe('ActsAceWebDevWebViewContStoreWebArchiveErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContStoreWebArchiveError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContStoreWebArchiveError state success " + JSON.stringify(pages));
if (!("webViewContStoreWebArchiveError" == pages.name)) {
console.info("get webViewContStoreWebArchiveError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContStoreWebArchiveError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContStoreWebArchiveError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContStoreWebArchiveError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContStoreWebArchiveError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5100
*tc.name testStoreWebArchiveInitErr
*tc.desc test interface of storeWebArchive with not been associated with specific Web Components
*/
it('teststoreWebArchiveInitErr',0,async function(done){
emitKey="emitStoreWebArchiveCallBackPathErr";
Utils.registerEvent("teststoreWebArchiveInitErr","17100001",700,done);
Utils.registerEvent("teststoreWebArchiveInitErr","Init error. The WebviewController must be associated with a Web component.",701,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5200
*tc.name testStoreWebArchiveCallBackPathErr
*tc.desc test interface of storeWebArchive with wrong resource path
*/
it('testStoreWebArchiveCallBackPathErr',0,async function(done){
emitKey="emitStoreWebArchiveCallBackUnAccessErr";
Utils.registerEvent("testStoreWebArchiveCallBackPathErr",17100003,702,done);
Utils.registerEvent("testStoreWebArchiveCallBackPathErr","Invalid resource path or file type.",703,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5300
*tc.name testStoreWebArchiveCallBackUnAccessErr
*tc.desc test interface of storeWebArchive with resource path cannot access
*/
it('testStoreWebArchiveCallBackUnAccessErr',0,async function(done){
emitKey="emitStoreWebArchivePromiseInitErr";
Utils.registerEvent("testStoreWebArchiveCallBackUnAccessErr",17100003,704,done);
Utils.registerEvent("testStoreWebArchiveCallBackUnAccessErr","Invalid resource path or file type.",705,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5400
*tc.name testStoreWebArchivePromiseInitErr
*tc.desc test interface of storeWebArchive promise with not been associated with specific Web Components
*/
it('testStoreWebArchivePromiseInitErr',0,async function(done){
emitKey="emitStoreWebArchivePromisePathErr";
Utils.registerEvent("testStoreWebArchivePromiseInitErr","17100001",706,done);
Utils.registerEvent("testStoreWebArchivePromiseInitErr","Init error. The WebviewController must be associated with a Web component.",707,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5500
*tc.name testStoreWebArchivePromisePathErr
*tc.desc test interface of storeWebArchive promise with wrong resource path
*/
it('testStoreWebArchivePromisePathErr',0,async function(done){
emitKey="emitStoreWebArchivePromiseUnAccessErr";
Utils.registerEvent("testStoreWebArchivePromisePathErr",17100003,708,done);
Utils.registerEvent("testStoreWebArchivePromisePathErr","Invalid resource path or file type.",709,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5600
*tc.name testStoreWebArchivePromiseUnAccessErr
*tc.desc test interface of storeWebArchive promise with resource path cannot access
*/
it('testStoreWebArchivePromiseUnAccessErr',0,async function(done){
emitKey="emitStoreWebArchivePromiseUnAccessErr";
Utils.registerEvent("testStoreWebArchivePromiseUnAccessErr",17100003,710,done);
Utils.registerEvent("testStoreWebArchivePromiseUnAccessErr","Invalid resource path or file type.",711,done);
sendEventByKey('webViewContStoreWebArchiveError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContWebMessageExtReturnError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitWebMessageExtGetStringError";
export default function webViewContWebMessageExtReturnError() {
describe('ActsAceWebDevWebViewContWebMessageExtReturnErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContWebMessageExtReturnError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContWebMessageExtReturnError state success " + JSON.stringify(pages));
if (!("webViewContWebMessageExtReturnError" == pages.name)) {
console.info("get webViewContWebMessageExtReturnError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContWebMessageExtReturnError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContWebMessageExtReturnError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContWebMessageExtReturnError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContWebMessageExtReturnError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1500
*tc.name testWebMessageExtGetStringError
*tc.desc test interface of WebMessageExt getString with unmatched type
*/
it('testWebMessageExtGetStringError',0,async function(done){
emitKey="emitWebMessageExtGetNumberError";
Utils.registerEvent("testWebMessageExtGetStringError","17100014",826,done);
Utils.registerEvent("testWebMessageExtGetStringError","The type does not match with the value of the result.",827,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1600
*tc.name testWebMessageExtGetNumberError
*tc.desc test interface of WebMessageExt getNumber with unmatched type
*/
it('testWebMessageExtGetNumberError',0,async function(done){
emitKey="emitWebMessageExtGetBooleanError";
Utils.registerEvent("testWebMessageExtGetNumberError","17100014",828,done);
Utils.registerEvent("testWebMessageExtGetNumberError","The type does not match with the value of the result.",829,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1700
*tc.name testWebMessageExtGetBooleanError
*tc.desc test interface of WebMessageExt getBoolean with unmatched type
*/
it('testWebMessageExtGetBooleanError',0,async function(done){
emitKey="emitWebMessageExtGetArrayBufferError";
Utils.registerEvent("testWebMessageExtGetBooleanError","17100014",830,done);
Utils.registerEvent("testWebMessageExtGetBooleanError","The type does not match with the value of the result.",831,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1800
*tc.name testWebMessageExtGetArrayBufferError
*tc.desc test interface of WebMessageExt getArrayBuffer with unmatched type
*/
it('testWebMessageExtGetArrayBufferError',0,async function(done){
emitKey="emitWebMessageExtGetArrayError";
Utils.registerEvent("testWebMessageExtGetArrayBufferError","17100014",832,done);
Utils.registerEvent("testWebMessageExtGetArrayBufferError","The type does not match with the value of the result.",833,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_1900
*tc.name testWebMessageExtGetArrayError
*tc.desc test interface of WebMessageExt getArray with unmatched type
*/
it('testWebMessageExtGetArrayError',0,async function(done){
emitKey="emitWebMessageExtGetErrorError";
Utils.registerEvent("testWebMessageExtGetArrayError","17100014",834,done);
Utils.registerEvent("testWebMessageExtGetArrayError","The type does not match with the value of the result.",835,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORHUNDRED_2000
*tc.name testWebMessageExtGetErrorError
*tc.desc test interface of WebMessageExt getError with unmatched type
*/
it('testWebMessageExtGetErrorError',0,async function(done){
emitKey="emitWebMessageExtGetErrorError";
Utils.registerEvent("testWebMessageExtGetErrorError","17100014",836,done);
Utils.registerEvent("testWebMessageExtGetErrorError","The type does not match with the value of the result.",837,done);
sendEventByKey('webViewContWebMessageExtReturnError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContZoomAndOthersError.test.ets
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitZoomInitErr";
export default function webViewContZoomAndOthersError() {
describe('ActsAceWebDevWebViewContZoomAndOthersErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContZoomAndOthersError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContZoomAndOthersError state success " + JSON.stringify(pages));
if (!("webViewContZoomAndOthersError" == pages.name)) {
console.info("get webViewContZoomAndOthersError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContZoomAndOthersError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContZoomAndOthersError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContZoomAndOthersError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContZoomAndOthersError afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3300
*tc.name testZoomInitErr
*tc.desc test interface of zoom with not been associated with specific Web Components
*/
it('testZoomInitErr',0,async function(done){
emitKey="emitZoomEnableErr";
Utils.registerEvent("testZoomInitErr","17100001",664,done);
Utils.registerEvent("testZoomInitErr","Init error. The WebviewController must be associated with a Web component.",665,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3400
*tc.name testZoomEnableErr
*tc.desc test interface of zoom with not been enabled
*/
it('testZoomEnableErr',0,async function(done){
emitKey="emitSearchAllAsyncInitErr";
Utils.registerEvent("testZoomEnableErr","17100004",666,done);
Utils.registerEvent("testZoomEnableErr","Function not enable.",667,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3500
*tc.name testSearchAllAsyncInitErr
*tc.desc test interface of searchAllAsync with not been associated with specific Web Components
*/
it('testSearchAllAsyncInitErr',0,async function(done){
emitKey="emitClearMatchesInitErr";
Utils.registerEvent("testSearchAllAsyncInitErr","17100001",668,done);
Utils.registerEvent("testSearchAllAsyncInitErr","Init error. The WebviewController must be associated with a Web component.",669,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3600
*tc.name testClearMatchesInitErr
*tc.desc test interface of clearMatches with not been associated with specific Web Components
*/
it('testClearMatchesInitErr',0,async function(done){
emitKey="emitSearchNextInitErr";
Utils.registerEvent("testClearMatchesInitErr","17100001",670,done);
Utils.registerEvent("testClearMatchesInitErr","Init error. The WebviewController must be associated with a Web component.",671,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3700
*tc.name testSearchNextInitErr
*tc.desc test interface of searchNext with not been associated with specific Web Components
*/
it('testSearchNextInitErr',0,async function(done){
emitKey="emitClearSslCacheInitErr";
Utils.registerEvent("testSearchNextInitErr","17100001",672,done);
Utils.registerEvent("testSearchNextInitErr","Init error. The WebviewController must be associated with a Web component.",673,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3800
*tc.name testClearSslCacheInitErr
*tc.desc test interface of clearSslCache with not been associated with specific Web Components
*/
it('testClearSslCacheInitErr',0,async function(done){
emitKey="emitClearClientAuthenticationCacheInitErr";
Utils.registerEvent("testClearSslCacheInitErr","17100001",674,done);
Utils.registerEvent("testClearSslCacheInitErr","Init error. The WebviewController must be associated with a Web component.",675,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_3900
*tc.name testClearClientAuthenticationCacheInitErr
*tc.desc test interface of clearClientAuthenticationCache with not been associated with specific Web Components
*/
it('testClearClientAuthenticationCacheInitErr',0,async function(done){
emitKey="emitCreateWebMessagePortsInitErr";
Utils.registerEvent("testClearClientAuthenticationCacheInitErr","17100001",676,done);
Utils.registerEvent("testClearClientAuthenticationCacheInitErr","Init error. The WebviewController must be associated with a Web component.",677,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4000
*tc.name testCreateWebMessagePortsInitErr
*tc.desc test interface of createWebMessagePorts with not been associated with specific Web Components
*/
it('testCreateWebMessagePortsInitErr',0,async function(done){
emitKey="emitRequestFocusInitErr";
Utils.registerEvent("testCreateWebMessagePortsInitErr","17100001",678,done);
Utils.registerEvent("testCreateWebMessagePortsInitErr","Init error. The WebviewController must be associated with a Web component.",679,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4100
*tc.name testRequestFocusInitErr
*tc.desc test interface of requestFocus with not been associated with specific Web Components
*/
it('testRequestFocusInitErr',0,async function(done){
emitKey="emitZoomInInitErr";
Utils.registerEvent("testRequestFocusInitErr","17100001",680,done);
Utils.registerEvent("testRequestFocusInitErr","Init error. The WebviewController must be associated with a Web component.",681,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4200
*tc.name testZoomInInitErr
*tc.desc test interface of zoomIn with not been associated with specific Web Components
*/
it('testZoomInInitErr',0,async function(done){
emitKey="emitZoomInEnableErr";
Utils.registerEvent("testZoomInInitErr","17100001",682,done);
Utils.registerEvent("testZoomInInitErr","Init error. The WebviewController must be associated with a Web component.",683,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4300
*tc.name testZoomInEnableErr
*tc.desc test interface of zoomIn with not been enabled
*/
it('testZoomInEnableErr',0,async function(done){
emitKey="emitZoomOutInitErr";
Utils.registerEvent("testZoomInEnableErr","17100004",684,done);
Utils.registerEvent("testZoomInEnableErr","Function not enable.",685,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4400
*tc.name testZoomOutInitErr
*tc.desc test interface of zoomOut with not been associated with specific Web Components
*/
it('testZoomOutInitErr',0,async function(done){
emitKey="emitZoomOutEnableErr";
Utils.registerEvent("testZoomOutInitErr","17100001",686,done);
Utils.registerEvent("testZoomOutInitErr","Init error. The WebviewController must be associated with a Web component.",687,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4500
*tc.name testZoomOutEnableErr
*tc.desc test interface of zoomOut with not been enabled
*/
it('testZoomOutEnableErr',0,async function(done){
emitKey="emitGetHitTestValueInitErr";
Utils.registerEvent("testZoomOutEnableErr","17100004",688,done);
Utils.registerEvent("testZoomOutEnableErr","Function not enable.",689,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4600
*tc.name testGetHitTestValueInitErr
*tc.desc test interface of getHitTestValue with not been associated with specific Web Components
*/
it('testGetHitTestValueInitErr',0,async function(done){
emitKey="emitGetWebIdInitErr";
Utils.registerEvent("testGetHitTestValueInitErr","17100001",690,done);
Utils.registerEvent("testGetHitTestValueInitErr","Init error. The WebviewController must be associated with a Web component.",691,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4700
*tc.name testGetWebIdInitErr
*tc.desc test interface of getWebId with not been associated with specific Web Components
*/
it('testGetWebIdInitErr',0,async function(done){
emitKey="emitGetUserAgentInitErr";
Utils.registerEvent("testGetWebIdInitErr","17100001",692,done);
Utils.registerEvent("testGetWebIdInitErr","Init error. The WebviewController must be associated with a Web component.",639,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4800
*tc.name testGetUserAgentInitErr
*tc.desc test interface of getUserAgent with not been associated with specific Web Components
*/
it('testGetUserAgentInitErr',0,async function(done){
emitKey="emitGetTitleInitErr";
Utils.registerEvent("testGetUserAgentInitErr","17100001",694,done);
Utils.registerEvent("testGetUserAgentInitErr","Init error. The WebviewController must be associated with a Web component.",695,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_4900
*tc.name testGetTitleInitErr
*tc.desc test interface of getTitle with not been associated with specific Web Components
*/
it('testGetTitleInitErr',0,async function(done){
emitKey="emitGetPageHeightInitErr";
Utils.registerEvent("testGetTitleInitErr","17100001",696,done);
Utils.registerEvent("testGetTitleInitErr","Init error. The WebviewController must be associated with a Web component.",697,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_5000
*tc.name testGetPageHeightInitErr
*tc.desc test interface of getPageHeight with not been associated with specific Web Components
*/
it('testGetPageHeightInitErr',0,async function(done){
emitKey="emitGetPageHeightInitErr";
Utils.registerEvent("testGetPageHeightInitErr","17100001",698,done);
Utils.registerEvent("testGetPageHeightInitErr","Init error. The WebviewController must be associated with a Web component.",699,done);
sendEventByKey('webViewContZoomAndOthersError',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/module.json
0 → 100644
浏览文件 @
05edbdf0
{
"module"
:
{
"name"
:
"phone"
,
"type"
:
"entry"
,
"srcEntrance"
:
"./ets/Application/AbilityStage.ts"
,
"description"
:
"$string:phone_entry_dsc"
,
"mainElement"
:
"MainAbility"
,
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
"uiSyntax"
:
"ets"
,
"pages"
:
"$profile:main_pages"
,
"metadata"
:
[
{
"name"
:
"ArkTSPartialUpdate"
,
"value"
:
"true"
}
],
"abilities"
:
[{
"name"
:
"com.example.myapplication.MainAbility"
,
"srcEntrance"
:
"./ets/MainAbility/MainAbility.ts"
,
"description"
:
"$string:phone_entry_main"
,
"icon"
:
"$media:icon"
,
"label"
:
"$string:entry_label"
,
"visible"
:
true
,
"orientation"
:
"portrait"
,
"skills"
:
[{
"actions"
:
[
"action.system.home"
],
"entities"
:
[
"entity.system.home"
]
}]
}],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.LOCATION"
},
{
"name"
:
"ohos.permission.INTERNET"
}
]
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
05edbdf0
{
"string"
:
[
{
"name"
:
"phone_entry_dsc"
,
"value"
:
"i am an entry for phone"
},
{
"name"
:
"phone_entry_main"
,
"value"
:
"the phone entry ability"
},
{
"name"
:
"entry_label"
,
"value"
:
"ActsContextTest"
},
{
"name"
:
"form_description"
,
"value"
:
"my form"
},
{
"name"
:
"serviceability_description"
,
"value"
:
"my whether"
},
{
"name"
:
"description_application"
,
"value"
:
"demo for test"
},
{
"name"
:
"app_name"
,
"value"
:
"Demo"
}
]
}
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
05edbdf0
15.1 KB
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/base/profile/main_pages.json
0 → 100644
浏览文件 @
05edbdf0
{
"src"
:
[
"MainAbility/pages/webViewContMessageError"
,
"MainAbility/pages/webViewContPageOperationsError"
,
"MainAbility/pages/webViewContJavaScriptError"
,
"MainAbility/pages/webViewContZoomAndOthersError"
,
"MainAbility/pages/webViewContStoreWebArchiveError"
,
"MainAbility/pages/webViewContGetUrlAndOthersError"
,
"MainAbility/pages/webViewContCookieToGeoLocationError"
,
"MainAbility/pages/webViewContJsMessageExtReturnError"
,
"MainAbility/pages/webViewContWebMessageExtReturnError"
]
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/icon.png
0 → 100644
浏览文件 @
05edbdf0
15.1 KB
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/index.html
0 → 100644
浏览文件 @
05edbdf0
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
index
</title>
<style>
#pageHeight
{
height
:
1300px
}
</style>
</head>
<body>
<div
id=
"container"
>
首页
</div>
<div
id=
"pageHeight"
></div>
<a
href=
"second.html"
id=
"fileAccess"
>
打开rawfile文件
</a>
<img
src=
"icon.png"
alt=
"icon"
id=
"imgs"
>
</body>
<script>
let
ele
=
document
.
getElementById
(
"
imgs
"
);
let
loadImage
;
ele
.
onload
=
function
(){
loadImage
=
"
load complete
"
}
function
getUserAgent
(){
return
navigator
.
userAgent
}
function
test
(){
backToEts
.
test
(
"
backToEts
"
)
}
function
testRunJavaScript
(){
return
"
testRunJavaScript
"
}
function
getPageHeight
(){
let
height
=
document
.
body
.
scrollHeight
return
height
}
function
proxy
(){
objName
.
register
(
"
backToEts
"
)
}
function
registerTest
(){
let
str
=
objName
.
register
();
console
.
log
(
str
);
return
str
}
function
jsAccess
(){
console
.
log
(
"
web111
"
)
}
function
consoleTest
(){
console
.
log
(
"
console test
"
)
}
function
alertTest
(){
alert
(
'
alert test
'
)
}
function
confirmTest
(){
confirm
(
"
confirm test
"
)
}
function
getImgResult
(){
return
loadImage
}
function
toPrompt
(){
let
result
=
prompt
(
"
age
"
,
"
20
"
);
console
.
log
(
"
result:
"
+
result
)
}
function
openRawFile
(){
document
.
getElementById
(
"
fileAccess
"
).
click
()
}
function
gettitle
(){
return
document
.
title
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/index.js
0 → 100644
浏览文件 @
05edbdf0
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//index.js
var
h5Port
;
window
.
addEventListener
(
'
message
'
,
function
(
event
)
{
if
(
event
.
data
==
'
init_web_messageport
'
)
{
if
(
event
.
ports
[
0
]
!=
null
)
{
h5Port
=
event
.
ports
[
0
];
// 1. 保存从ets侧发送过来的端口
h5Port
.
onmessage
=
function
(
event
)
{
console
.
log
(
"
hwd In html got message
"
);
// 2. 接收ets侧发送过来的消息.
var
result
=
event
.
data
;
console
.
log
(
"
In html got message, typeof:
"
,
typeof
(
result
));
console
.
log
(
"
In html got message, result:
"
,
(
result
));
if
(
typeof
(
result
)
==
"
string
"
)
{
console
.
log
(
"
In html got message, String:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
String:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
number
"
)
{
console
.
log
(
"
In html side got message, number:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
Number:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
boolean
"
)
{
console
.
log
(
"
In html side got message, boolean:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
Boolean:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
object
"
)
{
if
(
result
instanceof
ArrayBuffer
)
{
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
ArrayBuffer:
"
+
result
.
byteLength
;
console
.
log
(
"
In html got message, byteLength:
"
,
result
.
byteLength
);
}
else
if
(
result
instanceof
Error
)
{
console
.
log
(
"
In html error message, err:
"
+
(
result
));
console
.
log
(
"
In html error message, typeof err:
"
+
typeof
(
result
));
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
Error:
"
+
result
.
name
+
"
, msg:
"
+
result
.
message
;
}
else
if
(
result
instanceof
Array
)
{
console
.
log
(
"
In html got message, Array
"
);
console
.
log
(
"
In html got message, Array length:
"
+
result
.
length
);
console
.
log
(
"
In html got message, Array[0]:
"
+
(
result
[
0
]));
console
.
log
(
"
In html got message, typeof Array[0]:
"
+
typeof
(
result
[
0
]));
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
Array len:
"
+
result
.
length
+
"
, value:
"
+
result
;
}
else
{
console
.
log
(
"
In html got message, not any instance of support type
"
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
not any instance of support type
"
;
}
}
else
{
console
.
log
(
"
In html got message, not support type
"
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
not support type
"
;
}
}
h5Port
.
onmessageerror
=
(
event
)
=>
{
console
.
error
(
`hwd In html Error receiving message:
${
event
}
`
);
};
}
}
})
// 使用h5Port往ets侧发送String类型的消息.
function
postStringToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send string message
"
);
h5Port
.
postMessage
(
"
hello
"
);
console
.
log
(
"
In html send string message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
// 使用h5Port往ets侧发送Number类型的消息.
function
postNumberToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send number message
"
);
h5Port
.
postMessage
(
123456
);
console
.
log
(
"
In html send number message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
// 使用h5Port往ets侧发送Boolean类型的消息.
function
postBooleanToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send boolean message
"
);
h5Port
.
postMessage
(
true
);
console
.
log
(
"
In html send boolean message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
// 使用h5Port往ets侧发送ArrayBuffer类型的消息.
function
postArrayBufferToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send ArrayBuffer message
"
);
let
buffer
=
new
ArrayBuffer
(
12
);
buffer
[
0
]
=
'
a
'
;
h5Port
.
postMessage
(
buffer
);
console
.
log
(
"
In html send ArrayBuffer message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
// 使用h5Port往ets侧发送Array类型的消息.
function
postArrayToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Array message
"
);
let
a
=
Array
(
"
apple
"
,
"
banana
"
,
"
cherry
"
);
h5Port
.
postMessage
(
a
);
console
.
log
(
"
In html send Array message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
// 使用h5Port往ets侧发送Error类型的消息.
function
postErrorToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Error message
"
);
let
err
=
new
Error
(
'
An error occurred!
'
,
{
cause
:
'
4321
'
})
h5Port
.
postMessage
(
err
);
console
.
log
(
"
In html send Error message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
closeWin
()
{
window
.
opener
=
null
window
.
open
(
''
,
'
_self
'
,)
window
.
close
()
return
true
}
function
portClose
()
{
h5Port
.
close
()
}
function
test
()
{
backToEts
.
test
(
"
backToEts
"
)
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/indexEdit.html
0 → 100644
浏览文件 @
05edbdf0
<!--index.html-->
<!DOCTYPE html>
<html
lang=
"en-gb"
>
<head>
<title>
WebView MessagePort Demo
</title>
</head>
<body>
<h1>
Html5 Send and Receive Message
</h1>
<h3
id=
"msg"
>
Receive string:
</h3>
<h3
id=
"msg2"
>
Receive arraybuffer:
</h3>
<div
style=
"font-size: 10pt; text-align: center;"
>
<input
type=
"button"
value=
"Send String"
onclick=
"postStringToApp();"
/><br/>
<input
type=
"button"
value=
"Send Number"
onclick=
"postNumberToApp();"
/><br/>
<input
type=
"button"
value=
"Send Boolean"
onclick=
"postBooleanToApp();"
/><br/>
<input
type=
"button"
value=
"Send ArrayBuffer"
onclick=
"postArrayBufferToApp();"
/><br/>
<input
type=
"button"
value=
"Send Array"
onclick=
"postArrayToApp();"
/><br/>
<input
type=
"button"
value=
"Send Error"
onclick=
"postErrorToApp();"
/><br/>
</div>
</body>
<script
src=
"./index.js"
></script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/indexNoPermission.html
0 → 100644
浏览文件 @
05edbdf0
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
index
</title>
<style>
#pageHeight
{
height
:
1300px
}
</style>
</head>
<body>
<div
id=
"container"
>
首页
</div>
<div
id=
"pageHeight"
></div>
<a
href=
"second.html"
id=
"fileAccess"
>
打开rawfile文件
</a>
<img
src=
"icon.png"
alt=
"icon"
id=
"imgs"
>
</body>
<script>
let
ele
=
document
.
getElementById
(
"
imgs
"
);
let
loadImage
;
ele
.
onload
=
function
(){
loadImage
=
"
load complete
"
}
function
getUserAgent
(){
return
navigator
.
userAgent
}
function
test
(){
backToEts
.
test
(
"
backToEts
"
)
}
function
testRunJavaScript
(){
return
"
testRunJavaScript
"
}
function
getPageHeight
(){
let
height
=
document
.
body
.
scrollHeight
return
height
}
function
proxy
(){
objName
.
register
(
"
backToEts
"
)
}
function
registerTest
(){
let
str
=
objName
.
register
();
console
.
log
(
str
);
return
str
}
function
jsAccess
(){
console
.
log
(
"
web111
"
)
}
function
consoleTest
(){
console
.
log
(
"
console test
"
)
}
function
alertTest
(){
alert
(
'
alert test
'
)
}
function
confirmTest
(){
confirm
(
"
confirm test
"
)
}
function
getImgResult
(){
return
loadImage
}
function
toPrompt
(){
let
result
=
prompt
(
"
age
"
,
"
20
"
);
console
.
log
(
"
result:
"
+
result
)
}
function
openRawFile
(){
document
.
getElementById
(
"
fileAccess
"
).
click
()
}
function
gettitle
(){
return
document
.
title
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/second.html
0 → 100644
浏览文件 @
05edbdf0
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
second
</title>
</head>
<body>
<div
style=
"height: 1300px;background-color: #999999;"
>
second pages
</div>
</body>
<script>
function
gettitle
(){
return
document
.
title
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/resources/rawfile/testMessageExt.html
0 → 100644
浏览文件 @
05edbdf0
<!DOCTYPE html>
<html
lang=
"en-gb"
>
<body>
<h1>
run JavaScript Ext demo
</h1>
</body>
<script
type=
"text/javascript"
>
function
testString
()
{
return
"
hello, world
"
;
}
function
testNumber
()
{
return
01234567
;
}
function
testBoolean
()
{
return
true
;
}
function
testArrayBuffer
()
{
let
buffer
=
new
ArrayBuffer
(
12
);
buffer
[
0
]
=
'
a
'
;
return
buffer
}
function
testArray
()
{
let
a
=
Array
(
"
apple
"
,
"
banana
"
,
"
cherry
"
);
return
a
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
05edbdf0
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录