Closed Bug 289706 Opened 19 years ago Closed 19 years ago

E4X: contains called on complex XML object with a simple string argument yields true but should yield false

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8beta2

People

(Reporter: martin.honnen, Assigned: brendan)

Details

(Keywords: js1.5)

Attachments

(1 file)

The following test case

var gods = <gods>
  <god>Kibo</god>
  <god>Xibo</god>
</gods>;

print('XML markup is:\r\n' + gods.toXMLString());

var string = 'Kibo';
print('gods.contains(\'' + string + '\'): ' + gods.contains(string));
print('gods == \'' + string + '\': ' + (gods == string));

when run in the Spidermonkey shell (as pulled today via CVS) outputs:

XML markup is:
<gods>
  <god>Kibo</god>
  <god>Xibo</god>
</gods>
gods.contains('Kibo'): true
gods == 'Kibo': false

while the result should be

XML markup is:
<gods>
  <god>Kibo</god>
  <god>Xibo</god>
</gods>
gods.contains('Kibo'): false
gods == 'Kibo': false

as the E4X specification says about the contains method in section 13.4.4.10:
  "Return the result of the comparison x == value"
where the comparison operation == is specified in section 11.5.1 so the result
of the contains call should be the same as the result of the comparison, it
should be false.
Oops, looks like missing logic in Equals (jsxml.c).

/be
Assignee: general → brendan
Keywords: js1.5
OS: Windows XP → All
Priority: -- → P2
Hardware: PC → All
Target Milestone: --- → mozilla1.8beta2
Attached patch fixSplinter Review
See ECMA-357 9.{1,2}.1.9 [[Equals]].  E4X is a 1.8 required feature, so I'm
self-approving and checking in trivial fixes.

/be
Attachment #180191 - Flags: review+
Attachment #180191 - Flags: approval1.8b2+
Fixed.  Thanks, Martin!

/be
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
added to test library
Checking in 13.4.4.10.js;
/cvsroot/mozilla/js/tests/e4x/XML/13.4.4.10.js,v  <--  13.4.4.10.js
new revision: 1.4; previous revision: 1.3
Status: RESOLVED → VERIFIED
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: