Closed Bug 270657 Opened 20 years ago Closed 20 years ago

manipulating focus onmousedown causes exception "XULElement.selectedIndex..."

Categories

(Core :: DOM: Events, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

VERIFIED DUPLICATE of bug 236791

People

(Reporter: support, Unassigned)

Details

Attachments

(1 file)

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

When focus is in a text input field, if a mousedown handler elsewhere on the
page attempts to manipulate focus, an exception is thrown:

[Exception... "Permission denied to get property XULElement.selectedIndex' when
calling method: [nsIAutoCompletePopup::selectedIndex] nsresult: "0x80507001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
http://wrath:3000/isomorphic/QA/Native/Moz_firefox_focus.html :: focusInB ::
line 55" data:no]

Specifically the attached test-case (I will attach it when I've submitted the
bug) demonstrates how to cause this in 3 ways:

Starting with focus in a text input form item:
1 - have another element on the page, with a mousedown handler that fires
'focus()' on some second text input form item.
2 - have some other element on the page with a mousedown handler that fires
'blur()' on the input element with focus
3 - have some other element on the page with a mousedown handler that returns
false.  Having returned false, fire 'blur()' on the input element with focus
(can be set up from a timeout within the onmousedown handler).

The exception thrown cannot be caught by a try...catch block

Reproducible: Always
Steps to Reproduce:
1. Using the attached test case, put focus into the input box labelled "a"

-- case 1:
2. Click on the green DIV below the form.  This has an onmousedown handler
defined which calls focus() on the input box labelled "b"

-- case 2:
1. as above - put focus into "a"
2. click on the yellow DIV below the form.  This has an onmousedown handler
defined which calls blur() on the input box labelled "a"

-- case 3
1. as above - put focus into "a"
2. click on the red DIV below the form.  This has an onmousedown handler defined
which calls sets up a timeout to call blur() on the input box labelled "a", and
returns false
3. wait for the timeout to fire.


Actual Results:  
In each of these cases an exception is logged to the JavaScript console, similar to:
[Exception... "Permission denied to get property XULElement.selectedIndex' when
calling method: [nsIAutoCompletePopup::selectedIndex] nsresult: "0x80507001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
http://wrath:3000/isomorphic/QA/Native/Moz_firefox_focus.html :: focusInB ::
line 55" data:no]

-- Note that the line that causes the exception is enclosed in a try...catch
block which doesn't catch the error.

Expected Results:  
Expected behavior would be for the focus to be manipulated, with no error being
logged to the console.
Case1 should have put focus into input box "b"
Case2 should have taken focus from input box "a" (effectively a no-op since
focus was already natively taken away by the mousedown)
Case3 should have taken focus from input box "a" when the timeout fired.

*** This bug has been marked as a duplicate of 236791 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
v.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: