Closed Bug 889376 Opened 11 years ago Closed 11 years ago

NS_ERROR_UNEXPECTED calling dispatchEvent on a disabled, unattached element

Categories

(Firefox :: Untriaged, defect)

25 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: greg.houldsworth, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20130701 Firefox/25.0 (Nightly/Aurora)
Build ID: 20130701031115

Steps to reproduce:

var el = document.createElement('input');
el.addEventListener('poke', function(ev){ console.log(ev); }, false);
el.setAttribute('disabled', 'disabled');
el.dispatchEvent(new Event('poke'));


Actual results:

Throws Unexpected Error NS_ERROR_UNEXPECTED


Expected results:

Listeners added for the "poke" event should be executed.
The same behaviour is present starting in version 22, possibly earlier.
I downloaded the newest nightly (v25, buildId:20130701031115) and started in safe mode before testing.
Works for me in a new tab, error with different details on the home page.  At which page do you encounter the error?

2013-07-04-03-13-23-mozilla-central-firefox-25.0a1.en-US.linux-x86_64:

[16:19:52.840] var el = document.createElement('input');
el.addEventListener('poke', function(ev){ console.log(ev); }, false);
el.setAttribute('disabled', 'disabled');
el.dispatchEvent(new Event('poke'));
[16:19:52.853] true
[16:19:52.856] [object Event]

firefox-22.0.en-US.linux64:
[16:21:44.634] var el = document.createElement('input');
el.addEventListener('poke', function(ev){ console.log(ev); }, false);
el.setAttribute('disabled', 'disabled');
el.dispatchEvent(new Event('poke'));
[16:21:44.644] true
[16:21:44.648] [object Event]
Flags: needinfo?(greg.houldsworth)
It happens on every page I've tried that isn't a blank/speed-dial tab (didn't try that).

Try it on www.google.ca or github.com. Both produce the error for me.
This jsfiddle should show the error occurring with a disabled input.

http://jsfiddle.net/t4D7m/1/

Make sure firebug is open and click "Run" in the jsfiddle.
Flags: needinfo?(greg.houldsworth)
This appears to have been resolved as of at least v25.0. The event is never fired when firing on a disabled element but there is no longer an error.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
The NS_ERROR_UNEXPECTED exception is still being thrown for the attached fiddle (http://jsfiddle.net/t4D7m/1/) in the latest version of Firefox for OS X.

Some details for my environment:
Firefox 44.02 
Mac OS X Version 10.11.3
I was trying to replicate the same exception occured in my code and the exception NS_ERROR_UNEXPECTED is thrown when I tried to run the above (http://jsfiddle.net/t4D7m/1/). 

My environment: Firefox 44.0.2 / Mac OS X 10.11.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: