Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d5ededb9
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看板
提交
d5ededb9
编写于
10月 22, 2022
作者:
H
hekun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add new case
Signed-off-by:
N
hekun
<
hekun18@huawei.com
>
上级
985060db
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1303 addition
and
0 deletion
+1303
-0
arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets
..._apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets
+256
-0
arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets
...nt_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets
+415
-0
arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/webviewpageLackattr.ets
...ry/src/main/ets/MainAbility/pages/webviewpageLackattr.ets
+356
-0
arkui/ace_ets_component_attrlack/entry/src/main/ets/test/webviewPageLackattr.test.ets
...lack/entry/src/main/ets/test/webviewPageLackattr.test.ets
+276
-0
未找到文件。
arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets
0 → 100644
浏览文件 @
d5ededb9
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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';
@Entry
@Component
struct Index {
// add
@State isVoid: boolean = true;
handler: FullScreenExitHandler = null;
@State atio: number = 150;
ports: WebMessagePort[] = null;
testObj = {
test: (data1, data2, data3) => {
console.log("data1:" + data1);
console.log("data2:" + data2);
console.log("data3:" + data3);
return "AceString";
},
toString: () => {
console.log('toString' + "interface instead.");
}
}
message = new ConsoleMessage("1","12",23,MessageLevel.Debug);
controller:WebController = new WebController()
responseweb: WebResourceResponse = new WebResourceResponse()
@State str:string="emitStoreWebArchive"
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("web 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() {
// add api9
Web({ src: 'www.baidu.com', controller: this.controller })
.multiWindowAccess(true).key('multiwindow')
.onWindowExit(() => {
console.log("onWindowExit...");
setTimeout(()=>{
Utils.emitEvent(this.isVoid,800)
},1000)
}).
onWindowNew((event) => {
console.log("onWindowNew...");
var popController: WebController = new WebController();
event.handler.setWebController(popController);
setTimeout(()=>{
Utils.emitEvent(this.isVoid,801)
},1000)
}).onFullScreenEnter((event) => {
console.log("onFullScreenEnter...");
this.handler = event.handler;
setTimeout(()=>{
Utils.emitEvent(this.isVoid,802)
},1000)
}).onFullScreenExit(() => {
console.info("onFullScreenExit...");
this.handler.exitFullScreen();
})
Web({ src: 'www.baidu.com', controller: this.controller }).key('web2')
.onSslErrorEventReceive((event) => {
AlertDialog.show({
title: 'onSslErrorEventReceive',
message: 'text',
primaryButton: {
value: 'confirm',
action: () => {
event.handler.handleConfirm();
}
},
secondaryButton: {
value: 'cancel',
action: () => {
event.handler.handleCancel();
}
},
cancel: () => {
event.handler.handleCancel();
}
})
setTimeout(()=>{
Utils.emitEvent(this.isVoid,803)
},1000)
return true;
}).textZoomAtio(this.atio).tableData(true)
.javaScriptProxy({
object: this.testObj,
name: "objName",
methodList: ["test", "toString"],
controller: this.controller,
}).onConsole((event) => {
console.log('getMessage:' + event.message.getMessage());
console.log('getSourceId:' + event.message.getSourceId());
console.log('getLineNumber:' + event.message.getLineNumber());
console.log('getMessageLevel:' + event.message.getMessageLevel());
return false;
})
Button("web click").key('webcomponentapi9').onClick(async ()=>{
console.info("key==>"+this.str)
switch(this.str){
// add
case "emitGeturl":
let url = this.controller.getUrl();
Utils.emitEvent(url,810);
break;
case "emitclearClientAuthenticationCache":
this.controller.clearClientAuthenticationCache();
Utils.emitEvent(this.isVoid,811);
break;
case "emitclearSslCache":
this.controller.clearSslCache();
Utils.emitEvent(this.isVoid,812);
break;
case "emitsearchNext":
this.controller.searchNext(true);
Utils.emitEvent(this.isVoid,813);
break;
case "emitclearMatches":
this.controller.clearMatches();
Utils.emitEvent(this.isVoid,814);
break;
case "emitDefaultUserAgent":
let usrAgent = this.controller.getDefaultUserAgent();
Utils.emitEvent(usrAgent,815);
break;
case "emitgetWebId":
let webId = this.controller.getWebId();
Utils.emitEvent(webId,816);
break;
case "emitpostMessage":
var sendPortArray = new Array(this.ports[1]);
var msgEvent = new WebMessageEvent();
msgEvent.setData("__init_port__");
msgEvent.setPorts(sendPortArray);
this.controller.postMessage({message: msgEvent, uri: "*"});
break;
case "emitcreateWebMessagePorts":
this.ports = this.controller.createWebMessagePorts();
console.info("createWebMessagePorts size:" + this.ports.length)
Utils.emitEvent(this.ports.length,817);
break;
case "emitdeleteSessionCookie":
web_webview.WebCookieManager.deleteSessionCookie();
Utils.emitEvent(this.isVoid,818);
break;
case "emitdeleteExpiredCookie":
web_webview.WebCookieManager.deleteExpiredCookie();
Utils.emitEvent(this.isVoid,810);
break;
case "emitexistCookie":
let vaue = web_webview.WebCookieManager.existCookie();
Utils.emitEvent(vaue,820);
break;
case "emitgetCookie":
let value = web_webview.WebCookieManager.getCookie('www.baidu.com');
console.info("value: " + value);
Utils.emitEvent(value,821);
break;
case "emitsetCookie":
let value02 = web_webview.WebCookieManager.setCookie('www.baidu.com','a=b');
console.info("value: " + value02);
Utils.emitEvent(value02,822);
break;
case "emitsaveCookie":
web_webview.WebCookieManager.saveCookie();
Utils.emitEvent(this.isVoid,823);
break;
case "emitputAcceptFileURICookieEnabled":
web_webview.WebCookieManager.putAcceptFileURICookieEnabled(false)
Utils.emitEvent(this.isVoid,824);
break;
case "emitputAcceptThirdPartyCookieEnabled":
web_webview.WebCookieManager.putAcceptThirdPartyCookieEnabled(false)
Utils.emitEvent(this.isVoid,825);
break;
case "emitisFileURICookieAllowed":
let isAll = web_webview.WebCookieManager.isFileURICookieAllowed();
Utils.emitEvent(isAll,826);
break;
case "emitisThirdPartyCookieAllowed":
let isThirdParty = web_webview.WebCookieManager.isThirdPartyCookieAllowed();
Utils.emitEvent(isThirdParty,827);
break;
default:
console.info("can not match case")
}
})
}
}
}
arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets
0 → 100644
浏览文件 @
d5ededb9
/*
* 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 { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
let emitKey = "emitUserAgent";
export default function webJsunit() {
describe('ActsAceWebDevTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("web beforeEach start");
done();
})
afterEach(async function (done) {
console.info("web 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_API_0010
* @tc.name testmultiWindow01
* @tc.desic multiWindow
*/
it('testmultiWindow01', 0, async function (done) {
console.info('testmultiWindow01 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('multiwindow');
console.info("[multiwindow] component strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('web');
expect(obj.$attrs.multiWindow).assertTrue();
console.info("[testmultiWindow0010] value :" + obj.$attrs.multiWindow);
done();
});
/*
*tc.number SUB_ACE_BASIC_ETS_API_0012
*tc.name testonWindowExit02
*tc.desic onWindowExit
*/
it('testonWindowExit02',0,async function(done){
Utils.registerContainEvent("WindowExit",true,800,done);
sendEventByKey('multiwindow',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_0013
*tc.name testweb03
*tc.desic onWindowNew
*/
it('tesweb03',0,async function(done){
Utils.registerContainEvent("onWindowNew",true,801,done);
sendEventByKey('onWindowNew',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_0014
*tc.name testweb04
*tc.desc onFullScreen
*/
it('tesweb04',0,async function(done){
Utils.registerContainEvent("onFullScreen",true,802,done);
sendEventByKey('onWindowNew',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_0015
*tc.name testweb05
*tc.desc onSslErrorEventReceive
*/
it('tesweb05',0,async function(done){
Utils.registerContainEvent("onSslErrorEventReceive",true,803,done);
sendEventByKey('onSslErrorEventReceive',10,'');
})
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0016
* @tc.name testweb06
* @tc.desic multiWindow
*/
it('testweb06', 0, async function (done) {
console.info('testmultiWindow016 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('web2');
console.info("[multiwindow] component strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('web');
expect(obj.$attrs.atio).assertEqual(150);
console.info("[testmultiWindow0016] value :" + obj.$attrs.multiWindow);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0017
* @tc.name testweb07
* @tc.desic getUrl
*/
it('testweb07', 0, async function (done) {
emitKey="emitGeturl";
Utils.registerContainEvent("Geturl",null,810,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0018
* @tc.name testweb08
* @tc.desic clearClientAuthenticationCache
*/
it('testweb07', 0, async function (done) {
emitKey="emitclearClientAuthenticationCache";
Utils.registerContainEvent("clearClientAuthenticationCache",true,811,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0018
* @tc.name testweb08
* @tc.desic clearSslCache
*/
it('testweb08', 0, async function (done) {
emitKey="emitclearSslCache";
Utils.registerContainEvent("clearSslCache",true,812,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0019
* @tc.name testweb09
* @tc.desic searchNext
*/
it('testweb09', 0, async function (done) {
emitKey="emitsearchNext";
Utils.registerContainEvent("clearsearchNext",true,813,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0020
* @tc.name testweb10
* @tc.desic clearMatches
*/
it('testweb10', 0, async function (done) {
emitKey ="emitclearMatches";
Utils.registerContainEvent("clearMatches",true,814,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0021
* @tc.name testweb11
* @tc.desic getDefaultUserAgent
*/
it('testweb11', 0, async function (done) {
emitKey ="emitDefaultUserAgent";
Utils.registerContainEvent("getDefaultUserAgent","",815,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0022
* @tc.name testweb12
* @tc.desic getDefaultUserAgent
*/
it('testweb12', 0, async function (done) {
emitKey ="emitgetWebId";
Utils.registerContainEvent("getWebId",0,816,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0022
* @tc.name testweb13
* @tc.desic getDefaultUserAgent
*/
it('testweb13', 0, async function (done) {
emitKey ="emitcreateWebMessagePorts";
Utils.registerContainEvent("createWebMessagePorts",0,817,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0022
* @tc.name testweb14
* @tc.desic getDefaultUserAgent
*/
it('testweb14', 0, async function (done) {
emitKey = "emitdeleteSessionCookie";
Utils.registerContainEvent("deleteSessionCookie",true,818,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0023
* @tc.name testweb15
* @tc.desic getDefaultUserAgent
*/
it('testweb15', 0, async function (done) {
emitKey = "emitdeleteExpiredCookie";
Utils.registerContainEvent("deleteExpiredCookie",true,819,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0023
* @tc.name testweb16
* @tc.desic existCookie
*/
it('testweb16', 0, async function (done) {
emitKey = "emitexistCookie";
Utils.registerContainEvent("existCookie",true,820,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb17
* @tc.desic getCookie
*/
it('testweb17', 0, async function (done) {
emitKey = "emitgetCookie";
Utils.registerContainEvent("getCookie","",821,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb18
* @tc.desic getCookie
*/
it('testweb18', 0, async function (done) {
emitKey = "emitsetCookie";
Utils.registerContainEvent("setCookie",true,822,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb19
* @tc.desic saveCookie
*/
it('testweb19', 0, async function (done) {
emitKey = "emitsaveCookie";
Utils.registerContainEvent("saveCookie",true,823,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb20
* @tc.desic putAcceptFileURICookieEnabled
*/
it('testweb20', 0, async function (done) {
emitKey = "emitputAcceptFileURICookieEnabled";
Utils.registerContainEvent("putAcceptFileURICookieEnabled",true,823,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb20
* @tc.desic putAcceptFileURICookieEnabled
*/
it('testweb21', 0, async function (done) {
emitKey = "emitputAcceptThirdPartyCookieEnabled";
Utils.registerContainEvent("putAcceptThirdPartyCookieEnabled",true,824,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb22
* @tc.desic putAcceptFileURICookieEnabled
*/
it('testweb22', 0, async function (done) {
emitKey = "emitisFileURICookieAllowed";
Utils.registerContainEvent("isFileURICookieAllowed",false,825,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0024
* @tc.name testweb22
* @tc.desic putAcceptFileURICookieEnabled
*/
it('testweb23', 0, async function (done) {
emitKey = "emitisThirdPartyCookieAllowed";
Utils.registerContainEvent("isThirdPartyCookieAllowed",false,826,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
*tc.number SUB_ACE_BASIC_ETS_API_066
*tc.name storeWebArchive
*tc.desic Save current page
*/
it('storeWebArchive',0,async function(done){
emitKey="emitAllowGeolocation";
Utils.registerContainEvent("storeWebArchive","/data/storage/el2/base/",400,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_072
*tc.name isThirdPartyCookieAllowed
*tc.desic return whether the third party cookie is allowed
*/
it('isThirdPartyCookieAllowed',0,async function(done){
emitKey="emitExistCookie";
Utils.registerEvent("isThirdPartyCookieAllowed",false,412,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_073
*tc.name existCookie
*tc.desic return whether there exits cookie
*/
it('existCookie',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("existCookie",false,414,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_076
*tc.name getLineNumber
*tc.desic return the number of console message lines
*/
it('getLineNumber',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("getLineNumber","51",420,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_077
*tc.name getSourceId
*tc.desic return the source url
*/
it('getSourceId',0,async function(done){
emitKey="emitLoaData";
Utils.registerEvent("getSourceId","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",422,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_078
*tc.name loadData
*tc.desic load specific strings
*/
it('loadData',0,async function(done){
emitKey="emitZoomAccess";
Utils.registerEvent("loadData","index",424,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_080
*tc.name zoomAccess
*tc.desic set whether it is allowed to zoom
*/
it('zoomAccess',0,async function(done){
emitKey="emitSaveHttpAuthCredentials";
Utils.registerEvent("zoomAccess",false,428,done);
sendEventByKey('webcomponent',10,'');
})
})
}
arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/webviewpageLackattr.ets
0 → 100644
浏览文件 @
d5ededb9
// @ts-nocheck
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@ohos.prompt'
import events_emitter from '@ohos.events.emitter';
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State isLoad: boolean = false;
@State hitTestValue:HitTestTypeV9 = HitTestTypeV9.EditText;
@State hitTestValue1:HitTestTypeV9 = HitTestTypeV9.Email;
@State hitTestValu2:HitTestTypeV9 = HitTestTypeV9.HttpAnchor;
@State hitTestValu3:HitTestTypeV9 = HitTestTypeV9.HttpAnchorImg;
@State hitTestValue4:HitTestTypeV9 = HitTestTypeV9.Img;
@State hitTestValu5:HitTestTypeV9 = HitTestTypeV9.Map;
@State hitTestValue6:HitTestTypeV9 = HitTestTypeV9.Phone;
@State hitTestValue7:HitTestTypeV9 = HitTestTypeV9.Unknown;
@State hitTestValue8:HitTestValue = {
type:HitTestTypeV9.Phone,
extra:"hello"
};
@State webStorage:web_webview.WebStorageOrigin = {
origin:'prign',
usage: 2,
quota: 3
}
headers: Array<HeaderV9> = [{
headerKey: "requesstHeader",
headerValue: "requestValue"
}]
aboutToAppear() {
console.info(`aboutToAppear HeaderV9 start`)
}
aboutToDisappear(){
console.info(`aboutToDisAppear HeaderV9 end`)
}
build() {
Column() {
Button('loadUrl').onClick(() => {
try {
this.controller.loadUrl('www.baidu.com',this.headers);
this.isLoad = true;
try {
var backData = {
data: {
"STATUS": this.isLoad
}
}
let backEvent = {
eventId: 90201,
priority: events_emitter.EventPriority.LOW
}
console.info("loadUrl headerV9 to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("loadUrl headerV9 emit action state err: " + JSON.stringify(err.message))
}
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}).key('btloadurl')
Button('getHitTest').onClick(() => {
try {
let hitTestType = this.controller.getHitTest();
console.info("hitTestType: " + hitTestType);
try {
var backData = {
data: {
"STATUS": this.hitTestValue
}
}
let backEvent = {
eventId: 90202,
priority: events_emitter.EventPriority.LOW
}
console.info("loadUrl hitTestType to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("loadUrl hitTestType emit action state err: " + JSON.stringify(err.message))
}
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}).key('btngetHitTest')
Button('getHitTestValue').onClick(() => {
try {
let hitValue = this.controller.getHitTestValue();
try {
var backData = {
data: {
"STATUS": this.hitTestValue8
}
}
let backEvent = {
eventId: 90203,
priority: events_emitter.EventPriority.LOW
}
console.info("loadUrl getHitTestValue to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("loadUrl getHitTestValue emit action state err: " + JSON.stringify(err.message))
}
console.info("hitType: " + hitValue.type);
console.info("extra: " + hitValue.extra);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('getOrigins').onClick(() => {
try {
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(e => {
console.log('error: ' + e);
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('getOriginsPromise').onClick(() => {
try {
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);
}
try {
var backData = {
data: {
"STATUS": this.webStorage.origin
}
}
let backEvent = {
eventId: 90204,
priority: events_emitter.EventPriority.LOW
}
console.info("loadUrl getHitTestValue to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("loadUrl getHitTestValue emit action state err: " + JSON.stringify(err.message))
}
})
.catch(e => {
console.log('error: ' + e);
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('getOriginQuota')
.onClick(() => {
try {
web_webview.WebStorage.getOriginQuota('file:///')
.then(quota => {
console.info('quota: ' + quota);
})
.catch(e => {
console.info('error: ' + e);
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}).key('getOriginQuotakey')
Button('getOriginUsage')
.onClick(() => {
try {
web_webview.WebStorage.getOriginUsage('file:///')
.then(usage => {
console.info('usage: ' + usage);
try {
var backData = {
data: {
"STATUS": usage
}
}
let backEvent = {
eventId: 90206,
priority: events_emitter.EventPriority.LOW
}
console.info("getOriginUsage to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("getOriginUsage emit action state err: " + JSON.stringify(err.message))
}
})
.catch(e => {
console.info('error: ' + e);
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('saveCookieAsync')
.onClick(() => {
try {
web_webview.WebCookieManager.saveCookieAsync()
.then(() => {
console.log("saveCookieAsyncCallback success!");
})
.catch((error) => {
console.error("error: " + error);
});
try {
var backData = {
data: {
"STATUS": this.isLoad
}
}
let backEvent = {
eventId: 90207,
priority: events_emitter.EventPriority.LOW
}
console.info("saveCookieAsync to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("saveCookieAsync emit action state err: " + JSON.stringify(err.message))
}
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('saveWebArchive')
.onClick(() => {
try {
this.controller.storeWebArchive("/data/storage/el2/base/", true)
.then(filename => {
if (filename != null) {
console.info(`save web archive success: ${filename}`)
}
try {
var backData = {
data: {
"STATUS": filename
}
}
let backEvent = {
eventId: 90208,
priority: events_emitter.EventPriority.LOW
}
console.info("saveCookieAsync to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("saveCookieAsync emit action state err: " + JSON.stringify(err.message))
}
})
.catch(error => {
console.log('error: ' + JSON.stringify(error));
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.baidu.com', controller: this.controller })
.javaScriptAccess(true)
.onPageEnd(e => {
try {
this.controller.runJavaScript('test()')
.then(function (result) {
console.log('result: ' + result);
try {
var backData = {
data: {
"STATUS": result
}
}
let backEvent = {
eventId: 90209,
priority: events_emitter.EventPriority.LOW
}
console.info("runJavaScript to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("runJavaScript emit action state err: " + JSON.stringify(err.message))
}
})
.catch(function (error) {
console.error("error: " + error);
})
console.info('url: ', e.url);
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.baidu.com', controller: this.controller }).key('webattr')
}
}
}
arkui/ace_ets_component_attrlack/entry/src/main/ets/test/webviewPageLackattr.test.ets
0 → 100644
浏览文件 @
d5ededb9
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import events_emitter from '@ohos.events.emitter';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function webViewPageattrLackJsunit() {
describe('webViewPageattrLackJsunit', function () {
beforeAll(async function (done) {
console.info("webviewpageLackattr beforeEach start");
let options = {
uri: 'pages/webviewpageLackattr',
}
try {
router.clear();
let pages = router.getState();
console.info("get webviewpageLackattr state success " + JSON.stringify(pages));
if (!("webviewpageLackattr" == pages.name)) {
console.info("get webviewpageLackattr state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webviewpageLackattr page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webviewpageLackattr page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("webviewpageLackattr after each called");
});
/*
* @tc.number SUB_ACE_BASIC_HEADERV9_ETS_API_0001
* @tc.name testWebviewpageLackattr01
* @tc.desic test headerv9
*/
it('testWebviewpageLackattr01', 0, async function (done) {
console.info('testWebviewpageLackattr01 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr01 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertTrue();
}
let indexEvent = {
eventId: 90201,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('loadUrl', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr01 events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr01 END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_HitTestType_ETS_API_0002
* @tc.name testWebviewpageLackattr02
* @tc.desic test HitTestType
*/
it('testWebviewpageLackattr02', 0, async function (done) {
console.info('testWebviewpageLackattr02 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr02 get state result is: " + JSON.stringify(indexEvent));
expect(!!indexEvent.data.STATUS).assertTrue();
}
let indexEvent = {
eventId: 90202,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('getHitTest', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr02events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr02 END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_HitTestType_ETS_API_0004
* @tc.name testWebviewpageLackattr04
* @tc.desic test getOrigins
*/
it('testWebviewpageLackattr04', 0, async function (done) {
console.info('testWebviewpageLackattr04 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr04 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertEqual('prign');
}
let indexEvent = {
eventId: 90204,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('getOriginsPromise', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr04events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr04 END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_HitTestType_ETS_API_0003
* @tc.name testWebviewpageLackattr03
* @tc.desic test HitTestValue
*/
it('testWebviewpageLackattr03', 0, async function (done) {
console.info('testWebviewpageLackattr03 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr03 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS.extra).assertEqual('hello');
}
let indexEvent = {
eventId: 90203,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('getHitTestValue', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr03events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr03 END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_QUOTA_ETS_API_005
* @tc.name testgetOriginQuota005
* @tc.desic getOriginQuota
*/
it('testgetOriginQuota005', 0, async function (done) {
console.info('testgetOriginQuota005 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('getOriginQuotakey');
console.info("[testgetOriginQuota005] component strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Button');
done();
});
/*
* @tc.number SUB_ACE_BASIC_HitTestType_ETS_API_0006
* @tc.name testWebviewpageLackattr06
* @tc.desic test getOriginUsage
*/
it('testWebviewpageLackattr6', 0, async function (done) {
console.info('testWebviewpageLackattr06 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr06 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS.usage).assertEqual(0);
}
let indexEvent = {
eventId: 90206,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('getOriginUsage', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr06events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr06 END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_saveCookieAsync_ETS_API_0007
* @tc.name testWebviewpageLackattr07
* @tc.desic test saveCookieAsync
*/
it('testWebviewpageLackattr7', 0, async function (done) {
console.info('testWebviewpageLackattr07 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr07 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertTrue();
}
let indexEvent = {
eventId: 90207,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('saveCookieAsync', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr07events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr07END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_saveCookieAsync_ETS_API_0008
* @tc.name testWebviewpageLackattr08
* @tc.desic test saveCookieAsync
*/
it('testWebviewpageLackattr8', 0, async function (done) {
console.info('testWebviewpageLackattr08 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr08 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS !=null).assertTrue();
}
let indexEvent = {
eventId: 90208,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('saveWebArchive', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr8events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr08END');
done();
});
/*
* @tc.number SUB_ACE_BASIC_runJavaScript_ETS_API_0008
* @tc.name testWebviewpageLackattr08
* @tc.desic test runJavaScript
*/
it('testWebviewpageLackattr9', 0, async function (done) {
console.info('testrunJavaScript09 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("testWebviewpageLackattr09 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS !=null).assertTrue();
}
let indexEvent = {
eventId: 90209,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('runJavaScript', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("testWebviewpageLackattr9events_emitter err : " + JSON.stringify(err));
}
console.info('testWebviewpageLackattr09END');
done();
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录