Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
944dd96b
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
944dd96b
编写于
2月 22, 2023
作者:
Y
ywx1211260
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cover api
Signed-off-by:
N
ywx1211260
<
yupeng78@huawei.com
>
上级
40fd9b2c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
253 addition
and
3 deletion
+253
-3
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
...eb_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
+2
-1
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
...dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
+136
-0
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/List.test.ets
...e_ets_web_dev_three/entry/src/main/ets/test/List.test.ets
+2
-1
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebTwoJsunit.test.ets
...b_dev_three/entry/src/main/ets/test/WebTwoJsunit.test.ets
+78
-0
arkui/ace_ets_web_dev_three/entry/src/main/resources/base/profile/main_pages.json
...ree/entry/src/main/resources/base/profile/main_pages.json
+2
-1
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/indexTwo.html
..._dev_three/entry/src/main/resources/rawfile/indexTwo.html
+33
-0
未找到文件。
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets
浏览文件 @
944dd96b
...
...
@@ -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
arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/webTwo.ets
0 → 100644
浏览文件 @
944dd96b
@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
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/List.test.ets
浏览文件 @
944dd96b
...
...
@@ -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
arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebTwoJsunit.test.ets
0 → 100644
浏览文件 @
944dd96b
/*
* 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 = "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
arkui/ace_ets_web_dev_three/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
944dd96b
{
"src"
:
[
"MainAbility/pages/web"
"MainAbility/pages/web"
,
"MainAbility/pages/webTwo"
]
}
\ No newline at end of file
arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/indexTwo.html
0 → 100644
浏览文件 @
944dd96b
<!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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录