diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets index 6316dd25a363479483cfc26581c89baf51103d4e..f2cc190160e7d0cc77f46ffd5a515af74de8165b 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets +++ b/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/web.ets @@ -43,6 +43,7 @@ struct Index { @State geolocationAccess:boolean=true @State onlineImageAccess:boolean=true @State databaseAccess:boolean=true + @State overviewModeAccess:boolean=false @State initialScale:number=100 @State enterPageEnd:boolean=false @State newScale:number=0 @@ -53,6 +54,7 @@ struct Index { @State cacheError:boolean=false @State mixedSwitch:boolean=false @State mixedAllSwitch:boolean=false + @State overViewFalseHeight:number=0 @State isProgressFinish:boolean=false @State isHttpErrorReceive:boolean=false onPageShow(){ @@ -104,6 +106,7 @@ struct Index { .cacheMode(this.cacheMode) .initialScale(this.initialScale) .mixedMode(this.mixedMode) + .overviewModeAccess(this.overviewModeAccess) .userAgent("Mozila/5.0 (Linux; Andriod 9; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.4.1 MobileSafari/537.36") .javaScriptProxy({ object:this.jsObj, @@ -493,6 +496,32 @@ struct Index { },3000) break; } + case "emitOverviewModeAccessFalse":{ + this.overviewModeAccess=false + await Utils.sleep(1000) + this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"}); + setTimeout(()=>{ + let webPageHeight=this.controller.getPageHeight() + this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ + this.overViewFalseHeight=parseInt(res) + console.info("getViewResult==>"+res) + Utils.emitEventTwo(webPageHeight,res,168) + }}) + },3000) + break; + } + case "emitOverviewModeAccessTrue":{ + this.overviewModeAccess=true + await Utils.sleep(1000) + this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"}); + setTimeout(()=>{ + this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ + console.info("getViewResult==>"+res) + Utils.emitEventTwo(this.overViewFalseHeight,parseInt(res),170) + }}) + },3000) + break; + } case "emitOnPrompt":{ this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}); setTimeout(()=>{ @@ -753,4 +782,4 @@ struct Index { } } } -} +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/webTwo.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/webTwo.ets deleted file mode 100644 index bda60a1d2a064810aad507a14a8ca80d643f5d69..0000000000000000000000000000000000000000 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/MainAbility/pages/webTwo.ets +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 events_emitter from '@ohos.events.emitter'; -import Utils from '../../test/Utils'; - -@Entry -@Component -struct Second { - controller:WebController = new WebController() - @State str:string="emitOverviewModeAccessTrue" - @State overviewModeAccess:boolean=true - @State overviewScale:string="" - onPageShow(){ - let valueChangeEvent={ - eventId:10, - priority:events_emitter.EventPriority.LOW - }; - events_emitter.on(valueChangeEvent,this.valueChangeCallBack); - } - private valueChangeCallBack=(eventData)=>{ - console.info("web 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('webcomponenttwo').onClick(async ()=>{ - console.info("key==>"+this.str); - switch(this.str){ - case "emitOverviewModeAccessTrue":{ - this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ - console.info("getViewResult==>"+res); - this.overviewScale=res; - Utils.emitEventTwo(res,"1",168); - }}); - break; - } - case "emitOverviewModeAccessFalse":{ - this.overviewModeAccess=false; - await Utils.sleep(2000); - this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ - console.info("getViewResult==>"+res); - Utils.emitEventTwo(this.overviewScale,res,170); - }}); - break; - } - default: - console.info("can not match case"); - } - }) - } - Web({src:$rawfile('overview.html'),controller:this.controller}) - .overviewModeAccess(this.overviewModeAccess) - } - } -} diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/test/List.test.ets index bae210db91d571d0d991383c80ae2cc4ff79fe00..079023dd24ba05f62f21dacf79f7077bb41b6e0d 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_web_dev/entry/src/main/ets/test/List.test.ets @@ -13,8 +13,7 @@ * limitations under the License. */ import webJsunit from './WebJsunit.test' -import webTwoJsunit from './WebTwoJsunit.test' + export default function testsuite() { webJsunit() - webTwoJsunit() } \ No newline at end of file diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets index 4683d922e12ec1eccfd04965df9a559060a60e5f..0d0a2cfc362ddd748f2fb221facfbaafc23ec920 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets +++ b/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebJsunit.test.ets @@ -348,12 +348,32 @@ export default function webJsunit() { *tc.desic Sets allow the Web access the database */ it('databaseAccessTrue',0,async function(done){ - emitKey="emitOnPrompt"; + emitKey="emitOverviewModeAccessFalse"; Utils.registerContainEvent("databaseAccessTrue","openDatabase",164,done); sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_032 + *tc.number SUB_ACE_BASIC_ETS_API_032 + *tc.name overviewModeAccessFalse + *tc.desic Sets not allow the Web access overview mode + */ + it('overviewModeAccessFalse',0,async function(done){ + emitKey="emitOverviewModeAccessTrue"; + Utils.registerEventTwo("overviewModeAccessFalse",168,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_033 + *tc.name overviewModeAccessTrue + *tc.desic Sets allow the Web access overview mode + */ + it('overviewModeAccessTrue',0,async function(done){ + emitKey="emitOnPrompt"; + Utils.registerLargerEvent("overviewModeAccessTrue",170,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_034 *tc.name onPrompt *tc.desic Triggered when the web page wants to display a JavaScript prompt() dialog */ @@ -363,7 +383,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_033 + *tc.number SUB_ACE_BASIC_ETS_API_035 *tc.name cacheModeOnly *tc.desic load cache and not online */ @@ -373,7 +393,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_034 + *tc.number SUB_ACE_BASIC_ETS_API_036 *tc.name cacheModeDefault *tc.desic load cache when they are available and not expired, otherwise load online */ @@ -383,7 +403,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_035 + *tc.number SUB_ACE_BASIC_ETS_API_037 *tc.name mixedModeNone *tc.desic Sets Don't allow unsecure sources from a secure origin */ @@ -393,7 +413,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_036 + *tc.number SUB_ACE_BASIC_ETS_API_038 *tc.name mixedModeAll *tc.desic Sets Allows all HTTP and HTTPS content can be loaded */ @@ -403,7 +423,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_037 + *tc.number SUB_ACE_BASIC_ETS_API_039 *tc.name fileAccessTrue *tc.desic Sets enable local file system access in Web */ @@ -413,7 +433,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_038 + *tc.number SUB_ACE_BASIC_ETS_API_040 *tc.name onPageBegin *tc.desic Triggered when the page loading progress changes */ @@ -423,7 +443,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_039 + *tc.number SUB_ACE_BASIC_ETS_API_041 *tc.name onPageEnd *tc.desic Triggered at the begin of web page loading */ @@ -433,7 +453,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_040 + *tc.number SUB_ACE_BASIC_ETS_API_042 *tc.name onConsole *tc.desic Triggered when the web page receives a JavaScript console message */ @@ -443,7 +463,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_041 + *tc.number SUB_ACE_BASIC_ETS_API_043 *tc.name onAlert *tc.desic Triggered when the Web wants to display a JavaScript alert() dialog */ @@ -453,7 +473,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_042 + *tc.number SUB_ACE_BASIC_ETS_API_044 *tc.name onConfirm *tc.desic Triggered when the web page wants to display a JavaScript confirm() dialog */ @@ -463,7 +483,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_043 + *tc.number SUB_ACE_BASIC_ETS_API_045 *tc.name onErrorReceive *tc.desic Triggered when the web page receives a web resource loading error */ @@ -473,7 +493,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_044 + *tc.number SUB_ACE_BASIC_ETS_API_046 *tc.name onHttpErrorReceive *tc.desic Triggered when the web page receives a web resource loading HTTP error */ @@ -483,7 +503,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_045 + *tc.number SUB_ACE_BASIC_ETS_API_047 *tc.name onTitleReceive *tc.desic Triggered when the title of the main application document changes */ @@ -493,7 +513,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_046 + *tc.number SUB_ACE_BASIC_ETS_API_048 *tc.name onDownloadStart *tc.desic Triggered when starting to download */ @@ -503,7 +523,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_047 + *tc.number SUB_ACE_BASIC_ETS_API_049 *tc.name setCookie *tc.desic Sets the cookie */ @@ -513,7 +533,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_048 + *tc.number SUB_ACE_BASIC_ETS_API_050 *tc.name getCookie *tc.desic Gets all cookies for the given URL */ @@ -523,7 +543,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_049 + *tc.number SUB_ACE_BASIC_ETS_API_051 *tc.name zoom *tc.desic Let the Web zoom by */ @@ -533,7 +553,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_050 + *tc.number SUB_ACE_BASIC_ETS_API_052 *tc.name zoomOut *tc.desic Let the Web zoom out */ @@ -543,7 +563,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_051 + *tc.number SUB_ACE_BASIC_ETS_API_053 *tc.name zoomIn *tc.desic Let the Web zoom in */ @@ -553,7 +573,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_052 + *tc.number SUB_ACE_BASIC_ETS_API_054 *tc.name deleteEntireCookie *tc.desic Delete all cookies */ @@ -563,7 +583,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_053 + *tc.number SUB_ACE_BASIC_ETS_API_055 *tc.name saveCookieSync *tc.desic Saves the cookies */ @@ -573,7 +593,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_054 + *tc.number SUB_ACE_BASIC_ETS_API_056 *tc.name clearHistory *tc.desic Clears the history in the Web */ @@ -583,7 +603,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_055 + *tc.number SUB_ACE_BASIC_ETS_API_057 *tc.name stop *tc.desic Stops the current load */ @@ -593,7 +613,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_056 + *tc.number SUB_ACE_BASIC_ETS_API_058 *tc.name onInactive *tc.desic Let the Web inactive. */ @@ -603,7 +623,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_057 + *tc.number SUB_ACE_BASIC_ETS_API_059 *tc.name onActive *tc.desic Let the Web active */ @@ -613,7 +633,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_058 + *tc.number SUB_ACE_BASIC_ETS_API_060 *tc.name registerJavaScriptProxy *tc.desic Registers the JavaScript object and method list */ @@ -623,7 +643,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_059 + *tc.number SUB_ACE_BASIC_ETS_API_061 *tc.name deleteJavaScriptRegister *tc.desic Deletes a registered JavaScript object with given name */ @@ -633,7 +653,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_060 + *tc.number SUB_ACE_BASIC_ETS_API_062 *tc.name javaScriptAccess *tc.desic Sets whether the Web allows JavaScript scripts to execute */ @@ -643,7 +663,7 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) /* - *tc.number SUB_ACE_BASIC_ETS_API_061 + *tc.number SUB_ACE_BASIC_ETS_API_063 *tc.name getCookieManager *tc.desic Gets network cookie manager */ @@ -653,4 +673,4 @@ export default function webJsunit() { sendEventByKey('webcomponent',10,''); }) }) -} +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebTwoJsunit.test.ets b/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebTwoJsunit.test.ets deleted file mode 100644 index 601a2792cbef4acaf71fa138952e17b1ca8b9777..0000000000000000000000000000000000000000 --- a/arkui/ace_ets_web_dev/entry/src/main/ets/test/WebTwoJsunit.test.ets +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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. - */ -// @ts-nocheck -import { describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium"; -import events_emitter from '@ohos.events.emitter'; -import router from '@system.router'; -import Utils from './Utils.ets'; -let emitKey = "emitOverviewModeAccessTrue"; -export default function webTwoJsunit() { - describe('overviewTest', function () { - beforeAll(async function (done) { - let options = { - uri: 'MainAbility/pages/webTwo', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get webTwo state success " + JSON.stringify(pages)); - if (!("webTwo" == pages.name)) { - console.info("get webTwo state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push webTwo page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push webTwo page error: " + err); - } - done() - }); - beforeEach(async function (done) { - await Utils.sleep(2000); - console.info("web beforeEach start"); - done(); - }) - afterEach(async function (done) { - console.info("web 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_API_001 - *tc.name overviewModeAccessTrue - *tc.desic Sets allow the Web access overview mode - */ - it('overviewModeAccessTrue',0,async function(done){ - emitKey="emitOverviewModeAccessFalse"; - Utils.registerLargerEvent("overviewModeAccessTrue",168,done); - sendEventByKey('webcomponenttwo',10,''); - }) - /* - *tc.number SUB_ACE_BASIC_ETS_API_002 - *tc.name overviewModeAccessFalse - *tc.desic Sets not allow the Web access overview mode - */ - it('overviewModeAccessFalse',0,async function(done){ - emitKey="emitOverviewModeAccessFalse"; - Utils.registerLargerEvent("overviewModeAccessFalse",170,done); - sendEventByKey('webcomponenttwo',10,''); - }) - }) -} diff --git a/arkui/ace_ets_web_dev/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_web_dev/entry/src/main/resources/base/profile/main_pages.json index 49a8c1b20998079991aa83c52a3e6ad576f694f1..accbf272408dce05ff15f78a1adf077bafc62174 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_web_dev/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "MainAbility/pages/web", - "MainAbility/pages/webTwo" + "MainAbility/pages/web" ] } \ No newline at end of file diff --git a/arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html b/arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html index 7af0eb5b27b552dfc0df57833448fc439461b97e..9c32a8704f31069d8386431965226bfaca4b5d1f 100644 --- a/arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html +++ b/arkui/ace_ets_web_dev/entry/src/main/resources/rawfile/overview.html @@ -15,8 +15,8 @@ \ No newline at end of file