Zoom API's in chrome.tabs don't work correctly




WebExtensions: General
2 years ago
5 months ago


(Reporter: dw-dev, Unassigned)



50 Branch
Windows 10

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [zoom] triaged)



2 years ago
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160623154057

Steps to reproduce:

I am migrating my Zoom Page add-on to the new WebExtensions API's.

I have found that some of the Zoom API's in chrome.tabs do not work correctly and there are incompatibilities with Chrome.

Actual results:

What Works

1. chrome.tabs.setZoom(tabId, zoomFactor, callback) - correctly sets the zoom to the zoom factor.

2. chrome.tabs.getZoom(tabId, callback) - correctly returns the zoom factor.

3. chrome.tabs.getZoomSettings(tabId, callback) - correctly returns mode, scope and default zoom factor.

What Doesn't Work

4. chrome.tabs.setZoomSettings(tabId, { mode: "automatic", scope: "per-origin" }, callback) - always produces an error message in the console:

        Unsupported zoom settings: {"mode":"automatic","scope":"per-origin","defaultZoomFactor":null}        ExtensionUtils.jsm:283

    If these settings are unsupported, then why isn't it mentioned in the documentation?

    Why is "defaultZoomFactor" shown in this error message as a passed-in parameter,
    when in Chrome it is only available as a returned value in getZoomSettings()?
5. chrome.tabs.setZoomSettings(tabId, { mode: "automatic", scope: "per-tab" }, callback) - always produces an error message in the console:

        Unsupported zoom settings: {"mode":"automatic","scope":"per-tab","defaultZoomFactor":null}        ExtensionUtils.jsm:283

    Same comments as in 4.

6. Per-Origin zoom is forgotten when a page is reloaded.  It is remembered in Chrome.

7. Per-Origin zoom is forgotten when a page from the same site is loaded into another tab.  It is remembered in Chrome.

8. Per-Origin zoom is forgotten between browser sessions.  It is remembered in Chrome.

9. Per-Tab zoom applies zoom changes to other tabs from same site.  It is not applied in Chrome.

10. Per-Tab zoom does not apply Per-Origin zoom when page navigation occurs.  It is applied in Chrome.

Expected results:

4 & 5.  If it is not supported, then it should be documented.  If it is supported, then there should not be an error message in the console.  "defaultZoomFactor" should not be treated as a parameter.

6 & 7 & 8.  Per-Origin zoom should be remembered in all these cases.

9. Per-Tab zoom should not affect the zoom in other tabs.

10. Per-Tab zoom should apply Per-Origin zoom when page navigation occurs.


2 years ago
Component: Untriaged → WebExtensions
OS: Unspecified → Windows 10
Product: Firefox → Toolkit
Hardware: Unspecified → x86_64
Version: 47 Branch → 50 Branch
Per-tab zoom is not supported. setZoomSettings is only a stub which returns an error if any of the passed values don't match the current settings. I guess it should ignore settings that weren't passed, though.

Per-origin zoom should work as expected. There are tests for all of the cases that you mention in comment 0.

Comment 2

2 years ago
Updating my original comments ...

4. In the Chrome API documentation, although the ZoomSettings object can have three properties, only two (mode and scope) are used as parameters to setZoomSettings. It is noted that defaultZoomFactor is used to return the default zoom level for the current tab in calls to getZoomSettings. I do not understand why passing mode: "automatic" and scope: "per-origin" produces an error.  As far as I can see, this is the only valid combination!

5. Since "per-tab" zoom is not supported, producing an error message is okay. However, I cannot find the lack of support documented anywhere and the current error message is misleading.

6,7,8. I thought I had tested these cases with a version of Zoom Page that had the failed calls to setZoomSettings and some experimental event-driven logic both commented out, but it seems I was wrong. I have redone my testing and can now confirm that these cases all work.  Apologies!

9,10. Since "per-tab" zoom is not supported, my previous comments are not relevant.

So, points 4 & 5 are the only ones that need addressing.

It is a pity that "per-tab" zoom is not supported. It means that I will have to implement that functionality (and override "per-origin") directly in Zoom Page.  My aim is to support per-origin, per-tab and all-tabs zooming in both Firefox and Chrome with a single source code.

Comment 3

2 years ago

I have done some more investigation of the WebExtensions "zoom" API's.

It appears that "per-tab" zoom is supported if 'FullZoom.siteSpecific' (effectively 'browser.zoom.siteSpecific') is set to 'false' - see line 987 in browser/components/extensions/ext-tabs.js.

setZoomSettings() returns an error message if the parameters are not the same as the current settings returned by _getZoomSettings(), which will be mode: "automatic", scope: "per-tab" or "per-origin" depending on FullZoom.siteSpecific, and defaultZoomFactor: 1.

So, I have two issues with setZoomSEttings():

1. To be compatible with Chrome, setZoomSettings() should ignore any 'defaultZoomFactor' parameter (not compare it to the current settings).

2. Why doesn't setZoomSettings() change the setting of 'browser.zoom.siteSpecific' to reflect the value of the 'scope' parameter?
Duplicate of this bug: 1288307


2 years ago
Priority: -- → P2
Whiteboard: [zoom] triaged

Comment 5

2 years ago
Some more observations regarding setZoomSettings() and compatibility with Chrome:

- To be compatible with the way Chrome works, it must be possible to set the zoom scope (per-origin or per-tab) for each tab independently, rather than for all tabs using the existing 'browser.zoom.siteSpecific' preference.

- With Chrome, the zoom scope is automatically reset to 'per-origin' every time a page is loaded or reloaded. Setting the zoom scope to 'per-tab' for a particulat tab using setZoomSettings() only persists until that tab is loaded or reloaded.


5 months ago
Component: WebExtensions: Untriaged → WebExtensions: General
Priority: P2 → P5
Summary: WebExtensions: Zoom API's in chrome.tabs don't work correctly → Zoom API's in chrome.tabs don't work correctly
Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.