Closed Bug 1396881 Opened 7 years ago Closed 2 years ago

windows.create and windows.update ignore window position coordinates for type panel and popup

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1271047

People

(Reporter: u462496, Unassigned)

References

Details

windows.create and windows.update ignore window position coordinates if window is created with type: "panel" or "popup". This is documented as normal behavior. This allows no way to move the window programmatically. window.moveTo() from the panel's script will not work either. This means there is no way to persist last window position when the window is closed and re-opened. Re-opening the window always opens in the center of the screen. This would be very annoying to users.
(In reply to Kevin Jones from comment #0) > This is documented as normal behavior. This is the case because type=panel windows used to be chat-like windows in Chrome, which means they don't support changing the position: https://i.ytimg.com/vi/9Qzn9OXvc9s/maxresdefault.jpg Since Chrome 54, type=panel windows are simply windows with no url bar, which aligns with the current behaviour in Firefox. IMO, it makes sense to start allowing changing coordinates now that both browsers don't support sticky panels.
Priority: -- → P3
An Adblock Plus user noticed that this window always appears centered on the primary monitor, even if the active browser window is on another monitor. That's very suboptimal.
(In reply to Tim Nguyen :ntim from comment #2) > This is the code that currently forbids this in Firefox: > https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/ > ext-windows.js#198-203 This is different, it forbids the use of the "state" property in conjunction with top/left/width/height. "state" can be something like "minimized", "maximized", "fullscreen", etc. For these states, a width/height/position does obviously not make any sense. I have witnessed that a window with "type":"popup" can change top/left/width/height when I use the browser.windows.update API. This is on Linux, X11, KWin. (In reply to Wladimir Palant (for Adblock Plus info Cc bugzilla@adblockplus.org) from comment #3) > An Adblock Plus user noticed that this window always appears centered on the > primary monitor, even if the active browser window is on another monitor. > That's very suboptimal. Are you sure that this is a bug with Firefox? I reviewed ABP's source code (v3.0.1) and cannot find any use of "create", "update" (of the browser.windows API), or "moveTo" that explicitly positions the window. I create windows with an explicit position, and when I manually center a window, I apparently have to add screen.left/screen.top to get a proper position in a multi-display setup - https://github.com/Rob--W/open-in-browser/issues/6
(In reply to Rob Wu [:robwu] from comment #4) > Are you sure that this is a bug with Firefox? > I reviewed ABP's source code (v3.0.1) and cannot find any use of "create", > "update" (of the browser.windows API), or "moveTo" that explicitly positions > the window. Yes, definitely a Firefox bug, the same code in Chrome positions the window correctly in Chrome. The line in question is https://hg.adblockplus.org/adblockpluschrome/file/fe75016a7373/lib/filterComposer.js#l218 - the window opens in the top-left screen corner in Chrome and centered in Firefox. We'd like to address the issue with multi-display setup but that's not possible if Firefox overrides our position. Note that this is only about windows with type: "popup", regular browser windows can be positioned just fine.
(In reply to Wladimir Palant (for Adblock Plus info Cc bugzilla@adblockplus.org) from comment #5) > We'd like to address the issue with > multi-display setup but that's not possible if Firefox overrides our > position. Note that this is only about windows with type: "popup", regular > browser windows can be positioned just fine. A work-around is to use chrome.windows.update(windowId, {top: ... , left: ...}) in the callback of chrome.windows.create (and if that does not work, add a delay before calling chrome.windows.update). When either top or left is set, the implementation delegates to window.resizeTo: https://searchfox.org/mozilla-central/rev/bab833ebeef6b2202e71f81d225b968283521fd6/browser/components/extensions/ext-browser.js#745-752 I tried the following snippet from a privileged page (e.g. about:debugging) and observed that the window won't move (but it does resize; whether resizeTo is called does not matter): sleep = ms=>new Promise(r=>setTimeout(r,ms)); w = window.open('chrome://browser/content/browser.xul', '', 'chrome,dialog,centerscreen,titlebar,close'); w.resizeTo(100,100); w.moveTo(0,0); The following snippet seems to work though (i.e. the window is resized and moved): w = window.open('chrome://browser/content/browser.xul', '', 'chrome,dialog,centerscreen,titlebar,close'); w.addEventListener("pageshow", () => { setTimeout( () => { w.resizeTo(100,100); w.moveTo(0,0); }); });
Please this bug needs to be fixed.
Product: Toolkit → WebExtensions
Component: Untriaged → General

Can we get some priority to this bug. This is getting reported a ton to add-on developers instead of here because the users believes its an addon bug. Has a bigger reach than the bugzilla entry makes it seem like.

Severity: normal → S3
Status: NEW → RESOLVED
Closed: 2 years ago
Duplicate of bug: 1271047
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.