Closed Bug 1791640 Opened 2 years ago Closed 2 years ago

Tab zoom level is not preserved when switching to and from a browser toolbox tab opened from the about:debugging page

Categories

(DevTools :: about:debugging, defect)

Desktop
All
defect

Tracking

(firefox107 fixed)

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: scunnane, Assigned: jdescottes)

References

Details

Attachments

(1 file)

STR

  1. Put a debugger statement into an XPCShell test and run the test with $ ./mach xpcshell-test path/to/test/file --jsdebugger
  2. In Firefox, visit about:debugging and click on localhost:6000 in the left sidebar. Then scroll down and click "Inspect" to open the browser toolbox
  3. In the new browser toolbox tab, press ctrl-+ 5 times to zoom the UI to 150%
  4. Click on another open tab
  5. Click back on the browser toolbox tab

Expected
The browser toolbox tab preserves the 150% zoom level when I click away from and back to that tab.

Actual
The browser toolbox tab's zoom level reverts to 100% when I click away from the browser toolbox tab and then back to it. If I then try to bump the zoom level back up to 150%, I don't start from 100% zoom, I start from 150% zoom. (So the first time I press ctrl-+ after clicking back to the browser toolbox tab, the UI zooms from 100% to 160%.)

Note: this behavior happens regardless of whether I increase the zoom level to above 100% or reduce it to below 100%.

Summary: Tab zoom level is not preserved when switching to and from a debugger tab opened from the about:debugging page → Tab zoom level is not preserved when switching to and from a browser toolbox tab opened from the about:debugging page

Can reproduce on macos as well, thanks for filing! Not a recent regression. Maybe the devtools toolbox zoom handling conflicts with the default one from firefox?

OS: Windows 11 → All
Hardware: x86_64 → Desktop

devtools toolbox zoom handling conflicts with the default one from firefox?

I think that's it. If you zoom from the "View > Zoom" menu, then the zoom will persist when changing tabs.
The devtools zoom is handled at https://searchfox.org/mozilla-central/source/devtools/client/shared/zoom-keys.js
We basically override all the default zoom shortcuts and perform the following:

  const zoomIn = function(event) {
    setZoom(zoomValue + 0.1);
    event.preventDefault();
  };

  const zoomOut = function(event) {
    setZoom(zoomValue - 0.1);
    event.preventDefault();
  };

  const zoomReset = function(event) {
    setZoom(1);
    event.preventDefault();
  };

  const setZoom = function(newValue) {
    // cap zoom value
    zoomValue = Math.max(newValue, MIN_ZOOM);
    zoomValue = Math.min(zoomValue, MAX_ZOOM);
    // Prevent the floating-point error. (e.g. 1.1 + 0.1 = 1.2000000000000002)
    zoomValue = Math.round(zoomValue * 10) / 10;

    bc.fullZoom = zoomValue;

    Services.prefs.setCharPref(ZOOM_PREF, zoomValue);
  };

Considering that we call event.preventDefault();, maybe we prevent the browser to correctly persist the zoom somewhere.
Edit: yes we prevent the event to reach https://searchfox.org/mozilla-central/rev/b1e5f2c7c96be36974262551978d54f457db2cae/browser/base/content/browser-fullZoom.js#564-587 which should persist the zoom value.

We might just disable those shortcuts when the toolbox is in a "page" host.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a809e1d44ce8 [devtools] Do not use custom zoom keys when the toolbox is hosted in a tab r=ochameau
Regressions: 1791871
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: