accessing document.activeElement throws an exception

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Miroslav Kroc, Assigned: smaug)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; cs; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Build Identifier: Firefox 3.6.17, Firefox 4.0.0

JS exception "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE" occurs if property document.activeElement refers to DOM element from previous document. We discovered this bug in following scenario.

Website contains two pages. First page is login page with two input elements for username and password and "submit" button. Second page is a page accessing document.activeElement.
User click on "submit" button (first step) and then on input element with username (second step). JS exception mentioned above occurs when the second page (loaded after submitting the first page) tries to access document.activeElement property.
I can reproduce this bug easily in Firefox with Firebug.

Reproducible: Sometimes

Steps to Reproduce:
1. load simple login page (username, password, submit button)
2. fill username and password
3. click on "submit" button (active element is button)
4. click on input element before the second page appears (active element is input element)
5. wait until the second page is loaded

Actual Results:  
JS exception:
[Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMNSDocument.activeElement]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame ::
http://serverName/pathToFile ::
<TOP_LEVEL> :: line 24" data: no]


Expected Results:  
No js exception. Property document.activeElement refers to any DOM element in the current document or is null.

This bug is OS and version independent.

Used software:
- Firefox 3.6.17, Firefox 4.0.0
- Windows 7 x64, Windows 7 x86, MacOs 10.6
(Assignee)

Comment 1

6 years ago
A testcase would be great.
(Assignee)

Comment 2

6 years ago
But the implementation is certainly wrong.
(And I reviewed the code :( )
Status: UNCONFIRMED → NEW
Ever confirmed: true
(Assignee)

Updated

6 years ago
Assignee: nobody → Olli.Pettay
(Assignee)

Comment 3

6 years ago
Patch with tests coming....
(Assignee)

Comment 4

6 years ago
Created attachment 531662 [details] [diff] [review]
patch

This should do it. Make sure .activeElement doesn't throw, ever.
Attachment #531662 - Flags: review?(bzbarsky)
Comment on attachment 531662 [details] [diff] [review]
patch

r=me
Attachment #531662 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 6

6 years ago
http://hg.mozilla.org/mozilla-central/rev/a14401a8f9f2
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
(Reporter)

Comment 7

6 years ago
Thank you for fast solution. I apologize for missing testcase. We haven't finished simplified testcase when this bug was reported.
You need to log in before you can comment on or make changes to this bug.