[Bug 260239] www/firefox: Can't open URL in running instance

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 07 Dec 2021 11:03:27 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260239

--- Comment #3 from Jan Beich <jbeich@FreeBSD.org> ---
(In reply to Michael Eriksson from comment #2)
> 1. firefox-esr, and most likely also earlier versions of mainline firefox,
> don't use dbus for opening URLs in running instances. This can be verified by
> testing without dbus running or by watching dbus-monitor.

Before https://hg.mozilla.org/mozilla-central/rev/ef22d8cbf4ef one had to
define MOZ_DBUS_REMOTE via environ(7) to use DBus on X11 to open a window in an
existing Firefox instance.

> 2. The firefox port doesn't make sure that the machine is ready for running
> dbus (mainly by running "dbus-uuidgen --ensure"), and does not mention dbus in
> the pkg-message.

machine-id is mainly used by autolaunch and generic to all DBus consumers. If
you start session bus (as user after login) manually then neither "dbus-uuidgen
--ensure" nor "service dbus onestart" are required e.g.,

  $ cat >>/etc/profile
  # WARNING: zsh doesn't read this file by default, so use /etc/zprofile
instead
  # XDG_RUNTIME_DIR is preferred but usually requires pam_xdg or consolekit2
(pam_ck_connector or ck_launch_session)
  if [ -n "$XDG_RUNTIME_DIR" ]; then
      if ! pgrep -qf -U ${USER:-$(id -u)} dbus.\*--session; then
          dbus-daemon --session --fork --address=unix:runtime=yes 2>/dev/null
          # Only necessary for some apps that fail to find default session bus
(e.g., Emacs, Chrome)
          # https://gitlab.freedesktop.org/dbus/dbus/-/commit/e3f117e7610b
          export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
      fi
  else
      eval $(dbus-launch --sh-syntax --exit-with-session 2>/dev/null)
  fi

> 3. firefox can be built without the DBUS option, how will this work then?

On X11 by snooping X atoms to find matching window then setting
_MOZILLA_COMMANDLINE on that window.

https://searchfox.org/mozilla-release/rev/dbc7c5ca1e5a/toolkit/components/remote/nsXRemoteClient.cpp#31-37

$ xwininfo -root -children | awk '/^[[:space:]]*0x/ { print $1 }' | xargs -n1
xprop -id | fgrep _MOZILLA
_MOZILLA_PROFILE(STRING) = "default-esr"
_MOZILLA_PROGRAM(STRING) = "firefox"
_MOZILLA_USER(STRING) = "you"
_MOZILLA_VERSION(STRING) = "5.1"

$ pkg install go git
$ git clone https://github.com/siebenmann/ffox-remote
$ cd ffox-remote
$ go build
$ ./ffox-remote -P default-esr https://lists.freebsd.org/
$ ./ffox-remote -P default-esr http://itisatrap.org/firefox/its-a-trap.html

-- 
You are receiving this mail because:
You are the assignee for the bug.