[VD] Flush cookie / local storage in finalize 41/235841/2
authorliwei <wei90727.li@samsung.com>
Wed, 10 Jun 2020 01:58:53 +0000 (09:58 +0800)
committerliwei <wei90727.li@samsung.com>
Wed, 10 Jun 2020 09:05:58 +0000 (17:05 +0800)
When app call tizen.application.exit() directly, WRT will get "before_quit"
firstly, then set webapplciaton to null(_this.webApplication = null;), then
when WRT get "suspend" event, bcz webapplication is null, WRT will not flush
cookie / local storage.

Change-Id: I7d6ab667824d450763d58a1b7938a1dffc21be38
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/src/web_application.js

index 042d6b829a856658843748a0e1a69b54f1067f79..d5a3da4750a79d286fd8907c348e2f3955d3d20a 100755 (executable)
@@ -328,10 +328,7 @@ class WebApplication {
         }
         this.suspended = true;
         this.windowList[this.windowList.length - 1].hide();
-        if (wrt.tv) {
-            wrt.tv.flushCookie();
-            this.windowList.forEach((window) => window.webContents.session.flushStorageData());
-        }
+        flushData();
         if (!this.backgroundRunnable()) {
             if (!this.multitaskingSupport) {
                 // FIXME : terminate app after visibilitychange event handling
@@ -369,6 +366,7 @@ class WebApplication {
             this.inspectorSrc = '';
             wrt.tv.cancelDialogs(this.mainWindow.webContents);
         }
+        flushData();
         if (this.debugPort) {
             console.log('stop inspector server');
             this.debugPort = 0;
@@ -387,6 +385,13 @@ class WebApplication {
             console.log('WebApplication : quit - Invalid event emitter');
         }
     }
+    flushData() {
+        console.log('WebApplication : FlushData');
+        if (wrt.tv) {
+            wrt.tv.flushCookie();
+            this.windowList.forEach((window) => window.webContents.session.flushStorageData());
+        }
+    }
     sendAppControlEvent() {
         const kAppControlEventScript =
             '(function(){' +