Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c0103e13
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看板
未验证
提交
c0103e13
编写于
8月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5219 web组件xts接口用例新增
Merge pull request !5219 from 姚胜/master
上级
40468830
4d615d46
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
511 addition
and
2 deletion
+511
-2
arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
..._ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
+249
-0
arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets
...ce_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets
+241
-1
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/index.html
...e_ets_web_dev/entry/src/main/resources/rawfile/index.html
+20
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/second.html
..._ets_web_dev/entry/src/main/resources/rawfile/second.html
+1
-1
未找到文件。
arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
c0103e13
...
...
@@ -27,6 +27,16 @@ struct Index {
@State loadedResource:string=""
@State progress:string=""
@State newUrl:string=""
@State pageBegin:string=""
@State pageEnd:string=""
@State console:string=""
@State confirm:string=""
@State alert:string=""
@State errorReceive:string=""
@State httpErrorReceive:number=0
@State titleReceive:string=""
@State downloadStart:string=""
@State javaScriptAccess:boolean=true
onPageShow(){
let valueChangeEvent={
eventId:10,
...
...
@@ -49,6 +59,10 @@ struct Index {
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
aboutToAppear(){
...
...
@@ -62,6 +76,7 @@ struct Index {
build(){
Column(){
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.userAgent("Mozila/5.0 (Linux; Andriod 9; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.4.1 MobileSafari/537.36")
.javaScriptProxy({
object:this.jsObj,
...
...
@@ -93,6 +108,36 @@ struct Index {
.onFocus(()=>{
Utils.emitEvent("requestFocus",126)
})
.onPageBegin((event) => {
this.pageBegin = event.url
})
.onPageEnd((event) => {
this.pageEnd = event.url
})
.onConsole((event) => {
this.console = event.message.getMessage()
return false
})
.onAlert((event) => {
this.alert = event.message
return false
})
.onConfirm((event) => {
this.confirm = event.message
return false
})
.onErrorReceive((event) => {
this.errorReceive = event.request.getRequestUrl()
})
.onHttpErrorReceive((event) => {
this.httpErrorReceive = event.response.getResponseCode()
})
.onTitleReceive((event) => {
this.titleReceive = event.title
})
.onDownloadStart((event) => {
this.downloadStart = event.url
})
Row(){
Button("web click").key('webcomponent').onClick(()=>{
console.info("key==>"+this.str)
...
...
@@ -229,6 +274,210 @@ struct Index {
},3000)
break;
}
case "emitOnPageBegin":{
Utils.emitEvent(this.pageBegin,59)
break;
}
case "emitOnPageEnd":{
Utils.emitEvent(this.pageBegin,60)
break;
}
case "emitOnConsole":{
this.controller.runJavaScript({script:"consoleTest()"})
setTimeout(()=>{
Utils.emitEvent(this.console,62)
},3000)
break;
}
case "emitOnAlert":{
this.controller.runJavaScript({script:"alertTest()"})
setTimeout(()=>{
Utils.emitEvent(this.alert,63)
},3000)
break;
}
case "emitOnConfirm":{
this.controller.runJavaScript({script:"confirmTest()"})
setTimeout(()=>{
Utils.emitEvent(this.confirm,64)
},3000)
break;
}
case "emitOnErrorReceive":{
this.controller.loadUrl({url:'http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html'})
setTimeout(()=>{
this.controller.loadUrl({url:'http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html'})
setTimeout(() => {
Utils.emitEvent(this.errorReceive,65)
},3000)
},3000)
break;
}
case "emitOnHttpErrorReceive":{
this.controller.loadUrl({url:'http://example.com/path/does/not/exist/index.jsp'})
setTimeout(()=>{
Utils.emitEvent(this.httpErrorReceive,66)
},3000)
break;
}
case "emitOnTitleReceive":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
Utils.emitEvent(this.titleReceive,67)
},3000)
break;
}
case "emitOnDownloadStart":{
this.controller.loadUrl({url:"https://consumer.huawei.com/content/dam/huawei-cbg-site/cn/mkt/mobileservices/2022/download/PC107f1b3947c942ffaa14334a879065d8.2107261020.exe"})
setTimeout(()=>{
Utils.emitEvent(this.downloadStart,68)
},5000)
break;
}
case "emitSetCookie":{
this.controller.getCookieManager().setCookie('http://www.baidu.com','e=f')
setTimeout(()=>{
let setCookieCalled = this.controller.getCookieManager().getCookie('http://www.baidu.com')
Utils.emitEvent(setCookieCalled,76)
},3000)
break;
}
case "emitGetCookie":{
this.controller.getCookieManager().setCookie('https://www.bilibili.com/','e=f')
setTimeout(()=>{
let getCookieCalled = this.controller.getCookieManager().getCookie('https://www.bilibili.com/')
Utils.emitEvent(getCookieCalled,69)
},3000)
break;
}
case "emitZoom":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.zoom(2)
setTimeout(() => {
if(this.controller.getPageHeight() > 1400){
var zoomCalled = true
}
Utils.emitEvent(zoomCalled,77)
},3000)
},5000)
break;
}
case "emitZoomOut":{
this.controller.zoomOut()
setTimeout(()=>{
if(this.controller.getPageHeight() < 1500){
var zoomOutCalled = true
}
Utils.emitEvent(zoomOutCalled,78)
},3000)
break;
}
case "emitZoomIn":{
this.controller.zoomIn()
setTimeout(()=>{
var zoomInCalled = false
if(this.controller.getPageHeight() > 1400){
zoomInCalled = true
}
Utils.emitEvent(zoomInCalled,79)
},3000)
break;
}
case "emitDeleteEntireCookie":{
this.controller.getCookieManager().deleteEntireCookie()
setTimeout(()=>{
let deleteEntireCookieCalled = this.controller.getCookieManager().getCookie('http://www.baidu.com')
Utils.emitEvent(deleteEntireCookieCalled,80)
},3000)
break;
}
case "emitSaveCookieSync":{
let saveCookieSyncCalled = this.controller.getCookieManager().saveCookieSync()
Utils.emitEvent(saveCookieSyncCalled,81)
break;
}
case "emitClearHistory":{
this.controller.loadUrl({url:"http://www.baidu.com/"})
setTimeout(()=>{
this.controller.clearHistory()
setTimeout(() => {
let clearHistoryCalled = this.controller.accessBackward()
Utils.emitEvent(clearHistoryCalled,82)
},5000)
},10000)
break;
}
case "emitStop":{
this.controller.loadUrl({url:"http://appgallery.huawei.com/"})
this.controller.stop()
setTimeout(()=>{
var stopCalled = false
if(this.pageEnd !== 'http://appgallery.huawei.com/'){
stopCalled = true
}
Utils.emitEvent(stopCalled,83)
},3000)
break;
}
case "emitOnInactive":{
this.controller.onInactive()
this.controller.zoomOut()
setTimeout(()=>{
var onInactiveCalled = false
if(this.controller.getPageHeight() < 2600){
onInactiveCalled = true
}
Utils.emitEvent(onInactiveCalled,84)
},3000)
break;
}
case "emitOnActive":{
this.controller.onActive()
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
let onActiveCalled = this.pageBegin
Utils.emitEvent(onActiveCalled,85)
},5000)
break;
}
case "emitRegisterJavaScriptProxy":{
this.controller.registerJavaScriptProxy({object:this.jsObj,name:"objName",methodList:["test","toString","register"]})
this.controller.refresh()
setTimeout(()=>{
this.controller.runJavaScript({script:"proxy()"})
},3000)
break;
}
case "emitDeleteJavaScriptRegister":{
this.controller.deleteJavaScriptRegister("objName")
this.controller.runJavaScript({script:"registerTest()"})
setTimeout(()=>{
if(this.console !== "web222"){
let deleteEntireCookieCalled = true
Utils.emitEvent(deleteEntireCookieCalled,87)
}
},3000)
break;
}
case "emitJavaScriptAccess":{
this.javaScriptAccess = false
setTimeout(() => {
this.controller.runJavaScript({script:"jsAccess()"})
setTimeout(()=>{
if(this.console !== "web111"){
let javaScriptAccessCalled = true
Utils.emitEvent(javaScriptAccessCalled,88)
}
},3000)
},3000)
break;
}
case "emitGetCookieManager":{
let getCookieManagerCalled = this.controller.getCookieManager().setCookie("https://weibo.com","a=b")
Utils.emitEvent(getCookieManagerCalled,89)
break;
}
default:
console.info("can not match case")
}
...
...
arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
c0103e13
...
...
@@ -237,9 +237,249 @@ export default function webJsunit() {
*tc.desic Goes forward or back backOrForward in the history of the web page
*/
it('backOrForward',0,async function(done){
emitKey="emit
BackOrForward
";
emitKey="emit
OnPageBegin
";
Utils.registerEvent("backOrForward","index",138,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_021
*tc.name onPageBegin
*tc.desic Triggered when the page loading progress changes
*/
it('onPageBegin',0,async function(done){
emitKey="emitOnPageEnd";
Utils.registerEvent("onPageBegin","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",59,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_022
*tc.name onPageEnd
*tc.desic Triggered at the begin of web page loading
*/
it('onPageEnd',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("onPageEnd","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",60,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_023
*tc.name onConsole
*tc.desic Triggered when the web page receives a JavaScript console message
*/
it('onConsole',0,async function(done){
emitKey="emitOnAlert";
Utils.registerEvent("onConsole","console test",62,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_024
*tc.name onAlert
*tc.desic Triggered when the Web wants to display a JavaScript alert() dialog
*/
it('onAlert',0,async function(done){
emitKey="emitOnConfirm";
Utils.registerEvent("onAlert","alert test",63,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_025
*tc.name onConfirm
*tc.desic Triggered when the web page wants to display a JavaScript confirm() dialog
*/
it('onConfirm',0,async function(done){
emitKey="emitOnErrorReceive";
Utils.registerEvent("onConfirm","confirm test",64,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_026
*tc.name onErrorReceive
*tc.desic Triggered when the web page receives a web resource loading error
*/
it('onErrorReceive',0,async function(done){
emitKey="emitOnHttpErrorReceive";
Utils.registerEvent("onErrorReceive","http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html",65,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_027
*tc.name onHttpErrorReceive
*tc.desic Triggered when the web page receives a web resource loading HTTP error
*/
it('onHttpErrorReceive',0,async function(done){
emitKey="emitOnTitleReceive";
Utils.registerEvent("onHttpErrorReceive",404,66,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_028
*tc.name onTitleReceive
*tc.desic Triggered when the title of the main application document changes
*/
it('onTitleReceive',0,async function(done){
emitKey="emitOnDownloadStart";
Utils.registerEvent("onTitleReceive","index",67,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_029
*tc.name onDownloadStart
*tc.desic Triggered when starting to download
*/
it('onDownloadStart',0,async function(done){
emitKey="emitSetCookie";
Utils.registerEvent("onDownloadStart","https://consumer.huawei.com/content/dam/huawei-cbg-site/cn/mkt/mobileservices/2022/download/PC107f1b3947c942ffaa14334a879065d8.2107261020.exe",68,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_030
*tc.name setCookie
*tc.desic Sets the cookie
*/
it('setCookie',0,async function(done){
emitKey="emitGetCookie";
Utils.registerEvent("setCookie","e=f",76,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_031
*tc.name getCookie
*tc.desic Gets all cookies for the given URL
*/
it('getCookie',0,async function(done){
emitKey="emitZoom";
Utils.registerEvent("getCookie","e=f",69,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_032
*tc.name zoom
*tc.desic Let the Web zoom by
*/
it('zoom',0,async function(done){
emitKey="emitZoomOut";
Utils.registerEvent("zoom",true,77,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_033
*tc.name zoomOut
*tc.desic Let the Web zoom out
*/
it('zoomOut',0,async function(done){
emitKey="emitZoomIn";
Utils.registerEvent("zoomOut",true,78,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_034
*tc.name zoomIn
*tc.desic Let the Web zoom in
*/
it('zoomIn',0,async function(done){
emitKey="emitDeleteEntireCookie";
Utils.registerEvent("zoomIn",true,79,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_035
*tc.name deleteEntireCookie
*tc.desic Delete all cookies
*/
it('deleteEntireCookie',0,async function(done){
emitKey="emitSaveCookieSync";
Utils.registerEvent("deleteEntireCookie","",80,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_036
*tc.name saveCookieSync
*tc.desic Saves the cookies
*/
it('saveCookieSync',0,async function(done){
emitKey="emitClearHistory";
Utils.registerEvent("saveCookieSync",true,81,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_037
*tc.name clearHistory
*tc.desic Clears the history in the Web
*/
it('clearHistory',0,async function(done){
emitKey="emitStop";
Utils.registerEvent("clearHistory",false,82,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_038
*tc.name stop
*tc.desic Stops the current load
*/
it('stop',0,async function(done){
emitKey="emitOnInactive";
Utils.registerEvent("stop",true,83,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_039
*tc.name onInactive
*tc.desic Let the Web inactive.
*/
it('onInactive',0,async function(done){
emitKey="emitOnActive";
Utils.registerEvent("onInactive",true,84,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_040
*tc.name onActive
*tc.desic Let the Web active
*/
it('onActive',0,async function(done){
emitKey="emitRegisterJavaScriptProxy";
Utils.registerEvent("onActive","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",85,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_041
*tc.name registerJavaScriptProxy
*tc.desic Registers the JavaScript object and method list
*/
it('registerJavaScriptProxy',0,async function(done){
emitKey="emitDeleteJavaScriptRegister";
Utils.registerEvent("registerJavaScriptProxy","backToEts",86,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_042
*tc.name deleteJavaScriptRegister
*tc.desic Deletes a registered JavaScript object with given name
*/
it('deleteJavaScriptRegister',0,async function(done){
emitKey="emitJavaScriptAccess";
Utils.registerEvent("deleteJavaScriptRegister",true,87,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_043
*tc.name javaScriptAccess
*tc.desic Sets whether the Web allows JavaScript scripts to execute
*/
it('javaScriptAccess',0,async function(done){
emitKey="emitGetCookieManager";
Utils.registerEvent("javaScriptAccess",true,88,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_044
*tc.name getCookieManager
*tc.desic Gets network cookie manager
*/
it('getCookieManager',0,async function(done){
emitKey="emitGetCookieManager";
Utils.registerEvent("getCookieManager",true,89,done);
sendEventByKey('webcomponent',10,'');
})
})
}
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/index.html
浏览文件 @
c0103e13
...
...
@@ -29,5 +29,25 @@
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
"
)
}
</script>
</html>
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/second.html
浏览文件 @
c0103e13
...
...
@@ -7,6 +7,6 @@
<title>
second
</title>
</head>
<body>
<div>
second pages
</div>
<div
style=
"height: 1300px;background-color: #999999;"
>
second pages
</div>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录