Bug 1570566 - Don't block reloading during a resize event handler on Android and Nightly. r=bzbarsky
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 02 Aug 2019 16:30:41 +0000
changeset 485974 17ea0740773194cd5a8a172039a905b412f8c707
parent 485973 ff0125384d06fefae3ca60435b85a9be0fd9744e
child 485975 c4265d8d03017bd648b243a62a206ccfc3a4e631
push id36379
push useropoprus@mozilla.com
push dateFri, 02 Aug 2019 21:52:41 +0000
treeherdermozilla-central@37229cef2cc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1570566
milestone70.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 1570566 - Don't block reloading during a resize event handler on Android and Nightly. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D40430
dom/base/Location.cpp
dom/base/nsHistory.cpp
modules/libpref/init/StaticPrefList.yaml
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -732,17 +732,18 @@ void Location::SetSearch(const nsAString
 }
 
 nsresult Location::Reload(bool aForceget) {
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
   nsCOMPtr<nsPIDOMWindowOuter> window =
       docShell ? docShell->GetWindow() : nullptr;
 
-  if (window && window->IsHandlingResizeEvent()) {
+  if (StaticPrefs::dom_block_reload_from_resize_event_handler() && window &&
+      window->IsHandlingResizeEvent()) {
     // location.reload() was called on a window that is handling a
     // resize event. Sites do this since Netscape 4.x needed it, but
     // we don't, and it's a horrible experience for nothing. In stead
     // of reloading the page, just clear style data and reflow the
     // page since some sites may use this trick to work around gecko
     // reflow bugs, and this should have the same effect.
 
     nsCOMPtr<Document> doc = window->GetExtantDoc();
--- a/dom/base/nsHistory.cpp
+++ b/dom/base/nsHistory.cpp
@@ -148,17 +148,18 @@ void nsHistory::Go(int32_t aDelta, Error
   }
 
   if (!aDelta) {
     nsCOMPtr<nsPIDOMWindowOuter> window;
     if (nsIDocShell* docShell = GetDocShell()) {
       window = docShell->GetWindow();
     }
 
-    if (window && window->IsHandlingResizeEvent()) {
+    if (StaticPrefs::dom_block_reload_from_resize_event_handler() && window &&
+        window->IsHandlingResizeEvent()) {
       // history.go(0) (aka location.reload()) was called on a window
       // that is handling a resize event. Sites do this since Netscape
       // 4.x needed it, but we don't, and it's a horrible experience
       // for nothing.  In stead of reloading the page, just clear
       // style data and reflow the page since some sites may use this
       // trick to work around gecko reflow bugs, and this should have
       // the same effect.
 
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1187,16 +1187,35 @@
   mirror: always
 
 # Block multiple window.open() per single event.
 - name: dom.block_multiple_popups
   type: bool
   value: true
   mirror: always
 
+# Whether window.location.reload() and window.history.go(0) should be blocked
+# if called directly from a window resize event handler.
+#
+# This used to be necessary long ago to prevent terrible UX when using stuff
+# like TypeAheadFind (bug 258917), but it also causes compat issues on mobile
+# (bug 1570566).
+#
+# So for now disable it on Android and Desktop Nightly, to see if we have any
+# desktop regression before removing it completely. Note that this means that
+# non-nightly RDM behaves different than Android in this case.
+- name: dom.block_reload_from_resize_event_handler
+  type: bool
+#if defined(MOZ_WIDGET_ANDROID) || defined(NIGHTLY_BUILD)
+  value: false
+#else
+  value: true
+#endif
+  mirror: always
+
 # SW Cache API
 - name: dom.caches.enabled
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
 - name: dom.caches.testing.enabled
   type: RelaxedAtomicBool