Some dynamically created XUL elements don't have specific methods available

UNCONFIRMED
Unassigned

Status

()

UNCONFIRMED
4 years ago
3 years ago

People

(Reporter: mail, Unassigned)

Tracking

38 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8608034 [details]
prototype-bug.tar.bz2

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150511103818

Steps to reproduce:

A Firefox extension that demonstrates this bug has been attached.

1. In a Firefox extension, dynamically create a XUL element that is not immediately visible (e.g. not added to the nav bar)
2. Retrieve that element using getElementById
3. Try to use a method that is not defined on all XUL elements (e.g. getRowCount, if the element is a listbox)


Actual results:

The method is not defined. Further research shows that the prototype (__proto__) of the element is XULElementPrototype, not a prototype specific to the element.

The prototype of such elements is corrected every 10 seconds. That means, if you retrieve the element using getElementById 10 seconds later, the prototype will be the correct one and the method will be defined.
My experiments showed that the age of the element is not important. Rather, something happens every 10 seconds that updates those elements (for example, if I create an element 8 seconds after Firefox starts, it will have the correct prototype 2 seconds later).

The prototype will also be corrected when the element becomes visible. The attached extension contains a listbox that is added to a panel, which can be opened via a button in the nav bar. After opening the panel via the button, the prototype is updated.

I was able to reproduce variations of this problem on different Linux system with Firefox 37.0.2, 38.0 and the latest nightly (as of 2015-05-20). I also reproduced it on Windows 7 with either 37.0.2 or 38.0 (I don't remember the exact version).


Expected results:

I would have expected the element to have the correct prototype immediately after being created. For example, I would like to use the getRowCount method of a dynamically created listbox without having to display it and without having to wait 10 seconds.
(Reporter)

Updated

4 years ago
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
This seems to be under the core component. Please change accordingly if the the component has not been correctly changed.
Component: Untriaged → XUL
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.