Closed Bug 1295072 Opened 8 years ago Closed 8 years ago

Awesomebar doesn't get focus when creating tab from chrome.tabs.create()

Categories

(WebExtensions :: Frontend, defect, P3)

defect

Tracking

(firefox54 fixed)

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: shinglyu, Assigned: zombie)

References

Details

(Whiteboard: [design-decision-approved]triaged)

Attachments

(1 file)

STR: Create a tab using WebExtension's chrome.tabs.create({}) Expected: A new tab opens up, the focus is on the address bar (awesomebar) Actual: The focus is not on the address bar Notes: Tested on Chromium, the focus will be on the address bar. Environment: Firefox 50.0a2 Ubuntu 16.04 64bit
Priority: -- → P3
Whiteboard: [design-decision-needed]
Component: WebExtensions → WebExtensions: Frontend
Whiteboard: [design-decision-needed] → [design-decision-approved]triaged
Could this be made optional / parametrised, or otherwise controllable via API? For my New Tab Homepage add-on (which loads the user's homepage instead of about:newtab) one of the most requested features is to place focus with the page content, i.e. so if their homepage is Google, the search field will receive focus instead of the Awesomebar. I've never implemented this because it was tricky to get right, but the New Tab Override add-on does solve this problem and would presumably need the same functionality.
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Attachment #8827184 - Flags: review?(kmaglione+bmo)
(In reply to Ben Basson from comment #1) > Could this be made optional It doesn't need to be. This is only meant to focus the urlbar when opening an "empty" tab. And even then, the content can take the focus with a simple <input autofocus> field, or using javascript .focus() method. In fact, that's the only way this could work.
I'd be fine with that if it works. The current implementation doesn't seem consistent in its behaviour, judging by my inbox full of support emails. All my add-on does now is override the new tab page using nsIAboutNewTabService (previously NewTabURL.jsm) and I get mixed reports of Google taking focus vs. the URL bar.
Well, that's a different bug then. While working on this, I tested your use case: content is able reliably to take focus via methods described above. The ability for web extensions to override the newtab page is being worked on in bug 1234150. Once that lands, if this is still a problem, please file a bug.
Comment on attachment 8827184 [details] Bug 1295072 - Focus urlbar after opening an empty new tab Shane, can you look over this? Thanks.
Attachment #8827184 - Flags: feedback?(mixedpuppy)
Comment on attachment 8827184 [details] Bug 1295072 - Focus urlbar after opening an empty new tab https://reviewboard.mozilla.org/r/104946/#review108758 Looks straightforward. f+ ::: browser/components/extensions/test/browser/browser_ext_tabs_create.js:192 (Diff revision 1) > + > + // Test urlbar is focused after opening an empty tab > + extension.sendMessage("create", {}); > + const tab2 = yield extension.awaitMessage("result"); > + > + is(document.activeElement.tagName, "html:input", "Input element focused"); Do we need to be this granular, or can we just check gURLBar.focused?
Attachment #8827184 - Flags: feedback?(mixedpuppy) → feedback+
Comment on attachment 8827184 [details] Bug 1295072 - Focus urlbar after opening an empty new tab https://reviewboard.mozilla.org/r/104946/#review108758 > Do we need to be this granular, or can we just check gURLBar.focused? We don't, it's obvious I was strugling a bit to to find the right check, thanks.
(In reply to Tomislav Jovanovic :zombie from comment #9) > > Do we need to be this granular, or can we just check gURLBar.focused? > > We don't, it's obvious I was strugling a bit to to find the right check, > thanks. yeah, this code base is a continual struggle. Once you think you know something, someone else rewrites it.
Attachment #8827184 - Flags: review?(kmaglione+bmo) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/autoland/rev/70253d6678af Focus urlbar after opening an empty new tab r=kmag
Keywords: checkin-needed
(In reply to Shane Caraveo (:mixedpuppy) from comment #7) > Do we need to be this granular, or can we just check gURLBar.focused? Sigh, testing for gURLBar.focused doesn't seem to work on Linux for some reason. Checking document.activeElement seems to work as expected cross-platform, and since this is just test code, I reverted the test to my original patch (r=testonly).
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/autoland/rev/2b5a94ac86a6 Focus urlbar after opening an empty new tab r=kmag
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
Depends on: 1337975
See Also: → 1434275
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: