Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9cfaa6b6
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看板
未验证
提交
9cfaa6b6
编写于
8月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5239 web组件新增xts用例
Merge pull request !5239 from 章靖/master
上级
8ff7696d
695004e4
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
706 addition
and
27 deletion
+706
-27
arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
..._ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
+285
-3
arkui/ace_ets_web_dev/entry/src/main/ets/test/Utils.ets
arkui/ace_ets_web_dev/entry/src/main/ets/test/Utils.ets
+17
-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
+235
-24
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/databaseAccess.html
..._dev/entry/src/main/resources/rawfile/databaseAccess.html
+26
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/domApi.html
..._ets_web_dev/entry/src/main/resources/rawfile/domApi.html
+26
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/fileFromUrlAccess.html
...v/entry/src/main/resources/rawfile/fileFromUrlAccess.html
+27
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/geo.html
...ace_ets_web_dev/entry/src/main/resources/rawfile/geo.html
+28
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/icon.png
...ace_ets_web_dev/entry/src/main/resources/rawfile/icon.png
+0
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/index.html
...e_ets_web_dev/entry/src/main/resources/rawfile/index.html
+17
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/onlineImageAccess.html
...v/entry/src/main/resources/rawfile/onlineImageAccess.html
+23
-0
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html
...ts_web_dev/entry/src/main/resources/rawfile/overview.html
+22
-0
未找到文件。
arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
9cfaa6b6
...
...
@@ -37,6 +37,24 @@ struct Index {
@State titleReceive:string=""
@State downloadStart:string=""
@State javaScriptAccess:boolean=true
@State fileAccess:boolean=true
@State domStorageAccess:boolean=false
@State imageAccess:boolean=true
@State geolocationAccess:boolean=true
@State onlineImageAccess:boolean=true
@State fileFromUrlAccess:boolean=true
@State databaseAccess:boolean=true
@State overviewModeAccess:boolean=false
@State initialScale:number=100
@State enterPageEnd:boolean=false
@State newScale:number=0
@State scaleChange:boolean=false
@State geoShow:boolean=false
@State mixedMode:MixedMode=MixedMode.All
@State cacheMode:CacheMode=CacheMode.Default
@State cacheError:boolean=false
@State mixedSwitch:boolean=false
@State mixedAllSwitch:boolean=false
onPageShow(){
let valueChangeEvent={
eventId:10,
...
...
@@ -77,6 +95,17 @@ struct Index {
Column(){
Web({src:$rawfile('index.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.geolocationAccess(this.geolocationAccess)
.onlineImageAccess(this.onlineImageAccess)
.fileFromUrlAccess(this.fileFromUrlAccess)
.databaseAccess(this.databaseAccess)
.cacheMode(this.cacheMode)
.initialScale(this.initialScale)
.mixedMode(this.mixedMode)
.overviewModeAccess(this.overviewModeAccess)
.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,
...
...
@@ -113,9 +142,24 @@ struct Index {
})
.onPageEnd((event) => {
this.pageEnd = event.url
console.log("onPageEnd==>")
if(this.enterPageEnd){
Utils.emitEvent(this.newScale,97)
this.enterPageEnd=false
}
})
.onConsole((event) => {
this.console = event.message.getMessage()
let level=event.message.getMessageLevel()
let msg=event.message.getMessage()
console.log("html==>"+msg)
if(this.mixedSwitch){
Utils.emitEvent(msg,186)
this.mixedSwitch=false
}else if(this.mixedAllSwitch){
Utils.emitEvent(level,188)
this.mixedAllSwitch=false
}
return false
})
.onAlert((event) => {
...
...
@@ -128,6 +172,11 @@ struct Index {
})
.onErrorReceive((event) => {
this.errorReceive = event.request.getRequestUrl()
console.log("onErrorReceive==>")
if(this.cacheError){
Utils.emitEvent("cacheError",182)
this.cacheError=false
}
})
.onHttpErrorReceive((event) => {
this.httpErrorReceive = event.response.getResponseCode()
...
...
@@ -138,8 +187,28 @@ struct Index {
.onDownloadStart((event) => {
this.downloadStart = event.url
})
.onScaleChange((event)=>{
console.log("onScaleChange==>")
this.newScale=event.newScale
if(this.scaleChange){
Utils.emitEvent("onScaleChange",98)
this.scaleChange=false
}
})
.onPrompt((event)=>{
event.result.handlePromptConfirm("onPrompt ok")
Utils.emitEvent(event.message,178)
return true
})
.onGeolocationShow(()=>{
console.log("onGeolocationShow==>")
if(this.geoShow){
Utils.emitEvent("onGeolocationShow",99)
this.geoShow=false
}
})
Row(){
Button("web click").key('webcomponent').onClick(()=>{
Button("web click").key('webcomponent').onClick(
async
()=>{
console.info("key==>"+this.str)
switch(this.str){
case "emitUserAgent":{
...
...
@@ -274,6 +343,219 @@ struct Index {
},3000)
break;
}
case "emitGeolocationAccessFalse":{
this.geolocationAccess=false
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/geo.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getGeoResult()",callback:(res)=>{
console.info("getGeoResult==>"+res)
Utils.emitEvent(res,96)
}})
},3000)
break;
}
case "emitInitialScale":{
this.initialScale=120
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"})
this.enterPageEnd=true
break;
}
case "emitOnscaleChange":{
this.initialScale=110
this.scaleChange=true
await Utils.sleep(2000)
this.controller.loadUrl({url:"https://gitee.com/"})
break;
}
case "emitOnGeolocationShow":{
this.geolocationAccess=true
this.geoShow=true
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/geo.html"})
break;
}
case "emitDomStorageAccessFalse":{
this.domStorageAccess=false
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/domApi.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{
console.info("getDomResult==>"+res)
Utils.emitEvent(res,144)
}})
},3000)
break;
}
case "emitDomStorageAccessTrue":{
this.domStorageAccess=true
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/domApi.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{
console.info("getDomResult==>"+res)
Utils.emitEvent(res,146)
}})
},3000)
break;
}
case "emitImageAccessFalse":{
this.imageAccess=false
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{
console.info("getImgResult==>"+res)
Utils.emitEvent(res,148)
}})
},3000)
break;
}
case "emitImageAccessTrue":{
this.imageAccess=true
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{
console.info("getImgResult==>"+res)
Utils.emitEvent(res,150)
}})
},3000)
break;
}
case "emitOnlineImageAccessFalse":{
this.onlineImageAccess=false
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/onlineImageAccess.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{
console.info("getImageLoadResult==>"+res)
Utils.emitEvent(res,156)
}})
},3000)
break;
}
case "emitOnlineImageAccessTrue":{
this.onlineImageAccess=true
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/onlineImageAccess.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{
console.info("getImageLoadResult==>"+res)
Utils.emitEvent(res,158)
}})
},3000)
break;
}
case "emitFileFromUrlAccessFalse":{
this.fileFromUrlAccess=false
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/fileFromUrlAccess.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getFileResult()",callback:(res)=>{
console.info("getFileResult==>"+res)
Utils.emitEvent(res,160)
}})
},3000)
break;
}
case "emitFileFromUrlAccessTrue":{
this.fileFromUrlAccess=true
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/fileFromUrlAccess.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getFileResult()",callback:(res)=>{
console.info("getFileResult==>"+res)
Utils.emitEvent(res,162)
}})
},3000)
break;
}
case "emitDatabaseAccessTrue":{
this.databaseAccess=true
await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/databaseAccess.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getDataResult()",callback:(res)=>{
console.info("getDataResult==>"+res)
Utils.emitEvent(res,164)
}})
},3000)
break;
}
case "emitOverviewModeAccessFalse":{
this.overviewModeAccess=false
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res)
Utils.emitEventTwo(1150,res,168)
}})
},3000)
break;
}
case "emitOverviewModeAccessTrue":{
this.overviewModeAccess=true
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res)
Utils.emitEventTwo(2350,res,170)
}})
},3000)
break;
}
case "emitOnPrompt":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.runJavaScript({script:"toPrompt()"})
},3000)
break;
}
case "emitCacheModeOnly":{
this.cacheError=true
this.cacheMode=CacheMode.Only
await Utils.sleep(2000)
this.controller.loadUrl({url:"https://www.openharmony.cn/mainPlay"})
break;
}
case "emitCacheModeDefault":{
this.cacheMode=CacheMode.Default
await Utils.sleep(2000)
this.controller.loadUrl({url:"https://www.openharmony.cn/mainPlay"})
setTimeout(()=>{
let webTitle=this.controller.getTitle()
Utils.emitEvent(webTitle,184)
},3000)
break;
}
case "emitMixedModeNone":{
this.mixedSwitch=true
this.mixedMode=MixedMode.None
await Utils.sleep(2000)
this.controller.loadUrl({url:"https://www.openharmony.cn/mainPlay"})
break;
}
case "emitMixedModeAll":{
this.mixedAllSwitch=true
this.mixedMode=MixedMode.All
await Utils.sleep(2000)
this.controller.loadUrl({url:"https://www.openharmony.cn/mainPlay"})
break;
}
case "emitFileAccessTrue":{
this.fileAccess=true
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
this.controller.runJavaScript({script:"openRawFile()"})
setTimeout(()=>{
let webTitle=this.controller.getTitle()
Utils.emitEvent(webTitle,190)
},3000)
break;
}
case "emitOnPageBegin":{
Utils.emitEvent(this.pageBegin,59)
break;
...
...
arkui/ace_ets_web_dev/entry/src/main/ets/test/Utils.ets
浏览文件 @
9cfaa6b6
...
...
@@ -115,4 +115,21 @@ export default class Utils {
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));
}
}
}
arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
9cfaa6b6
此差异已折叠。
点击以展开。
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/databaseAccess.html
0 → 100644
浏览文件 @
9cfaa6b6
<!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>
databaseAccess
</title>
</head>
<body>
<div
id=
"status"
></div>
<script>
let
res
=
""
try
{
if
(
openDatabase
){
res
=
"
openDatabase
"
}
}
catch
(
e
){
console
.
log
(
"
err:
"
+
e
)
res
=
"
openDatabase is undefined
"
}
function
getDataResult
(){
return
res
}
</script>
</body>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/domApi.html
0 → 100644
浏览文件 @
9cfaa6b6
<!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>
domApi
</title>
</head>
<body>
<div
id=
"result"
></div>
<script>
if
(
typeof
(
Storage
)
!==
"
undefined
"
){
try
{
localStorage
.
setItem
(
"
sitename
"
,
"
domapi
"
);
document
.
getElementById
(
"
result
"
).
innerHTML
=
localStorage
.
getItem
(
"
sitename
"
);
}
catch
(
e
){
document
.
getElementById
(
"
result
"
).
innerHTML
=
"
sorry
"
}
}
function
getDomResult
(){
let
str
=
document
.
getElementById
(
"
result
"
).
innerHTML
return
str
}
</script>
</body>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/fileFromUrlAccess.html
0 → 100644
浏览文件 @
9cfaa6b6
<!DOCTYPE html>
<html>
<head>
<title>
fileFromUrlAccess
</title>
<meta
charset=
"utf-8"
>
</head>
<body>
<div
id=
"result"
>
fileFromUrlAccess
</div>
</body>
<script
type=
"text/javascript"
>
function
load
(
name
){
let
xhr
=
new
XMLHttpRequest
(),
okStatus
=
document
.
location
.
protocol
===
"
file:
"
?
0
:
200
;
console
.
log
(
"
okStatus:
"
+
okStatus
);
xhr
.
open
(
"
GET
"
,
name
,
false
);
xhr
.
overrideMimeType
(
"
text/html;charset=utf-8
"
)
xhr
.
send
(
null
);
return
xhr
.
status
===
okStatus
?
xhr
.
responseText
:
null
;
}
let
text
=
load
(
"
file:///data/storage/el1/bundle/phone/resources/rawfile/fileFromUrlAccess.html
"
);
document
.
getElementById
(
"
result
"
).
innerHTML
=
text
;
function
getFileResult
(){
let
text
=
document
.
getElementById
(
"
result
"
).
innerHTML
;
return
text
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/geo.html
0 → 100644
浏览文件 @
9cfaa6b6
<!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>
地理位置
</title>
</head>
<body>
<div
id=
"result"
></div>
<script>
navigator
.
geolocation
.
getCurrentPosition
(
function
(
position
){
let
cords
=
position
.
coords
;
document
.
getElementById
(
"
result
"
).
innerText
=
"
当前经度:
"
+
cords
.
longitude
},
function
(
error
){
let
errorTypes
=
{
1
:
"
位置服务被拒绝
"
,
2
:
"
获取不到位置信息
"
,
3
:
"
获取位置信息超时
"
};
document
.
getElementById
(
"
result
"
).
innerText
=
errorTypes
[
error
.
code
]
}
);
function
getGeoResult
(){
let
str
=
document
.
getElementById
(
"
result
"
).
innerText
return
str
}
</script>
</body>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/icon.png
0 → 100644
浏览文件 @
9cfaa6b6
15.1 KB
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/index.html
浏览文件 @
9cfaa6b6
...
...
@@ -14,8 +14,15 @@
<body>
<div
id=
"container"
>
首页
</div>
<div
id=
"pageHeight"
></div>
<a
href=
"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"
id=
"fileAccess"
>
打开rawfile文件
</a>
<img
src=
"file:///data/storage/el1/bundle/phone/resources/rawfile/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
}
...
...
@@ -49,5 +56,15 @@
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
()
}
</script>
</html>
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/onlineImageAccess.html
0 → 100644
浏览文件 @
9cfaa6b6
<!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>
onlineImageAccess
</title>
</head>
<body>
<div
id=
"result"
>
gitee
</div>
<img
src=
"https://assets.gitee.com/assets/enterprises/202007/nonprofit-plan-9f4df9ae0451144be097e42b8db40c94.png"
alt=
"gitee"
id=
"gitee"
>
<script>
let
ele
=
document
.
getElementById
(
"
gitee
"
);
let
loadImage
;
ele
.
onload
=
function
(){
loadImage
=
"
load image complete
"
}
function
getImageLoadResult
(){
return
loadImage
}
</script>
</body>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html
0 → 100644
浏览文件 @
9cfaa6b6
<html>
<head>
<title>
gailan
</title>
<style>
body
{
width
:
2000px
;
padding-right
:
170px
;
padding-left
:
170px
;
border
:
5px
solid
blueviolet
}
</style>
</head>
<body>
This is the test page to test SetLoadWithOverviewMode interface
</body>
<script>
function
getViewResult
(){
let
height
=
document
.
getElementsByTagName
(
"
body
"
)[
0
].
scrollHeight
return
height
}
</script>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录