diff --git a/arkui/ace_ets_web_dev_webController/BUILD.gn b/arkui/ace_ets_web_dev_webController/BUILD.gn index ffee979aefee8e157acb3f7be079e42562e9ea1d..0d3ca9f9814986b9e011bdf6480962e5a405e1b3 100644 --- a/arkui/ace_ets_web_dev_webController/BUILD.gn +++ b/arkui/ace_ets_web_dev_webController/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2023 iSoftStone Information Technology (Group) 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 diff --git a/arkui/ace_ets_web_dev_webviewController/BUILD.gn b/arkui/ace_ets_web_dev_webviewController/BUILD.gn index 651e413f9fcd05e6305228e92874400027057f39..c2048c13cf0b33751457dce4ff8c63f893c7c472 100644 --- a/arkui/ace_ets_web_dev_webviewController/BUILD.gn +++ b/arkui/ace_ets_web_dev_webviewController/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2023 iSoftStone Information Technology (Group) 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 diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSize.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSize.ets new file mode 100644 index 0000000000000000000000000000000000000000..124c3805094b61568287b57564f22570e0b5e6c3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSize.ets @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewDefaultFontSize { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitdefaultFontSize73AndminFontSize1"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State defaultFontSize: number = 13; + @State minFontSize: number = 13; + @State checkEleResult: Object = {}; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewDefaultFontSize page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewDefaultFontSize').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitdefaultFontSize73AndminFontSize1": { + try { + this.defaultFontSize = 73; + this.minFontSize = 1; + await Utils.sleep(2000) + console.log("fonsize of emitdefaultFontSize73AndminFontSize1 is :" + this.defaultFontSize + this.minFontSize); + this.controller.runJavaScript("getPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 332) + }) + break; + } + case "emitdefaultFontSize73AndminFontSize73": { + try { + this.defaultFontSize = 73; + this.minFontSize = 73; + await Utils.sleep(2000) + console.log("fonsize of emitdefaultFontSize73AndminFontSize73 is :" + this.defaultFontSize + this.minFontSize); + this.controller.runJavaScript("getPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 334) + }) + break; + } + } + }) + } + Web({ src:$rawfile('indexFive.html'), controller: this.controller }) + .defaultFontSize(this.defaultFontSize) + .minFontSize(this.minFontSize) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoAll.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoAll.ets new file mode 100644 index 0000000000000000000000000000000000000000..f86bb1c32af17e6e2965c548dd96ef666b7cf2b7 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoAll.ets @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewDefaultFontSizeNoAll { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitdefaultFontSizeAndminFontSizeNoAll"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State checkEleResult: Object = {}; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewDefaultFontSizeNoAll page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewDefaultFontSizeNoAll').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitdefaultFontSizeAndminFontSizeNoAll": { + try { + this.controller.runJavaScript("getPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 340) + }) + break; + } + } + }) + } + Web({ src:$rawfile('indexFive.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoMinFontSize.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoMinFontSize.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a41f0f8f0b1f5782ffc0184fe9fb51adc5cc279 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeNoMinFontSize.ets @@ -0,0 +1,109 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewDefaultFontSizeNoMinFontSize { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitdefaultFontSize7AndNominFontSize"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State defaultFontSize: number = 13; + @State checkEleResult: Object = {}; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewDefaultFontSizeNoMinFontSize page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewDefaultFontSizeNoMinFontSize').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitdefaultFontSize7AndNominFontSize": { + try { + this.defaultFontSize = 7; + await Utils.sleep(2000); + console.log("fonsize of emitdefaultFontSize7AndNominFontSize is :" + this.defaultFontSize); + this.controller.runJavaScript("getPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 336) + }) + break; + } + case "emitdefaultFontSize17AndCssFontSize9": { + try { + this.defaultFontSize = 17; + await Utils.sleep(2000); + console.log("fonsize of emitdefaultFontSize17AndCssFontSize9 is :" + this.defaultFontSize); + this.controller.runJavaScript("getTestPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getTestPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 338) + }) + break; + } + } + }) + } + Web({ src:$rawfile('indexFive.html'), controller: this.controller }) + .defaultFontSize(this.defaultFontSize) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeWithMinLogical.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeWithMinLogical.ets new file mode 100644 index 0000000000000000000000000000000000000000..af9eb41ac30ce87e6100ff694aea37271b7373c7 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDefaultFontSizeWithMinLogical.ets @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewDefaultFontSizeWithMinLogical { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitdefaultFontSizeHalfAndminFontSizeHalf"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State defaultFontSize: number = 13; + @State minFontSize: number = 13; + @State minLogicalFontSize: number = 13; + @State checkEleResult: Object = {}; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewDefaultFontSizeWithMinLogical page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewDefaultFontSizeWithMinLogical').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitdefaultFontSizeHalfAndminFontSizeHalf": { + try { + this.defaultFontSize = 0.5; + this.minFontSize = 0.5; + this.minLogicalFontSize = 0.5 + await Utils.sleep(2000); + console.log("fonsize of emitdefaultFontSizeHalfAndminFontSizeHalf is :" + this.defaultFontSize + this.minFontSize); + this.controller.runJavaScript("getPageFontsize()",(error, result) => { + this.checkEleResult = JSON.parse(result) + console.log(`The getPageFontsize() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult[1], 330) + }) + break; + } + } + }) + } + Web({ src:$rawfile('indexFive.html'), controller: this.controller }) + .defaultFontSize(this.defaultFontSize) + .minFontSize(this.minFontSize) + .minLogicalFontSize(this.minLogicalFontSize) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDeleteEntireCookie.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDeleteEntireCookie.ets new file mode 100644 index 0000000000000000000000000000000000000000..438b96a791636682aeb31951939f5110773df12a --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewDeleteEntireCookie.ets @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewDeleteEntireCookie { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitDeleteEntireCookie"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State checkEleResult:boolean=false; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewDeleteEntireCookie page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("cookieTest").key('webViewDeleteEntireCookie').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitDeleteEntireCookie": { + try { + web_webview.WebCookieManager.setCookie('https://www.example.com', 'a=b'); + Utils.sleep(1000); + web_webview.WebCookieManager.deleteEntireCookie(); + Utils.sleep(1000); + this.checkEleResult = web_webview.WebCookieManager.existCookie(); + console.log("this.checkEleResult: " + this.checkEleResult); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 348) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewExistCookie.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewExistCookie.ets new file mode 100644 index 0000000000000000000000000000000000000000..87643a5b1896f2a97fa509e5bd91a8e47d684e01 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewExistCookie.ets @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewExistCookie { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitExistCookie"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State checkEleResult:boolean=false; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewExistCookie page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("cookieTest").key('webViewExistCookie').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitExistCookie": { + try { + web_webview.WebCookieManager.setCookie('https://www.example.com', 'a=b'); + Utils.sleep(1000); + this.checkEleResult = web_webview.WebCookieManager.existCookie(); + console.log("this.checkEleResult: " + this.checkEleResult); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 346) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetAccessibleGeolocation.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetAccessibleGeolocation.ets new file mode 100644 index 0000000000000000000000000000000000000000..e572c39ed7d7f9cf6270a1265201e66a3d0fb7ff --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetAccessibleGeolocation.ets @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewGetAccessibleGeolocation { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitGetAccessAllowAndRetainAllFalse"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State geolocationAccess:boolean=true; + @State invokeAllow:boolean=true; + @State invokeRetain:boolean=true; + @State checkEleResult:boolean=false; + origin: string = "file:///"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewGetAccessibleGeolocation page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("geolocationTest").key('webViewGetAccessibleGeolocation').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitGetAccessAllowAndRetainAllFalse": { + try { + this.controller.loadUrl($rawfile('geo.html')); + await Utils.sleep(1000); + web_webview.GeolocationPermissions.deleteGeolocation(this.origin); + this.invokeAllow = false; + this.invokeRetain = false; + web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => { + if (error) { + console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error)); + return; + } + this.checkEleResult = result; + console.log('getAccessibleGeolocationAsync result: ' + result); + }); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 409) + }) + break; + } + case "emitGetAccessAllowAndRetainAllTrue": { + try { + web_webview.GeolocationPermissions.allowGeolocation(this.origin); + this.invokeAllow = true; + this.invokeRetain = true; + this.controller.loadUrl($rawfile('geo.html')); + await Utils.sleep(1000); + web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => { + if (error) { + console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error)); + return; + } + this.checkEleResult = result; + console.log('getAccessibleGeolocationAsync result: ' + result); + }); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 410) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .geolocationAccess(this.geolocationAccess) + .onGeolocationShow((event) => { + event.geolocation.invoke(event.origin, this.invokeAllow, this.invokeRetain) + console.log("webViewInVoke : onGeolocationShow : " + event.origin + this.invokeAllow, this.invokeRetain); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetCertificate.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetCertificate.ets new file mode 100644 index 0000000000000000000000000000000000000000..266e77f6950e4d09b472a49215029392be71ef22 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewGetCertificate.ets @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +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 +struct webViewGetCertificate { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitGetCertificateCallback"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State outputStr: string = '' + @State certificateResult:boolean=false; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewGetCertificate page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("getCertTest").key('webViewGetCertificate').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitGetCertificateCallback": { + try { + this.controller.loadUrl('https://expired.badssl.com'); + await Utils.sleep(2000); + this.controller.getCertificate((error, x509CertArray) => { + if (error) { + this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message; + } else { + this.outputStr = ParseX509CertInfo(x509CertArray); + } + }) + } catch (error) { + this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message; + } + console.log("getCertificate result of this page: " + this.outputStr); + if ((this.outputStr).includes("failed")) { + this.certificateResult = false + } + else { + this.certificateResult = true + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.certificateResult, 403) + }) + break; + } + case "emitGetCertificatePromise": { + try { + this.controller.clearHistory(); + this.controller.loadUrl('https://expired.badssl.com'); + await Utils.sleep(2000); + this.controller.getCertificate().then(x509CertArray => { + this.outputStr = ParseX509CertInfo(x509CertArray); + }) + } catch (error) { + this.outputStr = 'getCertificate failed: ' + error.code + ", errMsg: " + error.message; + } + console.log("getCertificate result of this page: " + this.outputStr); + if ((this.outputStr).includes("failed")) { + this.certificateResult = false + } + else { + this.certificateResult = true + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.certificateResult, 404) + }) + break; + } + } + }) + } + Web({ src:'https://expired.badssl.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onPageEnd((e) => { + this.outputStr = 'onPageEnd : url = ' + e.url + }) + .onSslErrorEventReceive((e) => { + e.handler.handleConfirm() + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVoke.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVoke.ets new file mode 100644 index 0000000000000000000000000000000000000000..92e6402ce1fee4d9e87a3082478b85e1af9598f8 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVoke.ets @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewInVoke { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitAllowAndRetainAllTrue"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State geolocationAccess:boolean=true; + @State invokeAllow:boolean=true; + @State invokeRetain:boolean=true; + @State checkEleResult:string=""; + origin: string = "file:///"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewInVoke page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("invokeTest").key('webViewInVoke').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitAllowAndRetainAllTrue": { + try { + this.controller.loadUrl($rawfile('geo.html')); + await Utils.sleep(1000); + web_webview.GeolocationPermissions.allowGeolocation(this.origin); + this.invokeAllow = true; + this.invokeRetain = true; + web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => { + if (error) { + console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error)); + return; + } + console.log('getAccessibleGeolocationAsync result: ' + result); + }); + this.controller.runJavaScript("getGeoResult()",(error, result) => { + this.checkEleResult = result; + console.log(`The getGeoResult() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 350) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .geolocationAccess(this.geolocationAccess) + .onGeolocationShow((event) => { + event.geolocation.invoke(event.origin, this.invokeAllow, this.invokeRetain) + console.log("webViewInVoke : onGeolocationShow : " + event.origin + this.invokeAllow, this.invokeRetain); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVokeFalse.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVokeFalse.ets new file mode 100644 index 0000000000000000000000000000000000000000..75e3438b7ff58459efae1a0aee25e43f0b4fdf7f --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewInVokeFalse.ets @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewInVokeFalse { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitAllowAndRetainAllFalse"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State geolocationAccess:boolean=true; + @State invokeAllow:boolean=false; + @State invokeRetain:boolean=false; + @State checkEleResult:string=""; + origin: string = "file:///"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewInVokeFalse page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("invokeTest").key('webViewInVokeFalse').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitAllowAndRetainAllFalse": { + try { + this.controller.loadUrl($rawfile('geo.html')); + await Utils.sleep(1000); + web_webview.GeolocationPermissions.deleteGeolocation(this.origin); + this.invokeAllow = false; + this.invokeRetain = false; + web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => { + if (error) { + console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error)); + return; + } + console.log('getAccessibleGeolocationAsync result: ' + result); + }); + this.controller.runJavaScript("getGeoResult()",(error, result) => { + this.checkEleResult = result; + console.log(`The getGeoResult() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkEleResult, 352) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .geolocationAccess(this.geolocationAccess) + .onGeolocationShow((event) => { + event.geolocation.invoke(event.origin, this.invokeAllow, this.invokeRetain) + console.log("webViewInVoke : onGeolocationShow : " + event.origin + this.invokeAllow, this.invokeRetain); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewMediaOption.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewMediaOption.ets new file mode 100644 index 0000000000000000000000000000000000000000..0190a64b7a45cc3c4d1e74fb2f01858891f9aa22 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewMediaOption.ets @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewMediaOption { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + controllerTwo: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitMediaOptionTrue"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State playing: boolean = false + @State checkResult:string=""; + @State checkResultTwo:string=""; + @State firstId:number= 415; + @State options: WebMediaOptions = {resumeInterval: 2, audioExclusive: true} + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewMediaOption page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("mediaOptionTest").key('webViewMediaOption').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitMediaOptionTrue": { + try { + await Utils.sleep(3000); + this.controller.requestFocus(); + this.controller.runJavaScript("play()",(error, result) => { + console.log(`The controller.play() return value is: ${result}`); + }) + this.controllerTwo.requestFocus(); + this.controllerTwo.runJavaScript("play()",(error, result) => { + console.log(`The controllerTwo.play() return value is: ${result}`); + }) + await Utils.sleep(3000); + this.controller.runJavaScript("checkState()",(error, result) => { + this.checkResult = result + console.log(`The controller.checkState() return value is: ${result}`); + }) + this.controllerTwo.runJavaScript("checkState()",(error, result) => { + this.checkResultTwo = result + console.log(`The controllerTwo.checkState() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent((this.checkResult == this.checkResultTwo), this.firstId) + }) + break; + } + } + }) + } + Web({ src:$rawfile('videoTest.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .mediaOptions(this.options) + .onAudioStateChanged(event => { + this.playing = event.playing + console.log('onAudioStateChanged playing: ' + this.playing + this.firstId); + }) + Web({src:$rawfile('videoTest.html'),controller:this.controllerTwo}).id('2').key('web2') + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .mediaOptions(this.options) + .onAudioStateChanged(event => { + this.playing = event.playing + console.log('onAudioStateChangedTwo playing: ' + this.playing + this.firstId); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceive.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceive.ets new file mode 100644 index 0000000000000000000000000000000000000000..13c06ebba2bfebaa7b7553dae59ea257c8df9e48 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceive.ets @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewONHttpErrorReceive { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnHttpErrorReceiveFixedUserAgent"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State title:string = "test"; + @State requestKey:string = ""; + @State requestValue:string = ""; + @State responseKey:string = ""; + @State responseValue:string = ""; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorReceive page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorReceive').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorReceiveFixedUserAgent": { + try { + this.controller.loadUrl("http://1.1.1.123/index.html"); + await Utils.sleep(2000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 390) + }) + break; + } + } + }) + } + Web({ src:'http://1.1.1.123/index.html', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + Utils.emitEvent(event.request.getRequestUrl(), 362); + console.log('isMainFrame:' + event.request.isMainFrame()); + Utils.emitEvent(event.request.isMainFrame(), 364); + console.log('isRedirect:' + event.request.isRedirect()); + Utils.emitEvent(event.request.isRedirect(), 366); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + Utils.emitEvent(event.request.isRequestGesture(), 368); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + Utils.emitEvent(event.request.getRequestMethod(), 370); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + Utils.emitEvent(JSON.stringify(event.response.getResponseData()), 372); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + Utils.emitEvent(event.response.getResponseEncoding(), 374); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + Utils.emitEvent(event.response.getResponseMimeType(), 376); + console.log('getResponseCode:' + event.response.getResponseCode()); + Utils.emitEvent(event.response.getResponseCode(), 378); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + Utils.emitEvent(event.response.getReasonMessage(), 380); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + this.requestKey = i.headerKey; + this.requestValue = i.headerValue; + } + console.log('The request header last result is ' + this.requestKey + this.requestValue); + Utils.emitEvent(this.requestKey, 382); + Utils.emitEvent(this.requestValue, 384); + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + this.responseKey = i.headerKey; + this.responseValue = i.headerValue; + } + console.log('The response header last result is ' + this.responseKey + this.responseValue); + Utils.emitEvent(this.responseKey, 386); + Utils.emitEvent(this.responseValue, 388); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveExample.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e34b7a3cc5ff46655fc6b5d9e6d6586a016f293 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveExample.ets @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewONHttpErrorReceiveExample { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + @State str:string="emitOnHttpErrorReceiveByExample"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorReceiveExample page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorReceiveExample').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorReceiveByExample": { + try { + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 392) + }) + break; + } + } + }) + } + Web({ src:'http://1.1.1.123/index.html', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseData(this.webdata) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + this.responseweb.setResponseIsReady(true) + return this.responseweb + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveIframe.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveIframe.ets new file mode 100644 index 0000000000000000000000000000000000000000..6061ca7ce64234c9878aaba0f56cd09066ccaf2f --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveIframe.ets @@ -0,0 +1,109 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewONHttpErrorReceiveIframe { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnHttpErrorReceiveByIframeHtml"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorReceiveIframe page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorReceiveIframe').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorReceiveByIframeHtml": { + try { + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 398) + }) + break; + } + } + }) + } + Web({ src:$rawfile('indexSix.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + Utils.emitEvent(event.request.isMainFrame(), 396); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveNumber.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveNumber.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3f56f9ba2f81369437d59618fc449ebcee7b874 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveNumber.ets @@ -0,0 +1,155 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; +import fs from '@ohos.file.fs'; +import fileio from '@ohos.fileio'; + +@Entry +@Component +struct webViewONHttpErrorReceiveNumber { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State str:string="emitOnHttpErrorReceiveByNumber"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State title:string = "test"; + @State webFilename:string=' '; + @State cachedir:string ='/data/storage/el2/base/cache' + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorReceiveNumber page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorReceiveNumber').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorReceiveByNumber": { + try { + this.controller.storeWebArchive("/data/storage/el2/base/test.html", false, (error, filename) => { + if (error) { + console.info(`save web archive error: ` + JSON.stringify(error)) + return; + } + if (filename != null) { + console.info(`save web archive success: ${filename}`) + this.webFilename = filename + } + }); + if(fs.accessSync(this.cachedir + "test.html")){ + try { + let fd = fileio.openSync(this.cachedir + 'test.html', 0o102, 0o666) + this.responseweb.setResponseData(fd) + this.responseweb.setResponseIsReady(true) + } catch(error) { + console.error('failed') + } + } + this.controller.refresh(); + await Utils.sleep(1000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 402) + }) + break; + } + } + }) + } + Web({ src:'http://1.1.1.123/index.html', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + return this.responseweb + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + Utils.emitEvent(event.response.getResponseCode(), 401); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveString.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveString.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c91178c952908721ae370e3a7a86c9279d51271 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorReceiveString.ets @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewONHttpErrorReceiveString { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State webdata: string = "onHttpErrorReceiveTest" + @State str:string="emitOnHttpErrorReceiveByString"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State searchString: string = "onHttpErrorReceive"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorReceiveString page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorReceiveString').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorReceiveByString": { + try { + this.controller.searchAllAsync(this.searchString); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:'http://1.1.1.123/index.html', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseData(this.webdata) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + this.responseweb.setResponseIsReady(true) + return this.responseweb + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + Utils.emitEvent(event.response.getResponseCode(), 399); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + .onSearchResultReceive(ret => { + console.log("on search result receive:" + "[cur]" + ret.activeMatchOrdinal + + "[total]" + ret.numberOfMatches + "[isDone]" + ret.isDoneCounting); + Utils.emitEvent(ret.numberOfMatches, 400) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorRecvExampleIsReady.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorRecvExampleIsReady.ets new file mode 100644 index 0000000000000000000000000000000000000000..929b55e87e7aecabe92cd2802a4122797378bb08 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewONHttpErrorRecvExampleIsReady.ets @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewONHttpErrorRecvExampleIsReady { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + @State str:string="emitOnHttpErrorRecvExampleIsReadyFalse"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State title:string = ""; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewONHttpErrorRecvExampleIsReady page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("onHttpErrorTest").key('webViewONHttpErrorRecvExampleIsReady').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnHttpErrorRecvExampleIsReadyFalse": { + try { + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 394) + }) + break; + } + } + }) + } + Web({ src:'http://1.1.1.123/index.html', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseData(this.webdata) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + this.responseweb.setResponseIsReady(false) + return this.responseweb + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestMethod:' + event.request.getRequestMethod()); + console.log('getResponseData:' + JSON.stringify(event.response.getResponseData())); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnAudioStateChanged.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnAudioStateChanged.ets new file mode 100644 index 0000000000000000000000000000000000000000..8432141de193af77614f6835a3c7cf82bc785df0 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnAudioStateChanged.ets @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnAudioStateChanged { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitAudioStatePlay"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State playing: boolean = false + @State checkResult:string=""; + @State firstId:number= 411; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnAudioStateChanged page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("audioStateTest").key('webViewOnAudioStateChanged').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitAudioStatePlay": { + try { + this.controller.requestFocus(); + this.controller.runJavaScript("play()",(error, result) => { + this.checkResult = result + console.log(`The controller.play() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkResult, 412) + }) + break; + } + case "emitAudioStatePause": { + try { + this.controller.requestFocus(); + this.firstId = 413; + this.controller.runJavaScript("pause()",(error, result) => { + this.checkResult = result + console.log(`The controller.pause() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.checkResult, 414) + }) + break; + } + } + }) + } + Web({ src:$rawfile('audioTest.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onAudioStateChanged(event => { + this.playing = event.playing + console.log('onAudioStateChanged playing: ' + this.playing + this.firstId); + Utils.emitEvent(this.playing, this.firstId) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnBeforeUnload.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnBeforeUnload.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae2c209c8b466612e0a7c26799c59c8960e1cabe --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnBeforeUnload.ets @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnBeforeUnload { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnBeforeUnload"; + @State firstId:number=302; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnBeforeUnload page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnBeforeUnload').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnBeforeUnload": { + try { + this.controller.loadUrl($rawfile('onBeforeUnloadTest.html')) + await Utils.sleep(1000); + console.log("action of emitOnBeforeUnload is refresh"); + this.controller.runJavaScript("myRefresh()",(error, result) => { + console.log(`The myRefresh() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + case "emitOnBeforeUnloadAgain": { + try { + this.firstId = 304; + this.controller.requestFocus(); + this.controller.refresh(); + await Utils.sleep(1000); + console.log("action of emitOnBeforeUnloadAgain is loadUrl new"); + this.controller.runJavaScript("myNewPage()",(error, result) => { + console.log(`The myNewPage() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:$rawfile('onBeforeUnloadTest.html'), controller: this.controller }) + .key("TestwebViewOnBeforeUnload") + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onBeforeUnload((event) => { + console.log("event.url:" + event.url) + console.log("event.message:" + event.message) + Utils.emitEvent(event.message, this.firstId) + console.log("event.result.handleCancel: " + event.result.handleCancel()); + console.log("event.result.handleConfirm: " + event.result.handleConfirm()); + return true + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstCont.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstCont.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b02ae158922f50861c15bbf82a018d6789aeee8 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstCont.ets @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFirstCont { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnfirstcontentfulpaint"; + @State firstId:number=322; + @State firstcontentfulpaint:string='NoSrcTest'; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFirstCont page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFirstCont').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnfirstcontentfulpaint": { + try { + this.controller.refresh(); + console.log("action of emitOnfirstcontentfulpaint is refresh"); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + Utils.emitEvent(this.firstcontentfulpaint, this.firstId) + break; + } + } + }) + } + Web({ src:'', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFirstContentfulPaint(event => { + console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" + + event.navigationStartTick + ", [firstContentfulPaintMs]:" + event.firstContentfulPaintMs) + this.firstcontentfulpaint = JSON.stringify(event) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContFour.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContFour.ets new file mode 100644 index 0000000000000000000000000000000000000000..575d00ba81b114a4cd30d2baaba62ab91bf03087 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContFour.ets @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFirstContFour { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitRefreshOnfirstcontentfulpaint"; + @State firstId:number=328; + @State firstcontentfulpaint:boolean=false; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State firstBoo:boolean=false; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFirstContFour page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFirstContFour').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitRefreshOnfirstcontentfulpaint": { + try { + this.controller.refresh(); + this.firstBoo = true + console.log("action of emitRefreshOnfirstcontentfulpaint is refresh"); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFirstContentfulPaint(event => { + console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" + + event.navigationStartTick + ", [firstContentfulPaintMs]:" + event.firstContentfulPaintMs + this.firstId) + if (event.firstContentfulPaintMs > 0 && event.firstContentfulPaintMs < 5000) { + this.firstcontentfulpaint = true; + console.error("result of onFirstContentfulPaint is: "+ this.firstcontentfulpaint + this.firstId); + } + }) + .onPageEnd((event) => { + console.log('url' + event.url + this.firstcontentfulpaint + this.firstId); + if (this.firstBoo) { + Utils.emitEvent(this.firstcontentfulpaint, this.firstId) + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContThree.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContThree.ets new file mode 100644 index 0000000000000000000000000000000000000000..21adbfdb7cd82e07532d198b26ba03982d426b04 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContThree.ets @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFirstContThree { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitLoadUrlOnfirstcontentfulpaint"; + @State firstId:number=326; + @State firstcontentfulpaint:boolean=false; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFirstContThree page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFirstContThree').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitLoadUrlOnfirstcontentfulpaint": { + try { + this.controller.loadUrl($rawfile('onfirstcontentfulpaint.html')) + console.log("action of emitLoadUrlOnfirstcontentfulpaint is loadUrl"); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + Utils.emitEvent(this.firstcontentfulpaint, this.firstId) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFirstContentfulPaint(event => { + console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" + + event.navigationStartTick + ", [firstContentfulPaintMs]:" + event.firstContentfulPaintMs + this.firstId) + if (event.firstContentfulPaintMs > 0 && event.firstContentfulPaintMs < 5000) { + this.firstcontentfulpaint = true; + console.error("result of onFirstContentfulPaint is: "+ this.firstcontentfulpaint + this.firstId); + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContTwo.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8fddf6bf0685a54c6871e87cf7e5ed2add5aab3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFirstContTwo.ets @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFirstContTwo { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitNoneOnfirstcontentfulpaint"; + @State firstId:number=324; + @State firstcontentfulpaint:string='VisibilityNoneTest'; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State webVisibility: Visibility = Visibility.None + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFirstContTwo page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFirstContTwo').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitNoneOnfirstcontentfulpaint": { + try { + this.controller.refresh(); + console.log("action of emitNoneOnfirstcontentfulpaint is refresh"); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + Utils.emitEvent(this.firstcontentfulpaint, this.firstId) + break; + } + } + }) + } + Web({ src:$rawfile('indexCopy.html'), controller: this.controller }) + .visibility(this.webVisibility) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFirstContentfulPaint(event => { + console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" + + event.navigationStartTick + ", [firstContentfulPaintMs]:" + event.firstContentfulPaintMs) + this.firstcontentfulpaint = JSON.stringify(event) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenEnter.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenEnter.ets new file mode 100644 index 0000000000000000000000000000000000000000..b50e4c01735c187a66f3815180726ef3c30e1561 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenEnter.ets @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFullScreenEnter { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + handler: FullScreenExitHandler = null + @State str:string="emitOnfullscreenenter"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State checkEleResult:string=""; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFullScreenEnter page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFullScreenEnter').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnfullscreenenter": { + try { + this.controller.runJavaScript("elementFullScreen()",(error, result) => { + console.log(`The elementFullScreen() return value is: ${result}`); + }) + await Utils.sleep(1000); + this.controller.runJavaScript("checkIsFullScreen()",(error, result) => { + this.checkEleResult = JSON.stringify(result) + console.log(`The checkIsFullScreen() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(JSON.stringify(this.handler).length + this.checkEleResult, 342) + }) + break; + } + } + }) + } + Web({ src:$rawfile('fullScreenTest.html'), controller: this.controller }) + .key("TestwebViewOnFullScreenEnter") + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFullScreenEnter((event) => { + console.log("onFullScreenEnter...") + this.handler = event.handler + console.log("this.handler: " + JSON.stringify(this.handler)) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenExit.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenExit.ets new file mode 100644 index 0000000000000000000000000000000000000000..20510e213c7b23a7743f0221eb4dd41a65317f4e --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnFullScreenExit.ets @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnFullScreenExit { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + handler: FullScreenExitHandler = null + @State str:string="emitOnfullscreenexit"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State checkEleResult:string=""; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnFullScreenExit page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnFullScreenExit').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnfullscreenexit": { + try { + this.controller.runJavaScript("elementFullScreen()",(error, result) => { + console.log(`The elementFullScreen() return value is: ${result}`); + }) + await Utils.sleep(1000); + this.controller.runJavaScript("elementExitFullScreen()",(error, result) => { + console.log(`The elementExitFullScreen() return value is: ${result}`); + }) + await Utils.sleep(1000); + this.controller.runJavaScript("checkIsFullScreen()",(error, result) => { + this.checkEleResult = JSON.stringify(result) + console.log(`The checkIsFullScreen() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(JSON.stringify(this.handler).length + this.checkEleResult, 344) + }) + break; + } + } + }) + } + Web({ src:$rawfile('fullScreenTest.html'), controller: this.controller }) + .key("TestwebViewOnFullScreenExit") + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onFullScreenExit(() => { + console.log("onFullScreenExit...") + console.log("this.handler: " + JSON.stringify(this.handler)) + this.handler.exitFullScreen() + }) + .onFullScreenEnter((event) => { + this.handler = event.handler + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqOne.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..6643524fb8af120875924961b01d0ee8501281d8 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqOne.ets @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnInterceptReqOne { + controller: web_webview.WebviewController = new web_webview.WebviewController() + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State str:string="emitOnInterceptRequest"; + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnInterceptReqOne page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnInterceptReqOne').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnInterceptRequest": { + try { + this.controller.loadUrl($rawfile('indexCopy.html')) + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + this.controller.runJavaScript("gettitle()",(error, result) => { + this.title = JSON.parse(result) + console.log(`The gettitle() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + Utils.emitEvent(this.title, 306) + break; + } + } + }) + } + Web({ src:$rawfile('indexCopy.html'), controller: this.controller }) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + return this.responseweb + console.log("this.responseweb: " + this.responseweb); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqThree.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqThree.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ee6f20862894d891c0341331babe64ee6023567 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqThree.ets @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnInterceptReqThree { + controller: web_webview.WebviewController = new web_webview.WebviewController() + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State str:string="emitOnInterceptRequestThird"; + @State firstId:number=310; + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnInterceptReqThree page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnInterceptReqThree').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnInterceptRequestThird": { + try { + this.controller.refresh(); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:$rawfile('indexCopy.html'), controller: this.controller }) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseData(this.webdata) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(404) + this.responseweb.setReasonMessage('OK') + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + return this.responseweb + console.log("this.responseweb: " + this.responseweb); + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()) + console.log('isMainFrame:' + event.request.isMainFrame()) + console.log('isRedirect:' + event.request.isRedirect()) + console.log('isRequestGesture:' + event.request.isRequestGesture()) + console.log('getResponseData:' + event.response.getResponseData()) + console.log('getResponseEncoding:' + event.response.getResponseEncoding()) + console.log('getResponseMimeType:' + event.response.getResponseMimeType()) + console.log('getResponseCode:' + event.response.getResponseCode()) + Utils.emitEvent(event.response.getResponseCode(), this.firstId) + console.log('getReasonMessage:' + event.response.getReasonMessage()) + let result = event.request.getRequestHeader() + console.log('The request header result size is ' + result.length) + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue) + } + let resph = event.response.getResponseHeader() + console.log('The response header result size is ' + resph.length) + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue) + } + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqTwo.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..25e339c64449aae58884b4d9af0b84698ec794d2 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnInterceptReqTwo.ets @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnInterceptReqTwo { + controller: web_webview.WebviewController = new web_webview.WebviewController() + responseweb: WebResourceResponse = new WebResourceResponse() + heads:Header[] = new Array() + @State str:string="emitOnInterceptRequestSecond"; + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnInterceptReqTwo page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnInterceptReqTwo').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnInterceptRequestSecond": { + try { + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + Utils.emitEvent(this.title, 308) + break; + } + } + }) + } + Web({ src:$rawfile('indexCopy.html'), controller: this.controller }) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()) + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1) + length = this.heads.push(head2) + this.responseweb.setResponseHeader(this.heads) + this.responseweb.setResponseData(this.webdata) + this.responseweb.setResponseEncoding('utf-8') + this.responseweb.setResponseMimeType('text/html') + this.responseweb.setResponseCode(200) + this.responseweb.setReasonMessage('OK') + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + return this.responseweb + console.log("this.responseweb: " + this.responseweb); + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a3f6dc6b733f88061bb31137dec07340cf9e073 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnScroll { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnscroll"; + @State textX:number=100; + @State textY:number=100; + @State firstId:number=312; + @State secondId:number=314; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnScroll page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnScroll').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnscroll": { + try { + this.controller.scrollBy(this.textX, this.textY); + await Utils.sleep(1000) + console.log("action of emitOnscroll is scrollBy" + this.textX + this.textY); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + case "emitOnscrollAgain": { + try { + this.firstId = 316; + this.secondId = 318; + this.textX = -100; + this.textY = -100; + this.controller.scrollBy(this.textX, this.textY); + await Utils.sleep(1000) + console.log("action of emitOnscroll is scrollBy" + this.textX + this.textY); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:$rawfile('indexFour.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onScroll((event) => { + console.info("x = " + event.xOffset + this.firstId) + Utils.emitEvent(event.xOffset, this.firstId) + console.info("y = " + event.yOffset + this.secondId) + Utils.emitEvent(event.yOffset, this.secondId) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnSslError.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnSslError.ets new file mode 100644 index 0000000000000000000000000000000000000000..aeff3f1d83e10e6520059ea5a6ccd06870fba2b3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnSslError.ets @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewOnSslError { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitOnsslerroreventreceive"; + @State firstId:number=320; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State sslerrorText:string="no call error" + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewOnSslError page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("web click").key('webViewOnSslError').onClick(async () => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitOnsslerroreventreceive": { + try { + this.controller.clearSslCache(); + await Utils.sleep(2000) + this.controller.loadUrl("https://wrong.host.badssl.com"); + console.log("action of emitOnsslerroreventreceive is loadUrl"); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + break; + } + } + }) + } + Web({ src:'https://wrong.host.badssl.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + .onSslErrorEventReceive((event) => { + console.log("event result is :" + JSON.stringify(event.handler) + event.error); + this.sslerrorText = JSON.stringify(event.error) + Utils.emitEvent(this.sslerrorText, this.firstId) + return true + }) + .onErrorReceive((event) => { + console.log('getErrorInfo:' + event.error.getErrorInfo()) + console.log('getErrorCode:' + event.error.getErrorCode()) + console.log('url:' + event.request.getRequestUrl()) + }) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetAudioMuted.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetAudioMuted.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9a1ec338596def8f9d8b14d6c1fa616c7ad50f3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetAudioMuted.ets @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewSetAudioMuted { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitSetAudioMuted"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; + @State mutedResult:string="false"; + @State checkResult:string=""; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewSetAudioMuted page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("setMutedTest").key('webViewSetAudioMuted').onClick(() => { + console.info("key==>" + this.str) + switch (this.str) { + case "emitSetAudioMuted": { + try { + this.controller.runJavaScript("enableMute()",(error, result) => { + this.mutedResult = result + console.log(`The controller.enableMute() return value is: ${result}`); + }) + this.controller.runJavaScript("checkMute()",(error, result) => { + this.checkResult = result + console.log(`The controller.checkMute() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.mutedResult, 405) + Utils.emitEvent(this.checkResult, 406) + }) + break; + } + case "emitSetAudioDisMuted": { + try { + this.controller.runJavaScript("disableMute()",(error, result) => { + this.mutedResult = result + console.log(`The controller.disableMute() return value is: ${result}`); + }) + this.controller.runJavaScript("checkMute()",(error, result) => { + this.checkResult = result + console.log(`The controller.checkMute() return value is: ${result}`); + }) + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.mutedResult, 407) + Utils.emitEvent(this.checkResult, 408) + }) + break; + } + } + }) + } + Web({ src:$rawfile('audioTest.html'), controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetHttpDns.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetHttpDns.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc0ec352223ed0acc6f42a3a15c73ee9f4a3a9b0 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewSetHttpDns.ets @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; + +@Entry +@Component +struct webViewSetHttpDns { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + @State str:string="emitSetHttpDnsSecureOnlyExample"; + @State javaScriptAccess:boolean=true; + @State fileAccess:boolean=true; + @State domStorageAccess:boolean=false; + @State imageAccess:boolean=true; + @State onlineImageAccess:boolean=true; + @State databaseAccess:boolean=true; + @State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + + " CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"; + @State title:string = "test"; + + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("webViewSetHttpDns page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + + build() { + Column() { + Row() { + Button("sethttpdnsTest").key('webViewSetHttpDns').onClick(async () => { + console.info("key==>" + this.str) + web_webview.WebviewController.initializeWebEngine() + switch (this.str) { + case "emitSetHttpDnsSecureOnlyExample": { + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.SecureOnly, "https://example1.test") + await Utils.sleep(1000); + this.controller.loadUrl("https://www.baidu.com/"); + await Utils.sleep(5000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 354) + }) + break; + } + case "emitSetHttpDnsSecureOnlyUserDefine": { + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.SecureOnly, "https://httpdns-browser.platform.dbankcloud.cn/dns-query{?dns}") + await Utils.sleep(2000); + this.controller.refresh(); + this.controller.loadUrl("https://weibo.com/"); + await Utils.sleep(10000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 356) + }) + break; + } + case "emitSetHttpDnsAutoExample": { + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Auto, "https://example1.test") + await Utils.sleep(1000); + this.controller.loadUrl("https://www.huawei.com/cn/"); + await Utils.sleep(6000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 358) + }) + break; + } + case "emitSetHttpDnsOffExample": { + try { + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Off, "https://example1.test") + await Utils.sleep(1000); + this.controller.loadUrl("https://www.openharmony.cn/mainPlay"); + await Utils.sleep(5000); + this.title = this.controller.getTitle(); + console.log("title of this page: " + this.title); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + this.controller.runJavaScript("test()",(res) => { + Utils.emitEvent(this.title, 360) + }) + break; + } + } + }) + } + Web({ src:'www.example.com', controller: this.controller }) + .javaScriptAccess(this.javaScriptAccess) + .fileAccess(this.fileAccess) + .imageAccess(this.imageAccess) + .domStorageAccess(this.domStorageAccess) + .onlineImageAccess(this.onlineImageAccess) + .databaseAccess(this.databaseAccess) + .userAgent(this.userAgent) + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets index ee35d14b9defbd92566ef95bd7748037b8cd39ee..c5544d726d8ead322363b25cc79caba15d2005e9 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets @@ -20,6 +20,41 @@ import webViewHasImageJsunit from './webViewHasImageJsunit.test' import webViewSrollToJsunit from './webViewSrollToJsunit.test' import webViewSrollByJsunit from './webViewSrollByJsunit.test' import WebViewWebStorageJsunit from './WebViewWebStorageJsunit.test' +import runJavaScript from './runJavaScript.test' +import storeWebArchive from './storeWebArchive.test' +import storeWebArchiveSaveFail from './storeWebArchiveSaveFail.test' +import webViewOnBeforeUnload from './webViewOnBeforeUnload.test' +import webViewOnInterceptReqOne from './webViewOnInterceptReqOne.test' +import webViewOnInterceptReqTwo from './webViewOnInterceptReqTwo.test' +import webViewOnInterceptReqThree from './webViewOnInterceptReqThree.test' +import webViewOnScroll from './webViewOnScroll.test' +import webViewOnSslError from './webViewOnSslError.test' +import webViewOnFirstCont from './webViewOnFirstCont.test' +import webViewOnFirstContTwo from './webViewOnFirstContTwo.test' +import webViewOnFirstContThree from './webViewOnFirstContThree.test' +import webViewOnFirstContFour from './webViewOnFirstContFour.test' +import webViewDefaultFontSizeWithMinLogical from './webViewDefaultFontSizeWithMinLogical.test' +import webViewDefaultFontSize from './webViewDefaultFontSize.test' +import webViewDefaultFontSizeNoMinFontSize from './webViewDefaultFontSizeNoMinFontSize.test' +import webViewDefaultFontSizeNoAll from './webViewDefaultFontSizeNoAll.test' +import webViewOnFullScreenEnter from './webViewOnFullScreenEnter.test' +import webViewOnFullScreenExit from './webViewOnFullScreenExit.test' +import webViewExistCookie from './webViewExistCookie.test' +import webViewDeleteEntireCookie from './webViewDeleteEntireCookie.test' +import webViewInVokeFalse from './webViewInVokeFalse.test' +import webViewInVoke from './webViewInVoke.test' +import webViewSetHttpDns from './webViewSetHttpDns.test' +import webViewONHttpErrorReceive from './webViewONHttpErrorReceive.test' +import webViewONHttpErrorReceiveExample from './webViewONHttpErrorReceiveExample.test' +import webViewONHttpErrorRecvExampleIsReady from './webViewONHttpErrorRecvExampleIsReady.test' +import webViewONHttpErrorReceiveIframe from './webViewONHttpErrorReceiveIframe.test' +import webViewONHttpErrorReceiveString from './webViewONHttpErrorReceiveString.test' +import webViewONHttpErrorReceiveNumber from './webViewONHttpErrorReceiveNumber.test' +import webViewGetCertificate from './webViewGetCertificate.test' +import webViewSetAudioMuted from './webViewSetAudioMuted.test' +import webViewGetAccessibleGeolocation from './webViewGetAccessibleGeolocation.test' +import webViewOnAudioStateChanged from './webViewOnAudioStateChanged.test' +import webViewMediaOption from './webViewMediaOption.test' export default function testsuite() { webViewControllerJsunit() webViewOnWindowNewJsunit() @@ -29,4 +64,39 @@ export default function testsuite() { webViewSrollToJsunit() webViewSrollByJsunit() WebViewWebStorageJsunit() + runJavaScript() + storeWebArchive() + storeWebArchiveSaveFail() + //webViewOnBeforeUnload() + webViewOnInterceptReqOne() + webViewOnInterceptReqTwo() + webViewOnInterceptReqThree() + webViewOnScroll() + webViewOnSslError() + webViewOnFirstCont() + webViewOnFirstContTwo() + webViewOnFirstContThree() + webViewOnFirstContFour() + webViewDefaultFontSizeWithMinLogical() + webViewDefaultFontSize() + webViewDefaultFontSizeNoMinFontSize() + webViewDefaultFontSizeNoAll() + //webViewOnFullScreenEnter() + //webViewOnFullScreenExit() + webViewExistCookie() + webViewDeleteEntireCookie() + webViewInVokeFalse() + webViewInVoke() + webViewSetHttpDns() + webViewONHttpErrorReceive() + webViewONHttpErrorReceiveExample() + webViewONHttpErrorRecvExampleIsReady() + webViewONHttpErrorReceiveIframe() + webViewONHttpErrorReceiveString() + webViewONHttpErrorReceiveNumber() + webViewGetCertificate() + webViewSetAudioMuted() + webViewGetAccessibleGeolocation() + //webViewOnAudioStateChanged() + //webViewMediaOption() } \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSize.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSize.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..99ed50f5ff1628c3c372ff88c83993e9b69de5f8 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSize.test.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitdefaultFontSize73AndminFontSize1"; +export default function webViewDefaultFontSize() { + describe('ActsAceWebDevWebViewDefaultFontSizeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewDefaultFontSize', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewDefaultFontSize state success " + JSON.stringify(pages)); + if (!("webViewDefaultFontSize" == pages.name)) { + console.info("get webViewDefaultFontSize state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewDefaultFontSize page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewDefaultFontSize page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewDefaultFontSize beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewDefaultFontSize afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0200 + *tc.name testDefaultFontSize73AndMinFontSize1 + *tc.desc test with defaultfontsize 73 and minfontsize 1 + */ + it('testDefaultFontSize73AndMinFontSize1',0,async function(done){ + emitKey="emitdefaultFontSize73AndminFontSize73"; + Utils.registerEvent("testDefaultFontSize73AndMinFontSize1","72px",332,done); + sendEventByKey('webViewDefaultFontSize',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0300 + *tc.name testDefaultFontSize73AndMinFontSize73 + *tc.desc test with defaultfontsize 73 and minfontsize 73 + */ + it('testDefaultFontSize73AndMinFontSize73',0,async function(done){ + emitKey="emitdefaultFontSize73AndminFontSize73"; + Utils.registerEvent("testDefaultFontSize73AndMinFontSize73","72px",334,done); + sendEventByKey('webViewDefaultFontSize',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoAll.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoAll.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0510e0d5f625d80772b16bd0f1acbd34e4e910c1 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoAll.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitdefaultFontSizeAndminFontSizeNoAll"; +export default function webViewDefaultFontSizeNoAll() { + describe('ActsAceWebDevWebViewDefaultFontSizeNoAllTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewDefaultFontSizeNoAll', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewDefaultFontSizeNoAll state success " + JSON.stringify(pages)); + if (!("webViewDefaultFontSizeNoAll" == pages.name)) { + console.info("get webViewDefaultFontSizeNoAll state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewDefaultFontSizeNoAll page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewDefaultFontSizeNoAll page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewDefaultFontSizeNoAll beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewDefaultFontSizeNoAll afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0600 + *tc.name testNoDefaultFontSizeAndNoMinFontSize + *tc.desc test with no set defaultfontsize or minfontsize + */ + it('testNoDefaultFontSizeAndNoMinFontSize',0,async function(done){ + emitKey="emitdefaultFontSizeAndminFontSizeNoAll"; + Utils.registerEvent("testNoDefaultFontSizeAndNoMinFontSize","16px",340,done); + sendEventByKey('webViewDefaultFontSizeNoAll',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoMinFontSize.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoMinFontSize.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..197787e44bec150ac964b1092b50e9203a420f63 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeNoMinFontSize.test.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitdefaultFontSize7AndNominFontSize"; +export default function webViewDefaultFontSizeNoMinFontSize() { + describe('ActsAceWebDevWebViewDefaultFontSizeNoMinFontSizeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewDefaultFontSizeNoMinFontSize', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewDefaultFontSizeNoMinFontSize state success " + JSON.stringify(pages)); + if (!("webViewDefaultFontSizeNoMinFontSize" == pages.name)) { + console.info("get webViewDefaultFontSizeNoMinFontSize state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewDefaultFontSizeNoMinFontSize page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewDefaultFontSizeNoMinFontSize page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewDefaultFontSizeNoMinFontSize beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewDefaultFontSizeNoMinFontSize afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0400 + *tc.name testDefaultFontSize7AndNoMinFontSize + *tc.desc test with defaultfontsize 7 and no set minfontsize + */ + it('testDefaultFontSize7AndNoMinFontSize',0,async function(done){ + emitKey="emitdefaultFontSize17AndCssFontSize9"; + Utils.registerEvent("testDefaultFontSize7AndNoMinFontSize","8px",336,done); + sendEventByKey('webViewDefaultFontSizeNoMinFontSize',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0500 + *tc.name testDefaultFontSize17AndCssFontSize9 + *tc.desc test with defaultfontsize 17 and css font-size 9 + */ + it('testDefaultFontSize17AndCssFontSize9',0,async function(done){ + emitKey="emitdefaultFontSize17AndCssFontSize9"; + Utils.registerEvent("testDefaultFontSize17AndCssFontSize9","9px",338,done); + sendEventByKey('webViewDefaultFontSizeNoMinFontSize',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeWithMinLogical.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeWithMinLogical.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f0c9092752e5334277541a6fb202f4b86c485d3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDefaultFontSizeWithMinLogical.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitdefaultFontSizeHalfAndminFontSizeHalf"; +export default function webViewDefaultFontSizeWithMinLogical() { + describe('ActsAceWebDevWebViewDefaultFontSizeWithMinLogicalTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewDefaultFontSizeWithMinLogical', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewDefaultFontSizeWithMinLogical state success " + JSON.stringify(pages)); + if (!("webViewDefaultFontSizeWithMinLogical" == pages.name)) { + console.info("get webViewDefaultFontSizeWithMinLogical state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewDefaultFontSizeWithMinLogical page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewDefaultFontSizeWithMinLogical page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewDefaultFontSizeWithMinLogical beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewDefaultFontSizeWithMinLogical afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR6_API_0100 + *tc.name testDefaultFontSizeHalfAndMinFontSizeHalf + *tc.desc test with defaultfontsize 0.5 , minfontsize 0.5 and minLogicalFontSize 0.5 + */ + it('testDefaultFontSizeHalfAndMinFontSizeHalf',0,async function(done){ + emitKey="emitdefaultFontSizeHalfAndminFontSizeHalf"; + Utils.registerEvent("testDefaultFontSizeHalfAndMinFontSizeHalf","1px",330,done); + sendEventByKey('webViewDefaultFontSizeWithMinLogical',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDeleteEntireCookie.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDeleteEntireCookie.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f378e27852c94133407ee50fefe96e5c652d46c4 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewDeleteEntireCookie.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitDeleteEntireCookie"; +export default function webViewDeleteEntireCookie() { + describe('ActsAceWebDevWebViewDeleteEntireCookieTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewDeleteEntireCookie', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewDeleteEntireCookie state success " + JSON.stringify(pages)); + if (!("webViewDeleteEntireCookie" == pages.name)) { + console.info("get webViewDeleteEntireCookie state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewDeleteEntireCookie page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewDeleteEntireCookie page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewDeleteEntireCookie beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewDeleteEntireCookie afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWCOOKIE_API_0200 + *tc.name testDeleteEntireCookie + *tc.desc test interface of existCookie after deleteentirecookie + */ + it('testDeleteEntireCookie',0,async function(done){ + emitKey="emitDeleteEntireCookie"; + Utils.registerEvent("testDeleteEntireCookie",false,348,done); + sendEventByKey('webViewDeleteEntireCookie',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewExistCookie.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewExistCookie.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..be94adcf7676f1749e402ab1a7eed097e6c17b1c --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewExistCookie.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitExistCookie"; +export default function webViewExistCookie() { + describe('ActsAceWebDevWebViewExistCookieTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewExistCookie', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewExistCookie state success " + JSON.stringify(pages)); + if (!("webViewExistCookie" == pages.name)) { + console.info("get webViewExistCookie state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewExistCookie page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewExistCookie page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewExistCookie beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewExistCookie afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWCOOKIE_API_0100 + *tc.name testExistCookie + *tc.desc test interface of existCookie after setcookie + */ + it('testExistCookie',0,async function(done){ + emitKey="emitExistCookie"; + Utils.registerEvent("testExistCookie",true,346,done); + sendEventByKey('webViewExistCookie',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetAccessibleGeolocation.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetAccessibleGeolocation.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3808313901f7e00cdd0038a4bc494ac28efbced --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetAccessibleGeolocation.test.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitGetAccessAllowAndRetainAllFalse"; +export default function webViewGetAccessibleGeolocation() { + describe('ActsAceWebDevWebViewGetAccessibleGeolocationTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewGetAccessibleGeolocation', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewGetAccessibleGeolocation state success " + JSON.stringify(pages)); + if (!("webViewGetAccessibleGeolocation" == pages.name)) { + console.info("get webViewGetAccessibleGeolocation state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewGetAccessibleGeolocation page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewGetAccessibleGeolocation page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewGetAccessibleGeolocation beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewGetAccessibleGeolocation afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWGETACCGEO_API_0100 + *tc.name testGetAccessibleGeolocationFalse + *tc.desc test interface of getaccessiblegeolocation with allow and retain all False + */ + it('testGetAccessibleGeolocationFalse',0,async function(done){ + emitKey="emitGetAccessAllowAndRetainAllTrue"; + Utils.registerEvent("testGetAccessibleGeolocationFalse",false,409,done); + sendEventByKey('webViewGetAccessibleGeolocation',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWGETACCGEO_API_0200 + *tc.name testGetAccessibleGeolocationTrue + *tc.desc test interface of getaccessiblegeolocation with allow and retain all true + */ + it('testGetAccessibleGeolocationTrue',0,async function(done){ + emitKey="emitGetAccessAllowAndRetainAllTrue"; + Utils.registerEvent("testGetAccessibleGeolocationTrue",true,410,done); + sendEventByKey('webViewGetAccessibleGeolocation',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetCertificate.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetCertificate.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..698e9a83b67ed5ed9c300b47ffb22489bc0edbc3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewGetCertificate.test.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitGetCertificateCallback"; +export default function webViewGetCertificate() { + describe('ActsAceWebDevWebViewGetCertificateTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewGetCertificate', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewGetCertificate state success " + JSON.stringify(pages)); + if (!("webViewGetCertificate" == pages.name)) { + console.info("get webViewGetCertificate state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewGetCertificate page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewGetCertificate page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewGetCertificate beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewGetCertificate afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWCERTIFICATE_API_0100 + *tc.name testGetCertificateCallback + *tc.desc test interface of getCertificate with callback + */ + it('testGetCertificateCallback',0,async function(done){ + emitKey="emitGetCertificatePromise"; + Utils.registerEvent("testGetCertificateCallback",true,403,done); + sendEventByKey('webViewGetCertificate',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWCERTIFICATE_API_0200 + *tc.name testGetCertificatePromise + *tc.desc test interface of getCertificate with promise + */ + it('testGetCertificatePromise',0,async function(done){ + emitKey="emitGetCertificatePromise"; + Utils.registerEvent("testGetCertificatePromise",true,404,done); + sendEventByKey('webViewGetCertificate',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVoke.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVoke.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..25c90255ffb50464126b0d80625cebe3fe090631 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVoke.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitAllowAndRetainAllTrue"; +export default function webViewInVoke() { + describe('ActsAceWebDevWebViewInVokeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewInVoke', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewInVoke state success " + JSON.stringify(pages)); + if (!("webViewInVoke" == pages.name)) { + console.info("get webViewInVoke state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewInVoke page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewInVoke page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewInVoke beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewInVoke afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWINVOKE_API_0200 + *tc.name testInvokeAllowAndRetainAllTrue + *tc.desc test interface of invoke with parameter allow and retain all true + */ + it('testInvokeAllowAndRetainAllTrue',0,async function(done){ + emitKey="emitAllowAndRetainAllTrue"; + Utils.registerEvent("testInvokeAllowAndRetainAllTrue","\"获å–ä¸åˆ°ä½ç½®ä¿¡æ¯\"",350,done); + sendEventByKey('webViewInVoke',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVokeFalse.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVokeFalse.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2faf4ebc65439e8f7638537ae64668fa341c57e --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewInVokeFalse.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitAllowAndRetainAllFalse"; +export default function webViewInVokeFalse() { + describe('ActsAceWebDevWebViewInVokeFalseTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewInVokeFalse', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewInVokeFalse state success " + JSON.stringify(pages)); + if (!("webViewInVokeFalse" == pages.name)) { + console.info("get webViewInVokeFalse state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewInVokeFalse page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewInVokeFalse page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewInVokeFalse beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewInVokeFalse afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWINVOKE_API_0100 + *tc.name testInvokeAllowAndRetainAllFalse + *tc.desc test interface of invoke with parameter allow and retain all false + */ + it('testInvokeAllowAndRetainAllFalse',0,async function(done){ + emitKey="emitAllowAndRetainAllFalse"; + Utils.registerEvent("testInvokeAllowAndRetainAllFalse","\"ä½ç½®æœåŠ¡è¢«æ‹’ç»\"",352,done); + sendEventByKey('webViewInVokeFalse',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewMediaOption.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewMediaOption.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7f21f547d5190c3912bd1155018dcbf57607682 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewMediaOption.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitMediaOptionTrue"; +export default function webViewMediaOption() { + describe('ActsAceWebDevWebViewMediaOptionTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewMediaOption', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewMediaOption state success " + JSON.stringify(pages)); + if (!("webViewMediaOption" == pages.name)) { + console.info("get webViewMediaOption state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewMediaOption page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewMediaOption page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewMediaOption beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewMediaOption afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWMEDIAOP_API_0100 + *tc.name testMediaOption + *tc.desc test interface of mediaoption with true + */ + it('testMediaOption',0,async function(done){ + emitKey="emitMediaOptionTrue"; + Utils.registerEvent("testMediaOption",false,415,done); + sendEventByKey('webViewMediaOption',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceive.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceive.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac8c2b0958755aeedd131f44762702d0e21fc7fc --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceive.test.ets @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorReceiveFixedUserAgent"; +export default function webViewONHttpErrorReceive() { + describe('ActsAceWebDevWebViewONHttpErrorReceiveTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorReceive', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorReceive state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorReceive" == pages.name)) { + console.info("get webViewONHttpErrorReceive state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorReceive page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorReceive page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorReceive beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorReceive afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0100 + *tc.name testOnHttpErrorReceiveFixedUserAgent + *tc.desc test interface of onHttpErrorReceive with parameter fixed userAgent + */ + it('testOnHttpErrorReceiveFixedUserAgent',0,async function(done){ + emitKey="emitOnHttpErrorReceiveFixedUserAgent"; + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","http://1.1.1.123/index.html",362,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent",true,364,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent",false,366,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent",false,368,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","GET",370,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","",372,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","utf-8",374,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","text/html",376,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent",403,378,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","Forbidden",380,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","User-Agent",382,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36",384,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","User-Agent",386,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36",388,done); + Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgent","Direct IP access not allowed | Cloudflare",390,done); + sendEventByKey('webViewONHttpErrorReceive',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveExample.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveExample.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0a7e8215dbbe393823c5202ce4fabbd98769698 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveExample.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorReceiveByExample"; +export default function webViewONHttpErrorReceiveExample() { + describe('ActsAceWebDevWebViewONHttpErrorReceiveExampleTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorReceiveExample', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorReceiveExample state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorReceiveExample" == pages.name)) { + console.info("get webViewONHttpErrorReceiveExample state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorReceiveExample page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorReceiveExample page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorReceiveExample beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorReceiveExample afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0200 + *tc.name testOnHttpErrorReceiveByExample + *tc.desc test interface of onHttpErrorReceive with parameter used by example + */ + it('testOnHttpErrorReceiveByExample',0,async function(done){ + emitKey="emitOnHttpErrorReceiveByExample"; + Utils.registerEvent("testOnHttpErrorReceiveByExample","intercept test",392,done); + sendEventByKey('webViewONHttpErrorReceiveExample',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveIframe.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveIframe.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2371cbeb7a7fb18d00d74b1ec433f04d9af8dd7 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveIframe.test.ets @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorReceiveByIframeHtml"; +export default function webViewONHttpErrorReceiveIframe() { + describe('ActsAceWebDevWebViewONHttpErrorReceiveIframeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorReceiveIframe', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorReceiveIframe state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorReceiveIframe" == pages.name)) { + console.info("get webViewONHttpErrorReceiveIframe state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorReceiveIframe page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorReceiveIframe page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorReceiveIframe beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorReceiveIframe afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0400 + *tc.name testOnHttpErrorReceiveByIframeHtml + *tc.desc test interface of onHttpErrorReceive with parameter used by html file with iframe + */ + it('testOnHttpErrorReceiveByIframeHtml',0,async function(done){ + emitKey="emitOnHttpErrorReceiveByIframeHtml"; + Utils.registerEvent("testOnHttpErrorReceiveByIframeHtml",false,396,done); + Utils.registerEvent("testOnHttpErrorReceiveByIframeHtml","index",398,done); + sendEventByKey('webViewONHttpErrorReceiveIframe',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveNumber.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveNumber.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..38f5c463a242856b01652bbf0f634c86c87390b4 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveNumber.test.ets @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorReceiveByNumber"; +export default function webViewONHttpErrorReceiveNumber() { + describe('ActsAceWebDevWebViewONHttpErrorReceiveNumberTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorReceiveNumber', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorReceiveNumber state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorReceiveNumber" == pages.name)) { + console.info("get webViewONHttpErrorReceiveNumber state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorReceiveNumber page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorReceiveNumber page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorReceiveNumber beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorReceiveNumber afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0600 + *tc.name testOnHttpErrorReceiveByNumber + *tc.desc test interface of onHttpErrorReceive with parameter used by number handle + */ + it('testOnHttpErrorReceiveByNumber',0,async function(done){ + emitKey="emitOnHttpErrorReceiveByNumber"; + Utils.registerEvent("testOnHttpErrorReceiveByNumber",403,401,done); + Utils.registerEvent("testOnHttpErrorReceiveByNumber","1.1.1.123/index.html",402,done); + sendEventByKey('webViewONHttpErrorReceiveNumber',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveString.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveString.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8eb235dc4dd72b7d2bcb62f5c72fbc88ca13fc3 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorReceiveString.test.ets @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorReceiveByString"; +export default function webViewONHttpErrorReceiveString() { + describe('ActsAceWebDevWebViewONHttpErrorReceiveStringTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorReceiveString', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorReceiveString state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorReceiveString" == pages.name)) { + console.info("get webViewONHttpErrorReceiveString state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorReceiveString page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorReceiveString page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorReceiveString beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorReceiveString afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0500 + *tc.name testOnHttpErrorReceiveByString + *tc.desc test interface of onHttpErrorReceive with parameter used by string + */ + it('testOnHttpErrorReceiveByString',0,async function(done){ + emitKey="emitOnHttpErrorReceiveByString"; + Utils.registerEvent("testOnHttpErrorReceiveByString",403,399,done); + Utils.registerEvent("testOnHttpErrorReceiveByString",1,400,done); + sendEventByKey('webViewONHttpErrorReceiveString',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorRecvExampleIsReady.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorRecvExampleIsReady.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..80ce599f7e1e8309ee4514f207fba79d28abb5f4 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewONHttpErrorRecvExampleIsReady.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnHttpErrorRecvExampleIsReadyFalse"; +export default function webViewONHttpErrorRecvExampleIsReady() { + describe('ActsAceWebDevWebViewONHttpErrorRecvExampleIsReadyTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewONHttpErrorRecvExampleIsReady', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewONHttpErrorRecvExampleIsReady state success " + JSON.stringify(pages)); + if (!("webViewONHttpErrorRecvExampleIsReady" == pages.name)) { + console.info("get webViewONHttpErrorRecvExampleIsReady state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewONHttpErrorRecvExampleIsReady page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewONHttpErrorRecvExampleIsReady page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewONHttpErrorRecvExampleIsReady beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewONHttpErrorRecvExampleIsReady afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWERRORRECV_API_0300 + *tc.name testOnHttpErrorRecvExampleIsReadyFalse + *tc.desc test interface of onHttpErrorReceive with parameter used by example but setResponseIsReady false + */ + it('testOnHttpErrorRecvExampleIsReadyFalse',0,async function(done){ + emitKey="emitOnHttpErrorRecvExampleIsReadyFalse"; + Utils.registerEvent("testOnHttpErrorRecvExampleIsReadyFalse","",394,done); + sendEventByKey('webViewONHttpErrorRecvExampleIsReady',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnAudioStateChanged.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnAudioStateChanged.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c56d2c549c4d99f01972a762227945e5a4da70b --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnAudioStateChanged.test.ets @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitAudioStatePlay"; +export default function webViewOnAudioStateChanged() { + describe('ActsAceWebDevWebViewOnAudioStateChangedTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnAudioStateChanged', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnAudioStateChanged state success " + JSON.stringify(pages)); + if (!("webViewOnAudioStateChanged" == pages.name)) { + console.info("get webViewOnAudioStateChanged state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnAudioStateChanged page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnAudioStateChanged page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnAudioStateChanged beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnAudioStateChanged afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWAUDIOSTATE_API_0100 + *tc.name testOnAudioStateChangedPlay + *tc.desc test interface of onaudiostatechanged with audio play + */ + it('testOnAudioStateChangedPlay',0,async function(done){ + emitKey="emitAudioStatePause"; + Utils.registerEvent("testOnAudioStateChangedPlay",true,411,done); + Utils.registerEvent("testOnAudioStateChangedPlay","false",412,done); + sendEventByKey('webViewOnAudioStateChanged',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWAUDIOSTATE_API_0200 + *tc.name testOnAudioStateChangedPause + *tc.desc test interface of onaudiostatechanged with audio pause + */ + it('testOnAudioStateChangedPause',0,async function(done){ + emitKey="emitAudioStatePause"; + Utils.registerEvent("testOnAudioStateChangedPause",false,413,done); + Utils.registerEvent("testOnAudioStateChangedPause","true",414,done); + sendEventByKey('webViewOnAudioStateChanged',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnBeforeUnload.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnBeforeUnload.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e5bc6ae117153277683ff3690bae28c4ad1974e --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnBeforeUnload.test.ets @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnBeforeUnload"; +export default function webViewOnBeforeUnload() { + describe('ActsAceWebDevWebViewOnBeforeUnloadTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnBeforeUnload', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnBeforeUnload state success " + JSON.stringify(pages)); + if (!("webViewOnBeforeUnload" == pages.name)) { + console.info("get webViewOnBeforeUnload state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnBeforeUnload page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnBeforeUnload page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnBeforeUnload beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnBeforeUnload afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEW_API_0100 + *tc.name testOnBeforeUnload + *tc.desc onBeforeUnload after page refresh + */ + it('testOnBeforeUnload',0,async function(done){ + emitKey="emitOnBeforeUnloadAgain"; + Utils.registerEvent("testOnBeforeUnload","Is it OK to leave/reload this page?",302,done); + sendEventByKey('webViewOnBeforeUnload',10,''); + sendEventByKey('TestwebViewOnBeforeUnload',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEW_API_0200 + *tc.name testOnBeforeUnloadAgain + *tc.desc onBeforeUnload after page loadUrl new + */ + it('testOnBeforeUnloadAgain',0,async function(done){ + sendEventByKey('TestwebViewOnBeforeUnload',10,''); + emitKey="emitOnBeforeUnloadAgain"; + Utils.registerEvent("testOnBeforeUnloadAgain","Is it OK to leave/reload this page?",304,done); + sendEventByKey('webViewOnBeforeUnload',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstCont.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstCont.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7292e5eb7567ed81b8fe6615320608c83cc2f5b --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstCont.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnfirstcontentfulpaint"; +export default function webViewOnFirstCont() { + describe('ActsAceWebDevWebViewOnFirstContTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFirstCont', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFirstCont state success " + JSON.stringify(pages)); + if (!("webViewOnFirstCont" == pages.name)) { + console.info("get webViewOnFirstCont state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFirstCont page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFirstCont page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFirstCont beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFirstCont afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR5_API_0100 + *tc.name testOnfirstcontentfulpaint + *tc.desc onfirstcontentfulpaint with web src null + */ + it('testOnfirstcontentfulpaint',0,async function(done){ + emitKey="emitOnfirstcontentfulpaint"; + Utils.registerEvent("testOnfirstcontentfulpaint","NoSrcTest",322,done); + sendEventByKey('webViewOnFirstCont',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContFour.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContFour.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dd767c09cae5829e52e5f9521782f75ee1ac176 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContFour.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitRefreshOnfirstcontentfulpaint"; +export default function webViewOnFirstContFour() { + describe('ActsAceWebDevWebViewOnFirstContFourTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFirstContFour', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFirstContFour state success " + JSON.stringify(pages)); + if (!("webViewOnFirstContFour" == pages.name)) { + console.info("get webViewOnFirstContFour state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFirstContFour page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFirstContFour page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFirstContFour beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFirstContFour afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR5_API_0400 + *tc.name testOnfirstcontentfulpaintrefresh + *tc.desc onfirstcontentfulpaint with web refresh + */ + it('testOnfirstcontentfulpaintrefresh',0,async function(done){ + emitKey="emitRefreshOnfirstcontentfulpaint"; + Utils.registerEvent("testOnfirstcontentfulpaintrefresh",true,328,done); + sendEventByKey('webViewOnFirstContFour',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContThree.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContThree.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b04d96ff038dc55ac8d755658882e2a1eda113a2 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContThree.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitLoadUrlOnfirstcontentfulpaint"; +export default function webViewOnFirstContThree() { + describe('ActsAceWebDevWebViewOnFirstContThreeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFirstContThree', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFirstContThree state success " + JSON.stringify(pages)); + if (!("webViewOnFirstContThree" == pages.name)) { + console.info("get webViewOnFirstContThree state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFirstContThree page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFirstContThree page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFirstContThree beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFirstContThree afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR5_API_0300 + *tc.name testOnfirstcontentfulpaintloadurl + *tc.desc onfirstcontentfulpaint with web load url + */ + it('testOnfirstcontentfulpaintloadurl',0,async function(done){ + emitKey="emitLoadUrlOnfirstcontentfulpaint"; + Utils.registerEvent("testOnfirstcontentfulpaintloadurl",true,326,done); + sendEventByKey('webViewOnFirstContThree',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContTwo.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContTwo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8973a1ca9e635d2e11722adb3fe506a867dbd164 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFirstContTwo.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitNoneOnfirstcontentfulpaint"; +export default function webViewOnFirstContTwo() { + describe('ActsAceWebDevWebViewOnFirstContTwoTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFirstContTwo', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFirstContTwo state success " + JSON.stringify(pages)); + if (!("webViewOnFirstContTwo" == pages.name)) { + console.info("get webViewOnFirstContTwo state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFirstContTwo page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFirstContTwo page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFirstContTwo beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFirstContTwo afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR5_API_0200 + *tc.name testOnfirstcontentfulpaintvisibilitynone + *tc.desc onfirstcontentfulpaint with web visibility none + */ + it('testOnfirstcontentfulpaintvisibilitynone',0,async function(done){ + emitKey="emitNoneOnfirstcontentfulpaint"; + Utils.registerEvent("testOnfirstcontentfulpaintvisibilitynone","VisibilityNoneTest",324,done); + sendEventByKey('webViewOnFirstContTwo',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenEnter.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenEnter.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..475d6435793780eabd7e24c54566aa8f66b7c80f --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenEnter.test.ets @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnfullscreenenter"; +export default function webViewOnFullScreenEnter() { + describe('ActsAceWebDevWebViewOnFullScreenEnterTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFullScreenEnter', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFullScreenEnter state success " + JSON.stringify(pages)); + if (!("webViewOnFullScreenEnter" == pages.name)) { + console.info("get webViewOnFullScreenEnter state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFullScreenEnter page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFullScreenEnter page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFullScreenEnter beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFullScreenEnter afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWFULLSCREEN_API_0100 + *tc.name testOnFullScreenEnter + *tc.desc test interface of onfullscreenenter with runjavascript handleFullScreen + */ + it('testOnFullScreenEnter',0,async function(done){ + sendEventByKey('TestwebViewOnFullScreenEnter',10,''); + emitKey="emitOnfullscreenenter"; + Utils.registerEvent("testOnFullScreenEnter","2\"true\"",342,done); + sendEventByKey('webViewOnFullScreenEnter',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenExit.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenExit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..69ed5b40e66c36456b6d97cf43576bb652811da1 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnFullScreenExit.test.ets @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnfullscreenexit"; +export default function webViewOnFullScreenExit() { + describe('ActsAceWebDevWebViewOnFullScreenExitTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnFullScreenExit', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnFullScreenExit state success " + JSON.stringify(pages)); + if (!("webViewOnFullScreenExit" == pages.name)) { + console.info("get webViewOnFullScreenExit state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnFullScreenExit page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnFullScreenExit page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnFullScreenExit beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnFullScreenExit afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWFULLSCREEN_API_0200 + *tc.name testOnFullScreenExit + *tc.desc test interface of onfullscreenexit with runjavascript exitFullscreen + */ + it('testOnFullScreenExit',0,async function(done){ + sendEventByKey('TestwebViewOnFullScreenExit',10,''); + emitKey="emitOnfullscreenexit"; + Utils.registerEvent("testOnFullScreenExit","2\"false\"",344,done); + sendEventByKey('webViewOnFullScreenExit',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqOne.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqOne.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bab0e3aa33d1de7db3f81f75f6e9b0813ee5f3b2 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqOne.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnInterceptRequest"; +export default function webViewOnInterceptReqOne() { + describe('ActsAceWebDevWebViewOnInterceptReqOneTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnInterceptReqOne', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnInterceptReqOne state success " + JSON.stringify(pages)); + if (!("webViewOnInterceptReqOne" == pages.name)) { + console.info("get webViewOnInterceptReqOne state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnInterceptReqOne page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnInterceptReqOne page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnInterceptReqOne beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnInterceptReqOne afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR2_API_0100 + *tc.name testOnInterceptRequest + *tc.desc onInterceptRequest without setting webresourceresponse + */ + it('testOnInterceptRequest',0,async function(done){ + emitKey="emitOnInterceptRequest"; + Utils.registerEvent("testOnInterceptRequest","resource://rawfile/indexCopy.html",306,done); + sendEventByKey('webViewOnInterceptReqOne',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqThree.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqThree.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2682a82ae057e85c097f82a2e717d6a0cbc6182 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqThree.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnInterceptRequestThird"; +export default function webViewOnInterceptReqThree() { + describe('ActsAceWebDevWebViewOnInterceptReqThreeTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnInterceptReqThree', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnInterceptReqThree state success " + JSON.stringify(pages)); + if (!("webViewOnInterceptReqThree" == pages.name)) { + console.info("get webViewOnInterceptReqThree state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnInterceptReqThree page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnInterceptReqThree page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnInterceptReqThree beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnInterceptReqThree afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR2_API_0300 + *tc.name testOnInterceptRequestThird + *tc.desc onInterceptRequest with setting setresponsecede 404 + */ + it('testOnInterceptRequestThird',0,async function(done){ + emitKey="emitOnInterceptRequestThird"; + Utils.registerEvent("testOnInterceptRequestThird",404,310,done); + sendEventByKey('webViewOnInterceptReqThree',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqTwo.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqTwo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e655818686b9d086f37488f09d4b5c020567ec6 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnInterceptReqTwo.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnInterceptRequestSecond"; +export default function webViewOnInterceptReqTwo() { + describe('ActsAceWebDevWebViewOnInterceptReqTwoTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnInterceptReqTwo', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnInterceptReqTwo state success " + JSON.stringify(pages)); + if (!("webViewOnInterceptReqTwo" == pages.name)) { + console.info("get webViewOnInterceptReqTwo state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnInterceptReqTwo page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnInterceptReqTwo page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnInterceptReqTwo beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnInterceptReqTwo afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR2_API_0200 + *tc.name testOnInterceptRequestAgain + *tc.desc onInterceptRequest with setting webresourceresponse + */ + it('testOnInterceptRequestAgain',0,async function(done){ + emitKey="emitOnInterceptRequestSecond"; + Utils.registerEvent("testOnInterceptRequestAgain","intercept test",308,done); + sendEventByKey('webViewOnInterceptReqTwo',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9a7132db81ff3e50cf498b1b8131d7ac808cadd --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnscroll"; +export default function webViewOnScroll() { + describe('ActsAceWebDevWbViewOnScrollTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnScroll', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnScroll state success " + JSON.stringify(pages)); + if (!("webViewOnScroll" == pages.name)) { + console.info("get webViewOnScroll state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnScroll page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnScroll page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnScroll beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnScroll afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR3_API_0100 + *tc.name testOnscroll + *tc.desc onscroll after scrollby 100,100 + */ + it('testOnscroll',0,async function(done){ + emitKey="emitOnscrollAgain"; + Utils.registerEvent("testOnscroll",100,312,done); + Utils.registerEvent("testOnscroll",100,314,done); + sendEventByKey('webViewOnScroll',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR3_API_0200 + *tc.name testOnscrollAgain + *tc.desc onscroll after scrollby -100,-100 + */ + it('testOnscrollAgain',0,async function(done){ + emitKey="emitOnscrollAgain"; + Utils.registerEvent("testOnscrollAgain",0,316,done); + Utils.registerEvent("testOnscrollAgain",0,318,done); + sendEventByKey('webViewOnScroll',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnSslError.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnSslError.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c254c94c286c812367fd017f2325eda2c189003 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnSslError.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitOnsslerroreventreceive"; +export default function webViewOnSslError() { + describe('ActsAceWebDevWebViewOnSslErrorTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewOnSslError', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewOnSslError state success " + JSON.stringify(pages)); + if (!("webViewOnSslError" == pages.name)) { + console.info("get webViewOnSslError state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewOnSslError page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewOnSslError page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewOnSslError beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewOnSslError afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWPATR4_API_0100 + *tc.name testOnsslerroreventreceive + *tc.desc onsslerroreventreceive after load http://http.badssl.com/ + */ + it('testOnsslerroreventreceive',0,async function(done){ + emitKey="emitOnsslerroreventreceive"; + Utils.registerEvent("testOnsslerroreventreceive","1",320,done); + sendEventByKey('webViewOnSslError',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetAudioMuted.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetAudioMuted.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2577a727ce9819015d5a46f45a803633b494ee38 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetAudioMuted.test.ets @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitSetAudioMuted"; +export default function webViewSetAudioMuted() { + describe('ActsAceWebDevWebViewSetAudioMutedTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewSetAudioMuted', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewSetAudioMuted state success " + JSON.stringify(pages)); + if (!("webViewSetAudioMuted" == pages.name)) { + console.info("get webViewSetAudioMuted state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewSetAudioMuted page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewSetAudioMuted page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewSetAudioMuted beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewSetAudioMuted afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWMUTED_API_0100 + *tc.name testSetAudioMuted + *tc.desc test interface of setaudiomuted with muted true + */ + it('testSetAudioMuted',0,async function(done){ + emitKey="emitSetAudioDisMuted"; + Utils.registerEvent("testSetAudioMuted","true",405,done); + Utils.registerEvent("testSetAudioMuted","muted",406,done); + sendEventByKey('webViewSetAudioMuted',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWMUTED_API_0200 + *tc.name testSetAudioDisMuted + *tc.desc test interface of setaudiomuted with muted false + */ + it('testSetAudioDisMuted',0,async function(done){ + emitKey="emitSetAudioDisMuted"; + Utils.registerEvent("testSetAudioDisMuted","false",407,done); + Utils.registerEvent("testSetAudioDisMuted","unmuted",408,done); + sendEventByKey('webViewSetAudioMuted',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetHttpDns.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetHttpDns.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef8cfad1351b5bf7ceb6dd82f02c531923875de2 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSetHttpDns.test.ets @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +import router from '@system.router'; +// @ts-nocheck +let emitKey = "emitSetHttpDnsSecureOnlyExample"; +export default function webViewSetHttpDns() { + describe('ActsAceWebDevWebViewSetHttpDnsTest', function () { + beforeAll(async function (done) { + let options = { + uri: 'MainAbility/pages/webViewSetHttpDns', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get webViewSetHttpDns state success " + JSON.stringify(pages)); + if (!("webViewSetHttpDns" == pages.name)) { + console.info("get webViewSetHttpDns state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push webViewSetHttpDns page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push webViewSetHttpDns page error: " + err); + } + done() + }); + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("webViewSetHttpDns beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("webViewSetHttpDns afterEach start:" + emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWSETHTTPDNS_API_0100 + *tc.name testSetHttpDnsSecureOnlyExample + *tc.desc test interface of sethttpdns with parameter SetHttpDnsSecureOnlyExample + */ + it('testSetHttpDnsSecureOnlyExample',0,async function(done){ + emitKey="emitSetHttpDnsSecureOnlyUserDefine"; + Utils.registerEvent("testSetHttpDnsSecureOnlyExample","https://www.baidu.com",354,done); + sendEventByKey('webViewSetHttpDns',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWSETHTTPDNS_API_0200 + *tc.name testSetHttpDnsSecureOnlyUserDefine + *tc.desc test interface of sethttpdns with parameter SetHttpDnsSecureOnlyExample + */ + it('testSetHttpDnsSecureOnlyUserDefine',0,async function(done){ + emitKey="emitSetHttpDnsAutoExample"; + Utils.registerEvent("testSetHttpDnsSecureOnlyUserDefine","å¾®åš",356,done); + sendEventByKey('webViewSetHttpDns',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWSETHTTPDNS_API_0300 + *tc.name testSetHttpDnsAutoExample + *tc.desc test interface of sethttpdns with parameter SetHttpDnsSecureOnlyExample + */ + it('testSetHttpDnsAutoExample',0,async function(done){ + emitKey="emitSetHttpDnsOffExample"; + Utils.registerEvent("testSetHttpDnsAutoExample","åŽä¸º - 构建万物互è”的智能世界",358,done); + sendEventByKey('webViewSetHttpDns',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_WEBVIEWSETHTTPDNS_API_0400 + *tc.name testSetHttpDnsOffExample + *tc.desc test interface of sethttpdns with parameter SetHttpDnsSecureOnlyExample + */ + it('testSetHttpDnsOffExample',0,async function(done){ + emitKey="emitSetHttpDnsOffExample"; + Utils.registerEvent("testSetHttpDnsOffExample","OpenAtom OpenHarmony",360,done); + sendEventByKey('webViewSetHttpDns',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/module.json b/arkui/ace_ets_web_dev_webviewController/entry/src/main/module.json index 689268dcc71f30d259eb9eb6ce784b485dc94eb5..085a2a2e365a760a305f42bd497a8aa4fba1bfe9 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/module.json +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/module.json @@ -46,6 +46,12 @@ }, { "name": "ohos.permission.GET_NETWORK_INFO" + }, + { + "name": "ohos.permission.APPROXIMATELY_LOCATION" + }, + { + "name": "ohos.permission.LOCATION_IN_BACKGROUND" } ] } diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json index 3adb9e28a017250761e1df5e2f664c0fe5e41354..dd76b0321ecb27e3a5303f9603b5a0199002fdd3 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json @@ -7,6 +7,41 @@ "MainAbility/pages/webViewHasImage", "MainAbility/pages/webViewScrollTo", "MainAbility/pages/webViewScrollBy", - "MainAbility/pages/webStorage" + "MainAbility/pages/webStorage", + "MainAbility/pages/runJavaScript", + "MainAbility/pages/storeWebArchive", + "MainAbility/pages/storeWebArchiveSaveFail", + "MainAbility/pages/webViewOnBeforeUnload", + "MainAbility/pages/webViewOnInterceptReqOne", + "MainAbility/pages/webViewOnInterceptReqTwo", + "MainAbility/pages/webViewOnInterceptReqThree", + "MainAbility/pages/webViewOnScroll", + "MainAbility/pages/webViewOnSslError", + "MainAbility/pages/webViewOnFirstCont", + "MainAbility/pages/webViewOnFirstContTwo", + "MainAbility/pages/webViewOnFirstContThree", + "MainAbility/pages/webViewOnFirstContFour", + "MainAbility/pages/webViewDefaultFontSizeWithMinLogical", + "MainAbility/pages/webViewDefaultFontSize", + "MainAbility/pages/webViewDefaultFontSizeNoMinFontSize", + "MainAbility/pages/webViewDefaultFontSizeNoAll", + "MainAbility/pages/webViewOnFullScreenEnter", + "MainAbility/pages/webViewOnFullScreenExit", + "MainAbility/pages/webViewExistCookie", + "MainAbility/pages/webViewDeleteEntireCookie", + "MainAbility/pages/webViewInVoke", + "MainAbility/pages/webViewInVokeFalse", + "MainAbility/pages/webViewSetHttpDns", + "MainAbility/pages/webViewONHttpErrorReceive", + "MainAbility/pages/webViewONHttpErrorReceiveExample", + "MainAbility/pages/webViewONHttpErrorRecvExampleIsReady", + "MainAbility/pages/webViewONHttpErrorReceiveIframe", + "MainAbility/pages/webViewONHttpErrorReceiveString", + "MainAbility/pages/webViewONHttpErrorReceiveNumber", + "MainAbility/pages/webViewGetCertificate", + "MainAbility/pages/webViewSetAudioMuted", + "MainAbility/pages/webViewGetAccessibleGeolocation", + "MainAbility/pages/webViewOnAudioStateChanged", + "MainAbility/pages/webViewMediaOption" ] } \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/01.mp3 b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/01.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..a53047f856fd7b41c19bd06c0b2cb57013c57d19 Binary files /dev/null and b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/01.mp3 differ diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/02.mp4 b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/02.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c21ce662c016b59ec79130b0d4f5c97637c6e34e --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/02.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb51187741f130068c6d4c67b44218a80cb328ba1478977990783338cbc8e2d3 +size 52795074 diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/audioTest.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/audioTest.html new file mode 100644 index 0000000000000000000000000000000000000000..fe6d79a64c43650b7dc3c8b65e1fddcb3963207a --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/audioTest.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>audioTest</title> +</head> +<body> + <audio controls autoplay loop name="media" id="my-bgm"> + <source src="./01.mp3" type="audio/mpeg"> + </audio> +</body> +<script> + let ele=document.getElementById("my-bgm"); + let loadAudio; + ele.onload=function(){ + loadAudio="load complete" + } + function test(){ + backToEts.test("backToEts") + } + function enableMute() { + var myVid = document.getElementById("my-bgm"); + myVid.muted = true; + return myVid.muted + } + function disableMute() { + var myVid = document.getElementById("my-bgm"); + myVid.muted = false; + return myVid.muted + } + function checkMute() { + var myVid = document.getElementById("my-bgm"); + if ( myVid.muted ) { + return "muted" + } else { + return "unmuted" + } + } + function play() { + var myVid = document.getElementById("my-bgm"); + if (myVid.paused) { + myVid.play() + } + return myVid.paused + } + function pause() { + var myVid = document.getElementById("my-bgm"); + myVid.pause() + return myVid.paused + } + play() +</script> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/fullScreenTest.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/fullScreenTest.html new file mode 100644 index 0000000000000000000000000000000000000000..abd352948e89170354982a520ee5f21c5abc8616 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/fullScreenTest.html @@ -0,0 +1,98 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>FullScreenTest</title> +</head> +<body> + <div id="content" onclick = "testFullScreen" style="width:500px;height:500px;background:red;"> + 这是被全å±çš„å…ƒç´ + <button id='btn'>å…¨å±</button> + <button id="closeBtn">退出全å±</button> + </div> +<script> + let ele=document.getElementById("content"); + let loadContent; + ele.onload=function(){ + loadContent="load complete" + } + + function test(){ + backToEts.test("backToEts") + } + + function fullScreen(el) { + var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen, + wscript; + if(typeof rfs != "undefined" && rfs) { + rfs.call(el); + return; + } + if(typeof window.ActiveXObject != "undefined") { + wscript = new ActiveXObject("WScript.Shell"); + if(wscript) { + wscript.SendKeys("{F11}"); + } + } + } + function exitFullScreen(el) { + var el= document, + cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen, + wscript; + if (typeof cfs != "undefined" && cfs) { + cfs.call(el); + return; + } + if (typeof window.ActiveXObject != "undefined") { + wscript = new ActiveXObject("WScript.Shell"); + if (wscript != null) { + wscript.SendKeys("{F11}"); + } + } + } + + btn.onclick = function(){ + var btn = document.getElementById('btn'); + var content = document.getElementById('content'); //被全å±æ˜¾ç¤ºçš„å…ƒç´ + fullScreen(content); + } + var closeBtn = document.getElementById('closeBtn'); + closeBtn.onclick = function(){ + exitFullScreen(); + } + + function elementFullScreen() { + let content = document.getElementById('content'); + return content.requestFullscreen() + } + + function testFullScreen() { + if (document.fullscreenElement) { + console.log("already fullscreen return") + return + } + // var de = document.documentElement; + // if (de.requestFullscreen) { + // de.requestFullscreen(); + // } else if (de.mozRequestFullScreen) { + // de.mozCancelFullScreen(); + // } else if (de.webkitRequestFullScreen) { + // de.webkitRequestFullScreen(); + // } + let content = document.getElementById('content'); + return content.requestFullscreen() + } + + function elementExitFullScreen() { + document.exitFullscreen() + } + + function checkIsFullScreen() { + var isFull =!! (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement) + return isFull + } +</script> +</body> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFive.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFive.html new file mode 100644 index 0000000000000000000000000000000000000000..c65e08261621b08a6c583aa96a688409217d17d5 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFive.html @@ -0,0 +1,97 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>index</title> + <style> + #pageHeight{ + height:350px + } + #pageHeight1{ + height:350px + } + </style> +</head> +<body> + <div id="container">首页</div> + <div id="pageHeight"></div> + <div id="contenttext" style="font-size: 9px;">内容</div> + <div id="pageHeight1"></div> + <div id="ending">末尾</div> + <a href="second.html" id="fileAccess">打开rawfile文件</a> + <img src="icon.png" alt="icon" id="imgs"> +</body> +<script> + let ele=document.getElementById("imgs"); + let loadImage; + ele.onload=function(){ + loadImage="load complete" + } + function getUserAgent(){ + return navigator.userAgent + } + function test(){ + backToEts.test("backToEts") + } + function testRunJavaScript(){ + return "testRunJavaScript" + } + function getPageHeight(){ + let height=document.body.scrollHeight + return height + } + function proxy(){ + objName.register("backToEts") + } + function registerTest(){ + let str=objName.register(); + console.log(str); + return str + } + function jsAccess(){ + console.log("web111") + } + function consoleTest(){ + console.log("console test") + } + function alertTest(){ + alert('alert test') + } + function confirmTest(){ + confirm("confirm test") + } + function getImgResult(){ + return loadImage + } + function toPrompt(){ + let result=prompt("age","20"); + console.log("result:"+result) + } + function openRawFile(){ + document.getElementById("fileAccess").click() + } + function gettitle(){ + return document.title + } + function getNavigatorOnLine(){ + let onlineResult = navigator.onLine; + return onlineResult + } + function getPageFontsize(){ + const start_element = document.getElementById("container"); + let StartEle = start_element.innerText; + let style = (window.getComputedStyle(document.getElementById("container"), null)).fontSize; + console.log("StartEle : " + StartEle + style); + return [StartEle,style] + } + function getTestPageFontsize(){ + const middle_element = document.getElementById("contenttext"); + let ContentEle = middle_element.innerText; + let style = (window.getComputedStyle(document.getElementById("contenttext"), null)).getPropertyValue('font-size') + console.log("ContentEle : " + ContentEle + style); + return [ContentEle,style] + } +</script> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFour.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFour.html new file mode 100644 index 0000000000000000000000000000000000000000..5c71d04e2a47fe63c98ed93f34c332c6aa1fed7e --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexFour.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>homework</title> + <style> + html{ + width:2000px; + } + #kuan{ + height:220px; + white-space:nowrap; + } + img{ + border-radius:5px; + margin-top:10px; + width:1000px; + height:200px; + display:inline + } + #centerHeight{ + height:3000px; + } + </style> +</head> +<body> +<div > + <div id="kuan"> + <img src="icon.png" id ="leftImg"> + <img src="icon.png" id ="centerImg"> + <img src="icon.png" id ="rightImg"> + </div> + <div id="gao"> + <div id="centerHeight"></div> + <img src="icon.png" alt="icon" id="bottomImg"> + </div> +</div> +</body> +</html> +<script> + let ele=document.getElementById("leftImg"); + let loadImage; + document.getElementById("imgs").click() + ele.onload=function(){ + loadImage="load complete" + } + function myRefresh() { + return window.location.reload(); + } +</script> +</html> + diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexSix.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexSix.html new file mode 100644 index 0000000000000000000000000000000000000000..6d7fc5768cc8ad3ec004c3a3cc437bb738a1b4c2 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/indexSix.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>index</title> + <style> + #pageHeight{ + height:350px + } + #pageHeight1{ + height:350px + } + </style> +</head> +<body> + <iframe src="https://wrong.host.badssl.com"></iframe> + <div id="container">首页</div> + <div id="pageHeight"></div> + <div id="contenttext" style="font-size: 9px;">内容</div> + <div id="pageHeight1"></div> + <div id="ending">末尾</div> + <a href="second.html" id="fileAccess">打开rawfile文件</a> + <img src="icon.png" alt="icon" id="imgs"> + <input type="button" onclick="handleFullScreen()" value="å…¨å±æ˜¾ç¤ºÊ¾"/> + <input type="button" onclick="exitFullscreen()" value="退出全å±"/> +</body> +<script> + let ele=document.getElementById("imgs"); + let loadImage; + ele.onload=function(){ + loadImage="load complete" + } + function getUserAgent(){ + return navigator.userAgent + } + function test(){ + backToEts.test("backToEts") + } + function testRunJavaScript(){ + return "testRunJavaScript" + } + function getPageHeight(){ + let height=document.body.scrollHeight + return height + } + function proxy(){ + objName.register("backToEts") + } + function registerTest(){ + let str=objName.register(); + console.log(str); + return str + } + function jsAccess(){ + console.log("web111") + } + function consoleTest(){ + console.log("console test") + } + function alertTest(){ + alert('alert test') + } + function confirmTest(){ + confirm("confirm test") + } + function getImgResult(){ + return loadImage + } + function toPrompt(){ + let result=prompt("age","20"); + console.log("result:"+result) + } + function openRawFile(){ + document.getElementById("fileAccess").click() + } + function gettitle(){ + return document.title + } + function getNavigatorOnLine(){ + let onlineResult = navigator.onLine; + return onlineResult + } +</script> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onBeforeUnloadTest.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onBeforeUnloadTest.html new file mode 100644 index 0000000000000000000000000000000000000000..c375c42f61fe3db2ef0b86407c09467f0b3a17c4 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onBeforeUnloadTest.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<meta http-equiv="refresh" content="10; URL=//rawfile/onBeforeUnloadTest.html"> +<title>W3Cschool在线教程(w3cschool.cn)</title> +</head> +<body onbeforeunload="return myFunction()"> + +<p>å…³é—当å‰çª—å£ï¼ŒæŒ‰ä¸‹ F5 æˆ–ç‚¹å‡»ä»¥ä¸‹é“¾æŽ¥è§¦å‘ onbeforeunload 事件。</p> +<a href="http://www.w3cschool.cn">点击跳转到W3Cschool在线教程</a> + <img src="icon.png" alt="icon" id="imgs"> +</body> +<script> + let ele=document.getElementById("imgs"); + let loadImage; + ele.onload=function(){ + loadImage=ele.click() + } + function test(){ + backToEts.test("backToEts") + } + function myFunction() { + document.getElementById("imgs").click() + return "我在这写点东西..."; + } + function myRefresh() { + return window.location.reload(); + } + function myNewPage() { + return window.location.replace("http://www.w3cschool.cn") + } + myFunction() +</script> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onfirstcontentfulpaint.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onfirstcontentfulpaint.html new file mode 100644 index 0000000000000000000000000000000000000000..78f02ea4656081783da222e110e27f9db8fcc746 --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/onfirstcontentfulpaint.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Title</title> +</head> +<body> + <h1>这里是直出的内容</h1> + <img src="https://avatars3.githubusercontent.com/u/8401872" alt=""> + <hr/> + <h1>下é¢æ˜¯å¼‚æ¥åŠ 载的内容</h1> + <img src="icon.png" alt="icon" id="imgs"> + <h2 id="title"></h2> + <div id="app"></div> + <script> + let ele=document.getElementById("imgs"); + let loadImage; + ele.onload=function(){ + loadImage="load complete" + } + function test(){ + backToEts.test("backToEts") + } + setTimeout(() => { + for (let i = 0; i < 200; i++) { + let newDiv = document.createElement("div"); + let newContent = document.createTextNode("异æ¥å›žæ¥çš„内容 " + i); + newDiv.appendChild(newContent); + document.querySelector('#app').appendChild(newDiv); + } + document.querySelector('#title').innerText = "第 1 次异æ¥"; + }, 200); + setTimeout(() => { + for (let i = 0; i < 200; i++) { + let newDiv = document.createElement("div"); + let newContent = document.createTextNode("异æ¥å›žæ¥çš„更多内容 " + i); + newDiv.appendChild(newContent); + document.querySelector('#app').appendChild(newDiv); + } + document.querySelector('#title').innerText = "第 2 次异æ¥ï¼Œæ›´å¤šçš„内容"; + }, 200); + </script> +</body> +</html> \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/videoTest.html b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/videoTest.html new file mode 100644 index 0000000000000000000000000000000000000000..4a8b1cca8ce54f92cb35797fdcb5dc6c92bcbf8f --- /dev/null +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/videoTest.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>videoTest</title> +</head> +<body> + <video controls autoplay loop name="media" id="my-bgm"> + <source src="./02.mp4" type="audio/mpeg"> + </video> +</body> +<script> + let ele=document.getElementById("my-bgm"); + let loadAudio; + ele.onload=function(){ + loadAudio="load complete" + } + function test(){ + backToEts.test("backToEts") + } + function enableMute() { + var myVid = document.getElementById("my-bgm"); + myVid.muted = true; + return myVid.muted + } + function disableMute() { + var myVid = document.getElementById("my-bgm"); + myVid.muted = false; + return myVid.muted + } + function checkMute() { + var myVid = document.getElementById("my-bgm"); + if ( myVid.muted ) { + return "muted" + } else { + return "unmuted" + } + } + function play() { + var myVid = document.getElementById("my-bgm"); + if (myVid.paused) { + myVid.play() + } + return myVid.paused + } + function pause() { + var myVid = document.getElementById("my-bgm"); + myVid.pause() + return myVid.paused + } + function checkState() { + var myVid = document.getElementById("my-bgm"); + return myVid.paused + } + play() +</script> +</html> \ No newline at end of file