browser.tabs.update with URL places focus in URL bar rather than loaded content

NEW
Unassigned

Status

P5
enhancement
a year ago
3 months ago

People

(Reporter: bugzilla, Unassigned)

Tracking

unspecified

Firefox Tracking Flags

(firefox57 wontfix)

Details

(Whiteboard: [design-decision-needed])

(Reporter)

Description

a year ago
When you press the "Home" button, Firefox loads the homepage in your current tab and gives focus to the content, e.g. in the case of Google, the search field receives focus. 

If I try to do this via browser.tabs.update(), the cursor goes into the URL bar instead, prior to the URL.

This request is similar, but subtly different to the request in bug 1409675, which suggests that the value in the URL bar should be selected.

Would it be possible to add an additional option to browser.tabs.update() so we can specify this behaviour? Something like

  browser.tabs.update({"url": "google.com", "focus": "content"});

With possible options: 

  "content" - the loaded page
  "url" - the URL bar (which should also select the text in full, as per bug 1409675) 

I can't think of any good reason to have an option for just plonking the cursor at the start of the URL as it does now.

This is literally the most requested feature for my New Tab Homepage add-on, to the tune of probably hundreds of emails historically. I thought I had a way to do it with Web Extensions (via browser.tabs.executeScript) but it doesn't work.

I note that the (web ext) add-on New Tab Override works around this by removing the tab that was just opened and creating a new one, so browser.tabs.create() provides focus to content in the way you would expect. I'm reluctant to implement this workaround because it's pretty jarring UI behaviour.
(Reporter)

Comment 1

a year ago
Just to add to the above, middle clicking the home button also exhibits the behaviour you'd expect, e.g. focus is given to content when the new tab is opened.

Updated

a year ago
status-firefox57: --- → wontfix

Updated

a year ago
Priority: -- → P5
Whiteboard: [design-decision-needed]
Duplicate of this bug: 1419223

Comment 3

a year ago
In the mean time, you could do this: https://github.com/cadeyrn/newtaboverride/blob/master/src/js/core/newtab.js#L81

Updated

10 months ago
Severity: normal → enhancement

Updated

8 months ago
User Story: (updated)

Comment 4

8 months ago
(sorry, accidentally put this in the user story. again [unfortunately it is the first large text field in w3m]. moving.)
I found this bug by way of the comments section of New Tab Homepage 0.6.2 which I was using to fix ctrl-t by having it set the new tab to about:blank - for some reason making new tab blank is something that Firefox preferences did not previously support.  However, about:blank was not selected and cursor was focused at the end which caused me to repeatedly reflexively (due to decades of muscle memory) paste the url after about:blank and get a 404.  And the bug referenced from this bug about auto-selecting the URL (about:blank in my case) was closed WONTFIX.

Anyway!

While I much appreciate what New Tab homepage was doing, I just wanted to let people know that in Nightly you can now choose between an arbitrary url, about:blank and "firefox home" for new tab spawning.  And the about:blank Firefox spawns has an empty url bar which is just about perfect.

So... this addon might have been obsoleted? Are there other use cases it can cover?  Just wanted to mention.
User Story: (updated)

Comment 5

8 months ago
Other functionality not provided by default FF: New Tab = local file.  The above FF fix only allows URLs.
(Reporter)

Comment 6

8 months ago
(In reply to nemo from comment #4)
> So... this addon might have been obsoleted? Are there other use cases it can
> cover?  Just wanted to mention.

I would be happy for it to be obsoleted. When I first developed it (in 2003) I did not expect it to survive 15 years before the functionality was implemented in Firefox. 

That doesn't really change the legitimacy of this bug, however.

(In reply to guzzy from comment #5)
> Other functionality not provided by default FF: New Tab = local file.  The
> above FF fix only allows URLs.

It doesn't work for every type of local file URI, just some. The bug I had to make it work consistently was closed as WONTFIX (due to security concerns) and my responses ignored. 

I think people hosting homepages on their local drives are going to be out of luck in the near future because eventually someone will care enough to close off that security hole.

Updated

7 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.