Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
0db4e38f
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看板
提交
0db4e38f
编写于
7月 20, 2023
作者:
Y
yupeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
app api
Signed-off-by:
N
yupeng
<
yupeng78@huawei.com
>
上级
0a5d0310
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
612 addition
and
61 deletion
+612
-61
arkui/ace_ets_web_dev_four/entry/src/main/ets/MainAbility/pages/web.ets
...web_dev_four/entry/src/main/ets/MainAbility/pages/web.ets
+64
-0
arkui/ace_ets_web_dev_four/entry/src/main/ets/MainAbility/pages/webTwo.ets
..._dev_four/entry/src/main/ets/MainAbility/pages/webTwo.ets
+62
-3
arkui/ace_ets_web_dev_four/entry/src/main/ets/test/WebJsunit.test.ets
...s_web_dev_four/entry/src/main/ets/test/WebJsunit.test.ets
+11
-3
arkui/ace_ets_web_dev_four/entry/src/main/ets/test/WebTwoJsunit.test.ets
...eb_dev_four/entry/src/main/ets/test/WebTwoJsunit.test.ets
+21
-1
arkui/ace_ets_web_dev_four/entry/src/main/module.json
arkui/ace_ets_web_dev_four/entry/src/main/module.json
+22
-27
arkui/ace_ets_web_dev_four/entry/src/main/resources/rawfile/index.html
..._web_dev_four/entry/src/main/resources/rawfile/index.html
+7
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContMessageError.ets
...rc/main/ets/MainAbility/pages/webViewContMessageError.ets
+1
-1
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageAndprepareForPageLoadErrorOne.ets
...ty/pages/webViewContPageAndprepareForPageLoadErrorOne.ets
+92
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageAndprepareForPageLoadErrorTwo.ets
...ty/pages/webViewContPageAndprepareForPageLoadErrorTwo.ets
+130
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/List.test.ets
...viewControllerError/entry/src/main/ets/test/List.test.ets
+5
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageAndprepareForPageLoadErrorOne.test.ets
...est/webViewContPageAndprepareForPageLoadErrorOne.test.ets
+78
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageAndprepareForPageLoadErrorTwo.test.ets
...est/webViewContPageAndprepareForPageLoadErrorTwo.test.ets
+98
-0
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/module.json
...web_dev_webviewControllerError/entry/src/main/module.json
+21
-26
未找到文件。
arkui/ace_ets_web_dev_four/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
0db4e38f
...
...
@@ -28,6 +28,7 @@ struct Index {
@State outputStr: string = ''
@State playing: boolean = false
@State str:string="emitOnLoadIntercept"
@State arrid:number = 0
onPageShow(){
let valueChangeEvent={
eventId:10,
...
...
@@ -62,6 +63,10 @@ struct Index {
this.controller.loadUrl("https://www.baidu.com/")
break;
}
case "emitOnControllerAttached":{
Utils.emitEvent(this.arrid,7)
break;
}
default:
console.info("can not match case")
...
...
@@ -83,6 +88,65 @@ struct Index {
Utils.emitEvent(event.error.getErrorInfo(),3)
})
.onScreenCaptureRequest((event) => {
AlertDialog.show({
title: 'title: ' + event.handler.getOrigin(),
message: 'text',
primaryButton: {
value: 'deny',
action: () => {
event.handler.deny()
}
},
secondaryButton: {
value: 'onConfirm',
action: () => {
event.handler.grant({ captureMode: WebCaptureMode.HOME_SCREEN })
}
},
cancel: () => {
event.handler.deny()
}
})
})
.onControllerAttached(() => {
try {
this.arrid = this.controller.getWebId();
console.log("id++++++: " + this.arrid);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
.onOverScroll((event) => {
console.info("x = " + event.xOffset)
console.info("y = " + event.yOffset)
})
.onClientAuthenticationRequest((event) => {
AlertDialog.show({
title: 'onClientAuthenticationRequest',
message: 'text',
primaryButton: {
value: 'confirm',
action: () => {
event.handler.confirm("/system/etc/user.pk8", "/system/etc/chain-user.pem")
}
},
secondaryButton: {
value: 'cancel',
action: () => {
event.handler.cancel()
}
},
cancel: () => {
event.handler.ignore()
}
})
})
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_four/entry/src/main/ets/MainAbility/pages/webTwo.ets
浏览文件 @
0db4e38f
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -15,6 +16,7 @@
import events_emitter from '@ohos.events.emitter';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import UIAbility from '@ohos.app.ability.UIAbility';
function Uint8ArrayToString(dataArray) {
var dataString = ''
...
...
@@ -41,6 +43,8 @@ function ParseX509CertInfo(x509CertArray) {
@Component
struct Second {
@State outputStr: string = ''
@State firsttime:number = 0
@State arr: Array<number> = [0, 0]
webviewCtl: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitGetCertificate"
onPageShow(){
...
...
@@ -79,12 +83,60 @@ struct Second {
break;
}
case "emitPrefetchPage": {
try {
this.webviewCtl.removeCache(true)
this.webviewCtl.loadUrl('https://www.huawei.com')
if (this.arr.length > 2) {
this.webviewCtl.removeCache(true)
}
this.webviewCtl.prefetchPage('https://www.huawei.com');
this.webviewCtl.loadUrl('https://www.huawei.com')
setTimeout(()=>{
if (this.arr.length > 3) {
if (this.arr[3]-this.arr[2] < 0) {
Utils.emitEvent("success",6)
}
}
},2000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitPrepareForPageLoad": {
try {
this.webviewCtl.removeCache(true)
this.webviewCtl.loadUrl('https://www.jd.com/')
if (this.arr.length > 4) {
this.webviewCtl.removeCache(true)
}
web_webview.WebviewController.prepareForPageLoad("https://www.jd.com/", true, 6);
this.webviewCtl.loadUrl('https://www.jd.com/')
setTimeout(()=>{
if (this.arr.length > 5) {
if (this.arr[5]-this.arr[4] < 0) {
Utils.emitEvent("success",8)
}
}
},2000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
default:
console.info("can not match case");
}
})
}
Web({ src: '
https://www.example
.com', controller: this.webviewCtl })
Web({ src: '
www.baidu
.com', controller: this.webviewCtl })
.fileAccess(true)
.javaScriptAccess(true)
.domStorageAccess(true)
...
...
@@ -92,6 +144,13 @@ struct Second {
.onPageEnd((e) => {
this.outputStr = 'onPageEnd : url = ' + e.url
})
.onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs)
this.firsttime = event.firstContentfulPaintMs - event.navigationStartTick/1000
this.arr.push(this.firsttime)
})
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_four/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
0db4e38f
...
...
@@ -45,14 +45,22 @@ export default function webJsunit() {
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_00
2
*tc.number SUB_ACE_BASIC_ETS_API_00
1
*tc.name OnLoadIntercept *tc.desic Injects the JavaScript object into window and invoke the function in window
*/
it('OnLoadIntercept',0,async function(done){
emitKey="emitOn
LoadIntercept
";
emitKey="emitOn
ControllerAttached
";
Utils.registerEvent("OnLoadIntercept","https://www.baidu.com/",2,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_002
*tc.name OnControllerAttached *tc.desic Injects the JavaScript object into window and invoke the function in window
*/
it('OnControllerAttached',0,async function(done){
emitKey="emitOnControllerAttached";
Utils.registerEvent("OnControllerAttached",1,7,done);
sendEventByKey('webcomponent',10,'');
})
})
}
arkui/ace_ets_web_dev_four/entry/src/main/ets/test/WebTwoJsunit.test.ets
浏览文件 @
0db4e38f
...
...
@@ -70,9 +70,29 @@ export default function webTwoJsunit() {
*tc.desic Sets allow the Web access overview mode
*/
it('GetCertificate',0,async function(done){
emitKey="emit
OverviewModeAccessFals
e";
emitKey="emit
GetCertificat
e";
Utils.registerEvent("GetCertificate","getCertificate success: len = 0",4,done);
sendEventByKey('webcomponenttwo',10,'');
})
///*
// *tc.number SUB_ACE_BASIC_ETS_API_002
// *tc.name PrefetchPage
// *tc.desic Sets allow the Web access overview mode
// */
//it('PrefetchPage',0,async function(done){
// emitKey="emitPrepareForPageLoad";
// Utils.registerEvent("PrefetchPage","success",6,done);
// sendEventByKey('webcomponenttwo',10,'');
//})
///*
// *tc.number SUB_ACE_BASIC_ETS_API_003
// *tc.name PrepareForPageLoad
// *tc.desic Sets allow the Web access overview mode
// */
//it('PrepareForPageLoad',0,async function(done){
// emitKey="emitPrepareForPageLoad";
// Utils.registerEvent("PrepareForPageLoad","success",8,done);
// sendEventByKey('webcomponenttwo',10,'');
//})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_four/entry/src/main/module.json
浏览文件 @
0db4e38f
...
...
@@ -8,8 +8,7 @@
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
,
"2in1"
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
...
...
@@ -21,8 +20,7 @@
"value"
:
"true"
}
],
"abilities"
:
[
{
"abilities"
:
[{
"name"
:
"com.example.myapplication.MainAbility"
,
"srcEntrance"
:
"./ets/MainAbility/MainAbility.ts"
,
"description"
:
"$string:phone_entry_main"
,
...
...
@@ -30,18 +28,15 @@
"label"
:
"$string:entry_label"
,
"visible"
:
true
,
"orientation"
:
"portrait"
,
"skills"
:
[
{
"skills"
:
[{
"actions"
:
[
"action.system.home"
],
"entities"
:
[
"entity.system.home"
]
}
]
}
],
}]
}],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.LOCATION"
...
...
arkui/ace_ets_web_dev_four/entry/src/main/resources/rawfile/index.html
0 → 100644
浏览文件 @
0db4e38f
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>
Hello World
</p>
</body>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContMessageError.ets
浏览文件 @
0db4e38f
...
...
@@ -113,7 +113,6 @@ struct webViewContMessageError {
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) => {
...
...
@@ -122,6 +121,7 @@ struct webViewContMessageError {
})
break;
}
}
})
}
...
...
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageAndprepareForPageLoadErrorOne.ets
0 → 100644
浏览文件 @
0db4e38f
/**
* 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 UIAbility from '@ohos.app.ability.UIAbility';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct webViewContPageAndprepareForPageLoadErrorOne {
controller20: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
msgPort: web_webview.WebMessagePort[] = null;
@State str:string="emitPrefetchPageErr";
@State errorCode: string = '0';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContPageAndprepareForPageLoadErrorOne 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('webViewContPageAndprepareForPageLoadErrorOne').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitPrefetchPageErr": {
try {
this.controller20.prefetchPage('百度');
console.info("---666---444---8888")
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("789+++987"+this.errorCode)
Utils.emitEvent(this.errorCode, 900)
}
break;
}
}
})
}
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/MainAbility/pages/webViewContPageAndprepareForPageLoadErrorTwo.ets
0 → 100644
浏览文件 @
0db4e38f
/**
* 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 UIAbility from '@ohos.app.ability.UIAbility';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct webViewContPageAndprepareForPageLoadErrorTwo {
controller: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
msgPort: web_webview.WebMessagePort[] = null;
@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 str:string="emitPostMessageInitErr";
@State errorCode: string = '0';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContPageAndprepareForPageLoadErrorTwo 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('webViewContPageAndprepareForPageLoadErrorTwo').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitPrefetchPageErr": {
try {
this.controller.prefetchPage('华为');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("123+++321"+this.errorCode)
Utils.emitEvent(this.errorCode, 903)
}
break;
}
case "emitPrepareForPageLoadErr": {
try {
web_webview.WebviewController.prepareForPageLoad("华为", true, 6);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("456+++654"+this.errorCode)
Utils.emitEvent(this.errorCode, 904)
}
break;
}
case "emitPrepareForPageLoadErrTwo": {
try {
web_webview.WebviewController.prepareForPageLoad("huawei", true, 7);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("4566+++6546"+this.errorCode)
Utils.emitEvent(this.errorCode, 905)
}
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)
.zoomAccess(this.zoomAccess)
}
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/List.test.ets
浏览文件 @
0db4e38f
...
...
@@ -21,6 +21,8 @@ import webViewContGetUrlAndOthersError from './webViewContGetUrlAndOthersError.t
import webViewContCookieToGeoLocationError from './webViewContCookieToGeoLocationError.test'
import webViewContJsMessageExtReturnError from './webViewContJsMessageExtReturnError.test'
import webViewContWebMessageExtReturnError from './webViewContWebMessageExtReturnError.test'
import webViewContPageAndprepareForPageLoadErrorOne from './webViewContPageAndprepareForPageLoadErrorOne.test'
import webViewContPageAndprepareForPageLoadErrorTwo from './webViewContPageAndprepareForPageLoadErrorTwo.test'
export default function testsuite() {
webViewContMessageError()
...
...
@@ -32,4 +34,7 @@ export default function testsuite() {
webViewContCookieToGeoLocationError()
webViewContJsMessageExtReturnError()
webViewContWebMessageExtReturnError()
//webViewContPageAndprepareForPageLoadErrorOne()
//webViewContPageAndprepareForPageLoadErrorTwo()
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageAndprepareForPageLoadErrorOne.test.ets
0 → 100644
浏览文件 @
0db4e38f
/**
* 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 = "emitPrefetchPageErr";
export default function webViewContPageAndprepareForPageLoadErrorOne() {
describe('ActsAceWebDevWebViewContPageAndPrepareForPageLoadErrorOneTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContPageAndprepareForPageLoadErrorOne',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContPageAndprepareForPageLoadErrorOne state success " + JSON.stringify(pages));
if (!("webViewContPageAndprepareForPageLoadErrorOne" == pages.name)) {
console.info("get webViewContPageAndprepareForPageLoadErrorOne state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContPageAndprepareForPageLoadErrorOne page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContPageAndprepareForPageLoadErrorOne page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContPageAndprepareForPageLoadErrorOne beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContPageAndprepareForPageLoadErrorOne 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('PrefetchPageErr',0,async function(done){
emitKey="emitPrepareForPageLoadErr";
Utils.registerEvent("PrefetchPageErr","17100001",900,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorOne',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/ets/test/webViewContPageAndprepareForPageLoadErrorTwo.test.ets
0 → 100644
浏览文件 @
0db4e38f
/**
* 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 = "emitPrefetchPageErr";
export default function webViewContPageAndprepareForPageLoadErrorTwo() {
describe('ActsAceWebDevWebViewContPageAndPrepareForPageLoadErrorTwoTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContPageAndprepareForPageLoadErrorTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContPageAndprepareForPageLoadErrorTwo state success " + JSON.stringify(pages));
if (!("webViewContPageAndprepareForPageLoadErrorTwo" == pages.name)) {
console.info("get webViewContPageAndprepareForPageLoadErrorTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContPageAndprepareForPageLoadErrorTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContPageAndprepareForPageLoadErrorTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContPageAndprepareForPageLoadErrorTwo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContPageAndprepareForPageLoadErrorTwo 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('PrefetchPageErr',0,async function(done){
emitKey="emitPrepareForPageLoadErr";
Utils.registerEvent("PrefetchPageErr","17100002",903,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',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('PrepareForPageLoadErr',0,async function(done){
emitKey="emitPrepareForPageLoadErrTwo";
Utils.registerEvent("PrepareForPageLoadErr","17100002",904,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',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('PrepareForPageLoadErrTwo',0,async function(done){
emitKey="emitPrepareForPageLoadErrTwo";
Utils.registerEvent("PrepareForPageLoadErrTwo","171000013",905,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',10,'');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewControllerError/entry/src/main/module.json
浏览文件 @
0db4e38f
...
...
@@ -8,8 +8,7 @@
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
,
"2in1"
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
...
...
@@ -21,8 +20,7 @@
"value"
:
"true"
}
],
"abilities"
:
[
{
"abilities"
:
[{
"name"
:
"com.example.myapplication.MainAbility"
,
"srcEntrance"
:
"./ets/MainAbility/MainAbility.ts"
,
"description"
:
"$string:phone_entry_main"
,
...
...
@@ -30,18 +28,15 @@
"label"
:
"$string:entry_label"
,
"visible"
:
true
,
"orientation"
:
"portrait"
,
"skills"
:
[
{
"skills"
:
[{
"actions"
:
[
"action.system.home"
],
"entities"
:
[
"entity.system.home"
]
}
]
}
],
}]
}],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.LOCATION"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录