From: yman.son Date: Thu, 20 Jul 2023 11:38:13 +0000 (+0900) Subject: [VD]exception handling when a cert error occurs during appbooting X-Git-Tag: submit/tizen/20230907.160022^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37e0a96c3d065c217e9314589d62a9ff46cee6cc;p=platform%2Fframework%2Fweb%2Fwrtjs.git [VD]exception handling when a cert error occurs during appbooting Exception handling for cert errors that may occur because time is not set in the AppBooting scenario. Shutdown the app in case of an exception. Change-Id: I22473444ed5cabc8e337635ecc324096c377f1f5 Signed-off-by: yman.son --- diff --git a/wrt_app/common/web_application_delegate.ts b/wrt_app/common/web_application_delegate.ts index ac5635d1..a51da49b 100644 --- a/wrt_app/common/web_application_delegate.ts +++ b/wrt_app/common/web_application_delegate.ts @@ -44,4 +44,6 @@ export class WebApplicationDelegate { needShowTimer() { return true; } onDidFinishLoad() { } profileName() { return 'common' } + certificateError(error: string) { return false; } + setInitValue(appControl: any) { } } diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index d0b14e93..d92e8d29 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -24,6 +24,7 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate { backgroundExecutionMetaData: string = 'false'; inspectorSrc: string = ''; isAlwaysReload: boolean = false; + initBundleValue: string = 'none'; preloadStatus: string = 'none'; runningStatus: string = 'none'; launchMode: string = 'none'; @@ -248,6 +249,20 @@ Then you can get profile log from the initial loading.`; return true; } + certificateError(error: string) { + console.log(`certificateError = ${error}, isColdAppBoot = ${this.initBundleValue}`); + if (error === 'net::ERR_CERT_DATE_INVALID' && this.initBundleValue === 'cold_appboot') { + return true; + } + return false; + } + + setInitValue(appControl: any) { + let initValue = appControl.getData('init'); + this.initBundleValue = initValue; + console.log(`initBundleValue = ${this.initBundleValue}`); + } + profileName() { return 'TV'; } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index b4e7c4e2..73a85ecd 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -122,6 +122,14 @@ export class WebApplication { app.on('certificate-error', (event: any, webContents: any, url: string, error: string, certificate: any, callback: any) => { console.log('A certificate error has occurred'); event.preventDefault(); + if (this.profileDelegate.certificateError(error)) { + console.log('App will quit!'); + setTimeout(() => { + app.quit(); + }, 0); + return; + } + if (certificate.data) { const id = ++this.pendingID; console.log(`Raising a certificate error response with id: ${id}`); @@ -318,6 +326,7 @@ export class WebApplication { } loadUrl(appControl: NativeWRTjs.AppControl) { + this.profileDelegate.setInitValue(appControl); this.contentSrc = appControl.getLoadInfo().getSrc(); if (this.earlyLoadedUrl === this.contentSrc) return;