From 2cabfdfe65170b580741fab1e98a64bbeed70282 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Fri, 30 Oct 2020 23:32:09 +0000 Subject: [PATCH] Bug 1671331. Create a new test-only pref that disables the zoom part of ZoomToFocusedInput and use it in layout/base/tests/ mochitests. r=botond layout/base/tests/test_bug332655-1.html calls focus on an element, this triggers a call to zoomToFocusedInput. This can zoom the parent document of the test, the mochitest harness. Then test layout/base/tests/test_bug667512.html runs. It ends by synthesizing a left arrow key and then a right arrow key. With the old scrollbar code this results in no scrolling because there is no layout scrolling that can be done either in the test or the parent document. With the new scrollbar code we can scroll the visual viewport using the keyboard so this scrolls the visual viewport of the test harness (because it got zoomed from a previous test). The test harness being scrolled means that the synthesized click in the next test test_bug677878 can not hit its intended target. Using the pref apz.zoom-to-focused-input.enabled to disable zoom to focused input in this directory does work to fix this, but I'm tired of doing that. I think the proper fix here would be to disable scrolling/zooming of the test harness document. Since it's the root content document and it is not scrollable if not zoomed this is equivalent to disabling the zooming part of zoom to focused input (except for tests that open their own window). To test the zooming part of zoom to focused input we can use a test that opens it's own window: we have gfx/layers/apz/test/mochitest/test_group_zoomToFocusedInput.html for this. We already have the pref formhelper.autozoom would seems like it would work for this purpose, except it is entangled with java stuff in mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java that I don't really understand that means setting the pref in mochitest.ini doesn't seem to take affect. So I created a new pref we can use specifically for this purpose. Hopefully we can use it instead of fully disabling the zoom to focused input, so we more closely test what we ship. Differential Revision: https://phabricator.services.mozilla.com/D95423 --- dom/base/nsDOMWindowUtils.cpp | 4 +++- layout/base/tests/mochitest.ini | 1 + modules/libpref/init/all.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index b33069fc5de2..76e66ddfe33d 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2686,7 +2686,9 @@ nsDOMWindowUtils::ZoomToFocusedInput() { } uint32_t flags = layers::DISABLE_ZOOM_OUT; - if (!Preferences::GetBool("formhelper.autozoom")) { + if (!Preferences::GetBool("formhelper.autozoom") || + Preferences::GetBool("formhelper.autozoom.force-disable.test-only", + /* aFallback = */ false)) { flags |= layers::PAN_INTO_VIEW_ONLY; } else { flags |= layers::ONLY_ZOOM_TO_DEFAULT_SCALE; diff --git a/layout/base/tests/mochitest.ini b/layout/base/tests/mochitest.ini index 797303d587ec..fd7d1cf25a33 100644 --- a/layout/base/tests/mochitest.ini +++ b/layout/base/tests/mochitest.ini @@ -1,6 +1,7 @@ [DEFAULT] prefs = plugin.load_flash_only=false + formhelper.autozoom.force-disable.test-only=true support-files = Ahem.ttf file_bug842853.html diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 86b07a9cbaf0..b5944a4718b3 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -582,6 +582,8 @@ pref("apz.overscroll.stretch_factor", "0.35"); pref("apz.zoom-to-focused-input.enabled", true); +pref("formhelper.autozoom.force-disable.test-only", false); + #ifdef XP_MACOSX // Whether to run in native HiDPI mode on machines with "Retina"/HiDPI // display.