diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets index 946b1e4a61441b85546f119333e1eb24dcd7f6ad..cc02206352c151fec73bfe787bba3d3d19b498b5 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/webapi9.ets @@ -29,6 +29,10 @@ struct Index { @State isVoid: boolean = true; handler: FullScreenExitHandler = null; @State atio: number = 150; + @State defaultSize: number = 13; + @State defaultFixed: number = 8; + @State minLogicalSize: number = 1; + @State netWorkStatus: boolean = false; ports: WebMessagePort[] = null; testObj = { test: (data1, data2, data3) => { @@ -118,6 +122,17 @@ struct Index { }) Web({ src: 'www.baidu.com', controller: this.controller }).key('web2') + .webStandardFont("HarmonyOS-Sans-Condensed") + .webSeriFont("HarmonyOS-Sans-Condensed") + .webSanSeriFont("HarmonyOS-Sans-Condensed") + .webFixedFont("HarmonyOS-Sans-Condensed") + .webFantasyFont("HarmonyOS-Sans-Condensed") + .webCursiveFont("HarmonyOS-Sans-Condensed") + .defaultFixedFontSize(this.defaultFixed) + .defaultFontSize(this.defaultFontSize) + .minLogicalSize(this.minLogicalSize) + .blockNetwork(false) + .defaultFontSize() .onSslErrorEventReceive((event) => { AlertDialog.show({ title: 'onSslErrorEventReceive', @@ -155,6 +170,24 @@ struct Index { console.log('getMessageLevel:' + event.message.getMessageLevel()); return false; }) + .onErrorReceive((event)=>{ + event.request.getRequestMethod(); + }) + .onTouchIconUrlRecevied((event)=>{ + event.url; + }) + .onFaviconReceived((event)=>{ + event.favicon; + }) + .onPageVisible((event)=>{ + event.url + }) + .onDataResubmitted((event)=>{ + event.handler.resend + }) + .onInterceptKeyEvent((e)=>{ + e.keyCode; + }) Button("web click").key('webcomponentapi9').onClick(async ()=>{ console.info("key==>"+this.str) @@ -245,7 +278,63 @@ struct Index { let isThirdParty = web_webview.WebCookieManager.isThirdPartyCookieAllowed(); Utils.emitEvent(isThirdParty,827); break; + case "hasImage": + let flag = true + try{ + thid.controllerTwo.hasImage((err.data)=>{ + if(err) { + console.info("has ImageError" + JSON.stringfy(err)) + return; + } + Utils.emitEvent(flag,828); + }); + }catch(error){ + console.error(`ErrorCode:${error.code},Message:${error.message}`); + } + break; + case "hasImageTwo": + let flag = true + try{ + thid.controllerTwo.hasImage().then((data)=>{ + Utils.emitEvent(flag,829); + }) + .catch(function(error)) { + console.error("error" +error) + } + }catch(error){ + console.error(`ErrorCode:${error.code},Message:${error.message}`); + } + break; + case "setNetworkAvailable": + this.controllerTwo.setNetworkAvailable(this.netWorkStatus); + Utils.emitEvent(this.netWorkStatus,830); + break; + case "getFavicon": + let icon = "baidu" + this.controllerTwo.getFavicon(); + Utils.emitEvent(this.icon,831); + break; + case "getOriginalUrl": + let url = "www.baidu.com" + this.controllerTwo.getOriginalUrl(); + Utils.emitEvent(this.netWorkStatus,832); + break; + case "history": + var res = 1; + let historyList = this.controllerTwo.getBackForwardEntries(); + this.controllerTwo.initializeWebEngine(); + let historyItem = historyList.getItemIndex(this.res); + historyItem.historyRawUrl + Utils.emitEvent(this.netWorkStatus,833); + break; + case "pageUp": + var res = true + this.controllerTwo.pageUp(true); + this.controllerTwo.pageDown(true); + this.controllerTwo.removeCache(true); + Utils.emitEvent(this.res,834); + break; default: console.info("can not match case") diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets index 9edbc1d2b1b05dbc417e85e9d4ea834ba5da2860..67a0333dadc3f75b90371ab2e5f1ee62cfb32602 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/test/WebJsunitApi9.test.ets @@ -316,10 +316,81 @@ export default function webJsunit() { * @tc.desic putAcceptFileURICookieEnabled */ it('testweb23', 0, async function (done) { - emitKey = "emitisThirdPartyCookieAllowed"; + emitKey = "hasImage"; Utils.registerContainEvent("isThirdPartyCookieAllowed",false,826,done); sendEventByKey('webcomponentapi9',10,''); }); - + + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0025 + * @tc.name testweb22 + * @tc.desic hasImageCallback + */ + it('testweb24', 0, async function (done) { + emitKey = "hasImageTwo"; + Utils.registerContainEvent("hasImage",true,828,done); + sendEventByKey('webcomponentapi9',10,''); + }); + + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0026 + * @tc.name testweb22 + * @tc.desic hasImagePromise + */ + it('testweb25', 0, async function (done) { + emitKey = "setNetworkAvailable"; + Utils.registerContainEvent("hasImage",true,829,done); + sendEventByKey('webcomponentapi9',10,''); + }); + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0027 + * @tc.name testweb22 + * @tc.desic setNetworkAvailable + */ + it('testweb26', 0, async function (done) { + emitKey = "getFavicon"; + Utils.registerContainEvent("setNetworkAvailable",false,830,done); + sendEventByKey('webcomponentapi9',10,''); + }); + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0028 + * @tc.name testweb22 + * @tc.desic getFavicon + */ + it('testweb27', 0, async function (done) { + emitKey = "getOriginalUrl"; + Utils.registerContainEvent("getFavicon","baidu",831,done); + sendEventByKey('webcomponentapi9',10,''); + }); + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0029 + * @tc.name testweb22 + * @tc.desic getFavicon + */ + it('testweb28', 0, async function (done) { + emitKey = "history"; + Utils.registerContainEvent("getOriginalUrl","www.baidu.com",832,done); + sendEventByKey('webcomponentapi9',10,''); + }); + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0030 + * @tc.name testweb22 + * @tc.desic getFavicon + */ + it('testweb29', 0, async function (done) { + emitKey = "pageUp"; + Utils.registerContainEvent("history",1,833,done); + sendEventByKey('webcomponentapi9',10,''); + }); + /* + * @tc.number SUB_ACE_BASIC_ETS_API_0031 + * @tc.name testweb22 + * @tc.desic getFavicon + */ + it('testweb30', 0, async function (done) { + emitKey = "pageUp"; + Utils.registerContainEvent("pageUp",true,834,done); + sendEventByKey('webcomponentapi9',10,''); + }); }) }