提交 ae23f38b 编写于 作者: W wangwentian

add webController_part1 xts_acts testcase & pages and offline some test

case
Signed-off-by: Nwangwentian <wtwanga@isoftstone.com>
上级 e6a68ec1
{
"app": {
"bundleName": "com.open.harmony.acewebtest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceWebDevWebControllerTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_web_dev_js_assets",
":ace_ets_web_dev_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceWebDevWebControllerTest"
}
ohos_app_scope("ace_ets_web_dev_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_web_dev_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("ace_ets_web_dev_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":ace_ets_web_dev_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.open.harmony.acewebtest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsAceWebDevWebControllerTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
globalThis.windowStage = windowStage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/webOnBeforeUnload", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/**
* 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';
@Entry
@Component
struct webDefaultFontSize {
controller: WebController = new WebController();
@State str:string="emitdefaultFontSize73AndminFontSize1WebC";
@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("webDefaultFontSize 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('webDefaultFontSize').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitdefaultFontSize73AndminFontSize1WebC": {
try {
this.defaultFontSize = 73;
this.minFontSize = 1;
await Utils.sleep(2000)
console.log("fonsize of emitdefaultFontSize73AndminFontSize1WebC is :" + this.defaultFontSize + this.minFontSize);
this.controller.runJavaScript({script:"getPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 432)
}})
break;
}
case "emitdefaultFontSize73AndminFontSize73WebC": {
try {
this.defaultFontSize = 73;
this.minFontSize = 73;
await Utils.sleep(2000)
console.log("fonsize of emitdefaultFontSize73AndminFontSize73WebC is :" + this.defaultFontSize + this.minFontSize);
this.controller.runJavaScript({script:"getPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 434)
}})
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';
@Entry
@Component
struct webDefaultFontSizeNoAll {
controller: WebController = new WebController();
@State str:string="emitdefaultFontSizeAndminFontSizeNoAllWebC";
@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("webDefaultFontSizeNoAll 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('webDefaultFontSizeNoAll').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitdefaultFontSizeAndminFontSizeNoAllWebC": {
try {
this.controller.runJavaScript({script:"getPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 440)
}})
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';
@Entry
@Component
struct webDefaultFontSizeNoMinFontSize {
controller: WebController = new WebController();
@State str:string="emitdefaultFontSize7AndNominFontSizeWebC";
@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("webDefaultFontSizeNoMinFontSize 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('webDefaultFontSizeNoMinFontSize').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitdefaultFontSize7AndNominFontSizeWebC": {
try {
this.defaultFontSize = 7;
await Utils.sleep(2000);
console.log("fonsize of emitdefaultFontSize7AndNominFontSizeWebC is :" + this.defaultFontSize);
this.controller.runJavaScript({script:"getPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 436)
}})
break;
}
case "emitdefaultFontSize17AndCssFontSize9WebC": {
try {
this.defaultFontSize = 17;
await Utils.sleep(2000);
console.log("fonsize of emitdefaultFontSize17AndCssFontSize9WebC is :" + this.defaultFontSize);
this.controller.runJavaScript({script:"getTestPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 438)
}})
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';
@Entry
@Component
struct webDefaultFontSizeWithMinLogical {
controller: WebController = new WebController();
@State str:string="emitdefaultFontSizeHalfAndminFontSizeHalfWebC";
@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("webDefaultFontSizeWithMinLogical 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('webDefaultFontSizeWithMinLogical').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitdefaultFontSizeHalfAndminFontSizeHalfWebC": {
try {
this.defaultFontSize = 0.5;
this.minFontSize = 0.5;
this.minLogicalFontSize = 0.5
await Utils.sleep(2000);
console.log("fonsize of emitdefaultFontSizeHalfAndminFontSizeHalfWebC is :" + this.defaultFontSize + this.minFontSize);
this.controller.runJavaScript({script:"getPageFontsize()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkEleResult[1], 430)
}})
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';
@Entry
@Component
struct webGetCookieManager {
controller: WebController = new WebController();
handler: FullScreenExitHandler = null
@State str:string="emitGetCookieManagerWebc";
@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 cookieManager: Object = {};
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webGetCookieManager 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('webGetCookieManager').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitGetCookieManagerWebc": {
try {
let result = this.controller.getCookieManager().setCookie()
console.log("result: " + result)
Utils.sleep(1000);
this.cookieManager = this.controller.getCookieManager()
console.log("this.cookieManager: " + JSON.stringify(this.cookieManager));
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(JSON.stringify(this.cookieManager).length, 446)
}})
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 UIAbility from '@ohos.app.ability.UIAbility';
@Entry
@Component
struct webONHttpErrorReceive {
controller: WebController = new WebController();
@State str:string="emitOnHttpErrorReceiveFixedUserAgentWebc";
@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("webONHttpErrorReceive 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('webONHttpErrorReceive').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnHttpErrorReceiveFixedUserAgentWebc": {
try {
this.controller.loadUrl({ url: 'http://1.1.1.123/index.html' });
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.title, 490)
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(), 462);
console.log('isMainFrame:' + event.request.isMainFrame());
Utils.emitEvent(event.request.isMainFrame(), 464);
console.log('isRedirect:' + event.request.isRedirect());
Utils.emitEvent(event.request.isRedirect(), 466);
console.log('isRequestGesture:' + event.request.isRequestGesture());
Utils.emitEvent(event.request.isRequestGesture(), 468);
console.log('getRequestMethod:' + event.request.getRequestMethod());
Utils.emitEvent(event.request.getRequestMethod(), 470);
console.log('getResponseData:' + JSON.stringify(event.response.getResponseData()));
Utils.emitEvent(JSON.stringify(event.response.getResponseData()), 472);
console.log('getResponseEncoding:' + event.response.getResponseEncoding());
Utils.emitEvent(event.response.getResponseEncoding(), 474);
console.log('getResponseMimeType:' + event.response.getResponseMimeType());
Utils.emitEvent(event.response.getResponseMimeType(), 476);
console.log('getResponseCode:' + event.response.getResponseCode());
Utils.emitEvent(event.response.getResponseCode(), 478);
this.title = JSON.stringify(event.response.getResponseCode()) + event.request.getRequestUrl();
console.log("this.title result is :" + this.title);
console.log('getReasonMessage:' + event.response.getReasonMessage());
Utils.emitEvent(event.response.getReasonMessage(), 480);
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, 482);
Utils.emitEvent(this.requestValue, 484);
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, 486);
Utils.emitEvent(this.responseValue, 488);
})
}
}
}
\ 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';
@Entry
@Component
struct webONHttpErrorReceiveExample {
controller: WebController = new WebController();
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"+
"<script>"+
"function gettitle(){ return document.write(document.title); }"+
"gettitle()"+
"</script>"+
"</body>\n"+
"</html>"
@State str:string="emitOnHttpErrorReceiveByExampleWebc";
@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("webONHttpErrorReceiveExample 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('webONHttpErrorReceiveExample').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnHttpErrorReceiveByExampleWebc": {
try {
this.controller.loadUrl({ url: 'http://1.1.1.123/index.html' });
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(this.title, 492);
}})
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(), 491)
console.log("this.title result is :" + this.title);
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);
}
})
.onTitleReceive((event) => {
console.log('title:' + event.title);
this.title = event.title
Utils.emitEvent(this.title, 492);
})
}
}
}
\ 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';
@Entry
@Component
struct webONHttpErrorReceiveIframe {
controller: WebController = new WebController();
@State str:string="emitOnHttpErrorReceiveByIframeHtmlWebc";
@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("webONHttpErrorReceiveIframe 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('webONHttpErrorReceiveIframe').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnHttpErrorReceiveByIframeHtmlWebc": {
try {
this.controller.runJavaScript({script:"gettitle()",callback:(result) => {
this.title = JSON.parse(result)
console.log(`The gettitle() return value is: ${result}`);
}})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(this.title, 498);
}})
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(), 496);
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';
@Entry
@Component
struct webONHttpErrorRecvExampleIsReady {
controller: WebController = new WebController();
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"+
"<script>"+
"function gettitle(){ return document.write(document.title); }"+
"gettitle()"+
"</script>"+
"</body>\n"+
"</html>"
@State str:string="emitOnHttpErrorRecvExampleIsReadyFalseWebc";
@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("webONHttpErrorRecvExampleIsReady 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('webONHttpErrorRecvExampleIsReady').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnHttpErrorRecvExampleIsReadyFalseWebc": {
try {
this.controller.loadUrl({ url: 'http://1.1.1.123/index.html' });
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(this.title, 494);
}})
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());
Utils.emitEvent(event.response.getResponseCode(), 493)
console.log("this.title result is :" + this.title);
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);
}
})
.onTitleReceive((event) => {
console.log('title:' + event.title);
this.title = event.title
Utils.emitEvent(this.title, 494);
})
}
}
}
\ 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';
@Entry
@Component
struct webOnAudioStateChanged {
controller: WebController = new WebController();
@State str:string="emitAudioStatePlayWebc";
@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= 501;
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webOnAudioStateChanged 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('webOnAudioStateChanged').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitAudioStatePlayWebc": {
try {
this.controller.requestFocus();
this.controller.runJavaScript({script:"play()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkResult, 502)
}})
break;
}
case "emitAudioStatePauseWebc": {
try {
this.controller.requestFocus();
this.firstId = 503;
this.controller.runJavaScript({script:"pause()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(this.checkResult, 504)
}})
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';
@Entry
@Component
struct webOnBeforeUnload {
controller: WebController = new WebController();
@State str:string="emitOnBeforeUnloadWebC";
@State firstId:number=402;
@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("webOnBeforeUnload page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
private jsObj={
test:(res)=>{
Utils.emitEvent(res,102);
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Column() {
Row() {
Button("web click").key('webOnBeforeUnload').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnBeforeUnloadWebC": {
try {
this.controller.refresh();
await Utils.sleep(1000);
console.log("action of emitOnBeforeUnload is refresh");
this.controller.runJavaScript({script:"myRefresh()",callback:(result) => {
console.log(`The myRefresh() return value is: ${result}`);
}})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitOnBeforeUnloadAgainWebC": {
try {
this.firstId = 404;
this.controller.requestFocus();
await Utils.sleep(1000);
console.log("action of emitOnBeforeUnloadAgain is loadUrl new");
this.controller.runJavaScript({script:"myNewPage()",callback:(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("TestwebOnBeforeUnload")
.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';
@Entry
@Component
struct webOnFirstCont {
controller: WebController = new WebController();
@State str:string="emitOnfirstcontentfulpaintWebc";
@State firstId:number=422;
@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("webOnFirstCont 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('webOnFirstCont').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnfirstcontentfulpaintWebc": {
try {
this.controller.refresh();
console.log("action of emitOnfirstcontentfulpaintWebc 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';
@Entry
@Component
struct webOnFirstContFour {
controller: WebController = new WebController();
@State str:string="emitRefreshOnfirstcontentfulpaintWebc";
@State firstId:number=428;
@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("webOnFirstContFour 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('webOnFirstContFour').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitRefreshOnfirstcontentfulpaintWebc": {
try {
this.controller.clearHistory();
this.controller.refresh();
this.firstBoo = true
console.log("action of emitRefreshOnfirstcontentfulpaintWebc 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 < 3000) {
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';
@Entry
@Component
struct webOnFirstContThree {
controller: WebController = new WebController();
@State str:string="emitLoadUrlOnfirstcontentfulpaintWebc";
@State firstId:number=426;
@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("webOnFirstContThree 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('webOnFirstContThree').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitLoadUrlOnfirstcontentfulpaintWebc": {
try {
this.controller.clearHistory();
this.controller.loadUrl({url:"resource://rawfile/onfirstcontentfulpaint.html"})
console.log("action of emitLoadUrlOnfirstcontentfulpaintWebc 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';
@Entry
@Component
struct webOnFirstContTwo {
controller: WebController = new WebController();
@State str:string="emitNoneOnfirstcontentfulpaintWebc";
@State firstId:number=424;
@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("webOnFirstContTwo 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('webOnFirstContTwo').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitNoneOnfirstcontentfulpaintWebc": {
try {
this.controller.refresh();
console.log("action of emitNoneOnfirstcontentfulpaintWebc 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';
@Entry
@Component
struct webOnFullScreenEnter {
controller: WebController = new WebController();
handler: FullScreenExitHandler = null
@State str:string="emitOnfullscreenenterWebc";
@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("webOnFullScreenEnter 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('webOnFullScreenEnter').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnfullscreenenterWebc": {
try {
this.controller.runJavaScript({script:"elementFullScreen()",callback:(result) => {
console.log(`The elementFullScreen() return value is: ${result}`);
}})
await Utils.sleep(1000);
this.controller.runJavaScript({script:"checkIsFullScreen()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(JSON.stringify(this.handler).length + this.checkEleResult, 442)
}})
break;
}
}
})
}
Web({ src:$rawfile('fullScreenTest.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)
.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';
@Entry
@Component
struct webOnFullScreenExit {
controller: WebController = new WebController();
handler: FullScreenExitHandler = null
@State str:string="emitOnfullscreenexitWebc";
@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("webOnFullScreenExit 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('webOnFullScreenExit').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnfullscreenexitWebc": {
try {
this.controller.runJavaScript({script:"elementFullScreen()",callback:(result) => {
console.log(`The elementFullScreen() return value is: ${result}`);
}})
await Utils.sleep(1000);
this.controller.runJavaScript({script:"elementExitFullScreen()",callback:(result) => {
console.log(`The elementExitFullScreen() return value is: ${result}`);
}})
await Utils.sleep(1000);
this.controller.runJavaScript({script:"checkIsFullScreen()",callback:(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({script:"test()",callback:(res) => {
Utils.emitEvent(JSON.stringify(this.handler).length + this.checkEleResult, 444)
}})
break;
}
}
})
}
Web({ src:$rawfile('fullScreenTest.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)
.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';
@Entry
@Component
struct webOnInterceptReqOne {
controller: WebController = new WebController();
responseweb: WebResourceResponse = new WebResourceResponse()
heads:Header[] = new Array()
@State str:string="emitOnInterceptRequestWebC";
@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("webOnInterceptReqOne 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('webOnInterceptReqOne').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnInterceptRequestWebC": {
try {
this.controller.loadUrl({url:"resource://rawfile/indexCopy.html"})
Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(this.title, 406);
}})
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);
})
.onTitleReceive((event) => {
console.log('title:' + event.title);
this.title = event.title
Utils.emitEvent(this.title, 492);
})
}
}
}
\ 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';
@Entry
@Component
struct webOnInterceptReqThree {
controller: WebController = new WebController();
responseweb: WebResourceResponse = new WebResourceResponse()
heads:Header[] = new Array()
@State str:string="emitOnInterceptRequestThirdWebC";
@State firstId:number=410;
@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("webOnInterceptReqThree 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('webOnInterceptReqThree').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnInterceptRequestThirdWebC": {
try {
this.controller.refresh();
this.controller.runJavaScript({script:"gettitle()",callback:(result) => {
this.title = JSON.parse(result)
console.log(`The gettitle() return value is: ${result}`);
}})
} 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.controller.runJavaScript({script:"gettitle()",callback:(result) => {
this.title = JSON.parse(result)
console.log(`The gettitle() return value is: ${result}`);
}})
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';
@Entry
@Component
struct webOnInterceptReqTwo {
controller: WebController = new WebController();
responseweb: WebResourceResponse = new WebResourceResponse()
heads:Header[] = new Array()
@State str:string="emitOnInterceptRequestSecondWebC";
@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("webOnInterceptReqTwo 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('webOnInterceptReqTwo').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnInterceptRequestSecondWebC": {
try {
this.controller.runJavaScript({script:"test()",callback:(res) => {
Utils.emitEvent(this.title, 408);
}})
} 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(200)
this.responseweb.setReasonMessage('OK')
return this.responseweb
console.log("this.responseweb: " + this.responseweb);
})
.onTitleReceive((event) => {
console.log('title:' + event.title);
this.title = event.title
Utils.emitEvent(this.title, 408);
})
}
}
}
\ 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';
@Entry
@Component
struct webOnSslError {
controller: WebController = new WebController();
@State str:string="emitOnsslerroreventreceiveWebC";
@State firstId:number=420;
@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("webOnSslError 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('webOnSslError').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitOnsslerroreventreceiveWebC": {
try {
this.controller.refresh();
await Utils.sleep(2000);
this.controller.loadUrl({ url: 'https://wrong.host.badssl.com' })
console.log("action of emitOnsslerroreventreceiveWebC 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) 2022 Huawei Device 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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 webOnBeforeUnload from './webOnBeforeUnload.test'
import webOnInterceptReqOne from './webOnInterceptReqOne.test'
import webOnInterceptReqTwo from './webOnInterceptReqTwo.test'
import webOnInterceptReqThree from './webOnInterceptReqThree.test'
import webOnSslError from './webOnSslError.test'
import webOnFirstCont from './webOnFirstCont.test'
import webOnFirstContTwo from './webOnFirstContTwo.test'
import webOnFirstContThree from './webOnFirstContThree.test'
import webOnFirstContFour from './webOnFirstContFour.test'
import webDefaultFontSizeWithMinLogical from './webDefaultFontSizeWithMinLogical.test'
import webDefaultFontSize from './webDefaultFontSize.test'
import webDefaultFontSizeNoMinFontSize from './webDefaultFontSizeNoMinFontSize.test'
import webDefaultFontSizeNoAll from './webDefaultFontSizeNoAll.test'
import webOnFullScreenEnter from './webOnFullScreenEnter.test'
import webOnFullScreenExit from './webOnFullScreenExit.test'
import webGetCookieManager from './webGetCookieManager.test'
import webONHttpErrorReceive from './webONHttpErrorReceive.test'
import webONHttpErrorReceiveExample from './webONHttpErrorReceiveExample.test'
import webONHttpErrorRecvExampleIsReady from './webONHttpErrorRecvExampleIsReady.test'
import webONHttpErrorReceiveIframe from './webONHttpErrorReceiveIframe.test'
import webOnAudioStateChanged from './webOnAudioStateChanged.test'
export default function testsuite() {
//webOnBeforeUnload()
webOnInterceptReqOne()
webOnInterceptReqTwo()
webOnInterceptReqThree()
webOnSslError()
webOnFirstCont()
webOnFirstContTwo()
webOnFirstContThree()
webOnFirstContFour()
webDefaultFontSizeWithMinLogical()
webDefaultFontSize()
webDefaultFontSizeNoMinFontSize()
webDefaultFontSizeNoAll()
//webOnFullScreenEnter()
//webOnFullScreenExit()
webGetCookieManager()
webONHttpErrorReceive()
webONHttpErrorReceiveExample()
webONHttpErrorRecvExampleIsReady()
webONHttpErrorReceiveIframe()
//webOnAudioStateChanged()
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device 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 { expect } from "@ohos/hypium";
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
static registerEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEvent(actualValue,eventId){
try {
let backData = {
data: {
"ACTION": actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerEventTwo(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEventTwo(expectedValue,actualValue,eventId){
try {
let backData = {
data: {
"expectedValue":expectedValue,
"actualValue":actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerContainEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static commitKey(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));
}
}
static registerLargerEvent(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
}
\ 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 = "emitdefaultFontSize73AndminFontSize1WebC";
export default function webDefaultFontSize() {
describe('ActsAceWebDevWebDefaultFontSizeTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webDefaultFontSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get webDefaultFontSize state success " + JSON.stringify(pages));
if (!("webDefaultFontSize" == pages.name)) {
console.info("get webDefaultFontSize state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webDefaultFontSize page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webDefaultFontSize page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webDefaultFontSize beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webDefaultFontSize 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_WEBPATR6_API_0200
*tc.name testDefaultFontSize73AndMinFontSize1WebC
*tc.desc test with defaultfontsize 73 and minfontsize 1
*/
it('testDefaultFontSize73AndMinFontSize1WebC',0,async function(done){
emitKey="emitdefaultFontSize73AndminFontSize73WebC";
Utils.registerEvent("testDefaultFontSize73AndMinFontSize1WebC","72px",432,done);
sendEventByKey('webDefaultFontSize',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBPATR6_API_0300
*tc.name testDefaultFontSize73AndMinFontSize73WebC
*tc.desc test with defaultfontsize 73 and minfontsize 73
*/
it('testDefaultFontSize73AndMinFontSize73WebC',0,async function(done){
emitKey="emitdefaultFontSize73AndminFontSize73WebC";
Utils.registerEvent("testDefaultFontSize73AndMinFontSize73WebC","72px",434,done);
sendEventByKey('webDefaultFontSize',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 = "emitdefaultFontSizeAndminFontSizeNoAllWebC";
export default function webDefaultFontSizeNoAll() {
describe('ActsAceWebDevWebDefaultFontSizeNoAllTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webDefaultFontSizeNoAll',
}
try {
router.clear();
let pages = router.getState();
console.info("get webDefaultFontSizeNoAll state success " + JSON.stringify(pages));
if (!("webDefaultFontSizeNoAll" == pages.name)) {
console.info("get webDefaultFontSizeNoAll state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webDefaultFontSizeNoAll page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webDefaultFontSizeNoAll page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webDefaultFontSizeNoAll beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webDefaultFontSizeNoAll 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_WEBPATR6_API_0600
*tc.name testNoDefaultFontSizeAndNoMinFontSizeWebC
*tc.desc test with no set defaultfontsize or minfontsize
*/
it('testNoDefaultFontSizeAndNoMinFontSizeWebC',0,async function(done){
emitKey="emitdefaultFontSizeAndminFontSizeNoAllWebC";
Utils.registerEvent("testNoDefaultFontSizeAndNoMinFontSizeWebC","16px",440,done);
sendEventByKey('webDefaultFontSizeNoAll',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 = "emitdefaultFontSize7AndNominFontSizeWebC";
export default function webDefaultFontSizeNoMinFontSize() {
describe('ActsAceWebDevWebDefaultFontSizeNoMinFontSizeTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webDefaultFontSizeNoMinFontSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get webDefaultFontSizeNoMinFontSize state success " + JSON.stringify(pages));
if (!("webDefaultFontSizeNoMinFontSize" == pages.name)) {
console.info("get webDefaultFontSizeNoMinFontSize state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webDefaultFontSizeNoMinFontSize page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webDefaultFontSizeNoMinFontSize page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webDefaultFontSizeNoMinFontSize beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webDefaultFontSizeNoMinFontSize 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_WEBPATR6_API_0400
*tc.name testDefaultFontSize7AndNoMinFontSizeWebC
*tc.desc test with defaultfontsize 7 and no set minfontsize
*/
it('testDefaultFontSize7AndNoMinFontSizeWebC',0,async function(done){
emitKey="emitdefaultFontSize17AndCssFontSize9WebC";
Utils.registerEvent("testDefaultFontSize7AndNoMinFontSizeWebC","8px",436,done);
sendEventByKey('webDefaultFontSizeNoMinFontSize',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBPATR6_API_0500
*tc.name testDefaultFontSize17AndCssFontSize9WebC
*tc.desc test with defaultfontsize 17 and css font-size 9
*/
it('testDefaultFontSize17AndCssFontSize9WebC',0,async function(done){
emitKey="emitdefaultFontSize17AndCssFontSize9WebC";
Utils.registerEvent("testDefaultFontSize17AndCssFontSize9WebC","9px",438,done);
sendEventByKey('webDefaultFontSizeNoMinFontSize',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 = "emitdefaultFontSizeHalfAndminFontSizeHalfWebC";
export default function webDefaultFontSizeWithMinLogical() {
describe('ActsAceWebDevWebDefaultFontSizeWithMinLogicalTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webDefaultFontSizeWithMinLogical',
}
try {
router.clear();
let pages = router.getState();
console.info("get webDefaultFontSizeWithMinLogical state success " + JSON.stringify(pages));
if (!("webDefaultFontSizeWithMinLogical" == pages.name)) {
console.info("get webDefaultFontSizeWithMinLogical state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webDefaultFontSizeWithMinLogical page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webDefaultFontSizeWithMinLogical page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webDefaultFontSizeWithMinLogical beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webDefaultFontSizeWithMinLogical 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_WEBPATR6_API_0100
*tc.name testDefaultFontSizeHalfAndMinFontSizeHalfWebC
*tc.desc test with defaultfontsize 0.5 , minfontsize 0.5 and minLogicalFontSize 0.5
*/
it('testDefaultFontSizeHalfAndMinFontSizeHalfWebC',0,async function(done){
emitKey="emitdefaultFontSizeHalfAndminFontSizeHalfWebC";
Utils.registerEvent("testDefaultFontSizeHalfAndMinFontSizeHalfWebC","1px",430,done);
sendEventByKey('webDefaultFontSizeWithMinLogical',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 = "emitGetCookieManagerWebc";
export default function webGetCookieManager() {
describe('ActsAceWebDevWebGetCookieManagerTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webGetCookieManager',
}
try {
router.clear();
let pages = router.getState();
console.info("get webGetCookieManager state success " + JSON.stringify(pages));
if (!("webGetCookieManager" == pages.name)) {
console.info("get webGetCookieManager state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webGetCookieManager page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webGetCookieManager page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webGetCookieManager beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webGetCookieManager 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_WEBGETCOOKIEMMANAGER_API_0100
*tc.name testGetCookieManagerWebc
*tc.desc test interface of onfullscreenexit with runjavascript exitFullscreen
*/
it('testGetCookieManagerWebc',0,async function(done){
emitKey="emitGetCookieManagerWebc";
Utils.registerEvent("testGetCookieManagerWebc",2,446,done);
sendEventByKey('webGetCookieManager',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 = "emitOnHttpErrorReceiveFixedUserAgentWebc";
export default function webONHttpErrorReceive() {
describe('ActsAceWebDevWebONHttpErrorReceiveTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webONHttpErrorReceive',
}
try {
router.clear();
let pages = router.getState();
console.info("get webONHttpErrorReceive state success " + JSON.stringify(pages));
if (!("webONHttpErrorReceive" == pages.name)) {
console.info("get webONHttpErrorReceive state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webONHttpErrorReceive page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webONHttpErrorReceive page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webONHttpErrorReceive beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webONHttpErrorReceive 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_WEBERRORRECV_API_0100
*tc.name testOnHttpErrorReceiveFixedUserAgentWebc
*tc.desc test interface of onHttpErrorReceive with parameter fixed userAgent
*/
it('testOnHttpErrorReceiveFixedUserAgentWebc',0,async function(done){
emitKey="emitOnHttpErrorReceiveFixedUserAgentWebc";
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","http://1.1.1.123/index.html",362,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUstestOnHttpErrorReceiveFixedUserAgentWebcerAgent",true,364,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc",false,466,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc",false,468,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","GET",470,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","",472,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","utf-8",474,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","text/html",476,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc",403,478,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","Forbidden",480,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","User-Agent",482,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36",484,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","User-Agent",486,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36",488,done);
Utils.registerEvent("testOnHttpErrorReceiveFixedUserAgentWebc","403http://1.1.1.123/index.html",490,done);
sendEventByKey('webONHttpErrorReceive',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 = "emitOnHttpErrorReceiveByExampleWebc";
export default function webONHttpErrorReceiveExample() {
describe('ActsAceWebDevWebONHttpErrorReceiveExampleTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webONHttpErrorReceiveExample',
}
try {
router.clear();
let pages = router.getState();
console.info("get webONHttpErrorReceiveExample state success " + JSON.stringify(pages));
if (!("webONHttpErrorReceiveExample" == pages.name)) {
console.info("get webONHttpErrorReceiveExample state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webONHttpErrorReceiveExample page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webONHttpErrorReceiveExample page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webONHttpErrorReceiveExample beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webONHttpErrorReceiveExample 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_WEBERRORRECV_API_0200
*tc.name testOnHttpErrorReceiveByExampleWebc
*tc.desc test interface of onHttpErrorReceive with parameter used by example
*/
it('testOnHttpErrorReceiveByExampleWebc',0,async function(done){
emitKey="emitOnHttpErrorReceiveByExampleWebc";
Utils.registerEvent("testOnHttpErrorReceiveByExampleWebc",403,491,done);
Utils.registerEvent("testOnHttpErrorReceiveByExampleWebc","intercept test",492,done);
sendEventByKey('webONHttpErrorReceiveExample',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 = "emitOnHttpErrorReceiveByIframeHtmlWebc";
export default function webONHttpErrorReceiveIframe() {
describe('ActsAceWebDevWebONHttpErrorReceiveIframeTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webONHttpErrorReceiveIframe',
}
try {
router.clear();
let pages = router.getState();
console.info("get webONHttpErrorReceiveIframe state success " + JSON.stringify(pages));
if (!("webONHttpErrorReceiveIframe" == pages.name)) {
console.info("get webONHttpErrorReceiveIframe state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webONHttpErrorReceiveIframe page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webONHttpErrorReceiveIframe page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webONHttpErrorReceiveIframe beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webONHttpErrorReceiveIframe 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_WEBERRORRECV_API_0300
*tc.name testOnHttpErrorReceiveByIframeHtmlWebc
*tc.desc test interface of onHttpErrorReceive with parameter used by html file with iframe
*/
it('testOnHttpErrorReceiveByIframeHtmlWebc',0,async function(done){
emitKey="emitOnHttpErrorReceiveByIframeHtmlWebc";
Utils.registerEvent("testOnHttpErrorReceiveByIframeHtmlWebc",false,496,done);
Utils.registerEvent("testOnHttpErrorReceiveByIframeHtmlWebc","index",498,done);
sendEventByKey('webONHttpErrorReceiveIframe',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 = "emitOnHttpErrorRecvExampleIsReadyFalseWebc";
export default function webONHttpErrorRecvExampleIsReady() {
describe('ActsAceWebDevWebONHttpErrorRecvExampleIsReadyTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webONHttpErrorRecvExampleIsReady',
}
try {
router.clear();
let pages = router.getState();
console.info("get webONHttpErrorRecvExampleIsReady state success " + JSON.stringify(pages));
if (!("webONHttpErrorRecvExampleIsReady" == pages.name)) {
console.info("get webONHttpErrorRecvExampleIsReady state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webONHttpErrorRecvExampleIsReady page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webONHttpErrorRecvExampleIsReady page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webONHttpErrorRecvExampleIsReady beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webONHttpErrorRecvExampleIsReady 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_WEBERRORRECV_API_0300
*tc.name testOnHttpErrorRecvExampleIsReadyFalseWebc
*tc.desc test interface of onHttpErrorReceive with parameter used by example but setResponseIsReady false
*/
it('testOnHttpErrorRecvExampleIsReadyFalseWebc',0,async function(done){
emitKey="emitOnHttpErrorRecvExampleIsReadyFalseWebc";
Utils.registerEvent("testOnHttpErrorRecvExampleIsReadyFalseWebc",403,493,done);
Utils.registerEvent("testOnHttpErrorRecvExampleIsReadyFalseWebc","",494,done);
sendEventByKey('webONHttpErrorRecvExampleIsReady',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 = "emitAudioStatePlayWebc";
export default function webOnAudioStateChanged() {
describe('ActsAceWebDevWebOnAudioStateChangedTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnAudioStateChanged',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnAudioStateChanged state success " + JSON.stringify(pages));
if (!("webOnAudioStateChanged" == pages.name)) {
console.info("get webOnAudioStateChanged state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnAudioStateChanged page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnAudioStateChanged page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnAudioStateChanged beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnAudioStateChanged 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_WEBAUDIOSTATE_API_0100
*tc.name testOnAudioStateChangedPlayWebc
*tc.desc test interface of onaudiostatechanged with audio play
*/
it('testOnAudioStateChangedPlayWebc',0,async function(done){
emitKey="emitAudioStatePauseWebc";
Utils.registerEvent("testOnAudioStateChangedPlayWebc",true,501,done);
Utils.registerEvent("testOnAudioStateChangedPlayWebc","false",502,done);
sendEventByKey('webOnAudioStateChanged',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBAUDIOSTATE_API_0200
*tc.name testOnAudioStateChangedPauseWebc
*tc.desc test interface of onaudiostatechanged with audio pause
*/
it('testOnAudioStateChangedPauseWebc',0,async function(done){
emitKey="emitAudioStatePauseWebc";
Utils.registerEvent("testOnAudioStateChangedPauseWebc",false,503,done);
Utils.registerEvent("testOnAudioStateChangedPauseWebc","true",504,done);
sendEventByKey('webOnAudioStateChanged',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 = "emitOnBeforeUnloadWebC";
export default function webOnBeforeUnload() {
describe('ActsAceWebDevWebOnBeforeUnloadTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnBeforeUnload beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnBeforeUnload 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_WEB_API_0100
*tc.name testOnBeforeUnloadWebC
*tc.desc onBeforeUnload after page refresh
*/
it('testOnBeforeUnloadWebC',0,async function(done){
emitKey="emitOnBeforeUnloadAgainWebC";
Utils.registerEvent("testOnBeforeUnloadWebC","Is it OK to leave/reload this page?",402,done);
sendEventByKey('webOnBeforeUnload',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEB_API_0200
*tc.name testOnBeforeUnloadAgainWebC
*tc.desc onBeforeUnload after page loadUrl new
*/
it('testOnBeforeUnloadAgainWebC',0,async function(done){
emitKey="emitOnBeforeUnloadAgainWebC";
Utils.registerEvent("testOnBeforeUnloadAgainWebC","Is it OK to leave/reload this page?",404,done);
sendEventByKey('webOnBeforeUnload',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 = "emitOnfirstcontentfulpaintWebc";
export default function webOnFirstCont() {
describe('ActsAceWebDevWebOnFirstContTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFirstCont',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFirstCont state success " + JSON.stringify(pages));
if (!("webOnFirstCont" == pages.name)) {
console.info("get webOnFirstCont state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFirstCont page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFirstCont page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFirstCont beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFirstCont 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_WEBPATR5_API_0100
*tc.name testOnfirstcontentfulpaintWebc
*tc.desc onfirstcontentfulpaint with web src null
*/
it('testOnfirstcontentfulpaintWebc',0,async function(done){
emitKey="emitOnfirstcontentfulpaintWebc";
Utils.registerEvent("testOnfirstcontentfulpaintWebc","NoSrcTest",422,done);
sendEventByKey('webOnFirstCont',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 = "emitRefreshOnfirstcontentfulpaintWebc";
export default function webOnFirstContFour() {
describe('ActsAceWebDevWebOnFirstContFourTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFirstContFour',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFirstContFour state success " + JSON.stringify(pages));
if (!("webOnFirstContFour" == pages.name)) {
console.info("get webOnFirstContFour state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFirstContFour page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFirstContFour page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFirstContFour beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFirstContFour 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_WEBPATR5_API_0400
*tc.name testOnfirstcontentfulpaintrefreshWebc
*tc.desc onfirstcontentfulpaint with web refresh
*/
it('testOnfirstcontentfulpaintrefreshWebc',0,async function(done){
emitKey="emitRefreshOnfirstcontentfulpaintWebc";
Utils.registerEvent("testOnfirstcontentfulpaintrefreshWebc",true,428,done);
sendEventByKey('webOnFirstContFour',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 = "emitLoadUrlOnfirstcontentfulpaintWebc";
export default function webOnFirstContThree() {
describe('ActsAceWebDevWebOnFirstContThreeTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFirstContThree',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFirstContThree state success " + JSON.stringify(pages));
if (!("webOnFirstContThree" == pages.name)) {
console.info("get webOnFirstContThree state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFirstContThree page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFirstContThree page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFirstContThree beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFirstContThree 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_WEBPATR5_API_0300
*tc.name testOnfirstcontentfulpaintloadurlWebc
*tc.desc onfirstcontentfulpaint with web load url
*/
it('testOnfirstcontentfulpaintloadurlWebc',0,async function(done){
emitKey="emitLoadUrlOnfirstcontentfulpaintWebc";
Utils.registerEvent("testOnfirstcontentfulpaintloadurlWebc",true,426,done);
sendEventByKey('webOnFirstContThree',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 = "emitNoneOnfirstcontentfulpaintWebc";
export default function webOnFirstContTwo() {
describe('ActsAceWebDevWebOnFirstContTwoTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFirstContTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFirstContTwo state success " + JSON.stringify(pages));
if (!("webOnFirstContTwo" == pages.name)) {
console.info("get webOnFirstContTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFirstContTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFirstContTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFirstContTwo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFirstContTwo 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_WEBPATR5_API_0200
*tc.name testOnfirstcontentfulpaintvisibilitynoneWebc
*tc.desc onfirstcontentfulpaint with web visibility none
*/
it('testOnfirstcontentfulpaintvisibilitynoneWebc',0,async function(done){
emitKey="emitNoneOnfirstcontentfulpaintWebc";
Utils.registerEvent("testOnfirstcontentfulpaintvisibilitynoneWebc","VisibilityNoneTest",424,done);
sendEventByKey('webOnFirstContTwo',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 = "emitOnfullscreenenterWebc";
export default function webOnFullScreenEnter() {
describe('ActsAceWebDevWebOnFullScreenEnterTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFullScreenEnter',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFullScreenEnter state success " + JSON.stringify(pages));
if (!("webOnFullScreenEnter" == pages.name)) {
console.info("get webOnFullScreenEnter state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFullScreenEnter page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFullScreenEnter page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFullScreenEnter beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFullScreenEnter 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_WEBFULLSCREEN_API_0100
*tc.name testOnFullScreenEnterWebc
*tc.desc test interface of onfullscreenenter with runjavascript handleFullScreen
*/
it('testOnFullScreenEnterWebc',0,async function(done){
emitKey="emitOnfullscreenenterWebc";
Utils.registerEvent("testOnFullScreenEnterWebc","2\"true\"",442,done);
sendEventByKey('webOnFullScreenEnter',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 = "emitOnfullscreenexitWebc";
export default function webOnFullScreenExit() {
describe('ActsAceWebDevWebOnFullScreenExitTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnFullScreenExit',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnFullScreenExit state success " + JSON.stringify(pages));
if (!("webOnFullScreenExit" == pages.name)) {
console.info("get webOnFullScreenExit state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnFullScreenExit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnFullScreenExit page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnFullScreenExit beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnFullScreenExit 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_WEBFULLSCREEN_API_0200
*tc.name testOnFullScreenExitWebc
*tc.desc test interface of onfullscreenexit with runjavascript exitFullscreen
*/
it('testOnFullScreenExitWebc',0,async function(done){
emitKey="emitOnfullscreenexitWebc";
Utils.registerEvent("testOnFullScreenExitWebc","2\"false\"",444,done);
sendEventByKey('webOnFullScreenExit',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 = "emitOnInterceptRequestWebC";
export default function webOnInterceptReqOne() {
describe('ActsAceWebDevWebOnInterceptReqOneTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnInterceptReqOne',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnInterceptReqOne state success " + JSON.stringify(pages));
if (!("webOnInterceptReqOne" == pages.name)) {
console.info("get webOnInterceptReqOne state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnInterceptReqOne page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnInterceptReqOne page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnInterceptReqOne beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnInterceptReqOne 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_WEBPATR2_API_0100
*tc.name testOnInterceptRequestWebC
*tc.desc onInterceptRequest without setting webresourceresponse
*/
it('testOnInterceptRequestWebC',0,async function(done){
emitKey="emitOnInterceptRequestWebC";
Utils.registerEvent("testOnInterceptRequestWebC","resource://rawfile/indexCopy.html",406,done);
sendEventByKey('webOnInterceptReqOne',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 = "emitOnInterceptRequestThirdWebC";
export default function webOnInterceptReqThree() {
describe('ActsAceWebDevWebOnInterceptReqThreeTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnInterceptReqThree',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnInterceptReqThree state success " + JSON.stringify(pages));
if (!("webOnInterceptReqThree" == pages.name)) {
console.info("get webOnInterceptReqThree state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnInterceptReqThree page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnInterceptReqThree page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnInterceptReqThree beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnInterceptReqThree 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_WEBPATR2_API_0300
*tc.name testOnInterceptRequestThirdWebC
*tc.desc onInterceptRequest with setting setresponsecede 404
*/
it('testOnInterceptRequestThirdWebC',0,async function(done){
emitKey="emitOnInterceptRequestThirdWebC";
Utils.registerEvent("testOnInterceptRequestThirdWebC",404,410,done);
sendEventByKey('webOnInterceptReqThree',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 = "emitOnInterceptRequestSecondWebC";
export default function webOnInterceptReqTwo() {
describe('ActsAceWebDevWebOnInterceptReqTwoTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnInterceptReqTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnInterceptReqTwo state success " + JSON.stringify(pages));
if (!("webOnInterceptReqTwo" == pages.name)) {
console.info("get webOnInterceptReqTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnInterceptReqTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnInterceptReqTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnInterceptReqTwo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnInterceptReqTwo 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_WEBPATR2_API_0200
*tc.name testOnInterceptRequestAgainWebC
*tc.desc onInterceptRequest with setting webresourceresponse
*/
it('testOnInterceptRequestAgainWebC',0,async function(done){
emitKey="emitOnInterceptRequestSecondWebC";
Utils.registerEvent("testOnInterceptRequestAgainWebC","intercept test",408,done);
sendEventByKey('webOnInterceptReqTwo',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 = "emitOnsslerroreventreceiveWebC";
export default function webOnSslError() {
describe('ActsAceWebDevWebOnSslErrorTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webOnSslError',
}
try {
router.clear();
let pages = router.getState();
console.info("get webOnSslError state success " + JSON.stringify(pages));
if (!("webOnSslError" == pages.name)) {
console.info("get webOnSslError state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webOnSslError page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webOnSslError page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webOnSslError beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webOnSslError 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_WEBPATR4_API_0100
*tc.name testOnsslerroreventreceiveWebC
*tc.desc onsslerroreventreceive after load https://wrong.host.badssl.com
*/
it('testOnsslerroreventreceiveWebC',0,async function(done){
emitKey="emitOnsslerroreventreceiveWebC";
Utils.registerEvent("testOnsslerroreventreceiveWebC","1",420,done);
sendEventByKey('webOnSslError',10,'');
})
})
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "true"
}
],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"requestPermissions": [
{
"name": "ohos.permission.LOCATION"
},
{
"name": "ohos.permission.INTERNET"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/webOnBeforeUnload",
"MainAbility/pages/webOnSslError",
"MainAbility/pages/webOnInterceptReqOne",
"MainAbility/pages/webOnInterceptReqTwo",
"MainAbility/pages/webOnInterceptReqThree",
"MainAbility/pages/webDefaultFontSizeWithMinLogical",
"MainAbility/pages/webDefaultFontSize",
"MainAbility/pages/webDefaultFontSizeNoMinFontSize",
"MainAbility/pages/webDefaultFontSizeNoAll",
"MainAbility/pages/webOnFirstCont",
"MainAbility/pages/webOnFirstContTwo",
"MainAbility/pages/webOnFirstContThree",
"MainAbility/pages/webOnFirstContFour",
"MainAbility/pages/webOnFullScreenEnter",
"MainAbility/pages/webOnFullScreenExit",
"MainAbility/pages/webGetCookieManager",
"MainAbility/pages/webONHttpErrorReceive",
"MainAbility/pages/webONHttpErrorReceiveExample",
"MainAbility/pages/webONHttpErrorRecvExampleIsReady",
"MainAbility/pages/webONHttpErrorReceiveIframe",
"MainAbility/pages/webOnAudioStateChanged"
]
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>audioTest</title>
</head>
<body>
<audio controls autoplay loop name="media" id="my-bgm">
<source src="./01.mp3" type="audio/mpeg">
</audio>
</body>
<script>
let ele=document.getElementById("my-bgm");
let loadAudio;
ele.onload=function(){
loadAudio="load complete"
}
function test(){
backToEts.test("backToEts")
}
function enableMute() {
var myVid = document.getElementById("my-bgm");
myVid.muted = true;
return myVid.muted
}
function disableMute() {
var myVid = document.getElementById("my-bgm");
myVid.muted = false;
return myVid.muted
}
function checkMute() {
var myVid = document.getElementById("my-bgm");
if ( myVid.muted ) {
return "muted"
} else {
return "unmuted"
}
}
function play() {
var myVid = document.getElementById("my-bgm");
if (myVid.paused) {
myVid.play()
}
return myVid.paused
}
function pause() {
var myVid = document.getElementById("my-bgm");
myVid.pause()
return myVid.paused
}
play()
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FullScreenTest</title>
</head>
<body>
<div id="content" style="width:500px;height:500px;background:red;">
这是被全屏的元素
<button id='btn'>全屏</button>
<button id="closeBtn">退出全屏</button>
</div>
<script>
let ele=document.getElementById("content");
let loadContent;
ele.onload=function(){
loadContent="load complete"
}
function test(){
backToEts.test("backToEts")
}
function fullScreen(el) {
var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
wscript;
if(typeof rfs != "undefined" && rfs) {
rfs.call(el);
return;
}
if(typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if(wscript) {
wscript.SendKeys("{F11}");
}
}
}
function exitFullScreen(el) {
var el= document,
cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
wscript;
if (typeof cfs != "undefined" && cfs) {
cfs.call(el);
return;
}
if (typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
}
}
var btn = document.getElementById('btn');
var content = document.getElementById('content'); //被全屏显示的元素
btn.onclick = function(){
fullScreen(content);
}
var closeBtn = document.getElementById('closeBtn');
closeBtn.onclick = function(){
exitFullScreen();
}
function elementFullScreen() {
let content = document.getElementById('content');
return content.requestFullscreen()
}
function elementExitFullScreen() {
document.exitFullscreen()
}
function checkIsFullScreen() {
var isFull =!! (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement)
return isFull
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index</title>
<style>
#pageHeight{
height:900px
}
#pageHeight1{
height:900px
}
</style>
</head>
<body>
<div id="container">首页</div>
<div id="pageHeight"></div>
<div id="contenttext">内容</div>
<div id="pageHeight1"></div>
<div id="ending">末尾</div>
<a href="second.html" id="fileAccess">打开rawfile文件</a>
<img src="icon.png" alt="icon" id="imgs">
</body>
<script>
let ele=document.getElementById("imgs");
let loadImage;
ele.onload=function(){
loadImage="load complete"
}
function getUserAgent(){
return navigator.userAgent
}
function test(){
backToEts.test("backToEts")
}
function testRunJavaScript(){
return "testRunJavaScript"
}
function getPageHeight(){
let height=document.body.scrollHeight
return height
}
function proxy(){
objName.register("backToEts")
}
function registerTest(){
let str=objName.register();
console.log(str);
return str
}
function jsAccess(){
console.log("web111")
}
function consoleTest(){
console.log("console test")
}
function alertTest(){
alert('alert test')
}
function confirmTest(){
confirm("confirm test")
}
function getImgResult(){
return loadImage
}
function toPrompt(){
let result=prompt("age","20");
console.log("result:"+result)
}
function openRawFile(){
document.getElementById("fileAccess").click()
}
function gettitle(){
return document.write(document.title);
}
function getNavigatorOnLine(){
let onlineResult = navigator.onLine;
return onlineResult
}
function checkPageUpEle(){
const up_element = document.getElementById("container");
let UpEle = up_element.innerText;
let x = up_element.scrollLeft;
let y = up_element.scrollTop;
let z = up_element.scrollHeight;
let w = up_element.scrollWidth;
let style = (window.getComputedStyle(document.getElementById("container"), null)).display;
let style2 = (window.getComputedStyle(document.getElementById("container"), null)).getPropertyValue("visibility");
console.log("UpEle : " + UpEle + style + style2 + x + y + z + w);
return [UpEle,style,style2,x,y,z,w]
}
function checkContentEle(){
const middle_element = document.getElementById("contenttext");
let ContentEle = middle_element.innerText;
let x = middle_element.scrollLeft;
let y = middle_element.scrollTop;
let z = middle_element.scrollHeight;
let w = middle_element.scrollWidth;
let style = (window.getComputedStyle(document.getElementById("contenttext"), null)).display;
let style2 = (window.getComputedStyle(document.getElementById("contenttext"), null)).getPropertyValue("visibility");
console.log("ContentEle : " + ContentEle + style + style2 + x + y + z + w);
return [ContentEle,style,style2,x,y,z,w]
}
function checkPageDownEle(){
const down_element = document.getElementById("ending");
let DownEle = down_element.innerText;
let x = down_element.scrollLeft;
let y = down_element.scrollTop;
let z = down_element.scrollHeight;
let w = down_element.scrollWidth;
let style = (window.getComputedStyle(document.getElementById("ending"), null)).display;
let style2 = (window.getComputedStyle(document.getElementById("ending"), null)).getPropertyValue("visibility");
console.log("DownEle : " + DownEle + style + style2 + x + y + z + w);
return [DownEle,style,style2,x,y,z,w]
}
function checkVIsible(){
let m = document.body.scrollHeight;
let n = document.documentElement.scrollHeight;
let a = document.body.scrollTop;
let b = document.documentElement.scrollTop;
console.log("checkVisible result is : " + m + n + a + b);
return [m,n,a,b]
}
gettitle()
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index</title>
<style>
#pageHeight{
height:350px
}
#pageHeight1{
height:350px
}
</style>
</head>
<body>
<div id="container">首页</div>
<div id="pageHeight"></div>
<div id="contenttext" style="font-size: 9px;">内容</div>
<div id="pageHeight1"></div>
<div id="ending">末尾</div>
<a href="second.html" id="fileAccess">打开rawfile文件</a>
<img src="icon.png" alt="icon" id="imgs">
</body>
<script>
let ele=document.getElementById("imgs");
let loadImage;
ele.onload=function(){
loadImage="load complete"
}
function getUserAgent(){
return navigator.userAgent
}
function test(){
backToEts.test("backToEts")
}
function testRunJavaScript(){
return "testRunJavaScript"
}
function getPageHeight(){
let height=document.body.scrollHeight
return height
}
function proxy(){
objName.register("backToEts")
}
function registerTest(){
let str=objName.register();
console.log(str);
return str
}
function jsAccess(){
console.log("web111")
}
function consoleTest(){
console.log("console test")
}
function alertTest(){
alert('alert test')
}
function confirmTest(){
confirm("confirm test")
}
function getImgResult(){
return loadImage
}
function toPrompt(){
let result=prompt("age","20");
console.log("result:"+result)
}
function openRawFile(){
document.getElementById("fileAccess").click()
}
function gettitle(){
return document.title
}
function getNavigatorOnLine(){
let onlineResult = navigator.onLine;
return onlineResult
}
function getPageFontsize(){
const start_element = document.getElementById("container");
let StartEle = start_element.innerText;
let style = (window.getComputedStyle(document.getElementById("container"), null)).fontSize;
console.log("StartEle : " + StartEle + style);
return [StartEle,style]
}
function getTestPageFontsize(){
const middle_element = document.getElementById("contenttext");
let ContentEle = middle_element.innerText;
let style = (window.getComputedStyle(document.getElementById("contenttext"), null)).getPropertyValue('font-size')
console.log("ContentEle : " + ContentEle + style);
return [ContentEle,style]
}
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>homework</title>
<style>
html{
width:2000px;
}
#kuan{
height:220px;
white-space:nowrap;
}
img{
border-radius:5px;
margin-top:10px;
width:1000px;
height:200px;
display:inline
}
#centerHeight{
height:3000px;
}
</style>
</head>
<body>
<div >
<div id="kuan">
<img src="icon.png" id ="leftImg">
<img src="icon.png" id ="centerImg">
<img src="icon.png" id ="rightImg">
</div>
<div id="gao">
<div id="centerHeight"></div>
<img src="icon.png" alt="icon" id="bottomImg">
</div>
</div>
</body>
</html>
<script>
let ele=document.getElementById("leftImg");
let loadImage;
document.getElementById("imgs").click()
ele.onload=function(){
loadImage="load complete"
}
function myRefresh() {
return window.location.reload();
}
</script>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册