[VD]exception handling when a cert error occurs during appbooting 38/303438/1
authoryman.son <yman.son@samsung.com>
Thu, 20 Jul 2023 11:38:13 +0000 (20:38 +0900)
committerSangYong Park <sy302.park@samsung.com>
Thu, 28 Dec 2023 02:09:58 +0000 (11:09 +0900)
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 <yman.son@samsung.com>
wrt_app/common/web_application_delegate.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index ac5635d10e199e4c403eb71b8726d711c178913e..a51da49b4d5788bd7b9a550d2c2f235db9ed5782 100644 (file)
@@ -44,4 +44,6 @@ export class WebApplicationDelegate {
   needShowTimer() { return true; }
   onDidFinishLoad() { }
   profileName() { return 'common' }
+  certificateError(error: string) { return false; }
+  setInitValue(appControl: any) { }
 }
index ed3b0742745ff7d55ea0438be2f8d6608da07433..c5577dade8ee44636280254380db18ab30c985e1 100644 (file)
@@ -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';
@@ -252,6 +253,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';
   }
index 5c49209e413464770e6a12a6b80fa04e18066df3..7b45f489d9baaac709e26e6aff9c48dd01ebc8cf 100644 (file)
@@ -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}`);
@@ -320,6 +328,7 @@ export class WebApplication {
   }
 
   loadUrl(appControl: NativeWRTjs.AppControl) {
+    this.profileDelegate.setInitValue(appControl);
     this.contentSrc = appControl.getLoadInfo().getSrc();
     if (this.earlyLoadedUrl === this.contentSrc)
       return;