Closed Bug 831161 Opened 12 years ago Closed 12 years ago

document.activeElement is not pointing to the focused textarea/input

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: navaneethkn, Assigned: ochameau)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:18.0) Gecko/20100101 Firefox/18.0 Build ID: 20130104151948 Steps to reproduce: I have an addon which creates a context menu item for all textareas and input controls. When user clicks on the menu item, my content script will hook up keydown event to the activeElement. In all pages I am getting the activeElement properly. But in some pages this activeElement is not pointing to the textarea/input which is in focus. Running document.activeElement from firebug console works well. But not from addon's content script. To reproduce -------- 1 - Download the attached same addon 2 - cfx run 3 - Goto gmail.com and login 4 - Right click on the top search bar and choose an item from "My addon" menu 5 - Observe the console output. Console output will say activeElement not found. Even document.getElementById is also not working in this case Actual results: document.activeElement is not pointing the focused control Expected results: document.activeElement should have pointed to the textarea/input where the focus is
I have created a Gist which has the two files for easiness. Please take a look at https://gist.github.com/4544929
What version of the SDK are you testing this with?
Flags: needinfo?(navaneethkn)
(In reply to Wes Kocher (:KWierso) from comment #2) > What version of the SDK are you testing this with? Add-on SDK 1.12 (9c31911385c15801523dd6ca27bcc2a5748ff476)
Flags: needinfo?(navaneethkn)
Alex, can you try to reproduce this and see what's going on?
Assignee: nobody → poirot.alex
Priority: -- → P3
Looks like adding attachTo: ['existing', 'top'] to the pageMod solved this issue. Not sure why this happens though.
The gist works fine for me. But I think that you were mostly tricked by the execution of your page-mod content script on all gmail iframe. And that is the reason why you don't see this issue when using `attachTo: ['existing', 'top']` as it will prevent applying content script to iframe so that you will now have only one content script per tab.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: