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)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
People
(Reporter: igor, Assigned: igor)
References
Details
Attachments
(1 file, 7 obsolete files)
33.34 KB,
patch
|
igor
:
review+
|
Details | Diff | Splinter Review |
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 | ||
Updated•18 years ago
|
Assignee: general → igor
Assignee | ||
Comment 1•18 years ago
|
||
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
Assignee | ||
Comment 2•18 years ago
|
||
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)
Assignee | ||
Comment 3•18 years ago
|
||
Comment 4•18 years ago
|
||
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 5•18 years ago
|
||
Comment on attachment 255489 [details] [diff] [review]
Implementation v1
r=me with nit fixed and jwalden r+.
/be
Attachment #255489 -
Flags: review?(brendan) → review+
Comment 6•18 years ago
|
||
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.
Assignee | ||
Comment 7•18 years ago
|
||
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)
Assignee | ||
Comment 8•18 years ago
|
||
Assignee | ||
Comment 9•18 years ago
|
||
Attachment #255537 -
Attachment is obsolete: true
Assignee | ||
Comment 10•18 years ago
|
||
Too many patch files :(
Attachment #255538 -
Attachment is obsolete: true
Assignee | ||
Comment 11•18 years ago
|
||
I wish bugzilla has an option to remove all those "real" attachments.
Attachment #255540 -
Attachment is obsolete: true
Assignee | ||
Comment 12•18 years ago
|
||
Ping: Jeff, can you review the patch? I need it for a few other bugs.
Comment 13•18 years ago
|
||
Sorry, I got/am a little bogged down -- I'll make sure to get to it later tonight.
Comment 14•18 years ago
|
||
Still bogged down -- but I'm reviewing now, so this should be done hopefully fairly quickly.
Comment 15•18 years ago
|
||
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+
Updated•18 years ago
|
Attachment #255536 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 16•18 years ago
|
||
(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.
Assignee | ||
Comment 17•18 years ago
|
||
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+
Assignee | ||
Comment 18•18 years ago
|
||
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
Comment 19•18 years ago
|
||
/cvsroot/mozilla/js/tests/e4x/Regress/regress-370372.js,v <-- regress-370372.js
Flags: in-testsuite+
Comment 20•18 years ago
|
||
verified fixed 1.9.0 20070226 windows/mac*/linux
Status: RESOLVED → VERIFIED
Updated•17 years ago
|
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.
Description
•