Closed Bug 272867 Opened 20 years ago Closed 19 years ago

Open in tabs: Gmail steals keyboard focus from active tab

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 310825

People

(Reporter: itsayellow, Unassigned)

References

()

Details

(Keywords: qawanted, Whiteboard: [sg:fix])

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

I have a bookmarks folder which I normally use with "Open in tabs".  The first
bookmark is yahoo mail, and the second one is gmail.

When I open this bookmarks folder using "Open in tabs", the yahoo mail login is
in the first tab, so it's the one I can see.  The gmail tab isn't showing, but
still, if I type stuff it will get entered into the hidden gmail tab.

Note: I also typically have gmail "not ask me my password for two weeks" so the
window that comes up is not the gmail login, but my actual messages.

Reproducible: Always
Steps to Reproduce:
1. make a bookmark folder with the two urls I mentioned (example urls), with
yahoo mail first, gmail second.
1b. enable keyboard shortcuts on your gmail account
2. Click on the bookmark folder and select "Open in tabs"
3. type "sjsjsj"

Actual Results:  
You won't see "sjsjsj" typed in the yahoo mail window, but if you go to the
gmail tab, you will see that your first three messages are starred, which is
what those keys do when typed into the gmail mail window.

Expected Results:  
NOT sent keystrokes to the gmail tab that wasn't visible.
Preferably sent keystrokes to the first text entry box of the yahoo mail tab
that was visible.

I've also seen this on the Linux Firefox 1.0.
Hint for those trying to reproduce: don't automatically click in a textbox on
the Yahoo signin page, you have to just start typing like you would if you
thought it did .focus(), or you were trying to use FAYT.
Blocks: 140346
Yahoo mail is troublesome: it only works if it remembers your username and not
your password, since that's the only way it doesn't focus a textbox and screw
things up. Better just to use something that never does, like mozilla.org, as
the first bookmark in the group. Then, it happens in both Firefox and with a
Seamonkey tab group.

Having something that does textbox.focus() in the first tab isn't a complete
killer, though, if it loads fast enough: with google.com as the first one, it
will load before Gmail, and Gmail will steal the focus away (you'll see the
caret in Google's search box, and then as Gmail finishes loading, it disappears).

I'm not sure if this is significant, but Gmail doesn't steal keystrokes if you
deny it access to window.focus(). With

user_pref("capability.policy.policynames", "boingo");
user_pref("capability.policy.boingo.sites", "http://gmail.google.com");
user_pref("capability.policy.boingo.Window.focus", "noAccess");

in user.js, Gmail no longer takes keystrokes from the active tab. I wondered
about blur(), too, since there's a bug about it being a focus-stealer, and they
do seem to call it some, but denying them blur on every HTML...Element that can
blur didn't stop it.

Also interesting, though maybe not significant: the tab that Gmail loads in can
then pass along the keystroke stealing ability: I thought I had a testcase just
passing window.onkeypress and window.onkeydown to a function that document.wrote
them, but it only worked when loaded on top of the Gmail tab, and also the
miswired keypress disappears when the window is minimized: my testcase was
working fine with the inherited onkeypress, I minimized and maximized, and it
was broken. So it may be possible, if a bit unlikely, for evil.com's keystroke
handler to get keyboard focus for other tabs when it loads in a tab where Gmail
started out.
Assignee: bugs → events
Status: UNCONFIRMED → NEW
Component: Tabbed Browser → Event Handling
Ever confirmed: true
Product: Firefox → Core
QA Contact: firefox.tabbed-browser → ian
Summary: Open in tabs: non-visible tab gets focus with javascript textbox.focus() → Open in tabs: Gmail steals keyboard focus from active tab
Version: unspecified → Trunk
A testcase would be helpful.  This might be a dup of bug 299677.
Keywords: qawanted
Whiteboard: [sg:fix]
and/or a dup of bug 270749
Still happens with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1)
Gecko/20051004 Firefox/1.6a1.

I'm pretty sure Gmail uses window.focus() to focus subframes, making this a dup
of bug 310825.

*** This bug has been marked as a duplicate of 310825 ***
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
*** Bug 270749 has been marked as a duplicate of this bug. ***
No longer blocks: 140346
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.