diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets index e242ed8735b54c8c3de80bb1532cfe4ca9ceb8dd..b5cbfc9ff41b5e618076009cacd42f87e7dd73d0 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets +++ b/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets @@ -404,13 +404,13 @@ struct Index { break; } case "emitOnErrorReceive":{ - this.controller.loadUrl({url:'http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html'}) + this.controller.loadUrl({url:'http://bianixnbo.com'}) setTimeout(()=>{ - this.controller.loadUrl({url:'http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html'}) + this.controller.loadUrl({url:'http://bianixnbo.com'}) setTimeout(() => { Utils.emitEvent(this.errorReceive,65) - },3000) - },3000) + },4000) + },4000) break; } case "emitOnHttpErrorReceive":{ diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets index 38180ee8eda31698668b58cfeea43cc6404d5ff5..632d60c75010fb37a9524d235ebbf200b6c7826a 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets +++ b/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets @@ -439,7 +439,7 @@ export default function webJsunit() { */ it('onErrorReceive',0,async function(done){ emitKey="emitOnHttpErrorReceive"; - Utils.registerEvent("onErrorReceive","http://192.168.5.40:9006/sso_web/html/H5/doctor/aboutUs.html",65,done); + Utils.registerEvent("onErrorReceive","http://bianixnbo.com/",65,done); sendEventByKey('webcomponent',10,''); }) /* diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets index 79afd9a91f37e154b34365279eca80ef6dc0f599..ab84bcbd874be897e55d61b0114eeb31a74ad2b5 100644 --- a/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets @@ -22,6 +22,25 @@ import fileio from '@ohos.fileio'; import prompt from '@system.prompt'; let loadedUrl; +function Uint8ArrayToString(dataArray) { + var dataString = '' + for (var i = 0; i < dataArray.length; i++) { + dataString += String.fromCharCode(dataArray[i]) + } + return dataString +} + +function ParseX509CertInfo(x509CertArray) { + let res: string = 'getCertificate success: len = ' + x509CertArray.length; + for (let i = 0; i < x509CertArray.length; i++) { + res += ', index = ' + i + ', issuer name = ' + + Uint8ArrayToString(x509CertArray[i].getIssuerName().data) + ', subject name = ' + + Uint8ArrayToString(x509CertArray[i].getSubjectName().data) + ', valid start = ' + + x509CertArray[i].getNotBeforeTime() + + ', valid end = ' + x509CertArray[i].getNotAfterTime() + } + return res +} @Entry @Component @@ -49,6 +68,10 @@ struct Index { @State getArray:boolean =false @State msg1:string="" @State type:number=0 + @State enterPageEndAuto: boolean =false + @State enterPageEndOff: boolean =false + @State outputStr: string = '' + @@ -572,7 +595,7 @@ struct Index { } case "emitSetHttpDnsSuccess":{ try { - web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.SecureOnly, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}") + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.SECURE_ONLY, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}") this.controller.loadUrl("https://www.example.com/"); this.enterPageEnd=true } catch(error) { @@ -856,6 +879,75 @@ struct Index { } break; } + case "emitGetAccessibleGeolocationPromise":{ + try { + web_webview.GeolocationPermissions.getAccessibleGeolocation("file:///") + .then(result => { + console.log('getAccessibleGeolocationPromise result: ' + result); + Utils.emitEvent(result,517) + }).catch(error => { + console.log('getAccessibleGeolocationPromise error: ' + JSON.stringify(error)); + }); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + case "emitSetHttpDnsSuccessAuto":{ + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.AUTO, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}") + this.controller.loadUrl("https://www.example.com/"); + this.enterPageEndAuto=true + } catch(error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + case "emitSetHttpDnsSuccessOff":{ + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.OFF, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}") + this.controller.loadUrl("https://www.example.com/"); + this.enterPageEndOff=true + } catch(error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + case "emitGetCertificateCallback":{ + try { + this.controller.loadUrl("https://www.example.com/"); + console.info("jinru") + this.controller.getCertificate((error, x509CertArray) => { + if (error) { + this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message; + } else { + this.outputStr = ParseX509CertInfo(x509CertArray); + console.info("hahahha"+this.outputStr.length) + console.info("hahahha"+this.outputStr) + Utils.emitEvent(this.outputStr.length,520) + } + }) + } catch (error) { + this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message; + } + break; + } + case "emitGetStoredGeolocationPromise":{ + try { + web_webview.GeolocationPermissions.allowGeolocation("file:///") + web_webview.GeolocationPermissions.getStoredGeolocation() + .then(origins => { + let origins_str: string = origins.join(); + console.log('getStoredGeolocationPromise origins: ' + origins_str); + Utils.emitEvent(origins_str, 521); + }).catch(error => { + console.log('getStoredGeolocationPromise error: ' + JSON.stringify(error)); + }); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } @@ -898,6 +990,14 @@ struct Index { Utils.emitEvent(1,446) this.enterPageEnd=false } + if(this.enterPageEndAuto){ + Utils.emitEvent(this.controller.getTitle(),518) + this.enterPageEndAuto=false + } + if(this.enterPageEndOff){ + Utils.emitEvent(this.controller.getTitle(),519) + this.enterPageEndOff=false + } if(this.getString){ try { this.controller.runJavaScriptExt( @@ -980,19 +1080,14 @@ struct Index { } if(this.getArray){ try { - this.controller.runJavaScriptExt( - 'getArrayForJs()', - (error, result) => { - if (error) { - console.info(`run JavaScript error: ` + JSON.stringify(error)) - return; - } - var type = result.getType() - if(web_webview.JsMessageType.ARRAY== type){ - this.msg1 = "result type:" + typeof (result.getArray()); - Utils.emitEvent(this.msg1+web_webview.JsMessageType.NOT_SUPPORT,504) - } - }); + this.controller.runJavaScriptExt('getArrayForJs()') + .then((result) => { + var type = result.getType() + if(web_webview.JsMessageType.ARRAY== type){ + this.msg1 = "result type:" + typeof (result.getArray()); + Utils.emitEvent(this.msg1+web_webview.JsMessageType.NOT_SUPPORT,504) + } + }) console.info('urlgetstring: ', event.url); } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets index 292092036c7a6e10b60764c771a4b945148b9da0..ea62fc8a51fc84ef3e82f704068a9e39d4d5e1e4 100644 --- a/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets @@ -602,9 +602,59 @@ export default function webJsunit() { *tc.desic Save current page */ it('WebMessExtGetError',0,async function(done){ - emitKey="emitWebMessExtGetError"; + emitKey="emitGetAccessibleGeolocationPromise"; Utils.registerEvent("WebMessExtGetError","result type:object",516,done); sendEventByKey('webcomponent',10,''); }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_056 + *tc.name GetAccessibleGeolocationPromise + *tc.desic Save current page + */ + it('GetAccessibleGeolocationPromise',0,async function(done){ + emitKey="emitSetHttpDnsSuccessAuto"; + Utils.registerEvent("GetAccessibleGeolocationPromise",true,517,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_057 + *tc.name SetHttpDnsSuccessAuto + *tc.desic Save current page + */ + it('SetHttpDnsSuccessAuto',0,async function(done){ + emitKey="emitSetHttpDnsSuccessOff"; + Utils.registerEvent("SetHttpDnsSuccessAuto","Example Domain",518,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_058 + *tc.name SetHttpDnsSuccessOff + *tc.desic Save current page + */ + it('SetHttpDnsSuccessOff',0,async function(done){ + emitKey="emitGetCertificateCallback"; + Utils.registerEvent("SetHttpDnsSuccessOff","Example Domain",519,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_059 + *tc.name GetCertificateCallback + *tc.desic Save current page + */ + it('GetCertificateCallback',0,async function(done){ + emitKey="emitGetStoredGeolocationPromise"; + Utils.registerEvent("GetCertificateCallback",31,520,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_060 + *tc.name GetStoredGeolocationPromise + *tc.desic Save current page + */ + it('GetStoredGeolocationPromise',0,async function(done){ + emitKey="emitGetStoredGeolocationPromise"; + Utils.registerEvent("GetStoredGeolocationPromise","file:///",521,done); + sendEventByKey('webcomponent',10,''); + }) }) }