提交 143791dd 编写于 作者: B bianxinbo

api setdns getAccessibleGeolocation

Signed-off-by: Nbianxinbo <bianxinbo@huawei.com>
上级 6ce815d9
...@@ -21,6 +21,8 @@ import web_webview from '@ohos.web.webview'; ...@@ -21,6 +21,8 @@ import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import prompt from '@system.prompt'; import prompt from '@system.prompt';
let loadedUrl; let loadedUrl;
@Entry @Entry
@Component @Component
struct Index { struct Index {
...@@ -37,6 +39,11 @@ struct Index { ...@@ -37,6 +39,11 @@ struct Index {
@State mode: WebDarkMode = WebDarkMode.Off @State mode: WebDarkMode = WebDarkMode.Off
@State mode1: WebDarkMode = WebDarkMode.On @State mode1: WebDarkMode = WebDarkMode.On
@State mode2: WebDarkMode = WebDarkMode.Auto @State mode2: WebDarkMode = WebDarkMode.Auto
@State enterPageEnd: boolean = false
ports: web_webview.WebMessagePort[]; ports: web_webview.WebMessagePort[];
testObj = { testObj = {
testOne: (data) => { testOne: (data) => {
...@@ -551,6 +558,34 @@ struct Index { ...@@ -551,6 +558,34 @@ struct Index {
} }
break; break;
} }
case "emitSetHttpDnsSuccess":{
try {
web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.SecureOnly, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}")
this.controller.loadUrl("https://www.example.com/");
this.enterPageEnd=true
} catch(error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetAccessibleGeolocation":{
try {
web_webview.GeolocationPermissions.allowGeolocation("file:///")
web_webview.GeolocationPermissions.getAccessibleGeolocation("file:///",(error, result) => {
if (error) {
console.log('getAccessibleGeolocation error: ' + JSON.stringify(error))
return;
}
if (result) {
console.log('getAccessibleGeolocationAsync result: ' + result);
Utils.emitEvent(result, 451);
}
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
default: default:
console.info("can not match case") console.info("can not match case")
} }
...@@ -584,6 +619,13 @@ struct Index { ...@@ -584,6 +619,13 @@ struct Index {
.onHttpErrorReceive((event) => { .onHttpErrorReceive((event) => {
event.response.setResponseIsReady(true) event.response.setResponseIsReady(true)
}) })
.onPageEnd((event) => {
if(this.enterPageEnd){
Utils.emitEvent(1,446)
this.enterPageEnd=false
}
console.log('url:' + event.url)
})
.darkMode(this.mode) .darkMode(this.mode)
.forceDarkAccess(false) .forceDarkAccess(false)
.webSerifFont('serif') .webSerifFont('serif')
......
...@@ -406,9 +406,30 @@ export default function webJsunit() { ...@@ -406,9 +406,30 @@ export default function webJsunit() {
*tc.desic Save current page *tc.desic Save current page
*/ */
it('GetStoredGeolocation',0,async function(done){ it('GetStoredGeolocation',0,async function(done){
emitKey="emitGetStoredGeolocation"; emitKey="emitSetHttpDnsSuccess";
Utils.registerEvent("GetStoredGeolocation","file:///",120,done); Utils.registerEvent("GetStoredGeolocation","file:///",120,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/*
*tc.number SUB_ACE_BASIC_ETS_API_037
*tc.name SetHttpDnsSuccess
*tc.desic Save current page
*/
it('SetHttpDnsSuccess',0,async function(done){
emitKey="emitGetAccessibleGeolocation";
Utils.registerEvent("SetHttpDnsSuccess",1,446,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_038
*tc.name GetAccessibleGeolocation
*tc.desic Save current page
*/
it('GetAccessibleGeolocation',0,async function(done){
emitKey="emitGetAccessibleGeolocation";
Utils.registerEvent("GetAccessibleGeolocation",true,451,done);
sendEventByKey('webcomponent',10,'');
})
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册