Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
49885b36
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看板
提交
49885b36
编写于
5月 29, 2023
作者:
B
bianxinbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
api_new2
Signed-off-by:
N
bianxinbo
<
bianxinbo@huawei.com
>
上级
ab1e4cd5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
10 deletion
+76
-10
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
+42
-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
+22
-1
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.js
...s_web_dev_three/entry/src/main/resources/rawfile/index.js
+12
-9
未找到文件。
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
49885b36
...
@@ -818,6 +818,44 @@ struct Index {
...
@@ -818,6 +818,44 @@ struct Index {
}
}
break;
break;
}
}
case "emitWebMessExtSetError":{
try {
console.log("URL Error");
throw new URIError("URI seq")
}
catch (e) {
console.log("hwd URIError:"+(e instanceof SyntaxError));
console.log("hwd URIError:"+e.message);
console.log("hwd URIError:"+e.name);
if (this.nativePort) {
setTimeout(()=>{
var message =new web_webview.WebMessageExt();
message.setType(web_webview.WebMessageType.ERROR)
this.message.setError(e);
this.nativePort.postMessageEventExt(message);
},2000)
}
}
setTimeout(()=>{
this.controller.runJavaScript("postErrorToHtml()",(error, result) => {
console.log(`The emitWebMessExtSetError() return value is: ${result}`);
Utils.emitEvent(result,515)
})
},3000)
break;
}
case "emitWebMessExtGetError":{
try {
this.controller.loadUrl($rawfile('webMessageExt.html'));
this.controller.runJavaScript("postErrorToApp()",(error, result) => {
console.log(`The emitWebMessExtGetError() return value is: ${result}`);
})
}
catch (error) {
console.log("In eTS side send message catch error:" + error.code + ", msg:" + error.message);
}
break;
}
...
@@ -993,6 +1031,10 @@ struct Index {
...
@@ -993,6 +1031,10 @@ struct Index {
this.msg1 = "result getArrayBuffer byteLength:" + ((result.getArrayBuffer().byteLength));
this.msg1 = "result getArrayBuffer byteLength:" + ((result.getArrayBuffer().byteLength));
Utils.emitEvent(this.msg1,514)
Utils.emitEvent(this.msg1,514)
}
}
if(this.type == web_webview.WebMessageType.ERROR){
this.msg1 = "result type:" + typeof (result.getError());
Utils.emitEvent(this.msg1,516)
}
}
}
catch (resError) {
catch (resError) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
...
...
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
49885b36
...
@@ -581,9 +581,30 @@ export default function webJsunit() {
...
@@ -581,9 +581,30 @@ export default function webJsunit() {
*tc.desic Save current page
*tc.desic Save current page
*/
*/
it('WebMessExtGetArrayBuffer',0,async function(done){
it('WebMessExtGetArrayBuffer',0,async function(done){
emitKey="emitWebMessExt
GetArrayBuffe
r";
emitKey="emitWebMessExt
SetErro
r";
Utils.registerEvent("WebMessExtGetArrayBuffer","result getArrayBuffer byteLength:8",514,done);
Utils.registerEvent("WebMessExtGetArrayBuffer","result getArrayBuffer byteLength:8",514,done);
sendEventByKey('webcomponent',10,'');
sendEventByKey('webcomponent',10,'');
})
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_054
*tc.name WebMessExtSetError
*tc.desic Save current page
*/
it('WebMessExtSetError',0,async function(done){
emitKey="emitWebMessExtGetError";
var result="Error:SyntaxError, msg:"
Utils.registerEvent("WebMessExtSetError",JSON.stringify(result),515,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_055
*tc.name WebMessExtGetError
*tc.desic Save current page
*/
it('WebMessExtGetError',0,async function(done){
emitKey="emitWebMessExtGetError";
Utils.registerEvent("WebMessExtGetError","result type:object",516,done);
sendEventByKey('webcomponent',10,'');
})
})
})
}
}
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.js
浏览文件 @
49885b36
/*
/*
* Copyright (
C) 2021
Huawei Device Co., Ltd.
* Copyright (
c) 2021~2023
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
...
@@ -113,13 +113,16 @@ function postArrayBufferToApp() {
...
@@ -113,13 +113,16 @@ function postArrayBufferToApp() {
}
}
}
}
function
postErrorToApp
()
{
function
postErrorToApp
()
{
if
(
h5Port
)
{
try
{
console
.
log
(
"
In html send error message
"
);
throw
new
URIError
(
"
URI seq 0222
"
)
let
err
=
{
name
:
"
cuowu
"
,
message
:
"
cuowu
"
};
}
h5Port
.
postMessage
(
err
);
catch
(
e
){
console
.
log
(
"
In html send error message end
"
);
console
.
log
(
"
hwd URIError:
"
+
(
e
instanceof
SyntaxError
));
}
else
{
console
.
log
(
"
hwd URIError:
"
+
e
.
message
);
console
.
error
(
"
In html h5port is null, please init first
"
);
console
.
log
(
"
hwd URIError:
"
+
e
.
name
);
if
(
h5Port
)
{
h5Port
.
postMessage
(
e
);
}
}
}
}
}
...
@@ -147,4 +150,4 @@ function postArrayBufferToHtml() {
...
@@ -147,4 +150,4 @@ function postArrayBufferToHtml() {
function
postErrorToHtml
()
{
function
postErrorToHtml
()
{
var
a
=
document
.
getElementById
(
"
msg2
"
).
innerText
var
a
=
document
.
getElementById
(
"
msg2
"
).
innerText
return
a
return
a
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录