From 54ce8c8653e97a4ea48e10981c3a04092d3c1fe3 Mon Sep 17 00:00:00 2001 From: Dylan Roeh Date: Wed, 22 May 2019 16:53:07 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- .../chrome/geckoview/GeckoViewContentChild.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mobile/android/chrome/geckoview/GeckoViewContentChild.js b/mobile/android/chrome/geckoview/GeckoViewContentChild.js index d196a04b96c2..19de6d640d1a 100644 --- a/mobile/android/chrome/geckoview/GeckoViewContentChild.js +++ b/mobile/android/chrome/geckoview/GeckoViewContentChild.js @@ -228,17 +228,22 @@ class GeckoViewContentChild extends GeckoViewChildModule { } }, {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 =