From 966418b8b0125570a8cf791d20f5cdcc420d520b Mon Sep 17 00:00:00 2001 From: yupeng Date: Wed, 26 Jul 2023 15:11:06 +0800 Subject: [PATCH] xiugai-xts Signed-off-by: yupeng --- .../ets/MainAbility/pages/onWindowNew.ets | 38 +++++++++++-------- .../MainAbility/pages/webViewController.ets | 2 +- .../ets/MainAbility/pages/webViewOnScroll.ets | 4 +- .../ets/test/webViewControllerJsunit.test.ets | 8 ++-- .../main/ets/test/webViewOnScroll.test.ets | 4 +- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets index 7a67dd9f8..f9e9f3deb 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets @@ -36,6 +36,7 @@ struct OnWindowNew { @State imageAccess:boolean=true; @State onlineImageAccess:boolean=true; @State databaseAccess:boolean=true; + @State arr:boolean = true; onPageShow(){ let valueChangeEvent={ eventId:10, @@ -78,9 +79,11 @@ struct OnWindowNew { this.javaScriptAccess = true; this.testAllowWindowOpenMethod = false; this.testMultiWindowAccess = true; - this.controller.runJavaScript("OpenNewWindow()", (res) => { - Utils.emitEvent(this.ref, 7102) - }) + setTimeout(()=> { + this.controller.runJavaScript("OpenNewWindow()", (res) => { + Utils.emitEvent(this.ref, 7102) + }) + },2000) } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } @@ -154,19 +157,20 @@ struct OnWindowNew { break; } case "emitGetOriginsPromiseLoadLocalHtml01": { + this.arr = false let length = -1; try { this.controller.loadUrl($rawfile('getOrigins.html')); - web_webview.WebStorage.getOrigins() - .then(origins => { - console.log(`getOrigins call`); - if (origins) { - length = origins.length; - console.log(`length is: ${length}`); - } - console.log(`getOrigins call end`); - Utils.emitEvent(length, 7166); + setTimeout(()=> { + web_webview.WebStorage.getOrigins() + .then(origins => { + console.log(`getOrigins call`); + length = origins.length; + console.log(`length is: ${length}`); + Utils.emitEvent(length, 7166); + console.log(`getOrigins call end`); }) + },2000) } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); Utils.emitEvent(length, 7166); @@ -189,10 +193,12 @@ struct OnWindowNew { } }) .onPageVisible((event) => { - if (event) { - console.log('onWindowNew onPageVisible url:' + event.url); - Utils.emitEvent(event.url, this.eventId); - } + if (this.arr) { + if (event) { + console.log('onWindowNew onPageVisible url:' + event.url); + Utils.emitEvent(event.url, this.eventId); + } + } }) .blockNetwork(this.block) .onErrorReceive((event) => { diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewController.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewController.ets index fcedf3faa..f167d6ca8 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewController.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewController.ets @@ -124,7 +124,7 @@ struct Index { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } this.controller.runJavaScript("test()",(res) => { - Utils.emitEvent(this.userAgentAll, 102) + Utils.emitEvent(this.userAgentAll, 1020) }) break; } diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets index 9a3f6dc6b..82447a435 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewOnScroll.ets @@ -74,8 +74,8 @@ struct webViewOnScroll { try { this.firstId = 316; this.secondId = 318; - this.textX = -100; - this.textY = -100; + this.textX = -50; + this.textY = -50; this.controller.scrollBy(this.textX, this.textY); await Utils.sleep(1000) console.log("action of emitOnscroll is scrollBy" + this.textX + this.textY); diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewControllerJsunit.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewControllerJsunit.test.ets index 937d656fb..6484ba0c1 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewControllerJsunit.test.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewControllerJsunit.test.ets @@ -60,9 +60,8 @@ export default function webViewControllerJsunit() { */ it('testGetUserAgent',0,async function(done){ emitKey="emitgetUserAgentAgain"; - let userAgent= "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile" + - " Safari/537.36Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 Mobile Safari/537.36"; - Utils.registerEvent("testGetUserAgent",userAgent,102,done); + let userAgent= "Mozilla/5.0 (OpenHarmony 4; ohos) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.0.0 Mobile Safari/537.36Mozilla/5.0 (OpenHarmony 4; ohos) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.0.0 Mobile Safari/537.36"; + Utils.registerEvent("testGetUserAgent",userAgent,1020,done); sendEventByKey('webcomponent',10,''); }) /* @@ -72,8 +71,7 @@ export default function webViewControllerJsunit() { */ it('testGetUserAgentAgain',0,async function(done){ emitKey="emitpageDown"; - let userAgent= "\"Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88" + - " Mobile Safari/537.36\""; + let userAgent= "\"Mozilla/5.0 (OpenHarmony 4; ohos) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.0.0 Mobile Safari/537.36\""; Utils.registerEvent("testGetUserAgentAgain",userAgent,104,done); sendEventByKey('webcomponent',10,''); }) diff --git a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets index e9a7132db..acb602e35 100644 --- a/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets +++ b/arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewOnScroll.test.ets @@ -82,8 +82,8 @@ export default function webViewOnScroll() { */ it('testOnscrollAgain',0,async function(done){ emitKey="emitOnscrollAgain"; - Utils.registerEvent("testOnscrollAgain",0,316,done); - Utils.registerEvent("testOnscrollAgain",0,318,done); + Utils.registerEvent("testOnscrollAgain",50,316,done); + Utils.registerEvent("testOnscrollAgain",50,318,done); sendEventByKey('webViewOnScroll',10,''); }) }) -- GitLab