[VD] Flush cookie / local storage in finalize 11/236111/1 accepted/tizen/unified/20200619.004621 submit/tizen/20200618.072514
authorliwei <wei90727.li@samsung.com>
Mon, 15 Jun 2020 02:50:28 +0000 (10:50 +0800)
committerliwei <wei90727.li@samsung.com>
Mon, 15 Jun 2020 02:50:28 +0000 (10:50 +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: I14304af991f583da2b985f31f8f8a35c207327c3
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/src/web_application.js

index 608ef2e..5f7204f 100644 (file)
@@ -344,10 +344,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
@@ -385,6 +382,7 @@ class WebApplication {
             this.inspectorSrc = '';
             wrt.tv.cancelDialogs(this.mainWindow.webContents);
         }
+        flushData();
         if (this.debugPort) {
             console.log('stop inspector server');
             this.debugPort = 0;
@@ -403,6 +401,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(){' +