未验证 提交 46f554b9 编写于 作者: O openharmony_ci 提交者: Gitee

!9008 add webViewController_part2 xts_acts testcase & pages

Merge pull request !9008 from 王闻天/webViewControllerPart2
# 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
......
# 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
......
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
......@@ -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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
......@@ -46,6 +46,12 @@
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION"
},
{
"name": "ohos.permission.LOCATION_IN_BACKGROUND"
}
]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册