When including JSON in a dialog then .toJSONString is treated as button

NEW
Unassigned

Status

()

Toolkit
XUL Widgets
10 years ago
10 years ago

People

(Reporter: Tom Aratyn, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
I've created a dialog box that includes JSON.

Expected Results:
1. open a dialog
2. no errors

Actual results:
1. open a dialog
2. error console says "Error: button.addEventListener is not a function
Source file: chrome://global/content/bindings/dialog.xml
Line: 224"

When a break is put on line 224 of dialog.xml then you'll notice dlgtype has the value toJSONString (the same name as a helper string JSON.js adds).

Experianced on:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20061201 Firefox/2.0.0.6 (Ubuntu-feisty)

This problem is caused by JSON's overriding Object's prototype not a bug in Moz, except in so much as it would be nice to provide a facility to do these kinds of extensions without breaking anything. 

to use JSON.jsm is the correct solution here.
Fixing this properly basically involves us making the entire Firefox UI safe from extensions manipulating the Object prototype. Might be nice at some point but I think the appropriate solution at this stage is just to discourage extension authors from doing such things, I've certainly discouraged them whenever I've heard of it already.
Version: 2.0 Branch → Trunk

Comment 2

10 years ago
Should this bug be about making the dialog binding use hasOwnProperty in its for..in loop?
Component: General → XUL Widgets
OS: Linux → All
Product: Firefox → Toolkit
QA Contact: general → xul.widgets
Hardware: PC → All
You need to log in before you can comment on or make changes to this bug.