Closed Bug 289790 Opened 19 years ago Closed 19 years ago

E4X: issues with contains method, should yield the same as == comparison but does not for text node compared to string and element compared to string

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: martin.honnen, Unassigned)

Details

Attachments

(1 file)

After bug https://bugzilla.mozilla.org/show_bug.cgi?id=289706 is fixed I think
there are still issues with the contains method of XML objects. The
specification clearly says that

When the contains method is called on an XML object x with parameter value, the
following step is taken:
!!!1. Return the result of the comparison x == value

so a simple test case should always yield the same result for
  xmlObject == value
and
  xmlObject.contains(value)
but with Spidermonkey that is not the case with the following two tests:

function containsTest (xmlObject, value) {
  print('Comparing ' + xmlObject.nodeKind() + ' against ' + (typeof value) + ':');
  var comparison = xmlObject == value;
  var containsCheck = xmlObject.contains(value);
  print('==: ' + comparison + '; contains: ' + containsCheck + 
  '; check ' + (comparison == containsCheck ? 'passed' : 'failed'));
  print('');
}

containsTest(new XML('Kibo'), 'Kibo');

containsTest(<god>Kibo</god>, 'Kibo');


Result with Spidermonkey:

Comparing text against string:
==: true; contains: false; check failed

Comparing element against string:
==: true; contains: false; check failed

so for both cases while == yields true contains does not which seems to be a bug.
Attached patch xml_contains fixSplinter Review
Argh, separate bug from the Equals one, but I should have seen it: xml_contains
is spec'ed in terms of ==, but for XML type it was calling Equals, an internal
common subroutine of xml_equality (the JSXMLObjectOps.equality hook that's used
for ==).

/be
Attachment #180280 - Flags: review+
Attachment #180280 - Flags: approval1.8b2+
Fixed -- clearly need more testsuite coverage here.

/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: