Bug 1543387 - Ignore initial about:blank load when restoring scroll position. r=snorp
authorDylan Roeh <droeh@mozilla.com>
Wed, 22 May 2019 16:53:07 +0000
changeset 475036 35991bb82eb3eaf7008ab3a97ad12c119afbaf5b
parent 475035 0ea1bd2302b2713271b60d799b872669835ed880
child 475037 d74592679774029165cba5b3cf4f3e3d8f6a98bb
push id36054
push userdvarga@mozilla.com
push dateThu, 23 May 2019 15:52:15 +0000
treeherdermozilla-central@199eaff06ecd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1543387
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1543387 - Ignore initial about:blank load when restoring scroll position. r=snorp When restoreState is called early in a GeckoSession's life, the scroll position restore code can catch the pageshow event for the initial about:blank load rather than for the page being restored, resulting in a failure to restore scroll position. Differential Revision: https://phabricator.services.mozilla.com/D32163
mobile/android/chrome/geckoview/GeckoViewContentChild.js
--- a/mobile/android/chrome/geckoview/GeckoViewContentChild.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContentChild.js
@@ -223,27 +223,32 @@ class GeckoViewContentChild extends Geck
                 // restore() will return false, and thus abort restoration for the
                 // current |frame| and its descendants, if |data.url| is given but
                 // doesn't match the loaded document's URL.
                 return SessionStoreUtils.restoreFormData(frame.document, data);
               });
             }
           }, {capture: true, mozSystemGroup: true, once: true});
 
-          addEventListener("pageshow", _ => {
-            const scrolldata = this._savedState.scrolldata;
-            if (scrolldata) {
-              this.Utils.restoreFrameTreeData(content, scrolldata, (frame, data) => {
-                if (data.scroll) {
-                  SessionStoreUtils.restoreScrollPosition(frame, data);
-                }
-              });
+          let scrollRestore = _ => {
+            if (content.location != "about:blank") {
+              const scrolldata = this._savedState.scrolldata;
+              if (scrolldata) {
+                this.Utils.restoreFrameTreeData(content, scrolldata, (frame, data) => {
+                  if (data.scroll) {
+                    SessionStoreUtils.restoreScrollPosition(frame, data);
+                  }
+                });
+              }
+              delete this._savedState;
+              removeEventListener("pageshow", scrollRestore);
             }
-            delete this._savedState;
-          }, {capture: true, mozSystemGroup: true, once: true});
+          }
+
+          addEventListener("pageshow", scrollRestore, {capture: true, mozSystemGroup: true});
 
           if (!this.progressFilter) {
             this.progressFilter =
               Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
               .createInstance(Ci.nsIWebProgress);
             this.flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
           }