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 7a67dd9f8dd87a3bd5b037ff3756ee657625a5cd..f9e9f3deb817d61201d76748f87661fde4500dac 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 fcedf3faa568c7aa9e2f07f0f9d42fa5d605510a..f167d6ca8c9b400876a62eb98309450ee9a9f654 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 9a3f6dc6b733f88061bb31137dec07340cf9e073..82447a435c8ebe2c2920109216d2442f349111f0 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 937d656fb81b440743116d1a761409bca3db95b7..6484ba0c127c875c3fc9d57aba3c69ee70f67cb1 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 e9a7132db81ff3e50cf498b1b8131d7ac808cadd..acb602e3598811e20b986deadef6da4eaa4fa54f 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,''); }) })