Object.prototype for( in ) hasOwnProperty isEnumerateProperty

RESOLVED INVALID

Status

()

Toolkit
XUL Widgets
--
critical
RESOLVED INVALID
12 years ago
10 years ago

People

(Reporter: francois achache, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

After modify the prototype of Object, when you use "for(dlgtype in buttons)" for enumerate buttons in dialog.xml line 214, firefox tell in jsconsole "this propertie hasnot property addEventListener"
You must test buttons.hasOwnProperty(dlgtype) at line 215 before continue.
Probably there is several others probleme like it, you must test hasOwnProperty.

Reproducible: Always

Steps to Reproduce:
// 1. modify l Object.prototype
Object.prototype._foo = null;
Object.prototype.getFoo = function() {return this._foo;};
Object.prototype.setFoo = function(foo) {this._foo= foo || 1};

2. Create a dialog window :
window.openDialog("myDialog.xul", "mydiag", "chrome...")

3. create a xul file for the dialog window myDialog.xul :
<?xml version="1.0" encoing="utf-8"?>
<dialog buttons="accept,cancel,extra1" ...>
...
</dialog>

Actual Results:  
the extra1 button is not visible because there is a javascript error in dialog.xml at line 214

Expected Results:  
You must test buttons.hasOwnProperty(dlgtype) at line 215 before continue.


Probably there is several others probleme like it, you must test hasOwnProperty.
For me is critical, I need to increse the prototype of Object. And I need extrabutton too.

Comment 1

12 years ago
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla%2Ftoolkit%2Fcontent%2Fwidgets%2Fdialog.xml&rev=1.26&mark=205-212,225-227#200

Ideally you should create attachments to bugzilla which show the problem.
If you have 2 files, A and B, and A references B. Attach B first. Then change A to reference the url for the attachment created for B. Then attach A.

Also, in jsconsole you can right click and choose copy to get a complete error message. it's much better for you to do that than to hand type the message.
Component: General → XUL Widgets
Product: Firefox → Toolkit
QA Contact: general → xul.widgets
This behavior is standard.  It's many years too late to change it.

Modifying Object.prototype and using for...in carelessly are both bad ideas for this very reason.

A future edition of ECMAScript will likely provide a way to define non-enumerable properties.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.