[Migration] Fix finalize code 53/260053/1 submit/tizen/20210618.160021
authorSangYong Park <sy302.park@samsung.com>
Wed, 16 Jun 2021 08:26:12 +0000 (17:26 +0900)
committerSangYong Park <sy302.park@samsung.com>
Fri, 18 Jun 2021 03:57:07 +0000 (12:57 +0900)
'quit' of app and 'closed' of BrowserWindow emit order is changed.
so, fix code that has dependency to remained BrowserWindow.

Related:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/260052/

Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/259881/

Change-Id: Ib988f230822c94becbf1d735f82fe85b22250f66
Signed-off-by: SangYong Park <sy302.park@samsung.com>
wrt_app/src/web_application.ts

index 4b9ff56..53e0899 100644 (file)
@@ -16,7 +16,7 @@
 
 'use strict';
 
-import { app } from 'electron';
+import { app, session } from 'electron';
 import { wrt } from '../browser/wrt';
 import * as WRTWebContents from '../browser/wrt_web_contents';
 import { WRTWindow } from '../browser/wrt_window';
@@ -285,7 +285,8 @@ export class WebApplication {
     console.log('WebApplication : suspend');
     addonManager.emit('lcSuspend', this.mainWindow.id);
     this.suspended = true;
-    this.windowList[this.windowList.length - 1].hide();
+    if (this.windowList.length > 0)
+      this.windowList[this.windowList.length - 1].hide();
     this.flushData();
     if (this.profileDelegate.canIgnoreSuspend())
       return;
@@ -344,7 +345,7 @@ export class WebApplication {
 
   private flushData() {
     console.log('WebApplication : FlushData');
-    this.windowList.forEach((window) => window.webContents.session.flushStorageData());
+    session.defaultSession?.flushStorageData();
   }
 
   sendAppControlEvent() {