未验证 提交 6edaadd2 编写于 作者: O openharmony_ci 提交者: Gitee

!8805 【OpenHarmony 4.0.7.3】【Master】【ARKUI子系统】【TOD】【rk3568】【必现】api接口,属性覆盖setError,getError

Merge pull request !8805 from 边鑫博/master
......@@ -818,6 +818,44 @@ struct Index {
}
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 {
this.msg1 = "result getArrayBuffer byteLength:" + ((result.getArrayBuffer().byteLength));
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) {
console.log(`log error code: ${resError.code}, Message: ${resError.message}`);
......
......@@ -581,9 +581,30 @@ export default function webJsunit() {
*tc.desic Save current page
*/
it('WebMessExtGetArrayBuffer',0,async function(done){
emitKey="emitWebMessExtGetArrayBuffer";
emitKey="emitWebMessExtSetError";
Utils.registerEvent("WebMessExtGetArrayBuffer","result getArrayBuffer byteLength:8",514,done);
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,'');
})
})
}
/*
* 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");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -113,13 +113,16 @@ function postArrayBufferToApp() {
}
}
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");
try {
throw new URIError("URI seq 0222")
}
catch (e){
console.log("hwd URIError:"+(e instanceof SyntaxError));
console.log("hwd URIError:"+e.message);
console.log("hwd URIError:"+e.name);
if (h5Port) {
h5Port.postMessage(e);
}
}
}
......@@ -147,4 +150,4 @@ function postArrayBufferToHtml() {
function postErrorToHtml() {
var a=document.getElementById("msg2").innerText
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.
先完成此消息的编辑!
想要评论请 注册