Bug 1261225 - Part 2 - Always capture form data on page navigation. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Fri, 01 Apr 2016 18:21:39 +0200
changeset 348166 3b8be583ceebfc25b77971d319108f850a8d6fb7
parent 348165 706c30212c8c07598e5dd5f877612a34db55b59f
child 348167 802f349ae7846c908af2bc507812b7f853454693
child 348186 ff8367387d5ac940efa28d143bb08b657f05afd4
push id14761
push usermozilla@buttercookie.de
push dateWed, 06 Apr 2016 19:41:12 +0000
Bug 1261225 - Part 2 - Always capture form data on page navigation. r=margaret As long as a tab is kept in memory, Gecko handles restoring of the form data during forward/back key navigation internally without involving the session store. After going back/forward, OnTabLoad() is triggered, which throws away the previous session store data for that tab and recreates only the session history part of it. Form data is only captured in OnTabInput(), which means that if Firefox is killed or the tab closed/zombified before the user interacts with the form (triggering input events), form contents won't be captured by the session store and will therefore get lost. MozReview-Commit-ID: LmZlYrHjw6k
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -419,16 +419,22 @@ SessionStore.prototype = {
     delete aBrowser.__SS_data;
     this._collectTabData(aWindow, aBrowser, data);
     if (aBrowser.__SS_restore_text_data) {
       // If the tab has been freshly restored and the "load" event
       // hasn't yet fired, we need to restore any form data that
       // might have been present.
       aBrowser.__SS_data.formdata = formdata;
+    } else {
+      // When navigating via the forward/back buttons, Gecko restores
+      // the form data all by itself and doesn't invoke any input events.
+      // As _collectTabData() doesn't save any form data, we need to manually
+      // capture it to bridge the time until the next input event arrives.
+      this.onTabInput(aWindow, aBrowser);
   onTabSelect: function ss_onTabSelect(aWindow, aBrowser) {