Closed Bug 370372 Opened 18 years ago Closed 18 years ago

function::name assignments do not work under with (xmllist) (e4x/Regress/regress-370372.js)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: igor, Assigned: igor)

References

Details

Attachments

(1 file, 7 obsolete files)

Consider the following test case: var tests = [<></>, <><a/></>, <><a/><b/></>] function do_one(x) { with (x) { function::toString = function::f = function() { return "test"; } } if (String(x) !== "test") throw "Failed to set toString"; if (x.f() !== "test") throw "Failed to set set function f"; if (x.function::toString != x.function::f) throw "toString and f are different"; } for (var i = 0; i != tests.length; ++i) do_one(tests[i]); Currently it fails with: ~/m/trunk/mozilla/js/src $ ./Linux_All_DBG.OBJ/js ~/s/x.js /home/igor/s/x.js:9: ReferenceError: reference to undefined XML name @mozilla.org/js/function::toString The reason for this is that PutProperty from jsxml.c does not treat function namespaces specially.
Assignee: general → igor
Blocks: 363530
No longer blocks: 363530
Blocks: 369740
The above test is incorrect as it assumes that assignments to non-existing property function::f is OK under with. This is wrong and here is the right one: var tests = [<></>, <><a/></>, <><a/><b/></>] function do_one(x) { x.function::f = Math.sin; with (x) { function::toString = function::f = function() { return "test"; } } if (String(x) !== "test") throw "Failed to set toString"; if (x.f() !== "test") throw "Failed to set set function f"; if (x.function::toString != x.function::f) throw "toString and f are different"; } for (var i = 0; i != tests.length; ++i) do_one(tests[i]);
Status: NEW → ASSIGNED
Attached patch Implementation v1 (obsolete) — Splinter Review
The patch refactors HasProperty/PutProperty to follow the same idea that was implemented for GetProperty and dispatch on the id type, not xml class. I altered the already refactored GetProperty to follow the same pattern that is present in HasNamedProperty as this is more convenient to use and saves code.
Attachment #255489 - Flags: review?(brendan)
Attached patch Implementation v1 (diff -w) (obsolete) — Splinter Review
Comment on attachment 255489 [details] [diff] [review] Implementation v1 >+ return found; >+ } else if (xml->xml_class == JSXML_CLASS_ELEMENT) { Please fix the else after return non-sequitur. Looks good to me; be great of waldo could vouch too, I'm too tired atm. /be
Attachment #255489 - Flags: review?(jwalden+bmo)
Comment on attachment 255489 [details] [diff] [review] Implementation v1 r=me with nit fixed and jwalden r+. /be
Attachment #255489 - Flags: review?(brendan) → review+
I have some work I've been punting so far this weekend that I need to do first, so I think I can fit this in Monday night.
Attached patch Implementation v1.b (obsolete) — Splinter Review
This is the previous patch with the nit addressed.
Attachment #255489 - Attachment is obsolete: true
Attachment #255490 - Attachment is obsolete: true
Attachment #255536 - Flags: review?(jwalden+bmo)
Attachment #255489 - Flags: review?(jwalden+bmo)
Attached patch Implementation v1.b (diff -w) (obsolete) — Splinter Review
Attachment #255537 - Attachment is obsolete: true
Too many patch files :(
Attachment #255538 - Attachment is obsolete: true
I wish bugzilla has an option to remove all those "real" attachments.
Attachment #255540 - Attachment is obsolete: true
Ping: Jeff, can you review the patch? I need it for a few other bugs.
Sorry, I got/am a little bogged down -- I'll make sure to get to it later tonight.
Still bogged down -- but I'm reviewing now, so this should be done hopefully fairly quickly.
Comment on attachment 255540 [details] [diff] [review] Implementation v1.b (diff -w) really for real >+HasNamedProperty(JSXML *xml, JSXMLQName* nameqn) Nit: position of * by nameqn doesn't seem to match house style. Is there a way for an XMLList to contain another XMLList? The obvious way of |list = new XMLList(list);| doesn't work (thinking about possible stack overflow from HasNamedProperty recurring), and I've not read the spec closely enough to know if a way exists.
Attachment #255540 - Flags: review+
Attachment #255536 - Flags: review?(jwalden+bmo)
(In reply to comment #15) > Is there a way for an XMLList to contain another XMLList? No: XMLList is an ordered set of XML trees. > The obvious way of > |list = new XMLList(list);| doesn't work. That just creates a copy of the original list.
Patch to commit with the nit from comment 15 addressed.
Attachment #255536 - Attachment is obsolete: true
Attachment #255541 - Attachment is obsolete: true
Attachment #255874 - Flags: review+
I committed the patch from comment 17 to the trunk: Checking in jsxml.c; /cvsroot/mozilla/js/src/jsxml.c,v <-- jsxml.c new revision: 3.142; previous revision: 3.141 done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
/cvsroot/mozilla/js/tests/e4x/Regress/regress-370372.js,v <-- regress-370372.js
Flags: in-testsuite+
verified fixed 1.9.0 20070226 windows/mac*/linux
Status: RESOLVED → VERIFIED
Summary: function::name assignments do not work under with (xmllist) → function::name assignments do not work under with (xmllist) (e4x/Regress/regress-370372.js)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: