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);
}
this.saveStateDelayed();
this._updateCrashReportURL(aWindow);
},
onTabSelect: function ss_onTabSelect(aWindow, aBrowser) {