Index: trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java	(revision 19272)
+++ trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java	(revision 19289)
@@ -8,4 +8,5 @@
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.util.Arrays;
 import java.util.List;
 
@@ -13,10 +14,16 @@
 import org.junit.jupiter.api.Test;
 import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
+import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.imagery.ImageryInfo;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.projection.ProjectionRegistry;
 import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.layer.TMSLayer;
 import org.openstreetmap.josm.gui.layer.WMSLayer;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
+import org.openstreetmap.josm.testutils.annotations.Main;
 import org.openstreetmap.josm.testutils.annotations.OsmApi;
 import org.openstreetmap.josm.testutils.annotations.Projection;
@@ -99,3 +106,43 @@
         assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
     }
+
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/24097">#24097</a>: Zoom to imagery layer
+     * This tests two things:
+     * <ul>
+     *     <li>Imagery layer zoom to action works properly</li>
+     *     <li>Imagery layer bounds is not zoomed to on layer add</li>
+     * </ul>
+     */
+    @Main
+    @Test
+    void testNonRegression24097() {
+        // First, add a new data layer
+        MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(),
+                "AddImageryLayerActionTest#testNonRegression24097", null));
+        // Now zoom to a random area
+        MainApplication.getMap().mapView.zoomTo(new Bounds(39.0665807, -108.5212326, 39.0793079, -108.4986591));
+        // Initialize the zoom actions
+        MainApplication.getMenu().initialize();
+        final Bounds startingBounds = MainApplication.getMap().mapView.getRealBounds();
+        ImageryInfo testInfo = new ImageryInfo("Test", "https://127.0.0.1/{zoom}/{x}/{y}.png", "tms", null, null, "Test");
+        testInfo.setBounds(new ImageryInfo.ImageryBounds("-0.001,-0.001,0.001,0.001", ","));
+        new AddImageryLayerAction(testInfo).actionPerformed(null);
+        GuiHelper.runInEDTAndWait(() -> { /* Sync GUI thread */ });
+        // There is a bit of zooming done during the load of the imagery
+        assertTrue(startingBounds.toBBox().bboxIsFunctionallyEqual(MainApplication.getMap().mapView.getRealBounds().toBBox(), 0.001),
+                "Adding an imagery layer should not zoom to the imagery layer bounds");
+        assertEquals(1, MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).size());
+        final TMSLayer tmsLayer = MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).get(0);
+        final AutoScaleAction autoScaleAction = Arrays.stream(tmsLayer.getMenuEntries()).filter(AutoScaleAction.class::isInstance)
+                .map(AutoScaleAction.class::cast).findFirst().orElseThrow();
+        autoScaleAction.actionPerformed(null);
+        // We can't check the bbox here, since the mapView doesn't have any actual width/height.
+        // So we just check the center.
+        assertTrue(new Bounds(-0.001, -0.001, 0.001, 0.001)
+                .contains(ProjectionRegistry.getProjection().eastNorth2latlon(
+                        MainApplication.getMap().mapView.getCenter())),
+                "The action should have zoomed to the bbox for the imagery layer");
+    }
 }
