Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
df6dc76d
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
df6dc76d
编写于
5月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8790 【OpenHarmony 4.0.7.3】【Master】【ARKUI子系统】【TOD】【rk3568】【必现】api接口,属性覆盖JsMessageType,WebMessageExt
Merge pull request !8790 from 边鑫博/master
上级
333449b4
a9f16b74
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
720 addition
and
4 deletion
+720
-4
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
...eb_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
+377
-2
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
...dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
+1
-0
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets
..._web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets
+156
-2
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.html
...web_dev_three/entry/src/main/resources/rawfile/index.html
+19
-0
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.js
...s_web_dev_three/entry/src/main/resources/rawfile/index.js
+150
-0
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/webMessageExt.html
...three/entry/src/main/resources/rawfile/webMessageExt.html
+17
-0
未找到文件。
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
df6dc76d
此差异已折叠。
点击以展开。
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
浏览文件 @
df6dc76d
...
...
@@ -101,6 +101,7 @@ struct indexTwo {
},3000)
break;
}
default:
console.info("can not match case")
}
...
...
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
df6dc76d
...
...
@@ -426,10 +426,164 @@ export default function webJsunit() {
*tc.desic Save current page
*/
it('GetAccessibleGeolocation',0,async function(done){
emitKey="emit
GetAccessibleGeolocation
";
emitKey="emit
JsMessExtGetString
";
Utils.registerEvent("GetAccessibleGeolocation",true,451,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_039
*tc.name JsMessExtGetString
*tc.desic Save current page
*/
it('JsMessExtGetString',0,async function(done){
emitKey="emitJsMessExtGetNum";
Utils.registerEvent("JsMessExtGetString","result type:string",500,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_040
*tc.name JsMessExtGetNum
*tc.desic Save current page
*/
it('JsMessExtGetNum',0,async function(done){
emitKey="emitJsMessExtGetBoo";
Utils.registerEvent("JsMessExtGetNum","result type:number",501,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_041
*tc.name JsMessExtGetBoo
*tc.desic Save current page
*/
it('JsMessExtGetBoo',0,async function(done){
emitKey="emitJsMessExtGetArrayBuffer";
Utils.registerEvent("JsMessExtGetBoo","result type:boolean",502,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_042
*tc.name JsMessExtGetArrayBuffer
*tc.desic Save current page
*/
it('JsMessExtGetArrayBuffer',0,async function(done){
emitKey="emitJsMessExtGetArray";
Utils.registerEvent("JsMessExtGetArrayBuffer","result type:object",503,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_043
*tc.name JsMessExtGetArray
*tc.desic Save current page
*/
it('JsMessExtGetArray',0,async function(done){
emitKey="emitWebMessExtSetString";
Utils.registerEvent("JsMessExtGetArray","result type:object0",504,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_044
*tc.name WebMessExtSetString
*tc.desic Save current page
*/
it('WebMessExtSetString',0,async function(done){
emitKey="emitWebMessExtGetString";
var result="String:helloFromEts"
Utils.registerEvent("WebMessExtSetString",JSON.stringify(result),506,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_045
*tc.name WebMessExtGetString
*tc.desic Save current page
*/
it('WebMessExtGetString',0,async function(done){
emitKey="emitWebMessExtSetNumber";
Utils.registerEvent("WebMessExtGetString","result type:string",505,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_046
*tc.name WebMessExtSetNumber
*tc.desic Save current page
*/
it('WebMessExtSetNumber',0,async function(done){
emitKey="emitWebMessExtGetNumber";
var result="Number:1"
Utils.registerEvent("WebMessExtSetNumber",JSON.stringify(result),507,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_047
*tc.name WebMessExtGetNumber
*tc.desic Save current page
*/
it('WebMessExtGetNumber',0,async function(done){
emitKey="emitWebMessExtSetBoolean";
Utils.registerEvent("WebMessExtGetNumber","result type:number0",508,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_048
*tc.name WebMessExtSetBoolean
*tc.desic Save current page
*/
it('WebMessExtSetBoolean',0,async function(done){
emitKey="emitWebMessExtGetBoolean";
var result="Boolean:true"
Utils.registerEvent("WebMessExtSetBoolean",JSON.stringify(result),509,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_049
*tc.name WebMessExtGetBoolean
*tc.desic Save current page
*/
it('WebMessExtGetBoolean',0,async function(done){
emitKey="emitWebMessExtSetArray";
Utils.registerEvent("WebMessExtGetBoolean","result type:boolean",510,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_050
*tc.name WebMessExtSetArray
*tc.desic Save current page
*/
it('WebMessExtSetArray',0,async function(done){
emitKey="emitWebMessExtGetArray";
var result="Array len:1, value:apple"
Utils.registerEvent("WebMessExtSetArray",JSON.stringify(result),511,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_051
*tc.name WebMessExtGetArray
*tc.desic Save current page
*/
it('WebMessExtGetArray',0,async function(done){
emitKey="emitWebMessExtSetArrayBuffer";
Utils.registerEvent("WebMessExtGetArray","result type:object",512,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_052
*tc.name WebMessExtSetArrayBuffer
*tc.desic Save current page
*/
it('WebMessExtSetArrayBuffer',0,async function(done){
emitKey="emitWebMessExtGetArrayBuffer";
var result="ArrayBuffer:8"
Utils.registerEvent("WebMessExtSetArrayBuffer",JSON.stringify(result),513,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_053
*tc.name WebMessExtGetArrayBuffer
*tc.desic Save current page
*/
it('WebMessExtGetArrayBuffer',0,async function(done){
emitKey="emitWebMessExtGetArrayBuffer";
Utils.registerEvent("WebMessExtGetArrayBuffer","result getArrayBuffer byteLength:8",514,done);
sendEventByKey('webcomponent',10,'');
})
})
}
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.html
浏览文件 @
df6dc76d
...
...
@@ -70,5 +70,24 @@
let
str
=
objName
.
testOne
(
'
Web
'
)
return
str
}
function
getStringForJs
()
{
return
"
hello, world
"
;
}
function
getNumForJs
()
{
return
1
;
}
function
getBooForJs
()
{
return
true
;
}
function
getArrayBufferForJs
()
{
const
buffer
=
new
ArrayBuffer
(
8
);
const
view
=
new
Int32Array
(
buffer
);
return
view
;
}
function
getArrayForJs
()
{
const
fruits
=
[];
fruits
.
push
(
"
banana
"
,
"
apple
"
,
"
peach
"
);
return
fruits
;
}
</script>
</html>
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.js
0 → 100644
浏览文件 @
df6dc76d
/*
* 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.
*/
var
h5Port
;
window
.
addEventListener
(
'
message
'
,
function
(
event
)
{
console
.
info
(
"
htmlSSSSS
"
)
if
(
event
.
data
==
'
init_web_messageport
'
)
{
if
(
event
.
ports
[
0
]
!=
null
)
{
h5Port
=
event
.
ports
[
0
];
// 1. 保存从ets侧发送过来的端口
h5Port
.
onmessage
=
function
(
event
)
{
console
.
info
(
"
hwd In html got message
"
);
// 2. 接收ets侧发送过来的消息.
var
result
=
event
.
data
;
console
.
info
(
"
In html got message, typeof:
"
,
typeof
(
result
));
console
.
info
(
"
In html got message, result:
"
,
(
result
));
if
(
typeof
(
result
)
==
"
string
"
)
{
console
.
log
(
"
In html got message, String:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
String:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
number
"
)
{
console
.
log
(
"
In html side got message, number:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
Number:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
boolean
"
)
{
console
.
log
(
"
In html side got message, boolean:
"
,
result
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
Boolean:
"
+
result
;
}
else
if
(
typeof
(
result
)
==
"
object
"
)
{
if
(
result
instanceof
ArrayBuffer
)
{
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
ArrayBuffer:
"
+
result
.
byteLength
;
console
.
log
(
"
In html got message, byteLength:
"
,
result
.
byteLength
);
}
else
if
(
result
instanceof
Error
)
{
console
.
log
(
"
In html error message, err:
"
+
(
result
));
console
.
log
(
"
In html error message, typeof err:
"
+
typeof
(
result
));
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
Error:
"
+
result
.
name
+
"
, msg:
"
+
result
.
message
;
}
else
if
(
result
instanceof
Array
)
{
console
.
log
(
"
In html got message, Array
"
);
console
.
log
(
"
In html got message, Array length:
"
+
result
.
length
);
console
.
log
(
"
In html got message, Array[0]:
"
+
(
result
[
0
]));
console
.
log
(
"
In html got message, typeof Array[0]:
"
+
typeof
(
result
[
0
]));
document
.
getElementById
(
"
msg2
"
).
innerHTML
=
"
Array len:
"
+
result
.
length
+
"
, value:
"
+
result
;
}
else
{
console
.
log
(
"
In html got message, not any instance of support type
"
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
not any instance of support type
"
;
}
}
else
{
console
.
log
(
"
In html got message, not support type
"
);
document
.
getElementById
(
"
msg
"
).
innerHTML
=
"
not support type
"
;
}
}
h5Port
.
onmessageerror
=
(
event
)
=>
{
console
.
error
(
`hwd In html Error receiving message:
${
event
}
`
);
};
}
}
})
// 使用h5Port往ets侧发送String类型的消息.
function
postStringToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send string message
"
);
h5Port
.
postMessage
(
"
hello
"
);
console
.
log
(
"
In html send string message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postNumberToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Number message
"
);
h5Port
.
postMessage
(
1
);
console
.
log
(
"
In html send Number message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postBooleanToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Boolean message
"
);
h5Port
.
postMessage
(
true
);
console
.
log
(
"
In html send Boolean message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postArrayToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Array message
"
);
const
fruits
=
[];
fruits
.
push
(
"
apple
"
);
h5Port
.
postMessage
(
fruits
);
console
.
log
(
"
In html send Array message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postArrayBufferToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send Buffer message
"
);
let
buffer
=
new
ArrayBuffer
(
8
);
h5Port
.
postMessage
(
buffer
);
console
.
log
(
"
In html send Buffer message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postErrorToApp
()
{
if
(
h5Port
)
{
console
.
log
(
"
In html send error message
"
);
let
err
=
{
name
:
"
cuowu
"
,
message
:
"
cuowu
"
};
h5Port
.
postMessage
(
err
);
console
.
log
(
"
In html send error message end
"
);
}
else
{
console
.
error
(
"
In html h5port is null, please init first
"
);
}
}
function
postStringToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg
"
).
innerText
return
a
}
function
postNumberToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg
"
).
innerText
return
a
}
function
postBooleanToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg
"
).
innerText
return
a
}
function
postArrayToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg2
"
).
innerText
return
a
}
function
postArrayBufferToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg2
"
).
innerText
return
a
}
function
postErrorToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg2
"
).
innerText
return
a
}
\ No newline at end of file
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/webMessageExt.html
0 → 100644
浏览文件 @
df6dc76d
<!--index.html-->
<!DOCTYPE html>
<html
lang=
"en-gb"
>
<head>
<title>
WebView MessagePort Demo
</title>
</head>
<body>
<h1>
Html5 Send and Receive Message
</h1>
<h3
id=
"msg"
>
Receive string:
</h3>
<h3
id=
"msg2"
>
Receive arraybuffer:
</h3>
<div
style=
"font-size: 10pt; text-align: center;"
>
<input
type=
"button"
value=
"Send String"
onclick=
"postStringToApp();"
/><br/>
</div>
</body>
<script
src=
"index.js"
></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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录