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

!7685 【OpenHarmony 4.0.3.5】【master】【ARKUI子系统】【TOD】【rk3568】【必现】新增web-xts用例

Merge pull request !7685 from yupeng/master
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021~2023 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
......@@ -19,12 +19,14 @@ import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
import prompt from '@system.prompt';
let loadedUrl;
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
dialogController:CustomDialogController;
scheme1: web_webview.WebCustomScheme = {schemeName: "name1", isSupportCORS: true, isSupportFetch: true}
scheme2: web_webview.WebCustomScheme = {schemeName: "name2", isSupportCORS: true, isSupportFetch: true}
scheme3: web_webview.WebCustomScheme = {schemeName: "name3", isSupportCORS: true, isSupportFetch: true}
......@@ -594,7 +596,6 @@ struct Index {
console.log('onTouchIconUrlReceived:' + JSON.stringify(event))
})
.pinchSmooth(true)
}
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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.
*/
@Extend(Button) function bu(){
.width('25%')
.type(ButtonType.Capsule)
.backgroundColor(Color.Orange)
.fontSize(8)
}
import router from '@ohos.router';
import web_webview from '@ohos.web.webview'
import prompt from '@system.prompt'
import Utils from '../../test/Utils'
import events_emitter from '@ohos.events.emitter'
const phoneUserAgent: string = "Mozilla/5.0 (Linux;Android 9; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) CHrome/92.0.4515.105 HuaweuBrowser/12.0.4.1 Mobile Safari/537.36"
const pcUserAgent: 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"
@CustomDialog
export struct NewWebViewComp {
dialogController: CustomDialogController;
url: string;
@State text: string = '日志在这里显示'
@State javaScriptAccess: boolean = true;
@State multitAccess: boolean = true;
@State fileAccess: boolean = true;
@State onlineImageAccess: boolean = true;
@State domStorageAccess: boolean = true;
@State imageAccess: boolean = true;
@State zoomAccess: boolean = true;
@State geolocationAccess: boolean = true;
@State allowWindow: boolean = true;
private controller: web_webview.WebviewController = new web_webview.WebviewController();
private dialog : any;
build() {
Column() {
Row({ space: 5 }) {
Web({ src: $rawfile('indexTwo.html'), controller: this.controller })
.fileAccess(this.fileAccess)
.onlineImageAccess(this.onlineImageAccess)
.domStorageAccess(this.domStorageAccess)
.imageAccess(this.imageAccess)
.zoomAccess(this.zoomAccess)
.geolocationAccess(this.geolocationAccess)
.javaScriptAccess(true)
.databaseAccess(true)
.backgroundColor(Color.Orange)
.onWindowExit(() => {
this.dialogController.close();
})
}
}
}
}
@Entry
@Component
struct indexTwo {
@State gameLeft: string = "console.info('webgame gameLeft'); _main.paddle.moveLeft();"
@State gameRight: string = "console.info('webgame gameRight'); _main.paddle.moveRight();"
@State gameStart: string = "console.info('webgame gameStart'); _main.game.start = _main.game.start_RUNNING; _main.ball.fired = true"
@State gameReset: string = "console.info('webgame gameReset'); if (_main.game.start === _main.game.start_GAMEOVER) { _main.game.start = _main.game.start_START; _main.start()}"
@State removeDesc: string = "console.info('webgame removeDesc'); y=document.getElementsBytagName('div')[0]; y.parentNode.removeChild(y)"
@State setJavaScriptOpenWindowFlagInZoom: boolean = true;
@State setMultiWindowFlag: boolean = true;
@State javaScriptAccess: boolean = true;
@State multitAccess: boolean = true;
controller: web_webview.WebviewController = new web_webview.WebviewController()
dialogController: CustomDialogController = null;
popController: web_webview.WebviewController = null;
@State allowWindow: boolean = true
@State str:string="emitAllowWindowOpenMethod"
build() {
Column() {
Row() {
Button("web click").key('webcomponentTwo').onClick(async ()=>{
console.info("key==>"+this.str)
switch(this.str){
case "emitAllowWindowOpenMethod":{
this.controller.loadUrl($rawfile("indexTwo.html"));
setTimeout(()=>{
this.controller.runJavaScript('openwindowAll()')
.then(function (result) {
console.log('result: ' + result);
})
},3000)
break;
}
default:
console.info("can not match case")
}
})
}
Web({ src: $rawfile('indexTwo.html'), controller: this.controller })
.javaScriptAccess(true)
.backgroundColor(Color.Orange)
.userAgent(pcUserAgent)
.domStorageAccess(true)
.fileAccess(true)
.onlineImageAccess(true)
.imageAccess(true)
.overviewModeAccess(true)
.zoomAccess(true)
.databaseAccess(true)
.multiWindowAccess(true)
.allowWindowOpenMethod(true)
.onWindowNew((event) => {
Utils.emitEvent("openwindow",110)
console.info("zfh window ts onWindowNew isAlert: " + event.isAlert + ", isUserTrigger: " + event.isUserTrigger + ", targetUrl: " + event.targetUrl);
if (this.dialogController != null) {
console.info("zfh window this.dialogController != null")
this.dialogController.close();
}
var targetUrlNew: string = event.targetUrl;
this.popController = new web_webview.WebviewController();
console.info("zfh window onWindowNew start")
this.dialogController = new CustomDialogController({
builder: NewWebViewComp({ url: targetUrlNew, controller: this.popController }),
autoCancel: false,
customStyle: true
});
console.info("zfh window onWindowNew start2")
this.dialogController.open();
event.handler.setWebController(this.popController);
console.info("zfh window onWindowNew start3")
})
.onWindowExit(() => {
console.info("closewindow")
this.dialogController.close();
})
}
}
}
\ No newline at end of file
......@@ -13,7 +13,8 @@
* 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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022~2023 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
......
/*
* Copyright (c) 2023 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 = "emitAllowWindowOpenMethod";
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 AllowWindowOpenMethod
*tc.desic Sets allow the Web access overview mode
*/
it('AllowWindowOpenMethod',0,async function(done){
emitKey="emitAllowWindowOpenMethod";
Utils.registerEvent("AllowWindowOpenMethod","openwindow",110,done);
sendEventByKey('webcomponentTwo',10,'');
})
})
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/web"
"MainAbility/pages/web",
"MainAbility/pages/webTwo"
]
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>allowWindowOpenMethodTest</title>
<style>
::-webkit-scrollbar { /* 1 */ }
::-webkit-scrollbar-button { /* 2 */ }
::-webkit-scrollbar-track { /* 3 */ }
::-webkit-scrollbar-track-piece { /* 4 */ }
::-webkit-scrollbar-thumb { /* 5 */ }
::-webkit-scrollbar-corner { /* 6 */ }
::-webkit-resizer { /* 7 */ }
</style>
</head>
<body>
<div>
<p id="baidu"><a href="https://www.bing.com/" target="_blank">新页面</a></p>
</div>
<script>
function openwindowAll(){
openwindowAll=window.open("https://www.baidu.com","_blank","height=400,width=600,top=100,scrollbars=yes")
setTimeout(function() {
window.close()
},3);
}
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册