Closed Bug 2070688 Opened 2 months ago Closed 2 months ago

[macOS] A window created by `windows.create()` while the parent window is in a native-fullscreen Space opens on a different Space

Categories

(Core :: Widget: Cocoa, defect)

ARM
macOS
defect

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox159 --- fixed

People

(Reporter: rio.syed, Assigned: rio.syed)

References

Details

Attachments

(1 file, 1 external file)

Steps to reproduce

  1. Load the attached test extension as a temporary add-on. It does nothing but
    call browser.windows.create({url, type: "popup", width: 520, height: 600})
    from its browser action.
  2. Put the browser window into native fullscreen (Ctrl+Cmd+F), so it occupies its
    own Space.
  3. Click the extension's button and choose windows.create type:"popup".

Actual result

The new window does not appear on the fullscreen Space. It opens on a different
Space, out of view, and the user has to go and find it.

Expected result

The window appears on the Space the user is currently on, the way a password
manager's credential picker needs to.

Notes

Found while using a password manager: choosing "use passkey" during a WebAuthn
prompt opens the manager's picker window, and with the browser in fullscreen the
picker lands on another Space. The test extension above reduces that to the
underlying API call, with no third-party software involved.

This is not the window.open path. nsWindowWatcher.cpp deliberately converts a
new-window request into a tab when the parent is fullscreen and
browser.link.open_newwindow.disabled_in_fullscreen is set:

bool isDisabledOpenNewWindow =
    aParent->GetFullScreen() &&
    Preferences::GetBool("browser.link.open_newwindow.disabled_in_fullscreen");
if (isDisabledOpenNewWindow &&
    (containerPref == nsIBrowserDOMWindow::OPEN_NEWWINDOW)) {
  containerPref = nsIBrowserDOMWindow::OPEN_NEWTAB;
}

So a page calling window.open in fullscreen gets a tab, which sidesteps the
problem. The WebExtensions windows.create() path does not go through that logic
and creates a real window, which is where the Space placement shows up.

Possibly the same family as bug 1688932, where a window that lacks
NSWindowCollectionBehaviorCanJoinAllSpaces and carries FullScreenPrimary will
not be composited onto another Space.

Environment

macOS 26.6, Apple silicon.

Reproduced on official Firefox Nightly 157.0a1 (the shipped .dmg from
mozilla.org, on a fresh profile), so this is not specific to any local build or
downstream fork. Also seen in Zen 1.22 and in a local build of the patch on bug
1688932, which rules that patch out as the cause.

A window created by browser.windows.create() with any type other than "normal"
opens on a different macOS Space when the parent window is in a native-fullscreen
Space, leaving it out of the user's view. This is what a password manager's
passkey picker hits: the browser is fullscreen, the picker appears somewhere else.

Extension popups render browser.xhtml, which declares macnativefullscreen="true",
so they are given NSWindowCollectionBehaviorFullScreenPrimary. A Primary window
declares that it can own a fullscreen Space of its own, and cannot be composited
onto an existing one, so the window server places it elsewhere.

An extension popup is not a primary application window. Opting it out of native
fullscreen routes through nsCocoaWindow::SetSupportsNativeFullscreen(false),
which swaps FullScreenPrimary for FullScreenAuxiliary -- the documented "can be
displayed on the same space as a fullscreen window" behaviour. This matches the
existing comment on that function, that Primary is wanted "only for primary
application windows", and follows the precedent already set by the Library window
in places.xhtml.

Scoped to the web-extension-popup-window case only. windows.create({type:
"normal"}) is deliberately left alone: a normal browser window genuinely is
primary and should keep the ability to enter fullscreen itself.

Testing: the bug reproduces on official Nightly 157.0a1 from mozilla.org on a
fresh profile, and in Zen 1.22, using the minimal test extension attached to the
bug -- load it, put the browser in native fullscreen, and create a popup window.
With this patch the popup is composited onto the fullscreen Space instead. The
type: "normal" case is unchanged, as intended. Verified manually on macOS 26.6;
I have not been able to exercise it in automation.

Assignee: nobody → rio.syed
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
See Also: → 2069666
Severity: -- → S3
Attachment #9640116 - Attachment description: Bug 2070688 - Don't claim FullScreenPrimary for WebExtension popup windows on macOS. r?#mac-reviewers → Bug 2070688 - Suppress initial fullscreen for extension popup and chromeless windows on macOS. r?#mac-reviewers
Attachment #9640116 - Attachment description: Bug 2070688 - Suppress initial fullscreen for extension popup and chromeless windows on macOS. r?#mac-reviewers → Bug 2070688 - Suppress initial fullscreen for extension popup and chromeless windows. r?#mac-reviewers
Pushed by rob@robwu.nl: https://github.com/mozilla-firefox/firefox/commit/4bbd3954d30d https://hg.mozilla.org/integration/autoland/rev/d469db5543bd Suppress initial fullscreen for extension popup and chromeless windows. r=mac-reviewers,bradwerth,spohl,extension-reviewers,robwu
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch
QA Whiteboard: [qa-triage-done-c160/b159]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: