Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
554faa70
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看板
提交
554faa70
编写于
2月 08, 2023
作者:
W
wang-xupeng2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add api
Signed-off-by:
N
wang-xupeng2
<
wangxupeng2@huawei.com
>
上级
006d1169
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
216 addition
and
12 deletion
+216
-12
arkui/ace_ets_web_dev_three/AppScope/app.json
arkui/ace_ets_web_dev_three/AppScope/app.json
+3
-3
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
+149
-1
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
+58
-2
arkui/ace_ets_web_dev_three/entry/src/main/module.json
arkui/ace_ets_web_dev_three/entry/src/main/module.json
+6
-6
未找到文件。
arkui/ace_ets_web_dev_three/AppScope/app.json
浏览文件 @
554faa70
...
...
@@ -11,10 +11,10 @@
"distributedNotificationEnabled"
:
true
,
"keepAlive"
:
true
,
"singleUser"
:
true
,
"minAPIVersion"
:
9
,
"targetAPIVersion"
:
9
,
"minAPIVersion"
:
10
,
"targetAPIVersion"
:
10
,
"car"
:
{
"apiCompatibleVersion"
:
9
,
"apiCompatibleVersion"
:
10
,
"singleUser"
:
false
}
}
...
...
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
554faa70
...
...
@@ -18,17 +18,22 @@ import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
let loadedUrl;
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
scheme1: web_webview.WebCustomScheme = {schemeName: "name1", isSupportCORS: true, isSupportFetch: true}
responseweb: WebResourceResponse = new WebResourceResponse()
@State str:string="emitLoadUrl"
@State text:boolean=false
@State num:number=0
@State mode: WebDarkMode = WebDarkMode.Off
@State mode1: WebDarkMode = WebDarkMode.On
@State mode2: WebDarkMode = WebDarkMode.Auto
ports: web_webview.WebMessagePort[];
testObj = {
testOne: (data) => {
Utils.emitEvent(data,13)
...
...
@@ -62,6 +67,14 @@ struct Index {
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
try{
web_webview.once("webInited",()=>{
web_webview.WebCookieManager.setCookie("https://www.huawei.com", "a=b");
})
}catch(error){
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}
build(){
Column(){
...
...
@@ -406,6 +419,113 @@ struct Index {
}
break;
}
case "emitOnce":{
try {
let re = web_webview.WebCookieManager.getCookie("https://www.huawei.com")
Utils.emitEvent(re, 31)
console.log("result: " + re);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetItemAtIndex":{
try {
let res = this.controller.getBackForwardEntries()
let item =res.getItemAtIndex(0)
Utils.emitEvent(item.title, 32)
console.log("result: " + item.title);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitSlideScroll":{
try {
this.controller.slideScroll(10, 10);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
let state = this.controller.serializeWebState();
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o2 | 0o100, 0o666);
fileio.writeSync(fd, state.buffer);
fileio.closeSync(fd);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o002, 0o666);
let stat = fileio.fstatSync(fd);
let size = stat.size;
let buf = new ArrayBuffer(size);
fileio.read(fd, buf, (err, data) => {
if (data) {
this.controller.restoreWebState(new Uint8Array(data.buffer));
}
fileio.closeSync(fd);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
this.ports = this.controller.createWebMessagePorts();
this.ports[1].onMessageEvent((msg) => {
if (typeof(msg) == "string") {
console.log("received string message from html5, string is:" + msg);
} else if (typeof(msg) == "object") {
if (msg instanceof ArrayBuffer) {
console.log("received arraybuffer from html5, length is:" + msg.byteLength);
} else {
console.log("not support");
}
} else {
console.log("not support");
}
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuMediaType":{
try {
let con = ContextMenuMediaType.Image
Utils.emitEvent(con, 33)
console.log("result: " + con);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuInputFieldType":{
try {
Utils.emitEvent(ContextMenuInputFieldType.PlainText, 34)
Utils.emitEvent(ContextMenuInputFieldType.Telephone, 35)
Utils.emitEvent(ContextMenuInputFieldType.Other, 36)
console.log("result: " + ContextMenuInputFieldType.PlainText);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuEditStateFlags":{
try {
Utils.emitEvent(ContextMenuEditStateFlags.NONE, 37)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_CUT, 38)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_COPY, 39)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_PASTE, 40)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_SELECT_ALL, 41)
console.log("result: " + ContextMenuEditStateFlags.CAN_SELECT_ALL);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
default:
console.info("can not match case")
}
...
...
@@ -415,6 +535,10 @@ struct Index {
.mediaPlayGestureAccess(true)
.javaScriptAccess(true)
.zoomAccess(this.text)
.onDataResubmitted((event) => {
console.log('onDataResubmitted')
event.handler.resend();
})
.onSearchResultReceive(ret=>{
var searchResult = ret.activeMatchOrdinal.toString() +
ret.numberOfMatches.toString()
...
...
@@ -423,6 +547,30 @@ struct Index {
Utils.emitEvent(searchResult,16)
},3000)
})
.onContextMenuShow((event) => {
console.info(event.param.getMediaType() + event.param.getSelectionText() + event.param.getSourceType())
console.info(event.param.getInputFieldType().toString())
console.info(event.param.isEditable().toString())
console.info(event.param.getEditStateFlags().toString())
event.result.paste()
event.result.cut()
return true
})
.onHttpErrorReceive((event) => {
event.response.setResponseIsReady(true)
})
.darkMode(this.mode)
.forceDarkAccess(false)
.webSerifFont('serif')
.webFixedFont('fixed')
.webSansSerifFont('serif')
.minLogicalFontSize(1)
.horizontalScrollBarAccess(true)
.verticalScrollBarAccess(true)
.onTouchIconUrlReceived((event) => {
console.log('onTouchIconUrlReceived:' + JSON.stringify(event))
})
.pinchSmooth(true)
}
}
...
...
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets
浏览文件 @
554faa70
...
...
@@ -340,9 +340,65 @@ export default function webJsunit() {
*tc.desic Save current page
*/
it('GetUrl',0,async function(done){
emitKey="emit
GetUrl
";
emitKey="emit
Once
";
Utils.registerContainEvent("GetUrl","17100001",30,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_031
*tc.name Once
*tc.desic Save current page
*/
it('Once',0,async function(done){
emitKey="emitGetItemAtIndex";
Utils.registerContainEvent("Once","a=b",31,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_032
*tc.name GetItemAtIndex
*tc.desic Save current page
*/
it('GetItemAtIndex',0,async function(done){
emitKey="emitContextMenuMediaType";
Utils.registerEvent("GetItemAtIndex","index",32,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_033
*tc.name ContextMenuMediaType
*tc.desic Save current page
*/
it('ContextMenuMediaType',0,async function(done){
emitKey="emitContextMenuInputFieldType";
Utils.registerEvent("ContextMenuMediaType",1,33,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_034
*tc.name ContextMenuInputFieldType
*tc.desic Save current page
*/
it('ContextMenuInputFieldType',0,async function(done){
emitKey="emitContextMenuEditStateFlags";
Utils.registerEvent("ContextMenuInputFieldType",1,34,done);
Utils.registerEvent("ContextMenuInputFieldType",4,35,done);
Utils.registerEvent("ContextMenuInputFieldType",5,36,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_035
*tc.name ContextMenuEditStateFlags
*tc.desic Save current page
*/
it('ContextMenuEditStateFlags',0,async function(done){
emitKey="emitContextMenuEditStateFlags";
Utils.registerEvent("ContextMenuEditStateFlags",0,37,done);
Utils.registerEvent("ContextMenuEditStateFlags",1,38,done);
Utils.registerEvent("ContextMenuEditStateFlags",2,39,done);
Utils.registerEvent("ContextMenuEditStateFlags",4,40,done);
Utils.registerEvent("ContextMenuEditStateFlags",8,41,done);
sendEventByKey('webcomponent',10,'');
})
})
}
\ No newline at end of file
}
arkui/ace_ets_web_dev_three/entry/src/main/module.json
浏览文件 @
554faa70
...
...
@@ -15,11 +15,11 @@
"uiSyntax"
:
"ets"
,
"pages"
:
"$profile:main_pages"
,
"metadata"
:
[
{
"name"
:
"ArkTSPartialUpdate"
,
"value"
:
"fals
e"
}
],
{
"name"
:
"ArkTSPartialUpdate"
,
"value"
:
"tru
e"
}
],
"abilities"
:
[{
"name"
:
"com.example.myapplication.MainAbility"
,
"srcEntrance"
:
"./ets/MainAbility/MainAbility.ts"
,
...
...
@@ -46,4 +46,4 @@
}
]
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录